Revert "force webkit to output <br> when enter pressed, instead of div"

This reverts commit e63c8e5619.
This commit is contained in:
Damien Elmes 2013-06-14 13:11:48 +09:00
parent 24995de437
commit 077d6b8187

View file

@ -74,29 +74,6 @@ function onKey() {
} }
}; };
function onKeyPress() {
if (window.event.which == 13) {
if (window.getSelection) {
var selection = window.getSelection(),
range = selection.getRangeAt(0),
br = document.createElement("br");
range.deleteContents();
range.insertNode(br);
range.setStartAfter(br);
range.setEndAfter(br);
selection.removeAllRanges();
selection.addRange(range);
return false;
}
}
}
function onKeyUp(elem) {
if (!elem.lastChild || elem.lastChild.nodeName.toLowerCase() != "br") {
elem.appendChild(document.createElement("br"));
}
}
function sendState() { function sendState() {
var r = { var r = {
'bold': document.queryCommandState("bold"), 'bold': document.queryCommandState("bold"),
@ -219,8 +196,7 @@ function setFields(fields, focusTo) {
txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%%>".format(n); txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%%>".format(n);
txt += "<div id=f{0} onkeydown='onKey();' onmouseup='onKey();'".format(i); txt += "<div id=f{0} onkeydown='onKey();' onmouseup='onKey();'".format(i);
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field "; txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
txt += "ondragover='onDragOver(this);' onkeyup='onKeyUp(this)' "; txt += "ondragover='onDragOver(this);' ";
txt += "onkeypress='return onKeyPress();' ";
txt += "contentEditable=true class=field>{0}</div>".format(f); txt += "contentEditable=true class=field>{0}</div>".format(f);
txt += "</td></tr>"; txt += "</td></tr>";
} }
@ -261,9 +237,11 @@ $(function () {
document.body.onmousedown = function () { document.body.onmousedown = function () {
mouseDown++; mouseDown++;
} }
document.body.onmouseup = function () { document.body.onmouseup = function () {
mouseDown--; mouseDown--;
} }
document.onclick = function (evt) { document.onclick = function (evt) {
var src = window.event.srcElement; var src = window.event.srcElement;
if (src.tagName == "IMG") { if (src.tagName == "IMG") {
@ -277,6 +255,7 @@ document.onclick = function (evt) {
} }
} }
} }
}); });
</script></head><body> </script></head><body>