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
return this.lookup[n];
}
});
tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
Separator : function(id, s) {
this.parent(id, s);
this.classPrefix = 'mceSeparator';
},
renderHTML : function() {
return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
}
});
(function(tinymce) {
var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
MenuItem : function(id, s) {
this.parent(id, s);
this.classPrefix = 'mceMenuItem';
},
setSelected : function(s) {
this.setState('Selected', s);
this.selected = s;
},
isSelected : function() {
return this.selected;
},
postRender : function() {
var t = this;
t.parent();
// Set pending state
if (is(t.selected))
t.setSelected(t.selected);
}
});
})(tinymce);
(function(tinymce) {
var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
Menu : function(id, s) {
var t = this;
t.parent(id, s);
t.items = {};
t.collapsed = false;
t.menuCount = 0;
t.onAddItem = new tinymce.util.Dispatcher(this);
},
expand : function(d) {
var t = this;
if (d) {
walk(t, function(o) {
if (o.expand)
o.expand();
}, 'items', t);
}
t.collapsed = false;
},
collapse : function(d) {
var t = this;
if (d) {
walk(t, function(o) {
if (o.collapse)
o.collapse();
}, 'items', t);
}
t.collapsed = true;
},
isCollapsed : function() {
return this.collapsed;
},
add : function(o) {
if (!o.settings)
o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
this.onAddItem.dispatch(this, o);
return this.items[o.id] = o;
},
addSeparator : function() {
return this.add({separator : true});
},
addMenu : function(o) {
if (!o.collapse)
o = this.createMenu(o);
this.menuCount++;
return this.add(o);
},
hasMenus : function() {
return this.menuCount !== 0;
},
remove : function(o) {
delete this.items[o.id];
},
removeAll : function() {
var t = this;
walk(t, function(o) {
if (o.removeAll)
o.removeAll();
else
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
dom : t.dom,
schema : t.schema
}));
t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer);
t.formatter = new tinymce.Formatter(this);
// Register default formats
t.formatter.register({
alignleft : [
{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},
{selector : 'img,table', styles : {'float' : 'left'}}
],
aligncenter : [
{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},
{selector : 'img', styles : {display : 'block', marginLeft : 'auto', marginRight : 'auto'}},
{selector : 'table', styles : {marginLeft : 'auto', marginRight : 'auto'}}
],
alignright : [
{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},
{selector : 'img,table', styles : {'float' : 'right'}}
],
alignfull : [
{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'justify'}}
],
bold : [
{inline : 'strong'},
{inline : 'span', styles : {fontWeight : 'bold'}},
{inline : 'b'}
],
italic : [
{inline : 'em'},
{inline : 'span', styles : {fontStyle : 'italic'}},
{inline : 'i'}
],
underline : [
{inline : 'span', styles : {textDecoration : 'underline'}, exact : true},
{inline : 'u'}
],
strikethrough : [
{inline : 'span', styles : {textDecoration : 'line-through'}, exact : true},
{inline : 'u'}
],
forecolor : {inline : 'span', styles : {color : '%value'}},
hilitecolor : {inline : 'span', styles : {backgroundColor : '%value'}},
fontname : {inline : 'span', styles : {fontFamily : '%value'}},
fontsize : {inline : 'span', styles : {fontSize : '%value'}},
fontsize_class : {inline : 'span', attributes : {'class' : '%value'}},
blockquote : {block : 'blockquote', wrapper : 1, remove : 'all'},
removeformat : [
{selector : 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, block_expand : true, deep : true},
{selector : 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
{selector : '*', attributes : ['style', 'class'], split : false, expand : false, deep : true}
]
});
// Register default block formats
each('p h1 h2 h3 h4 h5 h6 div address pre div code dt dd samp'.split(/\s/), function(name) {
t.formatter.register(name, {block : name, remove : 'all'});
});
// Register user defined formats
t.formatter.register(t.settings.formats);
t.undoManager = new tinymce.UndoManager(t);
// Pass through
t.undoManager.onAdd.add(function(um, l) {
if (!l.initial)
return t.onChange.dispatch(t, l, um);
});
t.undoManager.onUndo.add(function(um, l) {
return t.onUndo.dispatch(t, l, um);
});
t.undoManager.onRedo.add(function(um, l) {
return t.onRedo.dispatch(t, l, um);
});
t.forceBlocks = new tinymce.ForceBlocks(t, {
forced_root_block : s.forced_root_block
});
t.editorCommands = new tinymce.EditorCommands(t);
// Pass through
t.serializer.onPreProcess.add(function(se, o) {
return t.onPreProcess.dispatch(t, o, se);
});
t.serializer.onPostProcess.add(function(se, o) {
return t.onPostProcess.dispatch(t, o, se);
});
t.onPreInit.dispatch(t);
if (!s.gecko_spellcheck)
t.getBody().spellcheck = 0;
if (!s.readonly)
t._addEvents();
t.controlManager.onPostRender.dispatch(t, t.controlManager);
t.onPostRender.dispatch(t);
if (s.directionality)
t.getBody().dir = s.directionality;
if (s.nowrap)
t.getBody().style.whiteSpace = "nowrap";
if (s.custom_elements) {
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
dom = ed.dom,
selection = ed.selection,
TreeWalker = tinymce.dom.TreeWalker,
rangeUtils = new tinymce.dom.RangeUtils(dom),
isValid = ed.schema.isValid,
isBlock = dom.isBlock,
forcedRootBlock = ed.settings.forced_root_block,
nodeIndex = dom.nodeIndex,
INVISIBLE_CHAR = '\uFEFF',
MCE_ATTR_RE = /^(src|href|style)$/,
FALSE = false,
TRUE = true,
undefined,
pendingFormats = {apply : [], remove : []};
function isArray(obj) {
return obj instanceof Array;
};
function getParents(node, selector) {
return dom.getParents(node, selector, dom.getRoot());
};
function isCaretNode(node) {
return node.nodeType === 1 && (node.face === 'mceinline' || node.style.fontFamily === 'mceinline');
};
// Public functions
function get(name) {
return name ? formats[name] : formats;
};
function register(name, format) {
if (name) {
if (typeof(name) !== 'string') {
each(name, function(format, name) {
register(name, format);
});
} else {
// Force format into array and add it to internal collection
format = format.length ? format : [format];
each(format, function(format) {
// Set deep to false by default on selector formats this to avoid removing
// alignment on images inside paragraphs when alignment is changed on paragraphs
if (format.deep === undefined)
format.deep = !format.selector;
// Default to true
if (format.split === undefined)
format.split = !format.selector || format.inline;
// Default to true
if (format.remove === undefined && format.selector && !format.inline)
format.remove = 'none';
// Mark format as a mixed format inline + block level
if (format.selector && format.inline) {
format.mixed = true;
format.block_expand = true;
}
// Split classes if needed
if (typeof(format.classes) === 'string')
format.classes = format.classes.split(/\s+/);
});
formats[name] = format;
}
}
};
function apply(name, vars, node) {
var formatList = get(name), format = formatList[0], bookmark, rng, i;
function moveStart(rng) {
var container = rng.startContainer,
offset = rng.startOffset,
walker, node;
// Move startContainer/startOffset in to a suitable node
if (container.nodeType == 1 || container.nodeValue === "") {
container = container.nodeType == 1 ? container.childNodes[offset] : container;
// Might fail if the offset is behind the last element in it's container
if (container) {
walker = new TreeWalker(container, container.parentNode);
for (node = walker.current(); node; node = walker.next()) {
if (node.nodeType == 3 && !isWhiteSpaceNode(node)) {
rng.setStart(node, 0);
break;
}
}
}
}
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);
});
}
};
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
return clone || node;
};
childCount = getChildCount(node);
// Remove empty nodes
if (childCount === 0) {
dom.remove(node, 1);
return;
}
if (format.inline || format.wrapper) {
// Merges the current node with it's children of similar type to reduce the number of elements
if (!format.exact && childCount === 1)
node = mergeStyles(node);
// Remove/merge children
each(formatList, function(format) {
// Merge all children of similar type will move styles from child to parent
// this: <span style="color:red"><b><span style="color:red; font-size:10px">text</span></b></span>
// will become: <span style="color:red"><b><span style="font-size:10px">text</span></b></span>
each(dom.select(format.inline, node), function(child) {
removeFormat(format, vars, child, format.exact ? child : null);
});
});
// Remove child if direct parent is of same type
if (matchNode(node.parentNode, name, vars)) {
dom.remove(node, 1);
node = 0;
return TRUE;
}
// Look for parent with similar style format
if (format.merge_with_parents) {
dom.getParent(node.parentNode, function(parent) {
if (matchNode(parent, name, vars)) {
dom.remove(node, 1);
node = 0;
return TRUE;
}
});
}
// Merge next and previous siblings if they are similar <b>text</b><b>text</b> becomes <b>texttext</b>
if (node) {
node = mergeSiblings(getNonWhiteSpaceSibling(node), node);
node = mergeSiblings(node, getNonWhiteSpaceSibling(node, TRUE));
}
}
});
};
if (format) {
if (node) {
rng = dom.createRng();
rng.setStartBefore(node);
rng.setEndAfter(node);
applyRngStyle(expandRng(rng, formatList));
} else {
if (!selection.isCollapsed() || !format.inline) {
// Apply formatting to selection
bookmark = selection.getBookmark();
applyRngStyle(expandRng(selection.getRng(TRUE), formatList));
selection.moveToBookmark(bookmark);
selection.setRng(moveStart(selection.getRng(TRUE)));
ed.nodeChanged();
} else
performCaretAction('apply', name, vars);
}
}
};
function remove(name, vars, node) {
var formatList = get(name), format = formatList[0], bookmark, i, rng;
function moveStart(rng) {
var container = rng.startContainer,
offset = rng.startOffset,
walker, node, nodes, tmpNode;
// Convert text node into index if possible
if (container.nodeType == 3 && offset >= container.nodeValue.length - 1) {
container = container.parentNode;
offset = nodeIndex(container) + 1;
}
// Move startContainer/startOffset in to a suitable node
if (container.nodeType == 1) {
nodes = container.childNodes;
container = nodes[Math.min(offset, nodes.length - 1)];
walker = new TreeWalker(container);
// If offset is at end of the parent node walk to the next one
if (offset > nodes.length - 1)
walker.next();
for (node = walker.current(); node; node = walker.next()) {
if (node.nodeType == 3 && !isWhiteSpaceNode(node)) {
// IE has a "neat" feature where it moves the start node into the closest element
// we can avoid this by inserting an element before it and then remove it after we set the selection
tmpNode = dom.create('a', null, INVISIBLE_CHAR);
node.parentNode.insertBefore(tmpNode, node);
// Set selection and remove tmpNode
rng.setStart(node, 0);
selection.setRng(rng);
dom.remove(tmpNode);
return;
}
}
}
};
// Merges the styles for each node
function process(node) {
var children, i, l;
// Grab the children first since the nodelist might be changed
children = tinymce.grep(node.childNodes);
// Process current node
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
formatRootParent = format_root.parentNode;
for (parent = container.parentNode; parent && parent != formatRootParent; parent = parent.parentNode) {
clone = parent.cloneNode(FALSE);
for (i = 0; i < formatList.length; i++) {
if (removeFormat(formatList[i], vars, clone, clone)) {
clone = 0;
break;
}
}
// Build wrapper node
if (clone) {
if (lastClone)
clone.appendChild(lastClone);
if (!firstClone)
firstClone = clone;
lastClone = clone;
}
}
// Never split block elements if the format is mixed
if (split && (!format.mixed || !isBlock(format_root)))
container = dom.split(format_root, container);
// Wrap container in cloned formats
if (lastClone) {
target.parentNode.insertBefore(lastClone, target);
firstClone.appendChild(target);
}
}
return container;
};
function splitToFormatRoot(container) {
return wrapAndSplit(findFormatRoot(container), container, container, true);
};
function unwrap(start) {
var node = dom.get(start ? '_start' : '_end'),
out = node[start ? 'firstChild' : 'lastChild'];
// If the end is placed within the start the result will be removed
// So this checks if the out node is a bookmark node if it is it
// checks for another more suitable node
if (isBookmarkNode(out))
out = out[start ? 'firstChild' : 'lastChild'];
dom.remove(node, true);
return out;
};
function removeRngStyle(rng) {
var startContainer, endContainer;
rng = expandRng(rng, formatList, TRUE);
if (format.split) {
startContainer = getContainer(rng, TRUE);
endContainer = getContainer(rng);
if (startContainer != endContainer) {
// Wrap start/end nodes in span element since these might be cloned/moved
startContainer = wrap(startContainer, 'span', {id : '_start', _mce_type : 'bookmark'});
endContainer = wrap(endContainer, 'span', {id : '_end', _mce_type : 'bookmark'});
// Split start/end
splitToFormatRoot(startContainer);
splitToFormatRoot(endContainer);
// Unwrap start/end to get real elements again
startContainer = unwrap(TRUE);
endContainer = unwrap();
} else
startContainer = endContainer = splitToFormatRoot(startContainer);
// Update range positions since they might have changed after the split operations
rng.startContainer = startContainer.parentNode;
rng.startOffset = nodeIndex(startContainer);
rng.endContainer = endContainer.parentNode;
rng.endOffset = nodeIndex(endContainer) + 1;
}
// Remove items between start/end
rangeUtils.walk(rng, function(nodes) {
each(nodes, function(node) {
process(node);
});
});
};
// Handle node
if (node) {
rng = dom.createRng();
rng.setStartBefore(node);
rng.setEndAfter(node);
removeRngStyle(rng);
return;
}
if (!selection.isCollapsed() || !format.inline) {
bookmark = selection.getBookmark();
removeRngStyle(selection.getRng(TRUE));
selection.moveToBookmark(bookmark);
// Check if start element still has formatting then we are at: "<b>text|</b>text" and need to move the start into the next text node
if (match(name, vars, selection.getStart())) {
moveStart(selection.getRng(true));
}
ed.nodeChanged();
} else
performCaretAction('remove', name, vars);
};
function toggle(name, vars, node) {
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
return TRUE;
// Check for block match
if (isEq(node, format.block))
return TRUE;
// Check for selector match
if (format.selector)
return dom.is(node, format.selector);
};
function isEq(str1, str2) {
str1 = str1 || '';
str2 = str2 || '';
str1 = '' + (str1.nodeName || str1);
str2 = '' + (str2.nodeName || str2);
return str1.toLowerCase() == str2.toLowerCase();
};
function getStyle(node, name) {
var styleVal = dom.getStyle(node, name);
// Force the format to hex
if (name == 'color' || name == 'backgroundColor')
styleVal = dom.toHex(styleVal);
// Opera will return bold as 700
if (name == 'fontWeight' && styleVal == 700)
styleVal = 'bold';
return '' + styleVal;
};
function replaceVars(value, vars) {
if (typeof(value) != "string")
value = value(vars);
else if (vars) {
value = value.replace(/%(\w+)/g, function(str, name) {
return vars[name] || str;
});
}
return value;
};
function isWhiteSpaceNode(node) {
return node && node.nodeType === 3 && /^([\s\r\n]+|)$/.test(node.nodeValue);
};
function wrap(node, name, attrs) {
var wrapper = dom.create(name, attrs);
node.parentNode.insertBefore(wrapper, node);
wrapper.appendChild(node);
return wrapper;
};
function expandRng(rng, format, remove) {
var startContainer = rng.startContainer,
startOffset = rng.startOffset,
endContainer = rng.endContainer,
endOffset = rng.endOffset, sibling, lastIdx;
// This function walks up the tree if there is no siblings before/after the node
function findParentContainer(container, child_name, sibling_name, root) {
var parent, child;
root = root || dom.getRoot();
for (;;) {
// Check if we can move up are we at root level or body level
parent = container.parentNode;
// Stop expanding on block elements or root depending on format
if (parent == root || (!format[0].block_expand && isBlock(parent)))
return container;
for (sibling = parent[child_name]; sibling && sibling != container; sibling = sibling[sibling_name]) {
if (sibling.nodeType == 1 && !isBookmarkNode(sibling))
return container;
if (sibling.nodeType == 3 && !isWhiteSpaceNode(sibling))
return container;
}
container = container.parentNode;
}
return container;
};
// If index based start position then resolve it
if (startContainer.nodeType == 1 && startContainer.hasChildNodes()) {
lastIdx = startContainer.childNodes.length - 1;
startContainer = startContainer.childNodes[startOffset > lastIdx ? lastIdx : startOffset];
if (startContainer.nodeType == 3)
startOffset = 0;
}
// If index based end position then resolve it
if (endContainer.nodeType == 1 && endContainer.hasChildNodes()) {
lastIdx = endContainer.childNodes.length - 1;
endContainer = endContainer.childNodes[endOffset > lastIdx ? lastIdx : endOffset - 1];
if (endContainer.nodeType == 3)
endOffset = endContainer.nodeValue.length;
}
// Exclude bookmark nodes if possible
if (isBookmarkNode(startContainer.parentNode))
startContainer = startContainer.parentNode;
if (isBookmarkNode(startContainer))
startContainer = startContainer.nextSibling || startContainer;
if (isBookmarkNode(endContainer.parentNode))
endContainer = endContainer.parentNode;
if (isBookmarkNode(endContainer))
endContainer = endContainer.previousSibling || endContainer;
// Move start/end point up the tree if the leaves are sharp and if we are in different containers
// Example * becomes !: !<p><b><i>*text</i><i>text*</i></b></p>!
// This will reduce the number of wrapper elements that needs to be created
// Move start point up the tree
if (format[0].inline || format[0].block_expand) {
startContainer = findParentContainer(startContainer, 'firstChild', 'nextSibling');
endContainer = findParentContainer(endContainer, 'lastChild', 'previousSibling');
}
// Expand start/end container to matching selector
if (format[0].selector && format[0].expand !== FALSE && !format[0].inline) {
function findSelectorEndPoint(container, sibling_name) {
var parents, i, y;
if (container.nodeType == 3 && container.nodeValue.length == 0 && container[sibling_name])
container = container[sibling_name];
parents = getParents(container);
for (i = 0; i < parents.length; i++) {
for (y = 0; y < format.length; y++) {
if (dom.is(parents[i], format[y].selector))
return parents[i];
}
}
return container;
};
// Find new startContainer/endContainer if there is better one
startContainer = findSelectorEndPoint(startContainer, 'previousSibling');
endContainer = findSelectorEndPoint(endContainer, 'nextSibling');
}
// Expand start/end container to matching block element or text node
if (format[0].block || format[0].selector) {
function findBlockEndPoint(container, sibling_name, sibling_name2) {
var node;
// Expand to block of similar type
if (!format[0].wrapper)
node = dom.getParent(container, format[0].block);
// Expand to first wrappable block element or any block element
if (!node)
node = dom.getParent(container.nodeType == 3 ? container.parentNode : container, isBlock);
// Exclude inner lists from wrapping
if (node && format[0].wrapper)
node = getParents(node, 'ul,ol').reverse()[0] || node;
// Didn't find a block element look for first/last wrappable element
if (!node) {
node = container;
while (node[sibling_name] && !isBlock(node[sibling_name])) {
node = node[sibling_name];
// Break on BR but include it will be removed later on
// we can't remove it now since we need to check if it can be wrapped
if (isEq(node, 'br'))
break;
}
}
return node || container;
};
// Find new startContainer/endContainer if there is better one
startContainer = findBlockEndPoint(startContainer, 'previousSibling');
endContainer = findBlockEndPoint(endContainer, 'nextSibling');
// Non block element then try to expand up the leaf
if (format[0].block) {
if (!isBlock(startContainer))
startContainer = findParentContainer(startContainer, 'firstChild', 'nextSibling');
if (!isBlock(endContainer))
endContainer = findParentContainer(endContainer, 'lastChild', 'previousSibling');
}
}
// Setup index for startContainer
if (startContainer.nodeType == 1) {
startOffset = nodeIndex(startContainer);
startContainer = startContainer.parentNode;
}
// Setup index for endContainer
if (endContainer.nodeType == 1) {
endOffset = nodeIndex(endContainer) + 1;
endContainer = endContainer.parentNode;
}
// Return new range like object
return {
startContainer : startContainer,
startOffset : startOffset,
endContainer : endContainer,
endOffset : endOffset
};
}
function removeFormat(format, vars, node, compare_node) {
var i, attrs, stylesModified;
// Check if node matches format
if (!matchName(node, format))
return FALSE;
// Should we compare with format attribs and styles
if (format.remove != 'all') {
// Remove styles
each(format.styles, function(value, name) {
value = replaceVars(value, vars);
// Indexed array
if (typeof(name) === 'number') {
name = value;
compare_node = 0;
}
if (!compare_node || isEq(getStyle(compare_node, name), value))
dom.setStyle(node, name, '');
stylesModified = 1;
});
// Remove style attribute if it's empty
if (stylesModified && dom.getAttrib(node, 'style') == '') {
node.removeAttribute('style');
node.removeAttribute('_mce_style');
}
( run in 1.090 second using v1.01-cache-2.11-cpan-5623c5533a1 )