Apache-SdnFw
view release on metacpan or search on metacpan
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
if (how != CLONE)
n.nodeValue = oldNodeValue;
if (how == DELETE)
return;
newNode = n.cloneNode(FALSE);
newNode.nodeValue = newNodeValue;
return newNode;
}
if (how == DELETE)
return;
return n.cloneNode(FALSE);
};
function _traverseFullySelected(n, how) {
if (how != DELETE)
return how == CLONE ? n.cloneNode(TRUE) : n;
n.parentNode.removeChild(n);
};
};
ns.Range = Range;
})(tinymce.dom);
(function() {
function Selection(selection) {
var t = this, invisibleChar = '\uFEFF', range, lastIERng, dom = selection.dom, TRUE = true, FALSE = false;
// Returns a W3C DOM compatible range object by using the IE Range API
function getRange() {
var ieRange = selection.getRng(), domRange = dom.createRng(), element, collapsed;
// If selection is outside the current document just return an empty range
element = ieRange.item ? ieRange.item(0) : ieRange.parentElement();
if (element.ownerDocument != dom.doc)
return domRange;
// Handle control selection or text selection of a image
if (ieRange.item || !element.hasChildNodes()) {
domRange.setStart(element.parentNode, dom.nodeIndex(element));
domRange.setEnd(domRange.startContainer, domRange.startOffset + 1);
return domRange;
}
collapsed = selection.isCollapsed();
function findEndPoint(start) {
var marker, container, offset, nodes, startIndex = 0, endIndex, index, parent, checkRng, position;
// Setup temp range and collapse it
checkRng = ieRange.duplicate();
checkRng.collapse(start);
// Create marker and insert it at the end of the endpoints parent
marker = dom.create('a');
parent = checkRng.parentElement();
// If parent doesn't have any children then set the container to that parent and the index to 0
if (!parent.hasChildNodes()) {
domRange[start ? 'setStart' : 'setEnd'](parent, 0);
return;
}
parent.appendChild(marker);
checkRng.moveToElementText(marker);
position = ieRange.compareEndPoints(start ? 'StartToStart' : 'EndToEnd', checkRng);
if (position > 0) {
// The position is after the end of the parent element.
// This is the case where IE puts the caret to the left edge of a table.
domRange[start ? 'setStartAfter' : 'setEndAfter'](parent);
dom.remove(marker);
return;
}
// Setup node list and endIndex
nodes = tinymce.grep(parent.childNodes);
endIndex = nodes.length - 1;
// Perform a binary search for the position
while (startIndex <= endIndex) {
index = Math.floor((startIndex + endIndex) / 2);
// Insert marker and check it's position relative to the selection
parent.insertBefore(marker, nodes[index]);
checkRng.moveToElementText(marker);
position = ieRange.compareEndPoints(start ? 'StartToStart' : 'EndToEnd', checkRng);
if (position > 0) {
// Marker is to the right
startIndex = index + 1;
} else if (position < 0) {
// Marker is to the left
endIndex = index - 1;
} else {
// Maker is where we are
found = true;
break;
}
}
// Setup container
container = position > 0 || index == 0 ? marker.nextSibling : marker.previousSibling;
// Handle element selection
if (container.nodeType == 1) {
dom.remove(marker);
// Find offset and container
offset = dom.nodeIndex(container);
container = container.parentNode;
// Move the offset if we are setting the end or the position is after an element
if (!start || index > 0)
offset++;
} else {
// Calculate offset within text node
( run in 1.279 second using v1.01-cache-2.11-cpan-5623c5533a1 )