X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3193141f55df20910cf8ba35f9e669d79c90d3f4..22aac0da99594406b261f14c135812c855c196ef:/platforma/static/js/lib/codemirror/select.js diff --git a/platforma/static/js/lib/codemirror/select.js b/platforma/static/js/lib/codemirror/select.js index 7746240e..d513ba5f 100644 --- a/platforma/static/js/lib/codemirror/select.js +++ b/platforma/static/js/lib/codemirror/select.js @@ -52,7 +52,7 @@ var select = {}; while (pos && pos.offsetParent) { y += pos.offsetTop; // Don't count X offset for
nodes - if (!isBR(pos)) + if (pos.nodeName != "BR") x += pos.offsetLeft; pos = pos.offsetParent; } @@ -247,17 +247,13 @@ var select = {}; } if (cur) { try{range.moveToElementText(cur);} - catch(e){return false;} + catch(e){} range.collapse(false); } else range.moveToElementText(node.parentNode); if (count) range.move("character", count); } - else { - try{range.moveToElementText(node);} - catch(e){return false;} - } - return true; + else range.moveToElementText(node); } // Do a binary search through the container object, comparing @@ -266,7 +262,7 @@ var select = {}; while (start < end) { var middle = Math.ceil((end + start) / 2), node = container.childNodes[middle]; if (!node) return false; // Don't ask. IE6 manages this sometimes. - if (!moveToNodeStart(range2, node)) return false; + moveToNodeStart(range2, node); if (range.compareEndPoints("StartToStart", range2) == 1) start = middle; else @@ -318,7 +314,7 @@ var select = {}; if (!selection) return null; var topNode = select.selectionTopNode(container, start); - while (topNode && !isBR(topNode)) + while (topNode && topNode.nodeName != "BR") topNode = topNode.previousSibling; var range = selection.createRange(), range2 = range.duplicate(); @@ -411,7 +407,7 @@ var select = {}; // ancestors with a suitable offset. This goes down the DOM tree // until a 'leaf' is reached (or is it *up* the DOM tree?). function normalize(point){ - while (point.node.nodeType != 3 && !isBR(point.node)) { + while (point.node.nodeType != 3 && point.node.nodeName != "BR") { var newNode = point.node.childNodes[point.offset] || point.node.nextSibling; point.offset = 0; while (!newNode && point.node.parentNode) { @@ -429,9 +425,8 @@ var select = {}; }; select.selectMarked = function () { - var cs = currentSelection; - if (!(cs && (cs.changed || (webkit && cs.start.node == cs.end.node)))) return; - var win = cs.window, range = win.document.createRange(); + if (!currentSelection || !currentSelection.changed) return; + var win = currentSelection.window, range = win.document.createRange(); function setPoint(point, which) { if (point.node) { @@ -447,8 +442,8 @@ var select = {}; } } - setPoint(cs.end, "End"); - setPoint(cs.start, "Start"); + setPoint(currentSelection.end, "End"); + setPoint(currentSelection.start, "Start"); selectRange(range, win); }; @@ -476,7 +471,7 @@ var select = {}; var offset = start ? range.startOffset : range.endOffset; // Work around (yet another) bug in Opera's selection model. if (window.opera && !start && range.endContainer == container && range.endOffset == range.startOffset + 1 && - container.childNodes[range.startOffset] && isBR(container.childNodes[range.startOffset])) + container.childNodes[range.startOffset] && container.childNodes[range.startOffset].nodeName == "BR") offset--; // For text nodes, we look at the node itself if the cursor is @@ -491,7 +486,7 @@ var select = {}; // Occasionally, browsers will return the HTML node as // selection. If the offset is 0, we take the start of the frame // ('after null'), otherwise, we take the last node. - else if (node.nodeName.toUpperCase() == "HTML") { + else if (node.nodeName == "HTML") { return (offset == 1 ? null : container.lastChild); } // If the given node is our 'container', we just look up the @@ -562,7 +557,7 @@ var select = {}; if (!range) return; var topNode = select.selectionTopNode(container, start); - while (topNode && !isBR(topNode)) + while (topNode && topNode.nodeName != "BR") topNode = topNode.previousSibling; range = range.cloneRange();