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 (!o)
break;
}
return o;
},
addUnload : function(f, s) {
var t = this;
f = {func : f, scope : s || this};
if (!t.unloads) {
function unload() {
var li = t.unloads, o, n;
if (li) {
// Call unload handlers
for (n in li) {
o = li[n];
if (o && o.func)
o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
}
// Detach unload function
if (win.detachEvent) {
win.detachEvent('onbeforeunload', fakeUnload);
win.detachEvent('onunload', unload);
} else if (win.removeEventListener)
win.removeEventListener('unload', unload, false);
// Destroy references
t.unloads = o = li = w = unload = 0;
// Run garbarge collector on IE
if (win.CollectGarbage)
CollectGarbage();
}
};
function fakeUnload() {
var d = document;
// Is there things still loading, then do some magic
if (d.readyState == 'interactive') {
function stop() {
// Prevent memory leak
d.detachEvent('onstop', stop);
// Call unload handler
if (unload)
unload();
d = 0;
};
// Fire unload when the currently loading page is stopped
if (d)
d.attachEvent('onstop', stop);
// Remove onstop listener after a while to prevent the unload function
// to execute if the user presses cancel in an onbeforeunload
// confirm dialog and then presses the browser stop button
win.setTimeout(function() {
if (d)
d.detachEvent('onstop', stop);
}, 0);
}
};
// Attach unload handler
if (win.attachEvent) {
win.attachEvent('onunload', unload);
win.attachEvent('onbeforeunload', fakeUnload);
} else if (win.addEventListener)
win.addEventListener('unload', unload, false);
// Setup initial unload handler array
t.unloads = [f];
} else
t.unloads.push(f);
return f;
},
removeUnload : function(f) {
var u = this.unloads, r = null;
tinymce.each(u, function(o, i) {
if (o && o.func == f) {
u.splice(i, 1);
r = f;
return false;
}
});
return r;
},
explode : function(s, d) {
return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s;
},
_addVer : function(u) {
var v;
if (!this.query)
return u;
v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
if (u.indexOf('#') == -1)
return u + v;
return u.replace('#', v + '#');
}
};
// Initialize the API
tinymce._init();
// Expose tinymce namespace to the global namespace (window)
win.tinymce = win.tinyMCE = tinymce;
})(window);
tinymce.create('tinymce.util.Dispatcher', {
scope : null,
listeners : null,
Dispatcher : function(s) {
this.scope = s || this;
this.listeners = [];
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
},
clear : function(o) {
var t = this, a = t.events, i, e;
if (o) {
o = DOM.get(o);
for (i = a.length - 1; i >= 0; i--) {
e = a[i];
if (e.obj === o) {
t._remove(e.obj, e.name, e.cfunc);
e.obj = e.cfunc = null;
a.splice(i, 1);
}
}
}
},
cancel : function(e) {
if (!e)
return false;
this.stop(e);
return this.prevent(e);
},
stop : function(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
return false;
},
prevent : function(e) {
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
return false;
},
destroy : function() {
var t = this;
each(t.events, function(e, i) {
t._remove(e.obj, e.name, e.cfunc);
e.obj = e.cfunc = null;
});
t.events = [];
t = null;
},
_add : function(o, n, f) {
if (o.attachEvent)
o.attachEvent('on' + n, f);
else if (o.addEventListener)
o.addEventListener(n, f, false);
else
o['on' + n] = f;
},
_remove : function(o, n, f) {
if (o) {
try {
if (o.detachEvent)
o.detachEvent('on' + n, f);
else if (o.removeEventListener)
o.removeEventListener(n, f, false);
else
o['on' + n] = null;
} catch (ex) {
// Might fail with permission denined on IE so we just ignore that
}
}
},
_pageInit : function(win) {
var t = this;
// Keep it from running more than once
if (t.domLoaded)
return;
t.domLoaded = true;
each(t.inits, function(c) {
c();
});
t.inits = [];
},
_wait : function(win) {
var t = this, doc = win.document;
// No need since the document is already loaded
if (win.tinyMCE_GZ && tinyMCE_GZ.loaded) {
t.domLoaded = 1;
return;
}
// Use IE method
if (doc.attachEvent) {
doc.attachEvent("onreadystatechange", function() {
if (doc.readyState === "complete") {
doc.detachEvent("onreadystatechange", arguments.callee);
t._pageInit(win);
}
});
if (doc.documentElement.doScroll && win == win.top) {
(function() {
if (t.domLoaded)
return;
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
doc.documentElement.doScroll("left");
} catch (ex) {
setTimeout(arguments.callee, 0);
return;
}
t._pageInit(win);
})();
}
} else if (doc.addEventListener) {
t._add(win, 'DOMContentLoaded', function() {
t._pageInit(win);
});
}
t._add(win, 'load', function() {
t._pageInit(win);
});
},
_stoppers : {
preventDefault : function() {
this.returnValue = false;
},
stopPropagation : function() {
this.cancelBubble = true;
}
}
});
Event = tinymce.dom.Event = new tinymce.dom.EventUtils();
// Dispatch DOM content loaded event for IE and Safari
Event._wait(window);
tinymce.addUnload(function() {
Event.destroy();
});
})(tinymce);
(function(tinymce) {
tinymce.dom.Element = function(id, settings) {
var t = this, dom, el;
t.settings = settings = settings || {};
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
// Remove single BR at end of block elements since they get rendered
o.content = o.content.replace(/(<br \/>\s*)+<\/(p|h[1-6]|div|li)>/gi, function(a, b, c) {
// Check if it's a single element
if (/^<br \/>\s*<\//.test(a))
return '</' + c + '>';
return a;
});
});
}
// Remove XHTML element endings i.e. produce crap :) XHTML is better
if (s.element_format == 'html') {
t.onPostProcess.add(function(se, o) {
o.content = o.content.replace(/<([^>]+) \/>/g, '<$1>');
});
}
if (s.fix_list_elements) {
t.onPreProcess.add(function(se, o) {
var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np;
function prevNode(e, n) {
var a = n.split(','), i;
while ((e = e.previousSibling) != null) {
for (i=0; i<a.length; i++) {
if (e.nodeName == a[i])
return e;
}
}
return null;
};
for (x=0; x<a.length; x++) {
nl = t.dom.select(a[x], o.node);
for (i=0; i<nl.length; i++) {
n = nl[i];
p = n.parentNode;
if (r.test(p.nodeName)) {
np = prevNode(n, 'LI');
if (!np) {
np = t.dom.create('li');
np.innerHTML = ' ';
np.appendChild(n);
p.insertBefore(np, p.firstChild);
} else
np.appendChild(n);
}
}
}
});
}
if (s.fix_table_elements) {
t.onPreProcess.add(function(se, o) {
// Since Opera will crash if you attach the node to a dynamic document we need to brrowser sniff a specific build
// so Opera users with an older version will have to live with less compaible output not much we can do here
if (!tinymce.isOpera || opera.buildNumber() >= 1767) {
each(t.dom.select('p table', o.node).reverse(), function(n) {
var parent = t.dom.getParent(n.parentNode, 'table,p');
if (parent.nodeName != 'TABLE') {
try {
t.dom.split(parent, n);
} catch (ex) {
// IE can sometimes fire an unknown runtime error so we just ignore it
}
}
});
}
});
}
},
setEntities : function(s) {
var t = this, a, i, l = {}, v;
// No need to setup more than once
if (t.entityLookup)
return;
// Build regex and lookup array
a = s.split(',');
for (i = 0; i < a.length; i += 2) {
v = a[i];
// Don't add default & " etc.
if (v == 34 || v == 38 || v == 60 || v == 62)
continue;
l[String.fromCharCode(a[i])] = a[i + 1];
v = parseInt(a[i]).toString(16);
}
t.entityLookup = l;
},
setRules : function(s) {
var t = this;
t._setup();
t.rules = {};
t.wildRules = [];
t.validElements = {};
return t.addRules(s);
},
addRules : function(s) {
var t = this, dr;
if (!s)
return;
t._setup();
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
findRule : function(n) {
var t = this, rl = t.rules, i, r;
t._setup();
// Exact match
r = rl[n];
if (r)
return r;
// Try wildcards
rl = t.wildRules;
for (i = 0; i < rl.length; i++) {
if (rl[i].nameRE.test(n))
return rl[i];
}
return null;
},
findAttribRule : function(ru, n) {
var i, wa = ru.wildAttribs;
for (i = 0; i < wa.length; i++) {
if (wa[i].nameRE.test(n))
return wa[i];
}
return null;
},
serialize : function(n, o) {
var h, t = this, doc, oldDoc, impl, selected;
t._setup();
o = o || {};
o.format = o.format || 'html';
t.processObj = o;
// IE looses the selected attribute on option elements so we need to store it
// See: http://support.microsoft.com/kb/829907
if (isIE) {
selected = [];
each(n.getElementsByTagName('option'), function(n) {
var v = t.dom.getAttrib(n, 'selected');
selected.push(v ? v : null);
});
}
n = n.cloneNode(true);
// IE looses the selected attribute on option elements so we need to restore it
if (isIE) {
each(n.getElementsByTagName('option'), function(n, i) {
t.dom.setAttrib(n, 'selected', selected[i]);
});
}
// Nodes needs to be attached to something in WebKit/Opera
// Older builds of Opera crashes if you attach the node to an document created dynamically
// and since we can't feature detect a crash we need to sniff the acutal build number
// This fix will make DOM ranges and make Sizzle happy!
impl = n.ownerDocument.implementation;
if (impl.createHTMLDocument && (tinymce.isOpera && opera.buildNumber() >= 1767)) {
// Create an empty HTML document
doc = impl.createHTMLDocument("");
// Add the element or it's children if it's a body element to the new document
each(n.nodeName == 'BODY' ? n.childNodes : [n], function(node) {
doc.body.appendChild(doc.importNode(node, true));
});
// Grab first child or body element for serialization
if (n.nodeName != 'BODY')
n = doc.body.firstChild;
else
n = doc.body;
// set the new document in DOMUtils so createElement etc works
oldDoc = t.dom.doc;
t.dom.doc = doc;
}
t.key = '' + (parseInt(t.key) + 1);
// Pre process
if (!o.no_events) {
o.node = n;
t.onPreProcess.dispatch(t, o);
}
// Serialize HTML DOM into a string
t.writer.reset();
t._info = o;
t._serializeNode(n, o.getInner);
// Post process
o.content = t.writer.getContent();
// Restore the old document if it was changed
if (oldDoc)
t.dom.doc = oldDoc;
if (!o.no_events)
t.onPostProcess.dispatch(t, o);
t._postProcess(o);
o.node = null;
return tinymce.trim(o.content);
},
// Internal functions
_postProcess : function(o) {
var t = this, s = t.settings, h = o.content, sc = [], p;
if (o.format == 'html') {
// Protect some elements
p = t._protect({
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
onAdd : new Dispatcher(this),
get : function(n) {
return this.lookup[n];
},
requireLangPack : function(n) {
var s = tinymce.settings;
if (s && s.language)
tinymce.ScriptLoader.add(this.urls[n] + '/langs/' + s.language + '.js');
},
add : function(id, o) {
this.items.push(o);
this.lookup[id] = o;
this.onAdd.dispatch(this, id, o);
return o;
},
load : function(n, u, cb, s) {
var t = this;
if (t.urls[n])
return;
if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
u = tinymce.baseURL + '/' + u;
t.urls[n] = u.substring(0, u.lastIndexOf('/'));
tinymce.ScriptLoader.add(u, cb, s);
}
});
// Create plugin and theme managers
tinymce.PluginManager = new tinymce.AddOnManager();
tinymce.ThemeManager = new tinymce.AddOnManager();
}(tinymce));
(function(tinymce) {
// Shorten names
var each = tinymce.each, extend = tinymce.extend,
DOM = tinymce.DOM, Event = tinymce.dom.Event,
ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager,
explode = tinymce.explode,
Dispatcher = tinymce.util.Dispatcher, undefined, instanceCounter = 0;
// Setup some URLs where the editor API is located and where the document is
tinymce.documentBaseURL = window.location.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
if (!/[\/\\]$/.test(tinymce.documentBaseURL))
tinymce.documentBaseURL += '/';
tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
tinymce.baseURI = new tinymce.util.URI(tinymce.baseURL);
// Add before unload listener
// This was required since IE was leaking memory if you added and removed beforeunload listeners
// with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event
tinymce.onBeforeUnload = new Dispatcher(tinymce);
// Must be on window or IE will leak if the editor is placed in frame or iframe
Event.add(window, 'beforeunload', function(e) {
tinymce.onBeforeUnload.dispatch(tinymce, e);
});
tinymce.onAddEditor = new Dispatcher(tinymce);
tinymce.onRemoveEditor = new Dispatcher(tinymce);
tinymce.EditorManager = extend(tinymce, {
editors : [],
i18n : {},
activeEditor : null,
init : function(s) {
var t = this, pl, sl = tinymce.ScriptLoader, e, el = [], ed;
function execCallback(se, n, s) {
var f = se[n];
if (!f)
return;
if (tinymce.is(f, 'string')) {
s = f.replace(/\.\w+$/, '');
s = s ? tinymce.resolve(s) : 0;
f = tinymce.resolve(f);
}
return f.apply(s || this, Array.prototype.slice.call(arguments, 2));
};
s = extend({
theme : "simple",
language : "en"
}, s);
t.settings = s;
// Legacy call
Event.add(document, 'init', function() {
var l, co;
execCallback(s, 'onpageload');
switch (s.mode) {
case "exact":
l = s.elements || '';
if(l.length > 0) {
each(explode(l), function(v) {
if (DOM.get(v)) {
ed = new tinymce.Editor(v, s);
el.push(ed);
ed.render(1);
} else {
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/tiny_mce_src.js view on Meta::CPAN
// Not in the collection
if (!editors[editor.id])
return null;
delete editors[editor.id];
for (i = 0; i < editors.length; i++) {
if (editors[i] == editor) {
editors.splice(i, 1);
break;
}
}
// Select another editor since the active one was removed
if (t.activeEditor == editor)
t._setActive(editors[0]);
editor.destroy();
t.onRemoveEditor.dispatch(t, editor);
return editor;
},
execCommand : function(c, u, v) {
var t = this, ed = t.get(v), w;
// Manager commands
switch (c) {
case "mceFocus":
ed.focus();
return true;
case "mceAddEditor":
case "mceAddControl":
if (!t.get(v))
new tinymce.Editor(v, t.settings).render();
return true;
case "mceAddFrameControl":
w = v.window;
// Add tinyMCE global instance and tinymce namespace to specified window
w.tinyMCE = tinyMCE;
w.tinymce = tinymce;
tinymce.DOM.doc = w.document;
tinymce.DOM.win = w;
ed = new tinymce.Editor(v.element_id, v);
ed.render();
// Fix IE memory leaks
if (tinymce.isIE) {
function clr() {
ed.destroy();
w.detachEvent('onunload', clr);
w = w.tinyMCE = w.tinymce = null; // IE leak
};
w.attachEvent('onunload', clr);
}
v.page_window = null;
return true;
case "mceRemoveEditor":
case "mceRemoveControl":
if (ed)
ed.remove();
return true;
case 'mceToggleEditor':
if (!ed) {
t.execCommand('mceAddControl', 0, v);
return true;
}
if (ed.isHidden())
ed.show();
else
ed.hide();
return true;
}
// Run command on active editor
if (t.activeEditor)
return t.activeEditor.execCommand(c, u, v);
return false;
},
execInstanceCommand : function(id, c, u, v) {
var ed = this.get(id);
if (ed)
return ed.execCommand(c, u, v);
return false;
},
triggerSave : function() {
each(this.editors, function(e) {
e.save();
});
},
addI18n : function(p, o) {
var lo, i18n = this.i18n;
if (!tinymce.is(p, 'string')) {
each(p, function(o, lc) {
each(o, function(o, g) {
each(o, function(o, k) {
if (g === 'common')
i18n[lc + '.' + k] = o;
else
i18n[lc + '.' + g + '.' + k] = o;
( run in 0.363 second using v1.01-cache-2.11-cpan-e1769b4cff6 )