Nuestro conocimiento compartido. Nuestro tesoro compartido. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 2 var log_panel = null;3 4 window.addEventListener('load', init, true);5 6 7 function init() {8  log_panel = document.getElementById('log');9  10  var p1 = document.getElementById('parte1');11  p1.contentEditable=true;12  p1.addEventListener('keydown', div_editable_keydown, true);13 14 15  16  17 }18 19 var div_editable_keydown = function(event) {20  if (event.keyCode == 13) {21  var dom = document.createElement('div');22  var users1 = document.createElement('div'); users1.style.cssFloat = 'right'; users1.style.fontSize='10px';23  var users2 = document.createElement('div'); users2.innerHTML = 'Editando: fulanita'; 24  var editor = document.createElement('div');25  dom.appendChild(users1);26  dom.appendChild(editor);27  users1.appendChild(users2);28  editor.innerHTML = '';29  editor.style.minHeight = '15px';30  event.stopPropagation();31  event.preventDefault();32  editor.addEventListener('keydown', div_editable_keydown, true);33  editor.addEventListener('blur', div_editable_blur, true);34  if(this.parentNode.nextSibling) {35  this.parentNode.parentNode.insertBefore(dom, this.parentNode.nextSibling);36  } else {37  //this.appendChild(this.parentNode);38  }39  //this.parentNode.insertBefore(div, this.nextSibling);40  editor.contentEditable=true; 41  editor.focus();42  }43  log('part1 keyup '+event.keyCode);44 }45 46 var div_editable_blur = function (event) {47  log('Event change: '+event.target.innerHTML);48 }49 50 51 function log(txt) {52  if (log_panel != null) log_panel.innerHTML = txt+'<br>'+log_panel.innerHTML;53 }
Enlace
El enlace para compartir es: