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
v += n.nodeValue;
} while (n = n.nextSibling);
}
return v || s;
}
return s;
},
encode : function(str) {
return ('' + str).replace(encodeCharsRe, function(chr) {
return encodedChars[chr];
});
},
insertAfter : function(node, reference_node) {
reference_node = this.get(reference_node);
return this.run(node, function(node) {
var parent, nextSibling;
parent = reference_node.parentNode;
nextSibling = reference_node.nextSibling;
if (nextSibling)
parent.insertBefore(node, nextSibling);
else
parent.appendChild(node);
return node;
});
},
isBlock : function(n) {
if (n.nodeType && n.nodeType !== 1)
return false;
n = n.nodeName || n;
return blockRe.test(n);
},
replace : function(n, o, k) {
var t = this;
if (is(o, 'array'))
n = n.cloneNode(true);
return t.run(o, function(o) {
if (k) {
each(tinymce.grep(o.childNodes), function(c) {
n.appendChild(c);
});
}
return o.parentNode.replaceChild(n, o);
});
},
rename : function(elm, name) {
var t = this, newElm;
if (elm.nodeName != name.toUpperCase()) {
// Rename block element
newElm = t.create(name);
// Copy attribs to new block
each(t.getAttribs(elm), function(attr_node) {
t.setAttrib(newElm, attr_node.nodeName, t.getAttrib(elm, attr_node.nodeName));
});
// Replace block
t.replace(newElm, elm, 1);
}
return newElm || elm;
},
findCommonAncestor : function(a, b) {
var ps = a, pe;
while (ps) {
pe = b;
while (pe && ps != pe)
pe = pe.parentNode;
if (ps == pe)
break;
ps = ps.parentNode;
}
if (!ps && a.ownerDocument)
return a.ownerDocument.documentElement;
return ps;
},
toHex : function(s) {
var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
function hex(s) {
s = parseInt(s).toString(16);
return s.length > 1 ? s : '0' + s; // 0 -> 00
};
if (c) {
s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
return s;
}
return s;
},
getClasses : function() {
var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
// Insert BR element
rng.insertNode(br = dom.create('br'));
// Place caret after BR
rng.setStartAfter(br);
rng.setEndAfter(br);
selection.setRng(rng);
// Could not place caret after BR then insert an nbsp entity and move the caret
if (selection.getSel().focusNode == br.previousSibling) {
selection.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'), br));
selection.collapse(TRUE);
}
// Create a temporary DIV after the BR and get the position as it
// seems like getPos() returns 0 for text nodes and BR elements.
dom.insertAfter(div, br);
divYPos = dom.getPos(div).y;
dom.remove(div);
// Scroll to new position, scrollIntoView can't be used due to bug: http://bugs.webkit.org/show_bug.cgi?id=16117
if (divYPos > vpHeight) // It is not necessary to scroll if the DIV is inside the view port.
ed.getWin().scrollTo(0, divYPos);
};
ed.onKeyPress.add(function(ed, e) {
if (e.keyCode == 13 && (e.shiftKey || (s.force_br_newlines && !dom.getParent(selection.getNode(), 'h1,h2,h3,h4,h5,h6,ol,ul')))) {
insertBr(ed);
Event.cancel(e);
}
});
}
// Padd empty inline elements within block elements
// For example: <p><strong><em></em></strong></p> becomes <p><strong><em> </em></strong></p>
ed.onPreProcess.add(function(ed, o) {
each(dom.select('p,h1,h2,h3,h4,h5,h6,div', o.node), function(p) {
if (isEmpty(p)) {
each(dom.select('span,em,strong,b,i', o.node), function(n) {
if (!n.hasChildNodes()) {
n.appendChild(ed.getDoc().createTextNode('\u00a0'));
return FALSE; // Break the loop one padding is enough
}
});
}
});
});
// IE specific fixes
if (isIE) {
// Replaces IE:s auto generated paragraphs with the specified element name
if (s.element != 'P') {
ed.onKeyPress.add(function(ed, e) {
t.lastElm = selection.getNode().nodeName;
});
ed.onKeyUp.add(function(ed, e) {
var bl, n = selection.getNode(), b = ed.getBody();
if (b.childNodes.length === 1 && n.nodeName == 'P') {
n = dom.rename(n, s.element);
selection.select(n);
selection.collapse();
ed.nodeChanged();
} else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
bl = dom.getParent(n, 'p');
if (bl) {
dom.rename(bl, s.element);
ed.nodeChanged();
}
}
});
}
}
},
find : function(n, t, s) {
var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, FALSE), c = -1;
while (n = w.nextNode()) {
c++;
// Index by node
if (t == 0 && n == s)
return c;
// Node by index
if (t == 1 && c == s)
return n;
}
return -1;
},
forceRoots : function(ed, e) {
var t = this, ed = t.editor, b = ed.getBody(), d = ed.getDoc(), se = ed.selection, s = se.getSel(), r = se.getRng(), si = -2, ei, so, eo, tr, c = -0xFFFFFF;
var nx, bl, bp, sp, le, nl = b.childNodes, i, n, eid;
// Fix for bug #1863847
//if (e && e.keyCode == 13)
// return TRUE;
// Wrap non blocks into blocks
for (i = nl.length - 1; i >= 0; i--) {
nx = nl[i];
// Ignore internal elements
if (nx.nodeType === 1 && nx.getAttribute('_mce_type')) {
bl = null;
continue;
}
// Is text or non block element
if (nx.nodeType === 3 || (!t.dom.isBlock(nx) && nx.nodeType !== 8 && !/^(script|mce:script|style|mce:style)$/i.test(nx.nodeName))) {
if (!bl) {
// Create new block but ignore whitespace
if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
// Store selection
if (si == -2 && r) {
if (!isIE) {
// If selection is element then mark it
if (r.startContainer.nodeType == 1 && (n = r.startContainer.childNodes[r.startOffset]) && n.nodeType == 1) {
// Save the id of the selected element
eid = n.getAttribute("id");
n.setAttribute("id", "__mce");
} else {
// If element is inside body, might not be the case in contentEdiable mode
if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
}
}
}
}
return rng;
};
function setElementFormat(elm, fmt) {
fmt = fmt || format;
if (elm) {
each(fmt.styles, function(value, name) {
dom.setStyle(elm, name, replaceVars(value, vars));
});
each(fmt.attributes, function(value, name) {
dom.setAttrib(elm, name, replaceVars(value, vars));
});
each(fmt.classes, function(value) {
value = replaceVars(value, vars);
if (!dom.hasClass(elm, value))
dom.addClass(elm, value);
});
}
};
function applyRngStyle(rng) {
var newWrappers = [], wrapName, wrapElm;
// Setup wrapper element
wrapName = format.inline || format.block;
wrapElm = dom.create(wrapName);
setElementFormat(wrapElm);
rangeUtils.walk(rng, function(nodes) {
var currentWrapElm;
function process(node) {
var nodeName = node.nodeName.toLowerCase(), parentName = node.parentNode.nodeName.toLowerCase(), found;
// Stop wrapping on br elements
if (isEq(nodeName, 'br')) {
currentWrapElm = 0;
// Remove any br elements when we wrap things
if (format.block)
dom.remove(node);
return;
}
// If node is wrapper type
if (format.wrapper && matchNode(node, name, vars)) {
currentWrapElm = 0;
return;
}
// Can we rename the block
if (format.block && !format.wrapper && isTextBlock(nodeName)) {
node = dom.rename(node, wrapName);
setElementFormat(node);
newWrappers.push(node);
currentWrapElm = 0;
return;
}
// Handle selector patterns
if (format.selector) {
// Look for matching formats
each(formatList, function(format) {
if (dom.is(node, format.selector) && !isCaretNode(node)) {
setElementFormat(node, format);
found = true;
}
});
// Continue processing if a selector match wasn't found and a inline element is defined
if (!format.inline || found) {
currentWrapElm = 0;
return;
}
}
// Is it valid to wrap this item
if (isValid(wrapName, nodeName) && isValid(parentName, wrapName)) {
// Start wrapping
if (!currentWrapElm) {
// Wrap the node
currentWrapElm = wrapElm.cloneNode(FALSE);
node.parentNode.insertBefore(currentWrapElm, node);
newWrappers.push(currentWrapElm);
}
currentWrapElm.appendChild(node);
} else {
// Start a new wrapper for possible children
currentWrapElm = 0;
each(tinymce.grep(node.childNodes), process);
// End the last wrapper
currentWrapElm = 0;
}
};
// Process siblings from range
each(nodes, process);
});
// Cleanup
each(newWrappers, function(node) {
var childCount;
function getChildCount(node) {
var count = 0;
each(node.childNodes, function(node) {
if (!isWhiteSpaceNode(node) && !isBookmarkNode(node))
count++;
});
( run in 0.594 second using v1.01-cache-2.11-cpan-39bf76dae61 )