| | |
| | |
|
| | | /* file:jscripts/tiny_mce/classes/tinymce.js */
|
| | |
|
| | | var tinymce = {
|
| | | majorVersion : '3',
|
| | | minorVersion : '0.6.2',
|
| | | releaseDate : '2008-04-07',
|
| | | minorVersion : '2.3',
|
| | | releaseDate : '2009-04-23',
|
| | |
|
| | | _init : function() {
|
| | | var t = this, ua = navigator.userAgent, i, nl, n, base;
|
| | | var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
|
| | |
|
| | | // Browser checks
|
| | | t.isOpera = window.opera && opera.buildNumber;
|
| | | t.isOpera = w.opera && opera.buildNumber;
|
| | | t.isWebKit = /WebKit/.test(ua);
|
| | | t.isOldWebKit = t.isWebKit && !window.getSelection().getRangeAt;
|
| | | t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);
|
| | | t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
|
| | | t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
|
| | | t.isGecko = !t.isWebKit && /Gecko/.test(ua);
|
| | | t.isMac = ua.indexOf('Mac') != -1;
|
| | | t.isAir = /adobeair/i.test(ua);
|
| | |
|
| | | // TinyMCE .NET webcontrol might be setting the values for TinyMCE
|
| | | if (window.tinyMCEPreInit) {
|
| | | if (w.tinyMCEPreInit) {
|
| | | t.suffix = tinyMCEPreInit.suffix;
|
| | | t.baseURL = tinyMCEPreInit.base;
|
| | | t.query = tinyMCEPreInit.query;
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | t.suffix = '';
|
| | |
|
| | | // If base element found, add that infront of baseURL
|
| | | nl = document.getElementsByTagName('base');
|
| | | nl = d.getElementsByTagName('base');
|
| | | for (i=0; i<nl.length; i++) {
|
| | | if (nl[i].href)
|
| | | base = nl[i].href;
|
| | | if (v = nl[i].href) {
|
| | | // Host only value like http://site.com or http://site.com:8008
|
| | | if (/^https?:\/\/[^\/]+$/.test(v))
|
| | | v += '/';
|
| | |
|
| | | base = v ? v.match(/.*\//)[0] : ''; // Get only directory
|
| | | }
|
| | | }
|
| | |
|
| | | function getBase(n) {
|
| | | if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
|
| | | if (/_(src|dev)\.js/g.test(n.src))
|
| | | t.suffix = '_src';
|
| | |
|
| | | if ((p = n.src.indexOf('?')) != -1)
|
| | | t.query = n.src.substring(p + 1);
|
| | |
|
| | | t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
|
| | |
|
| | |
| | | };
|
| | |
|
| | | // Check document
|
| | | nl = document.getElementsByTagName('script');
|
| | | nl = d.getElementsByTagName('script');
|
| | | for (i=0; i<nl.length; i++) {
|
| | | if (getBase(nl[i]))
|
| | | return;
|
| | | }
|
| | |
|
| | | // Check head
|
| | | n = document.getElementsByTagName('head')[0];
|
| | | n = d.getElementsByTagName('head')[0];
|
| | | if (n) {
|
| | | nl = n.getElementsByTagName('script');
|
| | | for (i=0; i<nl.length; i++) {
|
| | |
| | | if (!t)
|
| | | return n != 'undefined';
|
| | |
|
| | | if (t == 'array' && (o instanceof Array))
|
| | | if (t == 'array' && (o.hasOwnProperty && o instanceof Array))
|
| | | return true;
|
| | |
|
| | | return n == t;
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | each : function(o, cb, s) {
|
| | | var n, l;
|
| | |
| | | return (s ? '' + s : '').replace(/^\s*|\s*$/g, '');
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | create : function(s, p) {
|
| | | var t = this, sp, ns, cn, scn, c, de = 0;
|
| | |
| | | },
|
| | |
|
| | | addUnload : function(f, s) {
|
| | | var t = this, w = window, unload;
|
| | | var t = this, w = window;
|
| | |
|
| | | f = {func : f, scope : s || this};
|
| | |
|
| | | if (!t.unloads) {
|
| | | unload = function() {
|
| | | function unload() {
|
| | | var li = t.unloads, o, n;
|
| | |
|
| | | // Call unload handlers
|
| | | for (n in li) {
|
| | | o = li[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
|
| | | if (o && o.func)
|
| | | o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
|
| | | }
|
| | |
|
| | | // Detach unload function
|
| | | if (w.detachEvent) {
|
| | | w.detachEvent('onbeforeunload', fakeUnload);
|
| | | w.detachEvent('onunload', unload);
|
| | | } else if (w.removeEventListener)
|
| | | w.removeEventListener('unload', unload, false);
|
| | |
|
| | | // Destroy references
|
| | | t.unloads = o = li = w = unload = 0;
|
| | |
|
| | | // Run garbarge collector on IE
|
| | | if (window.CollectGarbage)
|
| | | window.CollectGarbage();
|
| | | }
|
| | | };
|
| | |
|
| | | // Detach unload function
|
| | | if (w.detachEvent)
|
| | | w.detachEvent('onunload', unload);
|
| | | else if (w.removeEventListener)
|
| | | w.removeEventListener('unload', unload, false);
|
| | | function fakeUnload() {
|
| | | var d = document;
|
| | |
|
| | | // Destroy references
|
| | | o = li = w = unload = null;
|
| | | // Is there things still loading, then do some magic
|
| | | if (d.readyState == 'interactive') {
|
| | | function stop() {
|
| | | // Prevent memory leak
|
| | | d.detachEvent('onstop', stop);
|
| | |
|
| | | // Run garbarge collector on IE
|
| | | if (window.CollectGarbage)
|
| | | window.CollectGarbage();
|
| | | // 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
|
| | | window.setTimeout(function() {
|
| | | if (d)
|
| | | d.detachEvent('onstop', stop);
|
| | | }, 0);
|
| | | }
|
| | | };
|
| | |
|
| | | // Attach unload handler
|
| | | if (w.attachEvent)
|
| | | if (w.attachEvent) {
|
| | | w.attachEvent('onunload', unload);
|
| | | else if (w.addEventListener)
|
| | | w.attachEvent('onbeforeunload', fakeUnload);
|
| | | } else if (w.addEventListener)
|
| | | w.addEventListener('unload', unload, false);
|
| | |
|
| | | // Setup initial unload handler array
|
| | |
| | | },
|
| | |
|
| | | explode : function(s, d) {
|
| | | return tinymce.map(s.split(d || ','), tinymce.trim);
|
| | | 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();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */
|
| | |
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */
|
| | |
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/Dispatcher.js */
|
| | |
|
| | | tinymce.create('tinymce.util.Dispatcher', {
|
| | | scope : null,
|
| | | listeners : null,
|
| | |
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/URI.js */
|
| | |
|
| | | (function() {
|
| | | var each = tinymce.each;
|
| | |
|
| | |
| | | s = t.settings = s || {};
|
| | |
|
| | | // Strange app protocol or local anchor
|
| | | if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
|
| | | if (/^(mailto|tel|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
|
| | | t.source = u;
|
| | | return;
|
| | | }
|
| | |
| | | u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
|
| | |
|
| | | // Relative path
|
| | | if (u.indexOf('://') === -1 && u.indexOf('//') !== 0)
|
| | | if (u.indexOf(':/') === -1 && u.indexOf('//') !== 0)
|
| | | u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u);
|
| | |
|
| | | // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
|
| | |
| | | toRelative : function(u) {
|
| | | var t = this, o;
|
| | |
|
| | | if (u === "./")
|
| | | return u;
|
| | |
|
| | | u = new tinymce.util.URI(u, {base_uri : t});
|
| | |
|
| | | // Not on same domain/port or protocol
|
| | |
| | | },
|
| | |
|
| | | toRelPath : function(base, path) {
|
| | | var items, bp = 0, out = '', i;
|
| | | var items, bp = 0, out = '', i, l;
|
| | |
|
| | | // Split the paths
|
| | | base = base.substring(0, base.lastIndexOf('/'));
|
| | |
| | | items = path.split('/');
|
| | |
|
| | | if (base.length >= items.length) {
|
| | | for (i = 0; i < base.length; i++) {
|
| | | for (i = 0, l = base.length; i < l; i++) {
|
| | | if (i >= items.length || base[i] != items[i]) {
|
| | | bp = i + 1;
|
| | | break;
|
| | |
| | | }
|
| | |
|
| | | if (base.length < items.length) {
|
| | | for (i = 0; i < items.length; i++) {
|
| | | for (i = 0, l = items.length; i < l; i++) {
|
| | | if (i >= base.length || base[i] != items[i]) {
|
| | | bp = i + 1;
|
| | | break;
|
| | |
| | | if (bp == 1)
|
| | | return path;
|
| | |
|
| | | for (i = 0; i < base.length - (bp - 1); i++)
|
| | | for (i = 0, l = base.length - (bp - 1); i < l; i++)
|
| | | out += "../";
|
| | |
|
| | | for (i = bp - 1; i < items.length; i++) {
|
| | | for (i = bp - 1, l = items.length; i < l; i++) {
|
| | | if (i != bp - 1)
|
| | | out += "/" + items[i];
|
| | | else
|
| | |
| | | },
|
| | |
|
| | | toAbsPath : function(base, path) {
|
| | | var i, nb = 0, o = [];
|
| | | var i, nb = 0, o = [], tr;
|
| | |
|
| | | // Split paths
|
| | | tr = /\/$/.test(path) ? '/' : '';
|
| | | base = base.split('/');
|
| | | path = path.split('/');
|
| | |
|
| | |
| | |
|
| | | // If /a/b/c or /
|
| | | if (i <= 0)
|
| | | return '/' + o.reverse().join('/');
|
| | | return '/' + o.reverse().join('/') + tr;
|
| | |
|
| | | return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
|
| | | return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/') + tr;
|
| | | },
|
| | |
|
| | | getURI : function(nh) {
|
| | |
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/Cookie.js */
|
| | |
|
| | | (function() {
|
| | | var each = tinymce.each;
|
| | |
|
| | |
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/JSON.js */
|
| | |
|
| | | tinymce.create('static tinymce.util.JSON', {
|
| | | serialize : function(o) {
|
| | | var i, v, s = tinymce.util.JSON.serialize, t;
|
| | |
| | | if (t == 'string') {
|
| | | v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
|
| | |
|
| | | return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'])/g, function(a, b) {
|
| | | return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) {
|
| | | i = v.indexOf(b);
|
| | |
|
| | | if (i + 1)
|
| | |
| | | }
|
| | |
|
| | | if (t == 'object') {
|
| | | if (o instanceof Array) {
|
| | | if (o.hasOwnProperty && o instanceof Array) {
|
| | | for (i=0, v = '['; i<o.length; i++)
|
| | | v += (i > 0 ? ',' : '') + s(o[i]);
|
| | |
|
| | |
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/XHR.js */
|
| | |
|
| | | tinymce.create('static tinymce.util.XHR', {
|
| | | send : function(o) {
|
| | | var x, t, w = window, c = 0;
|
| | |
| | |
|
| | | x.send(o.data);
|
| | |
|
| | | // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
|
| | | t = w.setInterval(function() {
|
| | | if (x.readyState == 4 || c++ > 10000) {
|
| | | w.clearInterval(t);
|
| | |
|
| | | function ready() {
|
| | | if (!o.async || x.readyState == 4 || c++ > 10000) {
|
| | | if (o.success && c < 10000 && x.status == 200)
|
| | | o.success.call(o.success_scope, '' + x.responseText, x, o);
|
| | | else if (o.error)
|
| | | o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
|
| | |
|
| | | x = null;
|
| | | }
|
| | | }, 10);
|
| | | } else
|
| | | w.setTimeout(ready, 10);
|
| | | };
|
| | |
|
| | | // Syncronous request
|
| | | if (!o.async)
|
| | | return ready();
|
| | |
|
| | | // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
|
| | | t = w.setTimeout(ready, 10);
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/util/JSONRequest.js */
|
| | |
|
| | | (function() {
|
| | | var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | }());
|
| | | /* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */
|
| | |
|
| | | (function() {
|
| | | }());(function(tinymce) {
|
| | | // Shorten names
|
| | | var each = tinymce.each, is = tinymce.is;
|
| | | var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE;
|
| | |
| | | doc : null,
|
| | | root : null,
|
| | | files : null,
|
| | | listeners : {},
|
| | | pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/,
|
| | | cache : {},
|
| | | idPattern : /^#[\w]+$/,
|
| | | elmPattern : /^[\w_*]+$/,
|
| | | elmClassPattern : /^([\w_]*)\.([\w_]+)$/,
|
| | | props : {
|
| | | "for" : "htmlFor",
|
| | | "class" : "className",
|
| | | className : "className",
|
| | | checked : "checked",
|
| | | disabled : "disabled",
|
| | | maxlength : "maxLength",
|
| | | readonly : "readOnly",
|
| | | selected : "selected",
|
| | | value : "value",
|
| | | id : "id",
|
| | | name : "name",
|
| | | type : "type"
|
| | | },
|
| | |
|
| | | DOMUtils : function(d, s) {
|
| | | var t = this;
|
| | |
| | | },
|
| | |
|
| | | getRect : function(e) {
|
| | | var p, t = this, w, h;
|
| | | var p, t = this, sr;
|
| | |
|
| | | e = t.get(e);
|
| | | p = t.getPos(e);
|
| | | sr = t.getSize(e);
|
| | |
|
| | | return {
|
| | | x : p.x,
|
| | | y : p.y,
|
| | | w : sr.w,
|
| | | h : sr.h
|
| | | };
|
| | | },
|
| | |
|
| | | getSize : function(e) {
|
| | | var t = this, w, h;
|
| | |
|
| | | e = t.get(e);
|
| | | w = t.getStyle(e, 'width');
|
| | | h = t.getStyle(e, 'height');
|
| | |
|
| | |
| | | h = 0;
|
| | |
|
| | | return {
|
| | | x : p.x,
|
| | | y : p.y,
|
| | | w : parseInt(w) || e.offsetWidth || e.clientWidth,
|
| | | h : parseInt(h) || e.offsetHeight || e.clientHeight
|
| | | };
|
| | | },
|
| | |
|
| | | getParent : function(n, f, r) {
|
| | | var na, se = this.settings;
|
| | | is : function(n, patt) {
|
| | | return tinymce.dom.Sizzle.matches(patt, n.nodeType ? [n] : n).length > 0;
|
| | | },
|
| | |
|
| | | n = this.get(n);
|
| | | getParent : function(n, f, r) {
|
| | | return this.getParents(n, f, r, false);
|
| | | },
|
| | |
|
| | | getParents : function(n, f, r, c) {
|
| | | var t = this, na, se = t.settings, o = [];
|
| | |
|
| | | n = t.get(n);
|
| | | c = c === undefined;
|
| | |
|
| | | if (se.strict_root)
|
| | | r = r || this.getRoot();
|
| | | r = r || t.getRoot();
|
| | |
|
| | | // Wrap node name as func
|
| | | if (is(f, 'string')) {
|
| | | na = f.toUpperCase();
|
| | | na = f;
|
| | |
|
| | | f = function(n) {
|
| | | var s = false;
|
| | |
|
| | | // Any element
|
| | | if (n.nodeType == 1 && na === '*') {
|
| | | s = true;
|
| | | return false;
|
| | | }
|
| | |
|
| | | each(na.split(','), function(v) {
|
| | | if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName == v)) {
|
| | | s = true;
|
| | | return false; // Break loop
|
| | | }
|
| | | });
|
| | |
|
| | | return s;
|
| | | };
|
| | | if (f === '*') {
|
| | | f = function(n) {return n.nodeType == 1;};
|
| | | } else {
|
| | | f = function(n) {
|
| | | return t.is(n, na);
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | while (n) {
|
| | | if (n == r)
|
| | | return null;
|
| | | if (n == r || !n.nodeType || n.nodeType === 9)
|
| | | break;
|
| | |
|
| | | if (f(n))
|
| | | return n;
|
| | | if (!f || f(n)) {
|
| | | if (c)
|
| | | o.push(n);
|
| | | else
|
| | | return n;
|
| | | }
|
| | |
|
| | | n = n.parentNode;
|
| | | }
|
| | |
|
| | | return null;
|
| | | return c ? o : null;
|
| | | },
|
| | |
|
| | | get : function(e) {
|
| | | var n;
|
| | |
|
| | | if (this.doc && typeof(e) == 'string') {
|
| | | if (e && this.doc && typeof(e) == 'string') {
|
| | | n = e;
|
| | | e = this.doc.getElementById(e);
|
| | |
|
| | |
| | | return e;
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | select : function(pa, s) {
|
| | | var t = this, cs, c, pl, o = [], x, i, l, n;
|
| | | var t = this;
|
| | |
|
| | | s = t.get(s) || t.doc;
|
| | |
|
| | | // Look for native support and use that if it's found
|
| | | if (s.querySelectorAll) {
|
| | | // Element scope then use temp id
|
| | | // We need to do this to be compatible with other implementations
|
| | | // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461
|
| | | if (s != t.doc) {
|
| | | i = s.id;
|
| | | s.id = '_mc_tmp';
|
| | | pa = '#_mc_tmp ' + pa;
|
| | | }
|
| | |
|
| | | // Select elements
|
| | | l = tinymce.grep(s.querySelectorAll(pa));
|
| | |
|
| | | // Restore old id
|
| | | s.id = i;
|
| | |
|
| | | return l;
|
| | | }
|
| | |
|
| | | if (t.settings.strict) {
|
| | | function get(s, n) {
|
| | | return s.getElementsByTagName(n.toLowerCase());
|
| | | };
|
| | | } else {
|
| | | function get(s, n) {
|
| | | return s.getElementsByTagName(n);
|
| | | };
|
| | | }
|
| | |
|
| | | // Simple element pattern. For example: "p" or "*"
|
| | | if (t.elmPattern.test(pa)) {
|
| | | x = get(s, pa);
|
| | |
|
| | | for (i = 0, l = x.length; i<l; i++)
|
| | | o.push(x[i]);
|
| | |
|
| | | return o;
|
| | | }
|
| | |
|
| | | // Simple class pattern. For example: "p.class" or ".class"
|
| | | if (t.elmClassPattern.test(pa)) {
|
| | | pl = t.elmClassPattern.exec(pa);
|
| | | x = get(s, pl[1] || '*');
|
| | | c = ' ' + pl[2] + ' ';
|
| | |
|
| | | for (i = 0, l = x.length; i<l; i++) {
|
| | | n = x[i];
|
| | |
|
| | | if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
|
| | | o.push(n);
|
| | | }
|
| | |
|
| | | return o;
|
| | | }
|
| | |
|
| | | function collect(n) {
|
| | | if (!n.mce_save) {
|
| | | n.mce_save = 1;
|
| | | o.push(n);
|
| | | }
|
| | | };
|
| | |
|
| | | function collectIE(n) {
|
| | | if (!n.getAttribute('mce_save')) {
|
| | | n.setAttribute('mce_save', '1');
|
| | | o.push(n);
|
| | | }
|
| | | };
|
| | |
|
| | | function find(n, f, r) {
|
| | | var i, l, nl = get(r, n);
|
| | |
|
| | | for (i = 0, l = nl.length; i < l; i++)
|
| | | f(nl[i]);
|
| | | };
|
| | |
|
| | | each(pa.split(','), function(v, i) {
|
| | | v = tinymce.trim(v);
|
| | |
|
| | | // Simple element pattern, most common in TinyMCE
|
| | | if (t.elmPattern.test(v)) {
|
| | | each(get(s, v), function(n) {
|
| | | collect(n);
|
| | | });
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // Simple element pattern with class, fairly common in TinyMCE
|
| | | if (t.elmClassPattern.test(v)) {
|
| | | x = t.elmClassPattern.exec(v);
|
| | |
|
| | | each(get(s, x[1]), function(n) {
|
| | | if (t.hasClass(n, x[2]))
|
| | | collect(n);
|
| | | });
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!(cs = t.cache[pa])) {
|
| | | cs = 'x=(function(cf, s) {';
|
| | | pl = v.split(' ');
|
| | |
|
| | | each(pl, function(v) {
|
| | | var p = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i.exec(v);
|
| | |
|
| | | // Find elements
|
| | | p[1] = p[1] || '*';
|
| | | cs += 'find("' + p[1] + '", function(n) {';
|
| | |
|
| | | // Check id
|
| | | if (p[2])
|
| | | cs += 'if (n.id !== "' + p[2] + '") return;';
|
| | |
|
| | | // Check classes
|
| | | if (p[3]) {
|
| | | cs += 'var c = " " + n.className + " ";';
|
| | | cs += 'if (';
|
| | | c = '';
|
| | | each(p[3].split('.'), function(v) {
|
| | | if (v)
|
| | | c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
|
| | | });
|
| | | cs += c + ') return;';
|
| | | }
|
| | | });
|
| | |
|
| | | cs += 'cf(n);';
|
| | |
|
| | | for (i = pl.length - 1; i >= 0; i--)
|
| | | cs += '}, ' + (i ? 'n' : 's') + ');';
|
| | |
|
| | | cs += '})';
|
| | |
|
| | | // Compile CSS pattern function
|
| | | t.cache[pa] = cs = eval(cs);
|
| | | }
|
| | |
|
| | | // Run selector function
|
| | | cs(isIE ? collectIE : collect, s);
|
| | | });
|
| | |
|
| | | // Cleanup
|
| | | each(o, function(n) {
|
| | | if (isIE)
|
| | | n.removeAttribute('mce_save');
|
| | | else
|
| | | delete n.mce_save;
|
| | | });
|
| | |
|
| | | return o;
|
| | | return tinymce.dom.Sizzle(pa, t.get(s) || t.get(t.settings.root_element) || t.doc, []);
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | add : function(p, n, a, h, c) {
|
| | | var t = this;
|
| | |
| | | var e, k;
|
| | |
|
| | | e = is(n, 'string') ? t.doc.createElement(n) : n;
|
| | |
|
| | | if (a) {
|
| | | for (k in a) {
|
| | | if (a.hasOwnProperty(k) && !is(a[k], 'object'))
|
| | | t.setAttrib(e, k, '' + a[k]);
|
| | | }
|
| | |
|
| | | if (a.style && !is(a.style, 'string')) {
|
| | | each(a.style, function(v, n) {
|
| | | t.setStyle(e, n, v);
|
| | | });
|
| | | }
|
| | | }
|
| | | t.setAttribs(e, a);
|
| | |
|
| | | if (h) {
|
| | | if (h.nodeType)
|
| | |
| | | },
|
| | |
|
| | | remove : function(n, k) {
|
| | | var t = this;
|
| | |
|
| | | return this.run(n, function(n) {
|
| | | var p, g;
|
| | | var p, g, i;
|
| | |
|
| | | p = n.parentNode;
|
| | |
|
| | |
| | | return null;
|
| | |
|
| | | if (k) {
|
| | | each (n.childNodes, function(c) {
|
| | | p.insertBefore(c.cloneNode(true), n);
|
| | | });
|
| | | for (i = n.childNodes.length - 1; i >= 0; i--)
|
| | | t.insertAfter(n.childNodes[i], n);
|
| | |
|
| | | //each(n.childNodes, function(c) {
|
| | | // p.insertBefore(c.cloneNode(true), n);
|
| | | //});
|
| | | }
|
| | |
|
| | | // Fix IE psuedo leak
|
| | | /* if (isIE) {
|
| | | if (t.fixPsuedoLeaks) {
|
| | | p = n.cloneNode(true);
|
| | | n.outerHTML = '';
|
| | | k = 'IELeakGarbageBin';
|
| | | g = t.get(k) || t.add(t.doc.body, 'div', {id : k, style : 'display:none'});
|
| | | g.appendChild(n);
|
| | | g.innerHTML = '';
|
| | |
|
| | | return p;
|
| | | }*/
|
| | | }
|
| | |
|
| | | return p.removeChild(n);
|
| | | });
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | setStyle : function(n, na, v) {
|
| | | var t = this;
|
| | |
| | | setAttrib : function(e, n, v) {
|
| | | var t = this;
|
| | |
|
| | | // Whats the point
|
| | | if (!e || !n)
|
| | | return;
|
| | |
|
| | | // Strict XML mode
|
| | | if (t.settings.strict)
|
| | | n = n.toLowerCase();
|
| | |
| | |
|
| | | switch (n) {
|
| | | case "style":
|
| | | if (!is(v, 'string')) {
|
| | | each(v, function(v, n) {
|
| | | t.setStyle(e, n, v);
|
| | | });
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // No mce_style for elements with these since they might get resized by the user
|
| | | if (s.keep_values) {
|
| | | if (v)
|
| | | if (v && !t._isRes(v))
|
| | | e.setAttribute('mce_style', v, 2);
|
| | | else
|
| | | e.removeAttribute('mce_style', 2);
|
| | |
| | | }
|
| | |
|
| | | break;
|
| | | |
| | | case "shape":
|
| | | e.setAttribute('mce_style', v);
|
| | | break;
|
| | | }
|
| | |
|
| | | if (is(v) && v !== null && v.length !== 0)
|
| | |
| | | });
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | getAttrib : function(e, n, dv) {
|
| | | var v, t = this;
|
| | |
|
| | | e = t.get(e);
|
| | |
|
| | | if (!e)
|
| | | if (!e || e.nodeType !== 1)
|
| | | return false;
|
| | |
|
| | | if (!is(dv))
|
| | | dv = "";
|
| | | dv = '';
|
| | |
|
| | | // Try the mce variant for these
|
| | | if (/^(src|href|style|coords)$/.test(n)) {
|
| | | if (/^(src|href|style|coords|shape)$/.test(n)) {
|
| | | v = e.getAttribute("mce_" + n);
|
| | |
|
| | | if (v)
|
| | | return v;
|
| | | }
|
| | |
|
| | | v = e.getAttribute(n, 2);
|
| | |
|
| | | if (!v) {
|
| | | switch (n) {
|
| | | case 'class':
|
| | | v = e.className;
|
| | | break;
|
| | |
|
| | | default:
|
| | | // Fix for IE crash Bug: #1884376 probably due to invalid DOM structure
|
| | | if (isIE && n === 'name' && e.nodeName === 'A') {
|
| | | v = e.name;
|
| | | break;
|
| | | }
|
| | |
|
| | | v = e.attributes[n];
|
| | | v = v && is(v.nodeValue) ? v.nodeValue : v;
|
| | | }
|
| | | if (isIE && t.props[n]) {
|
| | | v = e[t.props[n]];
|
| | | v = v && v.nodeValue ? v.nodeValue : v;
|
| | | }
|
| | |
|
| | | switch (n) {
|
| | | case 'style':
|
| | | v = v || e.style.cssText;
|
| | | if (!v)
|
| | | v = e.getAttribute(n, 2);
|
| | |
|
| | | if (v) {
|
| | | v = t.serializeStyle(t.parseStyle(v));
|
| | | if (n === 'style') {
|
| | | v = v || e.style.cssText;
|
| | |
|
| | | if (t.settings.keep_values)
|
| | | e.setAttribute('mce_style', v);
|
| | | }
|
| | | if (v) {
|
| | | v = t.serializeStyle(t.parseStyle(v));
|
| | |
|
| | | break;
|
| | | if (t.settings.keep_values && !t._isRes(v))
|
| | | e.setAttribute('mce_style', v);
|
| | | }
|
| | | }
|
| | |
|
| | | // Remove Apple and WebKit stuff
|
| | |
| | |
|
| | | case 'size':
|
| | | // IE returns +0 as default value for size
|
| | | if (v === '+0')
|
| | | if (v === '+0' || v === 20 || v === 0)
|
| | | v = '';
|
| | |
|
| | | break;
|
| | |
|
| | | case 'width':
|
| | | case 'height':
|
| | | case 'vspace':
|
| | | case 'checked':
|
| | | case 'disabled':
|
| | | case 'readonly':
|
| | | if (v === 0)
|
| | | v = '';
|
| | |
|
| | | break;
|
| | |
| | |
|
| | | break;
|
| | |
|
| | | case 'maxlength':
|
| | | case 'tabindex':
|
| | | // IE returns 32768 as default value
|
| | | if (v === 32768)
|
| | | // IE returns default value
|
| | | if (v === 32768 || v === 2147483647 || v === '32768')
|
| | | v = '';
|
| | |
|
| | | break;
|
| | |
|
| | | case 'multiple':
|
| | | case 'compact':
|
| | | case 'noshade':
|
| | | case 'nowrap':
|
| | | if (v === 65535)
|
| | | return n;
|
| | |
|
| | | return dv;
|
| | |
|
| | | case 'shape':
|
| | | v = v.toLowerCase();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | return (v && v != '') ? '' + v : dv;
|
| | | return (v !== undefined && v !== null && v !== '') ? '' + v : dv;
|
| | | },
|
| | |
|
| | | getPos : function(n) {
|
| | | getPos : function(n, ro) {
|
| | | var t = this, x = 0, y = 0, e, d = t.doc, r;
|
| | |
|
| | | n = t.get(n);
|
| | | ro = ro || d.body;
|
| | |
|
| | | // Use getBoundingClientRect on IE, Opera has it but it's not perfect
|
| | | if (n && isIE) {
|
| | | n = n.getBoundingClientRect();
|
| | | e = t.boxModel ? d.documentElement : d.body;
|
| | | x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
|
| | | x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
|
| | | n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
|
| | | if (n) {
|
| | | // Use getBoundingClientRect on IE, Opera has it but it's not perfect
|
| | | if (isIE && !t.stdMode) {
|
| | | n = n.getBoundingClientRect();
|
| | | e = t.boxModel ? d.documentElement : d.body;
|
| | | x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
|
| | | x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
|
| | | n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
|
| | |
|
| | | return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
|
| | | }
|
| | |
|
| | | r = n;
|
| | | while (r) {
|
| | | x += r.offsetLeft || 0;
|
| | | y += r.offsetTop || 0;
|
| | | r = r.offsetParent;
|
| | | }
|
| | |
|
| | | r = n;
|
| | | while (r) {
|
| | | // Opera 9.25 bug fix, fixed in 9.50
|
| | | if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
|
| | | x -= r.scrollLeft || 0;
|
| | | y -= r.scrollTop || 0;
|
| | | return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
|
| | | }
|
| | |
|
| | | r = r.parentNode;
|
| | | r = n;
|
| | | while (r && r != ro && r.nodeType) {
|
| | | x += r.offsetLeft || 0;
|
| | | y += r.offsetTop || 0;
|
| | | r = r.offsetParent;
|
| | | }
|
| | |
|
| | | if (r == d.body)
|
| | | break;
|
| | | r = n.parentNode;
|
| | | while (r && r != ro && r.nodeType) {
|
| | | x -= r.scrollLeft || 0;
|
| | | y -= r.scrollTop || 0;
|
| | | r = r.parentNode;
|
| | | }
|
| | | }
|
| | |
|
| | | return {x : x, y : y};
|
| | |
| | | delete o[c];
|
| | | };
|
| | |
|
| | | st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities
|
| | |
|
| | | each(st.split(';'), function(v) {
|
| | | var sv, ur = [];
|
| | |
|
| | | if (v) {
|
| | | v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities
|
| | | v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
|
| | | v = v.split(':');
|
| | | sv = tinymce.trim(v[1]);
|
| | |
| | |
|
| | | if (s.url_converter) {
|
| | | sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
|
| | | return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null)) + ')';
|
| | | return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')';
|
| | | });
|
| | | }
|
| | |
|
| | |
| | |
|
| | | each(o, function(v, k) {
|
| | | if (k && v) {
|
| | | if (tinymce.isGecko && k.indexOf('-moz-') === 0)
|
| | | return;
|
| | |
|
| | | switch (k) {
|
| | | case 'color':
|
| | | case 'background-color':
|
| | |
| | | return;
|
| | |
|
| | | t.files[u] = true;
|
| | | t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : u});
|
| | | t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
|
| | | });
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | addClass : function(e, c) {
|
| | | return this.run(e, function(e) {
|
| | |
| | | isHidden : function(e) {
|
| | | e = this.get(e);
|
| | |
|
| | | return e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
|
| | | return !e || e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | uniqueId : function(p) {
|
| | | return (!p ? 'mce_' : p) + (this.counter++);
|
| | |
| | | if (x) {
|
| | | // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
|
| | | // after we use innerHTML we can fix the DOM tree
|
| | | h = h.replace(/<p([^>]+)>|<p>/g, '<div$1 mce_tmp="1">');
|
| | | h = h.replace(/<p ([^>]+)>|<p>/g, '<div $1 mce_tmp="1">');
|
| | | h = h.replace(/<\/p>/g, '</div>');
|
| | |
|
| | | // Set the new HTML with DIVs
|
| | |
| | | if (tinymce.isGecko) {
|
| | | h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
|
| | | h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
|
| | | } else if (isIE) {
|
| | | h = h.replace(/'/g, '''); // IE can't handle apos
|
| | | h = h.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi, ''); // IE doesn't handle default values correct
|
| | | }
|
| | |
|
| | | // Fix some issues
|
| | |
| | |
|
| | | // Store away src and href in mce_src and mce_href since browsers mess them up
|
| | | if (s.keep_values) {
|
| | | // Wrap scripts in comments for serialization purposes
|
| | | if (h.indexOf('<script') !== -1) {
|
| | | h = h.replace(/<script>/g, '<script type="text/javascript">');
|
| | | h = h.replace(/<script(|[^>]+)>(\s*<!--|\/\/\s*<\[CDATA\[)?[\r\n]*/g, '<mce:script$1><!--\n');
|
| | | h = h.replace(/\s*(\/\/\s*-->|\/\/\s*]]>)?<\/script>/g, '\n// --></mce:script>');
|
| | | h = h.replace(/<mce:script(|[^>]+)><!--\n\/\/ --><\/mce:script>/g, '<mce:script$1></mce:script>');
|
| | | // Wrap scripts and styles in comments for serialization purposes
|
| | | if (/<script|style/.test(h)) {
|
| | | function trim(s) {
|
| | | // Remove prefix and suffix code for element
|
| | | s = s.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n');
|
| | | s = s.replace(/^[\r\n]*|[\r\n]*$/g, '');
|
| | | s = s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<!\[CDATA\[|<!--|<!\[CDATA\[)[\r\n]*/g, '');
|
| | | s = s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->|\]\]-->)\s*$/g, '');
|
| | |
|
| | | return s;
|
| | | };
|
| | |
|
| | | // Preserve script elements
|
| | | h = h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g, function(v, a, b) {
|
| | | // Remove prefix and suffix code for script element
|
| | | b = trim(b);
|
| | |
|
| | | // Force type attribute
|
| | | if (!a)
|
| | | a = ' type="text/javascript"';
|
| | |
|
| | | // Wrap contents in a comment
|
| | | if (b)
|
| | | b = '<!--\n' + b + '\n// -->';
|
| | |
|
| | | // Output fake element
|
| | | return '<mce:script' + a + '>' + b + '</mce:script>';
|
| | | });
|
| | |
|
| | | // Preserve style elements
|
| | | h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g, function(v, a, b) {
|
| | | b = trim(b);
|
| | | return '<mce:style' + a + '><!--\n' + b + '\n--></mce:style><style' + a + ' mce_bogus="1">' + b + '</style>';
|
| | | });
|
| | | }
|
| | |
|
| | | h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->');
|
| | |
|
| | | // Process all tags with src, href or style
|
| | | h = h.replace(/<([\w:]+) [^>]*(src|href|style|coords)[^>]*>/gi, function(a, n) {
|
| | | h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
|
| | | function handle(m, b, c) {
|
| | | var u = c;
|
| | |
|
| | |
| | | return m;
|
| | |
|
| | | if (b == 'style') {
|
| | | // Why did I need this one?
|
| | | //if (isIE)
|
| | | // u = t.serializeStyle(t.parseStyle(u));
|
| | | // No mce_style for elements with these since they might get resized by the user
|
| | | if (t._isRes(c))
|
| | | return m;
|
| | |
|
| | | if (s.hex_colors) {
|
| | | u = u.replace(/rgb\([^\)]+\)/g, function(v) {
|
| | |
| | | return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
|
| | | });
|
| | | }
|
| | | } else if (b != 'coords') {
|
| | | } else if (b != 'coords' && b != 'shape') {
|
| | | if (s.url_converter)
|
| | | u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
|
| | | }
|
| | |
| | | return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
|
| | | };
|
| | |
|
| | | a = a.replace(/ (src|href|style|coords)=[\"]([^\"]+)[\"]/gi, handle); // W3C
|
| | | a = a.replace(/ (src|href|style|coords)=[\']([^\']+)[\']/gi, handle); // W3C
|
| | | a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C
|
| | | a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C
|
| | |
|
| | | return a.replace(/ (src|href|style|coords)=([^\s\"\'>]+)/gi, handle); // IE
|
| | | return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | if (!e)
|
| | | return null;
|
| | |
|
| | | if (isIE)
|
| | | if (e.outerHTML !== undefined)
|
| | | return e.outerHTML;
|
| | |
|
| | | d = (e.ownerDocument || this.doc).createElement("body");
|
| | |
| | | },
|
| | |
|
| | | decode : function(s) {
|
| | | var e;
|
| | | var e, n, v;
|
| | |
|
| | | // Look for entities to decode
|
| | | if (/&[^;]+;/.test(s)) {
|
| | | // Decode the entities using a div element not super efficient but less code
|
| | | e = this.doc.createElement("div");
|
| | | e.innerHTML = s;
|
| | | n = e.firstChild;
|
| | | v = '';
|
| | |
|
| | | return !e.firstChild ? s : e.firstChild.nodeValue;
|
| | | if (n) {
|
| | | do {
|
| | | v += n.nodeValue;
|
| | | } while (n.nextSibling);
|
| | | }
|
| | |
|
| | | return v || s;
|
| | | }
|
| | |
|
| | | return s;
|
| | |
| | | }) : s;
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | insertAfter : function(n, r) {
|
| | | var t = this;
|
| | |
| | | });
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | isBlock : function(n) {
|
| | | if (n.nodeType && n.nodeType !== 1)
|
| | |
| | |
|
| | | n = n.nodeName || n;
|
| | |
|
| | | return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
|
| | | return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TR|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
|
| | | },
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | replace : function(n, o, k) {
|
| | | var t = this;
|
| | |
|
| | | if (is(o, 'array'))
|
| | | n = n.cloneNode(true);
|
| | |
|
| | | return this.run(o, function(o) {
|
| | | return t.run(o, function(o) {
|
| | | if (k) {
|
| | | each(o.childNodes, function(c) {
|
| | | n.appendChild(c.cloneNode(true));
|
| | |
| | | }
|
| | |
|
| | | // Fix IE psuedo leak for elements since replacing elements if fairly common
|
| | | if (isIE && o.nodeType === 1) {
|
| | | // Will break parentNode for some unknown reason
|
| | | if (t.fixPsuedoLeaks && o.nodeType === 1) {
|
| | | o.parentNode.insertBefore(n, o);
|
| | | o.outerHTML = '';
|
| | | t.remove(o);
|
| | | return n;
|
| | | }
|
| | |
|
| | |
| | | });
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | 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);
|
| | |
| | | var t = this, o;
|
| | |
|
| | | if (t.doc && typeof(e) === 'string')
|
| | | e = t.doc.getElementById(e);
|
| | | e = t.get(e);
|
| | |
|
| | | if (!e)
|
| | | return false;
|
| | |
| | | // Manual destroy then remove unload handler
|
| | | if (!s)
|
| | | tinymce.removeUnload(t.destroy);
|
| | | },
|
| | |
|
| | | createRng : function() {
|
| | | var d = this.doc;
|
| | |
|
| | | return d.createRange ? d.createRange() : new tinymce.dom.Range(this);
|
| | | },
|
| | |
|
| | | split : function(pe, e, re) {
|
| | | var t = this, r = t.createRng(), bef, aft, pa;
|
| | |
|
| | | // W3C valid browsers tend to leave empty nodes to the left/right side of the contents, this makes sence
|
| | | // but we don't want that in our code since it serves no purpose
|
| | | // For example if this is chopped:
|
| | | // <p>text 1<span><b>CHOP</b></span>text 2</p>
|
| | | // would produce:
|
| | | // <p>text 1<span></span></p><b>CHOP</b><p><span></span>text 2</p>
|
| | | // this function will then trim of empty edges and produce:
|
| | | // <p>text 1</p><b>CHOP</b><p>text 2</p>
|
| | | function trimEdge(n, na) {
|
| | | n = n[na];
|
| | |
|
| | | if (n && n[na] && n[na].nodeType == 1 && isEmpty(n[na]))
|
| | | t.remove(n[na]);
|
| | | };
|
| | |
|
| | | function isEmpty(n) {
|
| | | n = t.getOuterHTML(n);
|
| | | n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
|
| | | n = n.replace(/<[^>]+>/g, ''); // Remove all tags
|
| | |
|
| | | return n.replace(/[ \t\r\n]+| | /g, '') == '';
|
| | | };
|
| | |
|
| | | if (pe && e) {
|
| | | // Get before chunk
|
| | | r.setStartBefore(pe);
|
| | | r.setEndBefore(e);
|
| | | bef = r.extractContents();
|
| | |
|
| | | // Get after chunk
|
| | | r = t.createRng();
|
| | | r.setStartAfter(e);
|
| | | r.setEndAfter(pe);
|
| | | aft = r.extractContents();
|
| | |
|
| | | // Insert chunks and remove parent
|
| | | pa = pe.parentNode;
|
| | |
|
| | | // Remove right side edge of the before contents
|
| | | trimEdge(bef, 'lastChild');
|
| | |
|
| | | if (!isEmpty(bef))
|
| | | pa.insertBefore(bef, pe);
|
| | |
|
| | | if (re)
|
| | | pa.replaceChild(re, e);
|
| | | else
|
| | | pa.insertBefore(e, pe);
|
| | |
|
| | | // Remove left site edge of the after contents
|
| | | trimEdge(aft, 'firstChild');
|
| | |
|
| | | if (!isEmpty(aft))
|
| | | pa.insertBefore(aft, pe);
|
| | |
|
| | | t.remove(pe);
|
| | |
|
| | | return re || e;
|
| | | }
|
| | | },
|
| | |
|
| | |
|
| | | _isRes : function(c) {
|
| | | // Is live resizble element
|
| | | return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c);
|
| | | }
|
| | |
|
| | | /*
|
| | |
| | |
|
| | | // Setup page DOM
|
| | | tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
|
| | | })(tinymce);
|
| | | (function(ns) {
|
| | | // Traverse constants
|
| | | var EXTRACT = 0, CLONE = 1, DELETE = 2, extend = tinymce.extend;
|
| | |
|
| | | function indexOf(child, parent) {
|
| | | var i, node;
|
| | |
|
| | | if (child.parentNode != parent)
|
| | | return -1;
|
| | |
|
| | | for (node = parent.firstChild, i = 0; node != child; node = node.nextSibling)
|
| | | i++;
|
| | |
|
| | | return i;
|
| | | };
|
| | |
|
| | | function nodeIndex(n) {
|
| | | var i = 0;
|
| | |
|
| | | while (n.previousSibling) {
|
| | | i++;
|
| | | n = n.previousSibling;
|
| | | }
|
| | |
|
| | | return i;
|
| | | };
|
| | |
|
| | | function getSelectedNode(container, offset) {
|
| | | var child;
|
| | |
|
| | | if (container.nodeType == 3 /* TEXT_NODE */)
|
| | | return container;
|
| | |
|
| | | if (offset < 0)
|
| | | return container;
|
| | |
|
| | | child = container.firstChild;
|
| | | while (child != null && offset > 0) {
|
| | | --offset;
|
| | | child = child.nextSibling;
|
| | | }
|
| | |
|
| | | if (child != null)
|
| | | return child;
|
| | |
|
| | | return container;
|
| | | };
|
| | |
|
| | | // Range constructor
|
| | | function Range(dom) {
|
| | | var d = dom.doc;
|
| | |
|
| | | extend(this, {
|
| | | dom : dom,
|
| | |
|
| | | // Inital states
|
| | | startContainer : d,
|
| | | startOffset : 0,
|
| | | endContainer : d,
|
| | | endOffset : 0,
|
| | | collapsed : true,
|
| | | commonAncestorContainer : d,
|
| | |
|
| | | // Range constants
|
| | | START_TO_START : 0,
|
| | | START_TO_END : 1,
|
| | | END_TO_END : 2,
|
| | | END_TO_START : 3
|
| | | });
|
| | | };
|
| | |
|
| | | // Add range methods
|
| | | extend(Range.prototype, {
|
| | | setStart : function(n, o) {
|
| | | this._setEndPoint(true, n, o);
|
| | | },
|
| | |
|
| | | setEnd : function(n, o) {
|
| | | this._setEndPoint(false, n, o);
|
| | | },
|
| | |
|
| | | setStartBefore : function(n) {
|
| | | this.setStart(n.parentNode, nodeIndex(n));
|
| | | },
|
| | |
|
| | | setStartAfter : function(n) {
|
| | | this.setStart(n.parentNode, nodeIndex(n) + 1);
|
| | | },
|
| | |
|
| | | setEndBefore : function(n) {
|
| | | this.setEnd(n.parentNode, nodeIndex(n));
|
| | | },
|
| | |
|
| | | setEndAfter : function(n) {
|
| | | this.setEnd(n.parentNode, nodeIndex(n) + 1);
|
| | | },
|
| | |
|
| | | collapse : function(ts) {
|
| | | var t = this;
|
| | |
|
| | | if (ts) {
|
| | | t.endContainer = t.startContainer;
|
| | | t.endOffset = t.startOffset;
|
| | | } else {
|
| | | t.startContainer = t.endContainer;
|
| | | t.startOffset = t.endOffset;
|
| | | }
|
| | |
|
| | | t.collapsed = true;
|
| | | },
|
| | |
|
| | | selectNode : function(n) {
|
| | | this.setStartBefore(n);
|
| | | this.setEndAfter(n);
|
| | | },
|
| | |
|
| | | selectNodeContents : function(n) {
|
| | | this.setStart(n, 0);
|
| | | this.setEnd(n, n.nodeType === 1 ? n.childNodes.length : n.nodeValue.length);
|
| | | },
|
| | |
|
| | | compareBoundaryPoints : function(h, r) {
|
| | | var t = this, sc = t.startContainer, so = t.startOffset, ec = t.endContainer, eo = t.endOffset;
|
| | |
|
| | | // Check START_TO_START
|
| | | if (h === 0)
|
| | | return t._compareBoundaryPoints(sc, so, sc, so);
|
| | |
|
| | | // Check START_TO_END
|
| | | if (h === 1)
|
| | | return t._compareBoundaryPoints(sc, so, ec, eo);
|
| | |
|
| | | // Check END_TO_END
|
| | | if (h === 2)
|
| | | return t._compareBoundaryPoints(ec, eo, ec, eo);
|
| | |
|
| | | // Check END_TO_START
|
| | | if (h === 3)
|
| | | return t._compareBoundaryPoints(ec, eo, sc, so);
|
| | | },
|
| | |
|
| | | deleteContents : function() {
|
| | | this._traverse(DELETE);
|
| | | },
|
| | |
|
| | | extractContents : function() {
|
| | | return this._traverse(EXTRACT);
|
| | | },
|
| | |
|
| | | cloneContents : function() {
|
| | | return this._traverse(CLONE);
|
| | | },
|
| | |
|
| | | insertNode : function(n) {
|
| | | var t = this, nn, o;
|
| | |
|
| | | // Node is TEXT_NODE or CDATA
|
| | | if (n.nodeType === 3 || n.nodeType === 4) {
|
| | | nn = t.startContainer.splitText(t.startOffset);
|
| | | t.startContainer.parentNode.insertBefore(n, nn);
|
| | | } else {
|
| | | // Insert element node
|
| | | if (t.startContainer.childNodes.length > 0)
|
| | | o = t.startContainer.childNodes[t.startOffset];
|
| | |
|
| | | t.startContainer.insertBefore(n, o);
|
| | | }
|
| | | },
|
| | |
|
| | | surroundContents : function(n) {
|
| | | var t = this, f = t.extractContents();
|
| | |
|
| | | t.insertNode(n);
|
| | | n.appendChild(f);
|
| | | t.selectNode(n);
|
| | | },
|
| | |
|
| | | cloneRange : function() {
|
| | | var t = this;
|
| | |
|
| | | return extend(new Range(t.dom), {
|
| | | startContainer : t.startContainer,
|
| | | startOffset : t.startOffset,
|
| | | endContainer : t.endContainer,
|
| | | endOffset : t.endOffset,
|
| | | collapsed : t.collapsed,
|
| | | commonAncestorContainer : t.commonAncestorContainer
|
| | | });
|
| | | },
|
| | |
|
| | | /*
|
| | | detach : function() {
|
| | | // Not implemented
|
| | | },
|
| | | */
|
| | | // Internal methods
|
| | |
|
| | | _isCollapsed : function() {
|
| | | return (this.startContainer == this.endContainer && this.startOffset == this.endOffset);
|
| | | },
|
| | |
|
| | | _compareBoundaryPoints : function (containerA, offsetA, containerB, offsetB) {
|
| | | var c, offsetC, n, cmnRoot, childA, childB;
|
| | |
|
| | | // In the first case the boundary-points have the same container. A is before B |
| | | // if its offset is less than the offset of B, A is equal to B if its offset is |
| | | // equal to the offset of B, and A is after B if its offset is greater than the |
| | | // offset of B.
|
| | | if (containerA == containerB) {
|
| | | if (offsetA == offsetB) {
|
| | | return 0; // equal
|
| | | } else if (offsetA < offsetB) {
|
| | | return -1; // before
|
| | | } else {
|
| | | return 1; // after
|
| | | }
|
| | | }
|
| | |
|
| | | // In the second case a child node C of the container of A is an ancestor |
| | | // container of B. In this case, A is before B if the offset of A is less than or |
| | | // equal to the index of the child node C and A is after B otherwise.
|
| | | c = containerB;
|
| | | while (c && c.parentNode != containerA) {
|
| | | c = c.parentNode;
|
| | | }
|
| | | if (c) {
|
| | | offsetC = 0;
|
| | | n = containerA.firstChild;
|
| | |
|
| | | while (n != c && offsetC < offsetA) {
|
| | | offsetC++;
|
| | | n = n.nextSibling;
|
| | | }
|
| | |
|
| | | if (offsetA <= offsetC) {
|
| | | return -1; // before
|
| | | } else {
|
| | | return 1; // after
|
| | | }
|
| | | }
|
| | |
|
| | | // In the third case a child node C of the container of B is an ancestor container |
| | | // of A. In this case, A is before B if the index of the child node C is less than |
| | | // the offset of B and A is after B otherwise.
|
| | | c = containerA;
|
| | | while (c && c.parentNode != containerB) {
|
| | | c = c.parentNode;
|
| | | }
|
| | |
|
| | | if (c) {
|
| | | offsetC = 0;
|
| | | n = containerB.firstChild;
|
| | |
|
| | | while (n != c && offsetC < offsetB) {
|
| | | offsetC++;
|
| | | n = n.nextSibling;
|
| | | }
|
| | |
|
| | | if (offsetC < offsetB) {
|
| | | return -1; // before
|
| | | } else {
|
| | | return 1; // after
|
| | | }
|
| | | }
|
| | |
|
| | | // In the fourth case, none of three other cases hold: the containers of A and B |
| | | // are siblings or descendants of sibling nodes. In this case, A is before B if |
| | | // the container of A is before the container of B in a pre-order traversal of the
|
| | | // Ranges' context tree and A is after B otherwise.
|
| | | cmnRoot = this.dom.findCommonAncestor(containerA, containerB);
|
| | | childA = containerA;
|
| | |
|
| | | while (childA && childA.parentNode != cmnRoot) {
|
| | | childA = childA.parentNode; |
| | | }
|
| | |
|
| | | if (!childA) {
|
| | | childA = cmnRoot;
|
| | | }
|
| | |
|
| | | childB = containerB;
|
| | | while (childB && childB.parentNode != cmnRoot) {
|
| | | childB = childB.parentNode;
|
| | | }
|
| | |
|
| | | if (!childB) {
|
| | | childB = cmnRoot;
|
| | | }
|
| | |
|
| | | if (childA == childB) {
|
| | | return 0; // equal
|
| | | }
|
| | |
|
| | | n = cmnRoot.firstChild;
|
| | | while (n) {
|
| | | if (n == childA) {
|
| | | return -1; // before
|
| | | }
|
| | |
|
| | | if (n == childB) {
|
| | | return 1; // after
|
| | | }
|
| | |
|
| | | n = n.nextSibling;
|
| | | }
|
| | | },
|
| | |
|
| | | _setEndPoint : function(st, n, o) {
|
| | | var t = this, ec, sc;
|
| | |
|
| | | if (st) {
|
| | | t.startContainer = n;
|
| | | t.startOffset = o;
|
| | | } else {
|
| | | t.endContainer = n;
|
| | | t.endOffset = o;
|
| | | }
|
| | |
|
| | | // If one boundary-point of a Range is set to have a root container |
| | | // other than the current one for the Range, the Range is collapsed to |
| | | // the new position. This enforces the restriction that both boundary-
|
| | | // points of a Range must have the same root container.
|
| | | ec = t.endContainer;
|
| | | while (ec.parentNode)
|
| | | ec = ec.parentNode;
|
| | |
|
| | | sc = t.startContainer;
|
| | | while (sc.parentNode)
|
| | | sc = sc.parentNode;
|
| | |
|
| | | if (sc != ec) {
|
| | | t.collapse(st);
|
| | | } else {
|
| | | // The start position of a Range is guaranteed to never be after the |
| | | // end position. To enforce this restriction, if the start is set to |
| | | // be at a position after the end, the Range is collapsed to that |
| | | // position.
|
| | | if (t._compareBoundaryPoints(t.startContainer, t.startOffset, t.endContainer, t.endOffset) > 0)
|
| | | t.collapse(st);
|
| | | }
|
| | |
|
| | | t.collapsed = t._isCollapsed();
|
| | | t.commonAncestorContainer = t.dom.findCommonAncestor(t.startContainer, t.endContainer);
|
| | | },
|
| | |
|
| | | // This code is heavily "inspired" by the Apache Xerces implementation. I hope they don't mind. :)
|
| | |
|
| | | _traverse : function(how) {
|
| | | var t = this, c, endContainerDepth = 0, startContainerDepth = 0, p, depthDiff, startNode, endNode, sp, ep;
|
| | |
|
| | | if (t.startContainer == t.endContainer)
|
| | | return t._traverseSameContainer(how);
|
| | |
|
| | | for (c = t.endContainer, p = c.parentNode; p != null; c = p, p = p.parentNode) {
|
| | | if (p == t.startContainer)
|
| | | return t._traverseCommonStartContainer(c, how);
|
| | |
|
| | | ++endContainerDepth;
|
| | | }
|
| | |
|
| | | for (c = t.startContainer, p = c.parentNode; p != null; c = p, p = p.parentNode) {
|
| | | if (p == t.endContainer)
|
| | | return t._traverseCommonEndContainer(c, how);
|
| | |
|
| | | ++startContainerDepth;
|
| | | }
|
| | |
|
| | | depthDiff = startContainerDepth - endContainerDepth;
|
| | |
|
| | | startNode = t.startContainer;
|
| | | while (depthDiff > 0) {
|
| | | startNode = startNode.parentNode;
|
| | | depthDiff--;
|
| | | }
|
| | |
|
| | | endNode = t.endContainer;
|
| | | while (depthDiff < 0) {
|
| | | endNode = endNode.parentNode;
|
| | | depthDiff++;
|
| | | }
|
| | |
|
| | | // ascend the ancestor hierarchy until we have a common parent.
|
| | | for (sp = startNode.parentNode, ep = endNode.parentNode; sp != ep; sp = sp.parentNode, ep = ep.parentNode) {
|
| | | startNode = sp;
|
| | | endNode = ep;
|
| | | }
|
| | |
|
| | | return t._traverseCommonAncestors(startNode, endNode, how);
|
| | | },
|
| | |
|
| | | _traverseSameContainer : function(how) {
|
| | | var t = this, frag, s, sub, n, cnt, sibling, xferNode;
|
| | |
|
| | | if (how != DELETE)
|
| | | frag = t.dom.doc.createDocumentFragment();
|
| | |
|
| | | // If selection is empty, just return the fragment
|
| | | if (t.startOffset == t.endOffset)
|
| | | return frag;
|
| | |
|
| | | // Text node needs special case handling
|
| | | if (t.startContainer.nodeType == 3 /* TEXT_NODE */) {
|
| | | // get the substring
|
| | | s = t.startContainer.nodeValue;
|
| | | sub = s.substring(t.startOffset, t.endOffset);
|
| | |
|
| | | // set the original text node to its new value
|
| | | if (how != CLONE) {
|
| | | t.startContainer.deleteData(t.startOffset, t.endOffset - t.startOffset);
|
| | |
|
| | | // Nothing is partially selected, so collapse to start point
|
| | | t.collapse(true);
|
| | | }
|
| | |
|
| | | if (how == DELETE)
|
| | | return null;
|
| | |
|
| | | frag.appendChild(t.dom.doc.createTextNode(sub));
|
| | | return frag;
|
| | | }
|
| | |
|
| | | // Copy nodes between the start/end offsets.
|
| | | n = getSelectedNode(t.startContainer, t.startOffset);
|
| | | cnt = t.endOffset - t.startOffset;
|
| | |
|
| | | while (cnt > 0) {
|
| | | sibling = n.nextSibling;
|
| | | xferNode = t._traverseFullySelected(n, how);
|
| | |
|
| | | if (frag)
|
| | | frag.appendChild( xferNode );
|
| | |
|
| | | --cnt;
|
| | | n = sibling;
|
| | | }
|
| | |
|
| | | // Nothing is partially selected, so collapse to start point
|
| | | if (how != CLONE)
|
| | | t.collapse(true);
|
| | |
|
| | | return frag;
|
| | | },
|
| | |
|
| | | _traverseCommonStartContainer : function(endAncestor, how) {
|
| | | var t = this, frag, n, endIdx, cnt, sibling, xferNode;
|
| | |
|
| | | if (how != DELETE)
|
| | | frag = t.dom.doc.createDocumentFragment();
|
| | |
|
| | | n = t._traverseRightBoundary(endAncestor, how);
|
| | |
|
| | | if (frag)
|
| | | frag.appendChild(n);
|
| | |
|
| | | endIdx = indexOf(endAncestor, t.startContainer);
|
| | | cnt = endIdx - t.startOffset;
|
| | |
|
| | | if (cnt <= 0) {
|
| | | // Collapse to just before the endAncestor, which |
| | | // is partially selected.
|
| | | if (how != CLONE) {
|
| | | t.setEndBefore(endAncestor);
|
| | | t.collapse(false);
|
| | | }
|
| | |
|
| | | return frag;
|
| | | }
|
| | |
|
| | | n = endAncestor.previousSibling;
|
| | | while (cnt > 0) {
|
| | | sibling = n.previousSibling;
|
| | | xferNode = t._traverseFullySelected(n, how);
|
| | |
|
| | | if (frag)
|
| | | frag.insertBefore(xferNode, frag.firstChild);
|
| | |
|
| | | --cnt;
|
| | | n = sibling;
|
| | | }
|
| | |
|
| | | // Collapse to just before the endAncestor, which |
| | | // is partially selected.
|
| | | if (how != CLONE) {
|
| | | t.setEndBefore(endAncestor);
|
| | | t.collapse(false);
|
| | | }
|
| | |
|
| | | return frag;
|
| | | },
|
| | |
|
| | | _traverseCommonEndContainer : function(startAncestor, how) {
|
| | | var t = this, frag, startIdx, n, cnt, sibling, xferNode;
|
| | |
|
| | | if (how != DELETE)
|
| | | frag = t.dom.doc.createDocumentFragment();
|
| | |
|
| | | n = t._traverseLeftBoundary(startAncestor, how);
|
| | | if (frag)
|
| | | frag.appendChild(n);
|
| | |
|
| | | startIdx = indexOf(startAncestor, t.endContainer);
|
| | | ++startIdx; // Because we already traversed it....
|
| | |
|
| | | cnt = t.endOffset - startIdx;
|
| | | n = startAncestor.nextSibling;
|
| | | while (cnt > 0) {
|
| | | sibling = n.nextSibling;
|
| | | xferNode = t._traverseFullySelected(n, how);
|
| | |
|
| | | if (frag)
|
| | | frag.appendChild(xferNode);
|
| | |
|
| | | --cnt;
|
| | | n = sibling;
|
| | | }
|
| | |
|
| | | if (how != CLONE) {
|
| | | t.setStartAfter(startAncestor);
|
| | | t.collapse(true);
|
| | | }
|
| | |
|
| | | return frag;
|
| | | },
|
| | |
|
| | | _traverseCommonAncestors : function(startAncestor, endAncestor, how) {
|
| | | var t = this, n, frag, commonParent, startOffset, endOffset, cnt, sibling, nextSibling;
|
| | |
|
| | | if (how != DELETE)
|
| | | frag = t.dom.doc.createDocumentFragment();
|
| | |
|
| | | n = t._traverseLeftBoundary(startAncestor, how);
|
| | | if (frag)
|
| | | frag.appendChild(n);
|
| | |
|
| | | commonParent = startAncestor.parentNode;
|
| | | startOffset = indexOf(startAncestor, commonParent);
|
| | | endOffset = indexOf(endAncestor, commonParent);
|
| | | ++startOffset;
|
| | |
|
| | | cnt = endOffset - startOffset;
|
| | | sibling = startAncestor.nextSibling;
|
| | |
|
| | | while (cnt > 0) {
|
| | | nextSibling = sibling.nextSibling;
|
| | | n = t._traverseFullySelected(sibling, how);
|
| | |
|
| | | if (frag)
|
| | | frag.appendChild(n);
|
| | |
|
| | | sibling = nextSibling;
|
| | | --cnt;
|
| | | }
|
| | |
|
| | | n = t._traverseRightBoundary(endAncestor, how);
|
| | |
|
| | | if (frag)
|
| | | frag.appendChild(n);
|
| | |
|
| | | if (how != CLONE) {
|
| | | t.setStartAfter(startAncestor);
|
| | | t.collapse(true);
|
| | | }
|
| | |
|
| | | return frag;
|
| | | },
|
| | |
|
| | | _traverseRightBoundary : function(root, how) {
|
| | | var t = this, next = getSelectedNode(t.endContainer, t.endOffset - 1), parent, clonedParent, prevSibling, clonedChild, clonedGrandParent;
|
| | | var isFullySelected = next != t.endContainer;
|
| | |
|
| | | if (next == root)
|
| | | return t._traverseNode(next, isFullySelected, false, how);
|
| | |
|
| | | parent = next.parentNode;
|
| | | clonedParent = t._traverseNode(parent, false, false, how);
|
| | |
|
| | | while (parent != null) {
|
| | | while (next != null) {
|
| | | prevSibling = next.previousSibling;
|
| | | clonedChild = t._traverseNode(next, isFullySelected, false, how);
|
| | |
|
| | | if (how != DELETE)
|
| | | clonedParent.insertBefore(clonedChild, clonedParent.firstChild);
|
| | |
|
| | | isFullySelected = true;
|
| | | next = prevSibling;
|
| | | }
|
| | |
|
| | | if (parent == root)
|
| | | return clonedParent;
|
| | |
|
| | | next = parent.previousSibling;
|
| | | parent = parent.parentNode;
|
| | |
|
| | | clonedGrandParent = t._traverseNode(parent, false, false, how);
|
| | |
|
| | | if (how != DELETE)
|
| | | clonedGrandParent.appendChild(clonedParent);
|
| | |
|
| | | clonedParent = clonedGrandParent;
|
| | | }
|
| | |
|
| | | // should never occur
|
| | | return null;
|
| | | },
|
| | |
|
| | | _traverseLeftBoundary : function(root, how) {
|
| | | var t = this, next = getSelectedNode(t.startContainer, t.startOffset);
|
| | | var isFullySelected = next != t.startContainer, parent, clonedParent, nextSibling, clonedChild, clonedGrandParent;
|
| | |
|
| | | if (next == root)
|
| | | return t._traverseNode(next, isFullySelected, true, how);
|
| | |
|
| | | parent = next.parentNode;
|
| | | clonedParent = t._traverseNode(parent, false, true, how);
|
| | |
|
| | | while (parent != null) {
|
| | | while (next != null) {
|
| | | nextSibling = next.nextSibling;
|
| | | clonedChild = t._traverseNode(next, isFullySelected, true, how);
|
| | |
|
| | | if (how != DELETE)
|
| | | clonedParent.appendChild(clonedChild);
|
| | |
|
| | | isFullySelected = true;
|
| | | next = nextSibling;
|
| | | }
|
| | |
|
| | | if (parent == root)
|
| | | return clonedParent;
|
| | |
|
| | | next = parent.nextSibling;
|
| | | parent = parent.parentNode;
|
| | |
|
| | | clonedGrandParent = t._traverseNode(parent, false, true, how);
|
| | |
|
| | | if (how != DELETE)
|
| | | clonedGrandParent.appendChild(clonedParent);
|
| | |
|
| | | clonedParent = clonedGrandParent;
|
| | | }
|
| | |
|
| | | // should never occur
|
| | | return null;
|
| | | },
|
| | |
|
| | | _traverseNode : function(n, isFullySelected, isLeft, how) {
|
| | | var t = this, txtValue, newNodeValue, oldNodeValue, offset, newNode;
|
| | |
|
| | | if (isFullySelected)
|
| | | return t._traverseFullySelected(n, how);
|
| | |
|
| | | if (n.nodeType == 3 /* TEXT_NODE */) {
|
| | | txtValue = n.nodeValue;
|
| | |
|
| | | if (isLeft) {
|
| | | offset = t.startOffset;
|
| | | newNodeValue = txtValue.substring(offset);
|
| | | oldNodeValue = txtValue.substring(0, offset);
|
| | | } else {
|
| | | offset = t.endOffset;
|
| | | newNodeValue = txtValue.substring(0, offset);
|
| | | oldNodeValue = txtValue.substring(offset);
|
| | | }
|
| | |
|
| | | if (how != CLONE)
|
| | | n.nodeValue = oldNodeValue;
|
| | |
|
| | | if (how == DELETE)
|
| | | return null;
|
| | |
|
| | | newNode = n.cloneNode(false);
|
| | | newNode.nodeValue = newNodeValue;
|
| | |
|
| | | return newNode;
|
| | | }
|
| | |
|
| | | if (how == DELETE)
|
| | | return null;
|
| | |
|
| | | return n.cloneNode(false);
|
| | | },
|
| | |
|
| | | _traverseFullySelected : function(n, how) {
|
| | | var t = this;
|
| | |
|
| | | if (how != DELETE)
|
| | | return how == CLONE ? n.cloneNode(true) : n;
|
| | |
|
| | | n.parentNode.removeChild(n);
|
| | | return null;
|
| | | }
|
| | | });
|
| | |
|
| | | ns.Range = Range;
|
| | | })(tinymce.dom);
|
| | | (function() {
|
| | | function Selection(selection) {
|
| | | var t = this, invisibleChar = '\uFEFF', range, lastIERng;
|
| | |
|
| | | function compareRanges(rng1, rng2) {
|
| | | if (rng1 && rng2) {
|
| | | // Both are control ranges and the selected element matches
|
| | | if (rng1.item && rng2.item && rng1.item(0) === rng2.item(0))
|
| | | return 1;
|
| | |
|
| | | // Both are text ranges and the range matches
|
| | | if (rng1.isEqual && rng2.isEqual && rng2.isEqual(rng1))
|
| | | return 1;
|
| | | }
|
| | |
|
| | | return 0;
|
| | | };
|
| | |
|
| | | function getRange() {
|
| | | var dom = selection.dom, ieRange = selection.getRng(), domRange = dom.createRng(), startPos, endPos, element, sc, ec, collapsed;
|
| | |
|
| | | function findIndex(element) {
|
| | | var nl = element.parentNode.childNodes, i;
|
| | |
|
| | | for (i = nl.length - 1; i >= 0; i--) {
|
| | | if (nl[i] == element)
|
| | | return i;
|
| | | }
|
| | |
|
| | | return -1;
|
| | | };
|
| | |
|
| | | function findEndPoint(start) {
|
| | | var rng = ieRange.duplicate(), parent, i, nl, n, offset = 0, index = 0, pos, tmpRng;
|
| | |
|
| | | // Insert marker character
|
| | | rng.collapse(start);
|
| | | parent = rng.parentElement();
|
| | | rng.pasteHTML(invisibleChar); // Needs to be a pasteHTML instead of .text = since IE has a bug with nodeValue
|
| | |
|
| | | // Find marker character
|
| | | nl = parent.childNodes;
|
| | | for (i = 0; i < nl.length; i++) {
|
| | | n = nl[i];
|
| | |
|
| | | // Calculate node index excluding text node fragmentation
|
| | | if (i > 0 && (n.nodeType !== 3 || nl[i - 1].nodeType !== 3))
|
| | | index++;
|
| | |
|
| | | // If text node then calculate offset
|
| | | if (n.nodeType === 3) {
|
| | | // Look for marker
|
| | | pos = n.nodeValue.indexOf(invisibleChar);
|
| | | if (pos !== -1) {
|
| | | offset += pos;
|
| | | break;
|
| | | }
|
| | |
|
| | | offset += n.nodeValue.length;
|
| | | } else
|
| | | offset = 0;
|
| | | }
|
| | |
|
| | | // Remove marker character
|
| | | rng.moveStart('character', -1);
|
| | | rng.text = '';
|
| | |
|
| | | return {index : index, offset : offset, parent : parent};
|
| | | };
|
| | |
|
| | | // 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, findIndex(element));
|
| | | domRange.setEnd(domRange.startContainer, domRange.startOffset + 1);
|
| | |
|
| | | return domRange;
|
| | | }
|
| | |
|
| | | // Check collapsed state
|
| | | collapsed = selection.isCollapsed();
|
| | |
|
| | | // Find start and end pos index and offset
|
| | | startPos = findEndPoint(true);
|
| | | endPos = findEndPoint(false);
|
| | |
|
| | | // Normalize the elements to avoid fragmented dom
|
| | | startPos.parent.normalize();
|
| | | endPos.parent.normalize();
|
| | |
|
| | | // Set start container and offset
|
| | | sc = startPos.parent.childNodes[Math.min(startPos.index, startPos.parent.childNodes.length - 1)];
|
| | |
|
| | | if (sc.nodeType != 3)
|
| | | domRange.setStart(startPos.parent, startPos.index);
|
| | | else
|
| | | domRange.setStart(startPos.parent.childNodes[startPos.index], startPos.offset);
|
| | |
|
| | | // Set end container and offset
|
| | | ec = endPos.parent.childNodes[Math.min(endPos.index, endPos.parent.childNodes.length - 1)];
|
| | |
|
| | | if (ec.nodeType != 3) {
|
| | | if (!collapsed)
|
| | | endPos.index++;
|
| | |
|
| | | domRange.setEnd(endPos.parent, endPos.index);
|
| | | } else
|
| | | domRange.setEnd(endPos.parent.childNodes[endPos.index], endPos.offset);
|
| | |
|
| | | // If not collapsed then make sure offsets are valid
|
| | | if (!collapsed) {
|
| | | sc = domRange.startContainer;
|
| | | if (sc.nodeType == 1)
|
| | | domRange.setStart(sc, Math.min(domRange.startOffset, sc.childNodes.length));
|
| | |
|
| | | ec = domRange.endContainer;
|
| | | if (ec.nodeType == 1)
|
| | | domRange.setEnd(ec, Math.min(domRange.endOffset, ec.childNodes.length));
|
| | | }
|
| | |
|
| | | // Restore selection to new range
|
| | | t.addRange(domRange);
|
| | |
|
| | | return domRange;
|
| | | };
|
| | |
|
| | | this.addRange = function(rng) {
|
| | | var ieRng, body = selection.dom.doc.body, startPos, endPos, sc, so, ec, eo;
|
| | |
|
| | | // Setup some shorter versions
|
| | | sc = rng.startContainer;
|
| | | so = rng.startOffset;
|
| | | ec = rng.endContainer;
|
| | | eo = rng.endOffset;
|
| | | ieRng = body.createTextRange();
|
| | |
|
| | | // Find element
|
| | | sc = sc.nodeType == 1 ? sc.childNodes[Math.min(so, sc.childNodes.length - 1)] : sc;
|
| | | ec = ec.nodeType == 1 ? ec.childNodes[Math.min(so == eo ? eo : eo - 1, ec.childNodes.length - 1)] : ec;
|
| | |
|
| | | // Single element selection
|
| | | if (sc == ec && sc.nodeType == 1) {
|
| | | // Make control selection for some elements
|
| | | if (/^(IMG|TABLE)$/.test(sc.nodeName) && so != eo) {
|
| | | ieRng = body.createControlRange();
|
| | | ieRng.addElement(sc);
|
| | | } else {
|
| | | ieRng = body.createTextRange();
|
| | |
|
| | | // Padd empty elements with invisible character
|
| | | if (!sc.hasChildNodes() && sc.canHaveHTML)
|
| | | sc.innerHTML = invisibleChar;
|
| | |
|
| | | // Select element contents
|
| | | ieRng.moveToElementText(sc);
|
| | |
|
| | | // If it's only containing a padding remove it so the caret remains
|
| | | if (sc.innerHTML == invisibleChar) {
|
| | | ieRng.collapse(true);
|
| | | sc.removeChild(sc.firstChild);
|
| | | }
|
| | | }
|
| | |
|
| | | if (so == eo)
|
| | | ieRng.collapse(eo <= rng.endContainer.childNodes.length - 1);
|
| | |
|
| | | ieRng.select();
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | function getCharPos(container, offset) {
|
| | | var nodeVal, rng, pos;
|
| | |
|
| | | if (container.nodeType != 3)
|
| | | return -1;
|
| | |
|
| | | nodeVal = container.nodeValue;
|
| | | rng = body.createTextRange();
|
| | |
|
| | | // Insert marker at offset position
|
| | | container.nodeValue = nodeVal.substring(0, offset) + invisibleChar + nodeVal.substring(offset);
|
| | |
|
| | | // Find char pos of marker and remove it
|
| | | rng.moveToElementText(container.parentNode);
|
| | | rng.findText(invisibleChar);
|
| | | pos = Math.abs(rng.moveStart('character', -0xFFFFF));
|
| | | container.nodeValue = nodeVal;
|
| | |
|
| | | return pos;
|
| | | };
|
| | |
|
| | | // Collapsed range
|
| | | if (rng.collapsed) {
|
| | | pos = getCharPos(sc, so);
|
| | |
|
| | | ieRng = body.createTextRange();
|
| | | ieRng.move('character', pos);
|
| | | ieRng.select();
|
| | |
|
| | | return;
|
| | | } else {
|
| | | // If same text container
|
| | | if (sc == ec && sc.nodeType == 3) {
|
| | | startPos = getCharPos(sc, so);
|
| | |
|
| | | ieRng.move('character', startPos);
|
| | | ieRng.moveEnd('character', eo - so);
|
| | | ieRng.select();
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // Get caret positions
|
| | | startPos = getCharPos(sc, so);
|
| | | endPos = getCharPos(ec, eo);
|
| | | ieRng = body.createTextRange();
|
| | |
|
| | | // Move start of range to start character position or start element
|
| | | if (startPos == -1) {
|
| | | ieRng.moveToElementText(sc);
|
| | | startPos = 0;
|
| | | } else
|
| | | ieRng.move('character', startPos);
|
| | |
|
| | | // Move end of range to end character position or end element
|
| | | tmpRng = body.createTextRange();
|
| | |
|
| | | if (endPos == -1)
|
| | | tmpRng.moveToElementText(ec);
|
| | | else
|
| | | tmpRng.move('character', endPos);
|
| | |
|
| | | ieRng.setEndPoint('EndToEnd', tmpRng);
|
| | | ieRng.select();
|
| | |
|
| | | return;
|
| | | }
|
| | | };
|
| | |
|
| | | this.getRangeAt = function() {
|
| | | // Setup new range if the cache is empty
|
| | | if (!range || !compareRanges(lastIERng, selection.getRng())) {
|
| | | range = getRange();
|
| | |
|
| | | // Store away text range for next call
|
| | | lastIERng = selection.getRng();
|
| | | }
|
| | |
|
| | | // Return cached range
|
| | | return range;
|
| | | };
|
| | |
|
| | | this.destroy = function() {
|
| | | // Destroy cached range and last IE range to avoid memory leaks
|
| | | lastIERng = range = null;
|
| | | };
|
| | | };
|
| | |
|
| | | // Expose the selection object
|
| | | tinymce.dom.TridentSelection = Selection;
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/Event.js */
|
| | | /*
|
| | | * Sizzle CSS Selector Engine - v1.0
|
| | | * Copyright 2009, The Dojo Foundation
|
| | | * Released under the MIT, BSD, and GPL Licenses.
|
| | | * More information: http://sizzlejs.com/
|
| | | */
|
| | | (function(){
|
| | |
|
| | | (function() {
|
| | | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
| | | done = 0,
|
| | | toString = Object.prototype.toString,
|
| | | hasDuplicate = false;
|
| | |
|
| | | var Sizzle = function(selector, context, results, seed) {
|
| | | results = results || [];
|
| | | var origContext = context = context || document;
|
| | |
|
| | | if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
| | | return [];
|
| | | }
|
| | | |
| | | if ( !selector || typeof selector !== "string" ) {
|
| | | return results;
|
| | | }
|
| | |
|
| | | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context);
|
| | | |
| | | // Reset the position of the chunker regexp (start from head)
|
| | | chunker.lastIndex = 0;
|
| | | |
| | | while ( (m = chunker.exec(selector)) !== null ) {
|
| | | parts.push( m[1] );
|
| | | |
| | | if ( m[2] ) {
|
| | | extra = RegExp.rightContext;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
| | | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
| | | set = posProcess( parts[0] + parts[1], context );
|
| | | } else {
|
| | | set = Expr.relative[ parts[0] ] ?
|
| | | [ context ] :
|
| | | Sizzle( parts.shift(), context );
|
| | |
|
| | | while ( parts.length ) {
|
| | | selector = parts.shift();
|
| | |
|
| | | if ( Expr.relative[ selector ] )
|
| | | selector += parts.shift();
|
| | |
|
| | | set = posProcess( selector, set );
|
| | | }
|
| | | }
|
| | | } else {
|
| | | // Take a shortcut and set the context if the root selector is an ID
|
| | | // (but not if it'll be faster if the inner selector is an ID)
|
| | | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
| | | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
| | | var ret = Sizzle.find( parts.shift(), context, contextXML );
|
| | | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
|
| | | }
|
| | |
|
| | | if ( context ) {
|
| | | var ret = seed ?
|
| | | { expr: parts.pop(), set: makeArray(seed) } :
|
| | | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
| | | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
|
| | |
|
| | | if ( parts.length > 0 ) {
|
| | | checkSet = makeArray(set);
|
| | | } else {
|
| | | prune = false;
|
| | | }
|
| | |
|
| | | while ( parts.length ) {
|
| | | var cur = parts.pop(), pop = cur;
|
| | |
|
| | | if ( !Expr.relative[ cur ] ) {
|
| | | cur = "";
|
| | | } else {
|
| | | pop = parts.pop();
|
| | | }
|
| | |
|
| | | if ( pop == null ) {
|
| | | pop = context;
|
| | | }
|
| | |
|
| | | Expr.relative[ cur ]( checkSet, pop, contextXML );
|
| | | }
|
| | | } else {
|
| | | checkSet = parts = [];
|
| | | }
|
| | | }
|
| | |
|
| | | if ( !checkSet ) {
|
| | | checkSet = set;
|
| | | }
|
| | |
|
| | | if ( !checkSet ) {
|
| | | throw "Syntax error, unrecognized expression: " + (cur || selector);
|
| | | }
|
| | |
|
| | | if ( toString.call(checkSet) === "[object Array]" ) {
|
| | | if ( !prune ) {
|
| | | results.push.apply( results, checkSet );
|
| | | } else if ( context && context.nodeType === 1 ) {
|
| | | for ( var i = 0; checkSet[i] != null; i++ ) {
|
| | | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
| | | results.push( set[i] );
|
| | | }
|
| | | }
|
| | | } else {
|
| | | for ( var i = 0; checkSet[i] != null; i++ ) {
|
| | | if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
| | | results.push( set[i] );
|
| | | }
|
| | | }
|
| | | }
|
| | | } else {
|
| | | makeArray( checkSet, results );
|
| | | }
|
| | |
|
| | | if ( extra ) {
|
| | | Sizzle( extra, origContext, results, seed );
|
| | | Sizzle.uniqueSort( results );
|
| | | }
|
| | |
|
| | | return results;
|
| | | };
|
| | |
|
| | | Sizzle.uniqueSort = function(results){
|
| | | if ( sortOrder ) {
|
| | | hasDuplicate = false;
|
| | | results.sort(sortOrder);
|
| | |
|
| | | if ( hasDuplicate ) {
|
| | | for ( var i = 1; i < results.length; i++ ) {
|
| | | if ( results[i] === results[i-1] ) {
|
| | | results.splice(i--, 1);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | Sizzle.matches = function(expr, set){
|
| | | return Sizzle(expr, null, null, set);
|
| | | };
|
| | |
|
| | | Sizzle.find = function(expr, context, isXML){
|
| | | var set, match;
|
| | |
|
| | | if ( !expr ) {
|
| | | return [];
|
| | | }
|
| | |
|
| | | for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
| | | var type = Expr.order[i], match;
|
| | | |
| | | if ( (match = Expr.match[ type ].exec( expr )) ) {
|
| | | var left = RegExp.leftContext;
|
| | |
|
| | | if ( left.substr( left.length - 1 ) !== "\\" ) {
|
| | | match[1] = (match[1] || "").replace(/\\/g, "");
|
| | | set = Expr.find[ type ]( match, context, isXML );
|
| | | if ( set != null ) {
|
| | | expr = expr.replace( Expr.match[ type ], "" );
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if ( !set ) {
|
| | | set = context.getElementsByTagName("*");
|
| | | }
|
| | |
|
| | | return {set: set, expr: expr};
|
| | | };
|
| | |
|
| | | Sizzle.filter = function(expr, set, inplace, not){
|
| | | var old = expr, result = [], curLoop = set, match, anyFound,
|
| | | isXMLFilter = set && set[0] && isXML(set[0]);
|
| | |
|
| | | while ( expr && set.length ) {
|
| | | for ( var type in Expr.filter ) {
|
| | | if ( (match = Expr.match[ type ].exec( expr )) != null ) {
|
| | | var filter = Expr.filter[ type ], found, item;
|
| | | anyFound = false;
|
| | |
|
| | | if ( curLoop == result ) {
|
| | | result = [];
|
| | | }
|
| | |
|
| | | if ( Expr.preFilter[ type ] ) {
|
| | | match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
| | |
|
| | | if ( !match ) {
|
| | | anyFound = found = true;
|
| | | } else if ( match === true ) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | | if ( match ) {
|
| | | for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
|
| | | if ( item ) {
|
| | | found = filter( item, match, i, curLoop );
|
| | | var pass = not ^ !!found;
|
| | |
|
| | | if ( inplace && found != null ) {
|
| | | if ( pass ) {
|
| | | anyFound = true;
|
| | | } else {
|
| | | curLoop[i] = false;
|
| | | }
|
| | | } else if ( pass ) {
|
| | | result.push( item );
|
| | | anyFound = true;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if ( found !== undefined ) {
|
| | | if ( !inplace ) {
|
| | | curLoop = result;
|
| | | }
|
| | |
|
| | | expr = expr.replace( Expr.match[ type ], "" );
|
| | |
|
| | | if ( !anyFound ) {
|
| | | return [];
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // Improper expression
|
| | | if ( expr == old ) {
|
| | | if ( anyFound == null ) {
|
| | | throw "Syntax error, unrecognized expression: " + expr;
|
| | | } else {
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | old = expr;
|
| | | }
|
| | |
|
| | | return curLoop;
|
| | | };
|
| | |
|
| | | var Expr = Sizzle.selectors = {
|
| | | order: [ "ID", "NAME", "TAG" ],
|
| | | match: {
|
| | | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
|
| | | CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
|
| | | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
|
| | | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
|
| | | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
|
| | | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
|
| | | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
|
| | | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
|
| | | },
|
| | | attrMap: {
|
| | | "class": "className",
|
| | | "for": "htmlFor"
|
| | | },
|
| | | attrHandle: {
|
| | | href: function(elem){
|
| | | return elem.getAttribute("href");
|
| | | }
|
| | | },
|
| | | relative: {
|
| | | "+": function(checkSet, part, isXML){
|
| | | var isPartStr = typeof part === "string",
|
| | | isTag = isPartStr && !/\W/.test(part),
|
| | | isPartStrNotTag = isPartStr && !isTag;
|
| | |
|
| | | if ( isTag && !isXML ) {
|
| | | part = part.toUpperCase();
|
| | | }
|
| | |
|
| | | for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
| | | if ( (elem = checkSet[i]) ) {
|
| | | while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
| | |
|
| | | checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ?
|
| | | elem || false :
|
| | | elem === part;
|
| | | }
|
| | | }
|
| | |
|
| | | if ( isPartStrNotTag ) {
|
| | | Sizzle.filter( part, checkSet, true );
|
| | | }
|
| | | },
|
| | | ">": function(checkSet, part, isXML){
|
| | | var isPartStr = typeof part === "string";
|
| | |
|
| | | if ( isPartStr && !/\W/.test(part) ) {
|
| | | part = isXML ? part : part.toUpperCase();
|
| | |
|
| | | for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
| | | var elem = checkSet[i];
|
| | | if ( elem ) {
|
| | | var parent = elem.parentNode;
|
| | | checkSet[i] = parent.nodeName === part ? parent : false;
|
| | | }
|
| | | }
|
| | | } else {
|
| | | for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
| | | var elem = checkSet[i];
|
| | | if ( elem ) {
|
| | | checkSet[i] = isPartStr ?
|
| | | elem.parentNode :
|
| | | elem.parentNode === part;
|
| | | }
|
| | | }
|
| | |
|
| | | if ( isPartStr ) {
|
| | | Sizzle.filter( part, checkSet, true );
|
| | | }
|
| | | }
|
| | | },
|
| | | "": function(checkSet, part, isXML){
|
| | | var doneName = done++, checkFn = dirCheck;
|
| | |
|
| | | if ( !part.match(/\W/) ) {
|
| | | var nodeCheck = part = isXML ? part : part.toUpperCase();
|
| | | checkFn = dirNodeCheck;
|
| | | }
|
| | |
|
| | | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
|
| | | },
|
| | | "~": function(checkSet, part, isXML){
|
| | | var doneName = done++, checkFn = dirCheck;
|
| | |
|
| | | if ( typeof part === "string" && !part.match(/\W/) ) {
|
| | | var nodeCheck = part = isXML ? part : part.toUpperCase();
|
| | | checkFn = dirNodeCheck;
|
| | | }
|
| | |
|
| | | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
|
| | | }
|
| | | },
|
| | | find: {
|
| | | ID: function(match, context, isXML){
|
| | | if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
| | | var m = context.getElementById(match[1]);
|
| | | return m ? [m] : [];
|
| | | }
|
| | | },
|
| | | NAME: function(match, context, isXML){
|
| | | if ( typeof context.getElementsByName !== "undefined" ) {
|
| | | var ret = [], results = context.getElementsByName(match[1]);
|
| | |
|
| | | for ( var i = 0, l = results.length; i < l; i++ ) {
|
| | | if ( results[i].getAttribute("name") === match[1] ) {
|
| | | ret.push( results[i] );
|
| | | }
|
| | | }
|
| | |
|
| | | return ret.length === 0 ? null : ret;
|
| | | }
|
| | | },
|
| | | TAG: function(match, context){
|
| | | return context.getElementsByTagName(match[1]);
|
| | | }
|
| | | },
|
| | | preFilter: {
|
| | | CLASS: function(match, curLoop, inplace, result, not, isXML){
|
| | | match = " " + match[1].replace(/\\/g, "") + " ";
|
| | |
|
| | | if ( isXML ) {
|
| | | return match;
|
| | | }
|
| | |
|
| | | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
| | | if ( elem ) {
|
| | | if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) {
|
| | | if ( !inplace )
|
| | | result.push( elem );
|
| | | } else if ( inplace ) {
|
| | | curLoop[i] = false;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | },
|
| | | ID: function(match){
|
| | | return match[1].replace(/\\/g, "");
|
| | | },
|
| | | TAG: function(match, curLoop){
|
| | | for ( var i = 0; curLoop[i] === false; i++ ){}
|
| | | return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
|
| | | },
|
| | | CHILD: function(match){
|
| | | if ( match[1] == "nth" ) {
|
| | | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
| | | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
|
| | | match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
|
| | | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
| | |
|
| | | // calculate the numbers (first)n+(last) including if they are negative
|
| | | match[2] = (test[1] + (test[2] || 1)) - 0;
|
| | | match[3] = test[3] - 0;
|
| | | }
|
| | |
|
| | | // TODO: Move to normal caching system
|
| | | match[0] = done++;
|
| | |
|
| | | return match;
|
| | | },
|
| | | ATTR: function(match, curLoop, inplace, result, not, isXML){
|
| | | var name = match[1].replace(/\\/g, "");
|
| | | |
| | | if ( !isXML && Expr.attrMap[name] ) {
|
| | | match[1] = Expr.attrMap[name];
|
| | | }
|
| | |
|
| | | if ( match[2] === "~=" ) {
|
| | | match[4] = " " + match[4] + " ";
|
| | | }
|
| | |
|
| | | return match;
|
| | | },
|
| | | PSEUDO: function(match, curLoop, inplace, result, not){
|
| | | if ( match[1] === "not" ) {
|
| | | // If we're dealing with a complex expression, or a simple one
|
| | | if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
|
| | | match[3] = Sizzle(match[3], null, null, curLoop);
|
| | | } else {
|
| | | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
| | | if ( !inplace ) {
|
| | | result.push.apply( result, ret );
|
| | | }
|
| | | return false;
|
| | | }
|
| | | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
| | | return true;
|
| | | }
|
| | | |
| | | return match;
|
| | | },
|
| | | POS: function(match){
|
| | | match.unshift( true );
|
| | | return match;
|
| | | }
|
| | | },
|
| | | filters: {
|
| | | enabled: function(elem){
|
| | | return elem.disabled === false && elem.type !== "hidden";
|
| | | },
|
| | | disabled: function(elem){
|
| | | return elem.disabled === true;
|
| | | },
|
| | | checked: function(elem){
|
| | | return elem.checked === true;
|
| | | },
|
| | | selected: function(elem){
|
| | | // Accessing this property makes selected-by-default
|
| | | // options in Safari work properly
|
| | | elem.parentNode.selectedIndex;
|
| | | return elem.selected === true;
|
| | | },
|
| | | parent: function(elem){
|
| | | return !!elem.firstChild;
|
| | | },
|
| | | empty: function(elem){
|
| | | return !elem.firstChild;
|
| | | },
|
| | | has: function(elem, i, match){
|
| | | return !!Sizzle( match[3], elem ).length;
|
| | | },
|
| | | header: function(elem){
|
| | | return /h\d/i.test( elem.nodeName );
|
| | | },
|
| | | text: function(elem){
|
| | | return "text" === elem.type;
|
| | | },
|
| | | radio: function(elem){
|
| | | return "radio" === elem.type;
|
| | | },
|
| | | checkbox: function(elem){
|
| | | return "checkbox" === elem.type;
|
| | | },
|
| | | file: function(elem){
|
| | | return "file" === elem.type;
|
| | | },
|
| | | password: function(elem){
|
| | | return "password" === elem.type;
|
| | | },
|
| | | submit: function(elem){
|
| | | return "submit" === elem.type;
|
| | | },
|
| | | image: function(elem){
|
| | | return "image" === elem.type;
|
| | | },
|
| | | reset: function(elem){
|
| | | return "reset" === elem.type;
|
| | | },
|
| | | button: function(elem){
|
| | | return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
|
| | | },
|
| | | input: function(elem){
|
| | | return /input|select|textarea|button/i.test(elem.nodeName);
|
| | | }
|
| | | },
|
| | | setFilters: {
|
| | | first: function(elem, i){
|
| | | return i === 0;
|
| | | },
|
| | | last: function(elem, i, match, array){
|
| | | return i === array.length - 1;
|
| | | },
|
| | | even: function(elem, i){
|
| | | return i % 2 === 0;
|
| | | },
|
| | | odd: function(elem, i){
|
| | | return i % 2 === 1;
|
| | | },
|
| | | lt: function(elem, i, match){
|
| | | return i < match[3] - 0;
|
| | | },
|
| | | gt: function(elem, i, match){
|
| | | return i > match[3] - 0;
|
| | | },
|
| | | nth: function(elem, i, match){
|
| | | return match[3] - 0 == i;
|
| | | },
|
| | | eq: function(elem, i, match){
|
| | | return match[3] - 0 == i;
|
| | | }
|
| | | },
|
| | | filter: {
|
| | | PSEUDO: function(elem, match, i, array){
|
| | | var name = match[1], filter = Expr.filters[ name ];
|
| | |
|
| | | if ( filter ) {
|
| | | return filter( elem, i, match, array );
|
| | | } else if ( name === "contains" ) {
|
| | | return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
|
| | | } else if ( name === "not" ) {
|
| | | var not = match[3];
|
| | |
|
| | | for ( var i = 0, l = not.length; i < l; i++ ) {
|
| | | if ( not[i] === elem ) {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | | },
|
| | | CHILD: function(elem, match){
|
| | | var type = match[1], node = elem;
|
| | | switch (type) {
|
| | | case 'only':
|
| | | case 'first':
|
| | | while (node = node.previousSibling) {
|
| | | if ( node.nodeType === 1 ) return false;
|
| | | }
|
| | | if ( type == 'first') return true;
|
| | | node = elem;
|
| | | case 'last':
|
| | | while (node = node.nextSibling) {
|
| | | if ( node.nodeType === 1 ) return false;
|
| | | }
|
| | | return true;
|
| | | case 'nth':
|
| | | var first = match[2], last = match[3];
|
| | |
|
| | | if ( first == 1 && last == 0 ) {
|
| | | return true;
|
| | | }
|
| | | |
| | | var doneName = match[0],
|
| | | parent = elem.parentNode;
|
| | | |
| | | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
| | | var count = 0;
|
| | | for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
| | | if ( node.nodeType === 1 ) {
|
| | | node.nodeIndex = ++count;
|
| | | }
|
| | | } |
| | | parent.sizcache = doneName;
|
| | | }
|
| | | |
| | | var diff = elem.nodeIndex - last;
|
| | | if ( first == 0 ) {
|
| | | return diff == 0;
|
| | | } else {
|
| | | return ( diff % first == 0 && diff / first >= 0 );
|
| | | }
|
| | | }
|
| | | },
|
| | | ID: function(elem, match){
|
| | | return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
| | | },
|
| | | TAG: function(elem, match){
|
| | | return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
|
| | | },
|
| | | CLASS: function(elem, match){
|
| | | return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
| | | .indexOf( match ) > -1;
|
| | | },
|
| | | ATTR: function(elem, match){
|
| | | var name = match[1],
|
| | | result = Expr.attrHandle[ name ] ?
|
| | | Expr.attrHandle[ name ]( elem ) :
|
| | | elem[ name ] != null ?
|
| | | elem[ name ] :
|
| | | elem.getAttribute( name ),
|
| | | value = result + "",
|
| | | type = match[2],
|
| | | check = match[4];
|
| | |
|
| | | return result == null ?
|
| | | type === "!=" :
|
| | | type === "=" ?
|
| | | value === check :
|
| | | type === "*=" ?
|
| | | value.indexOf(check) >= 0 :
|
| | | type === "~=" ?
|
| | | (" " + value + " ").indexOf(check) >= 0 :
|
| | | !check ?
|
| | | value && result !== false :
|
| | | type === "!=" ?
|
| | | value != check :
|
| | | type === "^=" ?
|
| | | value.indexOf(check) === 0 :
|
| | | type === "$=" ?
|
| | | value.substr(value.length - check.length) === check :
|
| | | type === "|=" ?
|
| | | value === check || value.substr(0, check.length + 1) === check + "-" :
|
| | | false;
|
| | | },
|
| | | POS: function(elem, match, i, array){
|
| | | var name = match[2], filter = Expr.setFilters[ name ];
|
| | |
|
| | | if ( filter ) {
|
| | | return filter( elem, i, match, array );
|
| | | }
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | var origPOS = Expr.match.POS;
|
| | |
|
| | | for ( var type in Expr.match ) {
|
| | | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
|
| | | }
|
| | |
|
| | | var makeArray = function(array, results) {
|
| | | array = Array.prototype.slice.call( array );
|
| | |
|
| | | if ( results ) {
|
| | | results.push.apply( results, array );
|
| | | return results;
|
| | | }
|
| | | |
| | | return array;
|
| | | };
|
| | |
|
| | | // Perform a simple check to determine if the browser is capable of
|
| | | // converting a NodeList to an array using builtin methods.
|
| | | try {
|
| | | Array.prototype.slice.call( document.documentElement.childNodes );
|
| | |
|
| | | // Provide a fallback method if it does not work
|
| | | } catch(e){
|
| | | makeArray = function(array, results) {
|
| | | var ret = results || [];
|
| | |
|
| | | if ( toString.call(array) === "[object Array]" ) {
|
| | | Array.prototype.push.apply( ret, array );
|
| | | } else {
|
| | | if ( typeof array.length === "number" ) {
|
| | | for ( var i = 0, l = array.length; i < l; i++ ) {
|
| | | ret.push( array[i] );
|
| | | }
|
| | | } else {
|
| | | for ( var i = 0; array[i]; i++ ) {
|
| | | ret.push( array[i] );
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return ret;
|
| | | };
|
| | | }
|
| | |
|
| | | var sortOrder;
|
| | |
|
| | | if ( document.documentElement.compareDocumentPosition ) {
|
| | | sortOrder = function( a, b ) {
|
| | | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
|
| | | if ( ret === 0 ) {
|
| | | hasDuplicate = true;
|
| | | }
|
| | | return ret;
|
| | | };
|
| | | } else if ( "sourceIndex" in document.documentElement ) {
|
| | | sortOrder = function( a, b ) {
|
| | | var ret = a.sourceIndex - b.sourceIndex;
|
| | | if ( ret === 0 ) {
|
| | | hasDuplicate = true;
|
| | | }
|
| | | return ret;
|
| | | };
|
| | | } else if ( document.createRange ) {
|
| | | sortOrder = function( a, b ) {
|
| | | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
|
| | | aRange.setStart(a, 0);
|
| | | aRange.setEnd(a, 0);
|
| | | bRange.setStart(b, 0);
|
| | | bRange.setEnd(b, 0);
|
| | | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
|
| | | if ( ret === 0 ) {
|
| | | hasDuplicate = true;
|
| | | }
|
| | | return ret;
|
| | | };
|
| | | }
|
| | |
|
| | | // Check to see if the browser returns elements by name when
|
| | | // querying by getElementById (and provide a workaround)
|
| | | (function(){
|
| | | // We're going to inject a fake input element with a specified name
|
| | | var form = document.createElement("div"),
|
| | | id = "script" + (new Date).getTime();
|
| | | form.innerHTML = "<a name='" + id + "'/>";
|
| | |
|
| | | // Inject it into the root element, check its status, and remove it quickly
|
| | | var root = document.documentElement;
|
| | | root.insertBefore( form, root.firstChild );
|
| | |
|
| | | // The workaround has to do additional checks after a getElementById
|
| | | // Which slows things down for other browsers (hence the branching)
|
| | | if ( !!document.getElementById( id ) ) {
|
| | | Expr.find.ID = function(match, context, isXML){
|
| | | if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
| | | var m = context.getElementById(match[1]);
|
| | | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
|
| | | }
|
| | | };
|
| | |
|
| | | Expr.filter.ID = function(elem, match){
|
| | | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
| | | return elem.nodeType === 1 && node && node.nodeValue === match;
|
| | | };
|
| | | }
|
| | |
|
| | | root.removeChild( form );
|
| | | })();
|
| | |
|
| | | (function(){
|
| | | // Check to see if the browser returns only elements
|
| | | // when doing getElementsByTagName("*")
|
| | |
|
| | | // Create a fake element
|
| | | var div = document.createElement("div");
|
| | | div.appendChild( document.createComment("") );
|
| | |
|
| | | // Make sure no comments are found
|
| | | if ( div.getElementsByTagName("*").length > 0 ) {
|
| | | Expr.find.TAG = function(match, context){
|
| | | var results = context.getElementsByTagName(match[1]);
|
| | |
|
| | | // Filter out possible comments
|
| | | if ( match[1] === "*" ) {
|
| | | var tmp = [];
|
| | |
|
| | | for ( var i = 0; results[i]; i++ ) {
|
| | | if ( results[i].nodeType === 1 ) {
|
| | | tmp.push( results[i] );
|
| | | }
|
| | | }
|
| | |
|
| | | results = tmp;
|
| | | }
|
| | |
|
| | | return results;
|
| | | };
|
| | | }
|
| | |
|
| | | // Check to see if an attribute returns normalized href attributes
|
| | | div.innerHTML = "<a href='#'></a>";
|
| | | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
| | | div.firstChild.getAttribute("href") !== "#" ) {
|
| | | Expr.attrHandle.href = function(elem){
|
| | | return elem.getAttribute("href", 2);
|
| | | };
|
| | | }
|
| | | })();
|
| | |
|
| | | if ( document.querySelectorAll ) (function(){
|
| | | var oldSizzle = Sizzle, div = document.createElement("div");
|
| | | div.innerHTML = "<p class='TEST'></p>";
|
| | |
|
| | | // Safari can't handle uppercase or unicode characters when
|
| | | // in quirks mode.
|
| | | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
| | | return;
|
| | | }
|
| | | |
| | | Sizzle = function(query, context, extra, seed){
|
| | | context = context || document;
|
| | |
|
| | | // Only use querySelectorAll on non-XML documents
|
| | | // (ID selectors don't work in non-HTML documents)
|
| | | if ( !seed && context.nodeType === 9 && !isXML(context) ) {
|
| | | try {
|
| | | return makeArray( context.querySelectorAll(query), extra );
|
| | | } catch(e){}
|
| | | }
|
| | | |
| | | return oldSizzle(query, context, extra, seed);
|
| | | };
|
| | |
|
| | | for ( var prop in oldSizzle ) {
|
| | | Sizzle[ prop ] = oldSizzle[ prop ];
|
| | | }
|
| | | })();
|
| | |
|
| | | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
|
| | | var div = document.createElement("div");
|
| | | div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
| | |
|
| | | // Opera can't find a second classname (in 9.6)
|
| | | if ( div.getElementsByClassName("e").length === 0 )
|
| | | return;
|
| | |
|
| | | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
| | | div.lastChild.className = "e";
|
| | |
|
| | | if ( div.getElementsByClassName("e").length === 1 )
|
| | | return;
|
| | |
|
| | | Expr.order.splice(1, 0, "CLASS");
|
| | | Expr.find.CLASS = function(match, context, isXML) {
|
| | | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
| | | return context.getElementsByClassName(match[1]);
|
| | | }
|
| | | };
|
| | | })();
|
| | |
|
| | | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
| | | var sibDir = dir == "previousSibling" && !isXML;
|
| | | for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
| | | var elem = checkSet[i];
|
| | | if ( elem ) {
|
| | | if ( sibDir && elem.nodeType === 1 ){
|
| | | elem.sizcache = doneName;
|
| | | elem.sizset = i;
|
| | | }
|
| | | elem = elem[dir];
|
| | | var match = false;
|
| | |
|
| | | while ( elem ) {
|
| | | if ( elem.sizcache === doneName ) {
|
| | | match = checkSet[elem.sizset];
|
| | | break;
|
| | | }
|
| | |
|
| | | if ( elem.nodeType === 1 && !isXML ){
|
| | | elem.sizcache = doneName;
|
| | | elem.sizset = i;
|
| | | }
|
| | |
|
| | | if ( elem.nodeName === cur ) {
|
| | | match = elem;
|
| | | break;
|
| | | }
|
| | |
|
| | | elem = elem[dir];
|
| | | }
|
| | |
|
| | | checkSet[i] = match;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
| | | var sibDir = dir == "previousSibling" && !isXML;
|
| | | for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
| | | var elem = checkSet[i];
|
| | | if ( elem ) {
|
| | | if ( sibDir && elem.nodeType === 1 ) {
|
| | | elem.sizcache = doneName;
|
| | | elem.sizset = i;
|
| | | }
|
| | | elem = elem[dir];
|
| | | var match = false;
|
| | |
|
| | | while ( elem ) {
|
| | | if ( elem.sizcache === doneName ) {
|
| | | match = checkSet[elem.sizset];
|
| | | break;
|
| | | }
|
| | |
|
| | | if ( elem.nodeType === 1 ) {
|
| | | if ( !isXML ) {
|
| | | elem.sizcache = doneName;
|
| | | elem.sizset = i;
|
| | | }
|
| | | if ( typeof cur !== "string" ) {
|
| | | if ( elem === cur ) {
|
| | | match = true;
|
| | | break;
|
| | | }
|
| | |
|
| | | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
| | | match = elem;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | elem = elem[dir];
|
| | | }
|
| | |
|
| | | checkSet[i] = match;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | var contains = document.compareDocumentPosition ? function(a, b){
|
| | | return a.compareDocumentPosition(b) & 16;
|
| | | } : function(a, b){
|
| | | return a !== b && (a.contains ? a.contains(b) : true);
|
| | | };
|
| | |
|
| | | var isXML = function(elem){
|
| | | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
|
| | | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML";
|
| | | };
|
| | |
|
| | | var posProcess = function(selector, context){
|
| | | var tmpSet = [], later = "", match,
|
| | | root = context.nodeType ? [context] : context;
|
| | |
|
| | | // Position selectors must be done after the filter
|
| | | // And so must :not(positional) so we move all PSEUDOs to the end
|
| | | while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
| | | later += match[0];
|
| | | selector = selector.replace( Expr.match.PSEUDO, "" );
|
| | | }
|
| | |
|
| | | selector = Expr.relative[selector] ? selector + "*" : selector;
|
| | |
|
| | | for ( var i = 0, l = root.length; i < l; i++ ) {
|
| | | Sizzle( selector, root[i], tmpSet );
|
| | | }
|
| | |
|
| | | return Sizzle.filter( later, tmpSet );
|
| | | };
|
| | |
|
| | | // EXPOSE
|
| | |
|
| | | window.tinymce.dom.Sizzle = Sizzle;
|
| | |
|
| | | })();
|
| | |
|
| | | (function(tinymce) {
|
| | | // Shorten names
|
| | | var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
|
| | |
|
| | |
| | | inits : [],
|
| | | events : [],
|
| | |
|
| | | // #if !jquery
|
| | |
|
| | | add : function(o, n, f, s) {
|
| | | var cb, t = this, el = t.events, r;
|
| | |
|
| | | // Handle array
|
| | | if (o && o instanceof Array) {
|
| | | if (o && o.hasOwnProperty && o instanceof Array) {
|
| | | r = [];
|
| | |
|
| | | each(o, function(o) {
|
| | |
| | | var t = this, a = t.events, s = false, r;
|
| | |
|
| | | // Handle array
|
| | | if (o && o instanceof Array) {
|
| | | if (o && o.hasOwnProperty && o instanceof Array) {
|
| | | r = [];
|
| | |
|
| | | each(o, function(o) {
|
| | |
| | | }
|
| | | },
|
| | |
|
| | | // #endif
|
| | |
|
| | | cancel : function(e) {
|
| | | if (!e)
|
| | |
| | | _pageInit : function() {
|
| | | var e = Event;
|
| | |
|
| | | // Keep it from running more than once
|
| | | if (e.domLoaded)
|
| | | return;
|
| | |
|
| | | e._remove(window, 'DOMContentLoaded', e._pageInit);
|
| | | e.domLoaded = true;
|
| | |
|
| | |
| | | },
|
| | |
|
| | | _wait : function() {
|
| | | var t;
|
| | |
|
| | | // No need since the document is already loaded
|
| | | if (window.tinyMCE_GZ && tinyMCE_GZ.loaded)
|
| | | if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
|
| | | Event.domLoaded = 1;
|
| | | return;
|
| | | }
|
| | |
|
| | | if (isIE && document.location.protocol != 'https:') {
|
| | | // Fake DOMContentLoaded on IE
|
| | | document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
|
| | | DOM.get("__ie_onload").onreadystatechange = function() {
|
| | | if (this.readyState == "complete") {
|
| | | // Use IE method
|
| | | if (document.attachEvent) {
|
| | | document.attachEvent("onreadystatechange", function() {
|
| | | if (document.readyState === "complete") {
|
| | | document.detachEvent("onreadystatechange", arguments.callee);
|
| | | Event._pageInit();
|
| | | DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
|
| | | }
|
| | | };
|
| | | } else {
|
| | | });
|
| | |
|
| | | if (document.documentElement.doScroll && window == window.top) {
|
| | | (function() {
|
| | | if (Event.domLoaded)
|
| | | return;
|
| | |
|
| | | try {
|
| | | // If IE is used, use the trick by Diego Perini
|
| | | // http://javascript.nwbox.com/IEContentLoaded/
|
| | | document.documentElement.doScroll("left");
|
| | | } catch (ex) {
|
| | | setTimeout(arguments.callee, 0);
|
| | | return;
|
| | | }
|
| | |
|
| | | Event._pageInit();
|
| | | })();
|
| | | }
|
| | | } else if (document.addEventListener)
|
| | | Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
|
| | |
|
| | | if (isIE || isWebKit) {
|
| | | t = setInterval(function() {
|
| | | if (/loaded|complete/.test(document.readyState)) {
|
| | | clearInterval(t);
|
| | | Event._pageInit();
|
| | | }
|
| | | }, 10);
|
| | | }
|
| | | }
|
| | | Event._add(window, 'load', Event._pageInit, Event);
|
| | | }
|
| | |
|
| | | });
|
| | |
| | | // Dispatch DOM content loaded event for IE and Safari
|
| | | Event._wait();
|
| | | tinymce.addUnload(Event._unload);
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/Element.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var each = tinymce.each;
|
| | |
|
| | | tinymce.create('tinymce.dom.Element', {
|
| | |
| | | 'get'
|
| | | ], function(k) {
|
| | | t[k] = function() {
|
| | | var a = arguments, o;
|
| | | var a = [id], i;
|
| | |
|
| | | // Opera fails
|
| | | if (tinymce.isOpera) {
|
| | | a = [id];
|
| | | for (i = 0; i < arguments.length; i++)
|
| | | a.push(arguments[i]);
|
| | |
|
| | | each(arguments, function(v) {
|
| | | a.push(v);
|
| | | });
|
| | | } else
|
| | | Array.prototype.unshift.call(a, el || id);
|
| | |
|
| | | o = dom[k].apply(dom, a);
|
| | | a = dom[k].apply(dom, a);
|
| | | t.update(k);
|
| | |
|
| | | return o;
|
| | | return a;
|
| | | };
|
| | | });
|
| | | },
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | function trimNl(s) {
|
| | | return s.replace(/[\n\r]+/g, '');
|
| | | };
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/Selection.js */
|
| | |
|
| | | (function() {
|
| | | // Shorten names
|
| | | var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each;
|
| | |
|
| | |
| | | t.dom = dom;
|
| | | t.win = win;
|
| | | t.serializer = serializer;
|
| | |
|
| | | // Add events
|
| | | each([
|
| | | 'onBeforeSetContent',
|
| | | 'onBeforeGetContent',
|
| | | 'onSetContent',
|
| | | 'onGetContent'
|
| | | ], function(e) {
|
| | | t[e] = new tinymce.util.Dispatcher(t);
|
| | | });
|
| | |
|
| | | // No W3C Range support
|
| | | if (!t.win.getSelection)
|
| | | t.tridentSel = new tinymce.dom.TridentSelection(t);
|
| | |
|
| | | // Prevent leaks
|
| | | tinymce.addUnload(t.destroy, t);
|
| | |
| | | wb = wa = '';
|
| | | s.get = true;
|
| | | s.format = s.format || 'html';
|
| | | t.onBeforeGetContent.dispatch(t, s);
|
| | |
|
| | | if (s.format == 'text')
|
| | | return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : ''));
|
| | |
| | |
|
| | | s.getInner = true;
|
| | |
|
| | | return t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
|
| | | s.content = t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
|
| | | t.onGetContent.dispatch(t, s);
|
| | |
|
| | | return s.content;
|
| | | },
|
| | |
|
| | | setContent : function(h, s) {
|
| | | var t = this, r = t.getRng(), d;
|
| | | var t = this, r = t.getRng(), c, d = t.win.document;
|
| | |
|
| | | s = s || {format : 'html'};
|
| | | s.set = true;
|
| | | h = t.dom.processHTML(h);
|
| | | h = s.content = t.dom.processHTML(h);
|
| | |
|
| | | // Dispatch before set content event
|
| | | t.onBeforeSetContent.dispatch(t, s);
|
| | | h = s.content;
|
| | |
|
| | | if (r.insertNode) {
|
| | | d = t.win.document;
|
| | | // Make caret marker since insertNode places the caret in the beginning of text after insert
|
| | | h += '<span id="__caret">_</span>';
|
| | |
|
| | | // Gecko has a bug where if you insert using InsertHTML it will insert a space instead
|
| | | // So we simply check if the input is HTML or text and then insert text using the insertNode method
|
| | | if (tinymce.isGecko && h.indexOf('<') == -1) {
|
| | | r.deleteContents();
|
| | | r.insertNode(t.getRng().createContextualFragment(h + '<span id="__caret">_</span>'));
|
| | | t.select(t.dom.get('__caret'));
|
| | | t.getRng().deleteContents();
|
| | | return;
|
| | | }
|
| | | // Delete and insert new node
|
| | | r.deleteContents();
|
| | | r.insertNode(t.getRng().createContextualFragment(h));
|
| | |
|
| | | // Use insert HTML if it exists (places cursor after content)
|
| | | try {
|
| | | // This might fail with an exception see bug #1893736
|
| | | if (d.queryCommandEnabled('InsertHTML'))
|
| | | return d.execCommand('InsertHTML', false, h);
|
| | | } catch (ex) {
|
| | | // Use old school method
|
| | | r.deleteContents();
|
| | | r.insertNode(t.getRng().createContextualFragment(h));
|
| | | }
|
| | | // Move to caret marker
|
| | | c = t.dom.get('__caret');
|
| | |
|
| | | // Make sure we wrap it compleatly, Opera fails with a simple select call
|
| | | r = d.createRange();
|
| | | r.setStartBefore(c);
|
| | | r.setEndAfter(c);
|
| | | t.setRng(r);
|
| | |
|
| | | // Delete the marker, and hopefully the caret gets placed in the right location
|
| | | // Removed this since it seems to remove in FF and simply deleting it
|
| | | // doesn't seem to affect the caret position in any browser
|
| | | //d.execCommand('Delete', false, null);
|
| | |
|
| | | // Remove the caret position
|
| | | t.dom.remove('__caret');
|
| | | } else {
|
| | | if (r.item)
|
| | | r.item(0).outerHTML = h;
|
| | | else
|
| | | r.pasteHTML(h);
|
| | | if (r.item) {
|
| | | // Delete content and get caret text selection
|
| | | d.execCommand('Delete', false, null);
|
| | | r = t.getRng();
|
| | | }
|
| | |
|
| | | r.pasteHTML(h);
|
| | | }
|
| | |
|
| | | // Dispatch set content event
|
| | | t.onSetContent.dispatch(t, s);
|
| | | },
|
| | |
|
| | | getStart : function() {
|
| | |
| | | r.collapse(1);
|
| | | e = r.parentElement();
|
| | |
|
| | | if (e.nodeName == 'BODY')
|
| | | if (e && e.nodeName == 'BODY')
|
| | | return e.firstChild;
|
| | |
|
| | | return e;
|
| | |
| | | if (e.nodeName == 'BODY')
|
| | | return e.firstChild;
|
| | |
|
| | | return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
|
| | | return t.dom.getParent(e, '*');
|
| | | }
|
| | | },
|
| | |
|
| | |
| | | r.collapse(0);
|
| | | e = r.parentElement();
|
| | |
|
| | | if (e.nodeName == 'BODY')
|
| | | if (e && e.nodeName == 'BODY')
|
| | | return e.lastChild;
|
| | |
|
| | | return e;
|
| | |
| | | if (e.nodeName == 'BODY')
|
| | | return e.lastChild;
|
| | |
|
| | | return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
|
| | | return t.dom.getParent(e, '*');
|
| | | }
|
| | | },
|
| | |
|
| | |
| | | return d;
|
| | | }
|
| | |
|
| | | p += tinymce.trim(n.nodeValue || '').length;
|
| | | p += trimNl(n.nodeValue || '').length;
|
| | | }
|
| | |
|
| | | return null;
|
| | |
| | | return {scrollX : sx, scrollY : sy};
|
| | |
|
| | | // Count whitespace before
|
| | | (s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
| | | trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
| | |
|
| | | return {
|
| | | start : Math.max(e.start + s.anchorOffset - wb, 0),
|
| | |
| | | e = getPos(ro, r.startContainer, r.endContainer);
|
| | |
|
| | | // Count whitespace before start and end container
|
| | | (r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
| | | (r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
|
| | | //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
| | | //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
|
| | |
|
| | | if (!e)
|
| | | return {scrollX : sx, scrollY : sy};
|
| | |
| | | wa = wb = 0;
|
| | |
|
| | | nv = n.nodeValue || '';
|
| | | nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
|
| | | nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
|
| | | //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
|
| | | //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
|
| | |
|
| | | nvl = tinymce.trim(nv).length;
|
| | | nvl = trimNl(nv).length;
|
| | | p += nvl;
|
| | |
|
| | | if (p >= sp && !d.startNode) {
|
| | |
| | | select : function(n, c) {
|
| | | var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document;
|
| | |
|
| | | function first(n) {
|
| | | return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null;
|
| | | };
|
| | | function find(n, start) {
|
| | | var walker, o;
|
| | |
|
| | | function last(n) {
|
| | | var c, o, w;
|
| | | if (n) {
|
| | | walker = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
|
| | |
|
| | | if (!n)
|
| | | return null;
|
| | | // Find first/last non empty text node
|
| | | while (n = walker.nextNode()) {
|
| | | o = n;
|
| | |
|
| | | w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
|
| | | while (c = w.nextNode())
|
| | | o = c;
|
| | | if (tinymce.trim(n.nodeValue).length != 0) {
|
| | | if (start)
|
| | | return n;
|
| | | else
|
| | | o = n;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return o;
|
| | | };
|
| | |
| | | }
|
| | | } else {
|
| | | if (c) {
|
| | | fn = first(n);
|
| | | ln = last(n);
|
| | | fn = find(n, 1) || t.dom.select('br:first', n)[0];
|
| | | ln = find(n, 0) || t.dom.select('br:last', n)[0];
|
| | |
|
| | | if (fn && ln) {
|
| | | //console.debug(fn, ln);
|
| | | r = d.createRange();
|
| | | r.setStart(fn, 0);
|
| | | r.setEnd(ln, ln.nodeValue.length);
|
| | |
|
| | | if (fn.nodeName == 'BR')
|
| | | r.setStartBefore(fn);
|
| | | else
|
| | | r.setStart(fn, 0);
|
| | |
|
| | | if (ln.nodeName == 'BR')
|
| | | r.setEndBefore(ln);
|
| | | else
|
| | | r.setEnd(ln, ln.nodeValue.length);
|
| | | } else
|
| | | r.selectNode(n);
|
| | | } else
|
| | |
| | | if (!r || r.item)
|
| | | return false;
|
| | |
|
| | | return !s || r.boundingWidth == 0 || s.isCollapsed;
|
| | | return !s || r.boundingWidth == 0 || r.collapsed;
|
| | | },
|
| | |
|
| | | collapse : function(b) {
|
| | |
| | | return w.getSelection ? w.getSelection() : w.document.selection;
|
| | | },
|
| | |
|
| | | getRng : function() {
|
| | | var t = this, s = t.getSel(), r;
|
| | | getRng : function(w3c) {
|
| | | var t = this, s, r;
|
| | |
|
| | | // Found tridentSel object then we need to use that one
|
| | | if (w3c && t.tridentSel)
|
| | | return t.tridentSel.getRangeAt(0);
|
| | |
|
| | | try {
|
| | | if (s)
|
| | | if (s = t.getSel())
|
| | | r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange());
|
| | | } catch (ex) {
|
| | | // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
|
| | |
| | | },
|
| | |
|
| | | setRng : function(r) {
|
| | | var s;
|
| | | var s, t = this;
|
| | |
|
| | | if (!isIE) {
|
| | | s = this.getSel();
|
| | | if (!t.tridentSel) {
|
| | | s = t.getSel();
|
| | |
|
| | | if (s) {
|
| | | s.removeAllRanges();
|
| | | s.addRange(r);
|
| | | }
|
| | | } else {
|
| | | // Is W3C Range
|
| | | if (r.cloneRange) {
|
| | | t.tridentSel.addRange(r);
|
| | | return;
|
| | | }
|
| | |
|
| | | // Is IE specific range
|
| | | try {
|
| | | r.select();
|
| | | } catch (ex) {
|
| | |
| | |
|
| | | // Handle selection a image or other control like element such as anchors
|
| | | if (!r.collapsed) {
|
| | | if (r.startContainer == r.endContainer || (tinymce.isWebKit && r.startContainer == r.endContainer.parentNode)) {
|
| | | if (r.startOffset - r.endOffset < 2 || tinymce.isWebKit) {
|
| | | // If the anchor node is a element instead of a text node then return this element
|
| | | if (tinymce.isWebKit && s.anchorNode && s.anchorNode.nodeType == 1) |
| | | return s.anchorNode.childNodes[s.anchorOffset]; |
| | |
|
| | | if (r.startContainer == r.endContainer) {
|
| | | if (r.startOffset - r.endOffset < 2) {
|
| | | if (r.startContainer.hasChildNodes())
|
| | | e = r.startContainer.childNodes[r.startOffset];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return t.dom.getParent(e, function(n) {
|
| | | return n.nodeType == 1;
|
| | | });
|
| | | return t.dom.getParent(e, '*');
|
| | | }
|
| | |
|
| | | return r.item ? r.item(0) : r.parentElement();
|
| | | },
|
| | |
|
| | | getSelectedBlocks : function(st, en) {
|
| | | var t = this, dom = t.dom, sb, eb, n, bl = [];
|
| | |
|
| | | sb = dom.getParent(st || t.getStart(), dom.isBlock);
|
| | | eb = dom.getParent(en || t.getEnd(), dom.isBlock);
|
| | |
|
| | | if (sb)
|
| | | bl.push(sb);
|
| | |
|
| | | if (sb && eb && sb != eb) {
|
| | | n = sb;
|
| | |
|
| | | while ((n = n.nextSibling) && n != eb) {
|
| | | if (dom.isBlock(n))
|
| | | bl.push(n);
|
| | | }
|
| | | }
|
| | |
|
| | | if (eb && sb != eb)
|
| | | bl.push(eb);
|
| | |
|
| | | return bl;
|
| | | },
|
| | |
|
| | | destroy : function(s) {
|
| | |
| | |
|
| | | t.win = null;
|
| | |
|
| | | if (t.tridentSel)
|
| | | t.tridentSel.destroy();
|
| | |
|
| | | // Manual destroy then remove unload handler
|
| | | if (!s)
|
| | | tinymce.removeUnload(t.destroy);
|
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | tinymce.create('tinymce.dom.XMLWriter', {
|
| | | node : null,
|
| | |
|
| | |
| | | },
|
| | |
|
| | | writeComment : function(v) {
|
| | | this.node.appendChild(this.doc.createComment(v));
|
| | | // Fix for bug #2035694
|
| | | if (tinymce.isIE)
|
| | | v = v.replace(/^\-|\-$/g, ' ');
|
| | |
|
| | | this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' ')));
|
| | | },
|
| | |
|
| | | getContent : function() {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/StringWriter.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | tinymce.create('tinymce.dom.StringWriter', {
|
| | | str : null,
|
| | | tags : null,
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/Serializer.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | // Shorten names
|
| | | var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko;
|
| | |
|
| | | // Returns only attribites that have values not all attributes in IE
|
| | | function getIEAtts(n) {
|
| | | var o = [];
|
| | |
|
| | | // Object will throw exception in IE
|
| | | if (n.nodeName == 'OBJECT')
|
| | | return n.attributes;
|
| | |
|
| | | n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
|
| | | o.push({specified : 1, nodeName : b});
|
| | | });
|
| | |
|
| | | return o;
|
| | | };
|
| | |
|
| | | function wildcardToRE(s) {
|
| | | return s.replace(/([?+*])/g, '.$1');
|
| | |
| | | t.onPreProcess = new Dispatcher(t);
|
| | | t.onPostProcess = new Dispatcher(t);
|
| | |
|
| | | if (tinymce.relaxedDomain && tinymce.isGecko) {
|
| | | // Gecko has a bug where we can't create a new XML document if domain relaxing is used
|
| | | try {
|
| | | t.writer = new tinymce.dom.XMLWriter();
|
| | | } catch (ex) {
|
| | | // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
|
| | | t.writer = new tinymce.dom.StringWriter();
|
| | | } else {
|
| | | try {
|
| | | t.writer = new tinymce.dom.XMLWriter();
|
| | | } catch (ex) {
|
| | | // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
|
| | | t.writer = new tinymce.dom.StringWriter();
|
| | | }
|
| | | }
|
| | |
|
| | | // Default settings
|
| | |
| | | node_filter : 0,
|
| | | attr_filter : 0,
|
| | | invalid_attrs : /^(mce_|_moz_)/,
|
| | | closed : /(br|hr|input|meta|img|link|param)/,
|
| | | closed : /^(br|hr|input|meta|img|link|param|area)$/,
|
| | | entity_encoding : 'named',
|
| | | entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',
|
| | | bool_attrs : /(checked|disabled|readonly|selected|nowrap)/,
|
| | | valid_elements : '*[*]',
|
| | | extended_valid_elements : 0,
|
| | | valid_child_elements : 0,
|
| | | invalid_elements : 0,
|
| | | fix_table_elements : 0,
|
| | | fix_table_elements : 1,
|
| | | fix_list_elements : true,
|
| | | fix_content_duplication : true,
|
| | | convert_fonts_to_spans : false,
|
| | |
| | | indent_mode : 'simple',
|
| | | indent_char : '\t',
|
| | | indent_levels : 1,
|
| | | remove_linebreaks : 1
|
| | | remove_linebreaks : 1,
|
| | | remove_redundant_brs : 1,
|
| | | element_format : 'xhtml'
|
| | | }, s);
|
| | |
|
| | | t.dom = s.dom;
|
| | |
|
| | | if (s.remove_redundant_brs) {
|
| | | t.onPostProcess.add(function(se, o) {
|
| | | // 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) {
|
| | |
| | |
|
| | | if (s.fix_table_elements) {
|
| | | t.onPreProcess.add(function(se, o) {
|
| | | each(t.dom.select('table', o.node), function(e) {
|
| | | var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns;
|
| | |
|
| | | if (pa) {
|
| | | pa2 = pa.cloneNode(false);
|
| | |
|
| | | pl.push(e);
|
| | | for (n = e; n = n.parentNode;) {
|
| | | pl.push(n);
|
| | |
|
| | | if (n == pa)
|
| | | break;
|
| | | }
|
| | |
|
| | | tm = pa2;
|
| | | for (i = pl.length - 1; i >= 0; i--) {
|
| | | if (i == pl.length - 1) {
|
| | | while (ns = pl[i - 1].nextSibling)
|
| | | tm.appendChild(ns.parentNode.removeChild(ns));
|
| | | } else {
|
| | | n = pl[i].cloneNode(false);
|
| | |
|
| | | if (i != 0) {
|
| | | while (ns = pl[i - 1].nextSibling)
|
| | | n.appendChild(ns.parentNode.removeChild(ns));
|
| | | }
|
| | |
|
| | | tm = tm.appendChild(n);
|
| | | }
|
| | | }
|
| | |
|
| | | e = t.dom.insertAfter(e.parentNode.removeChild(e), pa);
|
| | | t.dom.insertAfter(e, pa);
|
| | | t.dom.insertAfter(pa2, e);
|
| | | }
|
| | | each(t.dom.select('p table', o.node), function(n) {
|
| | | t.dom.split(t.dom.getParent(n, 'p'), n);
|
| | | });
|
| | | });
|
| | | }
|
| | |
| | | // Internal functions
|
| | |
|
| | | _postProcess : function(o) {
|
| | | var t = this, s = t.settings, h = o.content, sc = [], p, l;
|
| | | var t = this, s = t.settings, h = o.content, sc = [], p;
|
| | |
|
| | | if (o.format == 'html') {
|
| | | // Protect some elements
|
| | | p = t._protect({
|
| | | content : h,
|
| | | patterns : [
|
| | | /(<script[^>]*>)(.*?)(<\/script>)/g,
|
| | | /(<style[^>]*>)(.*?)(<\/style>)/g,
|
| | | /(<pre[^>]*>)(.*?)(<\/pre>)/g
|
| | | {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
|
| | | {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
|
| | | {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1},
|
| | | {pattern : /(<!--\[CDATA\[)(.*?)(\]\]-->)/g}
|
| | | ]
|
| | | });
|
| | |
|
| | | h = p.content;
|
| | |
|
| | | // Entity encode
|
| | | if (s.entity_encoding !== 'raw') {
|
| | | if (s.entity_encoding.indexOf('named') != -1) {
|
| | | t.setEntities(s.entities);
|
| | | l = t.entityLookup;
|
| | |
|
| | | h = h.replace(t.entitiesRE, function(a) {
|
| | | var v;
|
| | |
|
| | | if (v = l[a])
|
| | | a = '&' + v + ';';
|
| | |
|
| | | return a;
|
| | | });
|
| | | }
|
| | |
|
| | | if (s.entity_encoding.indexOf('numeric') != -1) {
|
| | | h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
|
| | | return '&#' + a.charCodeAt(0) + ';';
|
| | | });
|
| | | }
|
| | | }
|
| | | if (s.entity_encoding !== 'raw')
|
| | | h = t._encode(h);
|
| | |
|
| | | // Use BR instead of padded P elements inside editor and use <p> </p> outside editor
|
| | | /* if (o.set)
|
| | |
| | | }
|
| | |
|
| | | h = t._unprotect(h, p);
|
| | |
|
| | | // Restore CDATA sections
|
| | | h = h.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g, '<![CDATA[$1]]>');
|
| | |
|
| | | // Restore the \u00a0 character if raw mode is enabled
|
| | | if (s.entity_encoding == 'raw')
|
| | |
| | |
|
| | | // Add wild attributes
|
| | | if (ru.validAttribsRE) {
|
| | | at = isIE ? getIEAtts(n) : n.attributes;
|
| | | at = t.dom.getAttribs(n);
|
| | | for (i=at.length-1; i>-1; i--) {
|
| | | no = at[i];
|
| | |
|
| | |
| | | }
|
| | |
|
| | | // Padd empty nodes with a
|
| | | if (!hc && ru.padd)
|
| | | w.writeText('\u00a0');
|
| | | if (ru.padd) {
|
| | | // If it has only one bogus child, padd it anyway workaround for <td><br /></td> bug
|
| | | if (hc && (cn = n.firstChild) && cn.nodeType === 1 && n.childNodes.length === 1) {
|
| | | if (cn.hasAttribute ? cn.hasAttribute('mce_bogus') : cn.getAttribute('mce_bogus'))
|
| | | w.writeText('\u00a0');
|
| | | } else if (!hc)
|
| | | w.writeText('\u00a0'); // No children then padd it
|
| | | }
|
| | |
|
| | | break;
|
| | |
|
| | |
| | | },
|
| | |
|
| | | _protect : function(o) {
|
| | | var t = this;
|
| | |
|
| | | o.items = o.items || [];
|
| | |
|
| | | function enc(s) {
|
| | |
| | | };
|
| | |
|
| | | each(o.patterns, function(p) {
|
| | | o.content = dec(enc(o.content).replace(p, function(x, a, b, c) {
|
| | | o.items.push(dec(b));
|
| | | o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
|
| | | b = dec(b);
|
| | |
|
| | | if (p.encode)
|
| | | b = t._encode(b);
|
| | |
|
| | | o.items.push(b);
|
| | | return a + '<!--mce:' + (o.items.length - 1) + '-->' + c;
|
| | | }));
|
| | | });
|
| | |
| | | return h;
|
| | | },
|
| | |
|
| | | _encode : function(h) {
|
| | | var t = this, s = t.settings, l;
|
| | |
|
| | | // Entity encode
|
| | | if (s.entity_encoding !== 'raw') {
|
| | | if (s.entity_encoding.indexOf('named') != -1) {
|
| | | t.setEntities(s.entities);
|
| | | l = t.entityLookup;
|
| | |
|
| | | h = h.replace(t.entitiesRE, function(a) {
|
| | | var v;
|
| | |
|
| | | if (v = l[a])
|
| | | a = '&' + v + ';';
|
| | |
|
| | | return a;
|
| | | });
|
| | | }
|
| | |
|
| | | if (s.entity_encoding.indexOf('numeric') != -1) {
|
| | | h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
|
| | | return '&#' + a.charCodeAt(0) + ';';
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | return h;
|
| | | },
|
| | |
|
| | | _setup : function() {
|
| | | var t = this, s = this.settings;
|
| | |
|
| | |
| | | t.addValidChildRules(s.valid_child_elements);
|
| | |
|
| | | if (s.invalid_elements)
|
| | | t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(',', '|').toLowerCase()) + ')$');
|
| | | t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
|
| | |
|
| | | if (s.attrib_value_filter)
|
| | | t.attribValueFilter = s.attribValueFilter;
|
| | |
| | | }
|
| | |
|
| | | v = this.dom.getAttrib(n, na);
|
| | |
|
| | | // Bool attr
|
| | | if (this.settings.bool_attrs.test(na) && v) {
|
| | | v = ('' + v).toLowerCase();
|
| | |
|
| | | if (v === 'false' || v === '0')
|
| | | return null;
|
| | |
|
| | | v = na;
|
| | | }
|
| | |
|
| | | switch (na) {
|
| | | case 'rowspan':
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */
|
| | |
|
| | | (function() {
|
| | | var each = tinymce.each;
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var each = tinymce.each, Event = tinymce.dom.Event;
|
| | |
|
| | | tinymce.create('tinymce.dom.ScriptLoader', {
|
| | | ScriptLoader : function(s) {
|
| | |
| | | }
|
| | |
|
| | | function loadScript(u) {
|
| | | if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) {
|
| | | if (Event.domLoaded || t.settings.strict_mode) {
|
| | | tinymce.util.XHR.send({
|
| | | url : u,
|
| | | url : tinymce._addVer(u),
|
| | | error : t.settings.error,
|
| | | async : false,
|
| | | success : function(co) {
|
| | |
| | | }
|
| | | });
|
| | | } else
|
| | | document.write('<script type="text/javascript" src="' + u + '"></script>');
|
| | | document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
|
| | | };
|
| | |
|
| | | if (!tinymce.is(u, 'string')) {
|
| | |
| | |
|
| | | o.state = 1; // Is loading
|
| | |
|
| | | tinymce.dom.ScriptLoader.loadScript(o.url, function() {
|
| | | done(o);
|
| | | allDone();
|
| | | });
|
| | |
|
| | | /*
|
| | | tinymce.util.XHR.send({
|
| | | url : o.url,
|
| | | error : t.settings.error,
|
| | |
| | | allDone();
|
| | | }
|
| | | });
|
| | | */
|
| | | };
|
| | |
|
| | | each(sc, function(o) {
|
| | |
| | | if (o.state > 0)
|
| | | return;
|
| | |
|
| | | if (!tinymce.dom.Event.domLoaded && !t.settings.strict_mode) {
|
| | | if (!Event.domLoaded && !t.settings.strict_mode) {
|
| | | var ix, ol = '';
|
| | |
|
| | | // Add onload events
|
| | |
| | | ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"';
|
| | | }
|
| | |
|
| | | document.write('<script type="text/javascript" src="' + u + '"' + ol + '></script>');
|
| | | document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
|
| | |
|
| | | if (!o.func)
|
| | | done(o);
|
| | |
| | | _onLoad : function(e, u, ix) {
|
| | | if (!tinymce.isIE || e.readyState == 'complete')
|
| | | this._funcs[ix].call(this);
|
| | | },
|
| | |
|
| | | loadScript : function(u, cb) {
|
| | | var id = tinymce.DOM.uniqueId(), e;
|
| | |
|
| | | function done() {
|
| | | Event.clear(id);
|
| | | tinymce.DOM.remove(id);
|
| | |
|
| | | if (cb) {
|
| | | cb.call(document, u);
|
| | | cb = 0;
|
| | | }
|
| | | };
|
| | |
|
| | | if (tinymce.isIE) {
|
| | | /* Event.add(e, 'readystatechange', function(e) {
|
| | | if (e.target && e.target.readyState == 'complete')
|
| | | done();
|
| | | });*/
|
| | |
|
| | | tinymce.util.XHR.send({
|
| | | url : tinymce._addVer(u),
|
| | | async : false,
|
| | | success : function(co) {
|
| | | window.execScript(co);
|
| | | done();
|
| | | }
|
| | | });
|
| | | } else {
|
| | | e = tinymce.DOM.create('script', {id : id, type : 'text/javascript', src : tinymce._addVer(u)});
|
| | | Event.add(e, 'load', done);
|
| | |
|
| | | // Check for head or body
|
| | | (document.getElementsByTagName('head')[0] || document.body).appendChild(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | // Global script loader
|
| | | tinymce.ScriptLoader = new tinymce.dom.ScriptLoader();
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/Control.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | // Shorten class names
|
| | | var DOM = tinymce.DOM, is = tinymce.is;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | /* file:jscripts/tiny_mce/classes/ui/Container.js */
|
| | |
|
| | | tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
|
| | | })(tinymce);tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
|
| | | Container : function(id, s) {
|
| | | this.parent(id, s);
|
| | | this.controls = [];
|
| | |
| | |
|
| | | });
|
| | |
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/Separator.js */
|
| | |
|
| | | tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
|
| | | Separator : function(id, s) {
|
| | | this.parent(id, s);
|
| | |
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */
|
| | |
|
| | | (function() {
|
| | | (function(tinymce) {
|
| | | var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
|
| | |
|
| | | tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/Menu.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
|
| | |
|
| | | tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | /* file:jscripts/tiny_mce/classes/ui/DropMenu.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);(function(tinymce) {
|
| | | var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
|
| | |
|
| | | tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
|
| | |
| | | this.onShowMenu = new tinymce.util.Dispatcher(this);
|
| | | this.onHideMenu = new tinymce.util.Dispatcher(this);
|
| | | this.classPrefix = 'mceMenu';
|
| | |
|
| | | // Fix for odd IE bug: #1903622
|
| | | this.fixIE = tinymce.isIE && DOM.win.top != DOM.win;
|
| | | },
|
| | |
|
| | | createMenu : function(s) {
|
| | |
| | | t.element.update();
|
| | |
|
| | | t.isMenuVisible = 1;
|
| | | t.mouseClickFunc = Event.add(co, t.fixIE ? 'mousedown' : 'click', function(e) {
|
| | | t.mouseClickFunc = Event.add(co, 'click', function(e) {
|
| | | var m;
|
| | |
|
| | | e = e.target;
|
| | |
|
| | | if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
|
| | | if (e && (e = DOM.getParent(e, 'tr')) && !DOM.hasClass(e, cp + 'ItemSub')) {
|
| | | m = t.items[e.id];
|
| | |
|
| | | if (m.isDisabled())
|
| | |
| | | var m, r, mi;
|
| | |
|
| | | e = e.target;
|
| | | if (e && (e = DOM.getParent(e, 'TR'))) {
|
| | | if (e && (e = DOM.getParent(e, 'tr'))) {
|
| | | m = t.items[e.id];
|
| | |
|
| | | if (t.lastMenu)
|
| | |
| | | if (s.keyboard_focus) {
|
| | | Event.add(co, 'keydown', t._keyHandler, t);
|
| | | DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
|
| | | t._focusIdx = 0;
|
| | | }
|
| | | },
|
| | |
|
| | |
| | | return;
|
| | |
|
| | | Event.remove(co, 'mouseover', t.mouseOverFunc);
|
| | | Event.remove(co, t.fixIE ? 'mousedown' : 'click', t.mouseClickFunc);
|
| | | Event.remove(co, 'click', t.mouseClickFunc);
|
| | | Event.remove(co, 'keydown', t._keyHandler);
|
| | | DOM.hide(co);
|
| | | t.isMenuVisible = 0;
|
| | |
| | | // Internal functions
|
| | |
|
| | | _keyHandler : function(e) {
|
| | | // Accessibility feature
|
| | | if (e.keyCode == 27)
|
| | | this.hideMenu();
|
| | | var t = this, kc = e.keyCode;
|
| | |
|
| | | function focus(d) {
|
| | | var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
|
| | |
|
| | | if (e) {
|
| | | t._focusIdx = i;
|
| | | e.focus();
|
| | | }
|
| | | };
|
| | |
|
| | | switch (kc) {
|
| | | case 38:
|
| | | focus(-1); // Select first link
|
| | | return;
|
| | |
|
| | | case 40:
|
| | | focus(1);
|
| | | return;
|
| | |
|
| | | case 13:
|
| | | return;
|
| | |
|
| | | case 27:
|
| | | return this.hideMenu();
|
| | | }
|
| | | },
|
| | |
|
| | | _add : function(tb, o) {
|
| | | var n, s = o.settings, a, ro, it, cp = this.classPrefix;
|
| | | var n, s = o.settings, a, ro, it, cp = this.classPrefix, ic;
|
| | |
|
| | | if (s.separator) {
|
| | | ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
|
| | |
| | |
|
| | | DOM.addClass(it, s['class']);
|
| | | // n = DOM.add(n, 'span', {'class' : 'item'});
|
| | | DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
|
| | |
|
| | | ic = DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
|
| | |
|
| | | if (s.icon_src)
|
| | | DOM.add(ic, 'img', {src : s.icon_src});
|
| | |
|
| | | n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
|
| | |
|
| | | if (o.settings.style)
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | /* file:jscripts/tiny_mce/classes/ui/Button.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);(function(tinymce) {
|
| | | var DOM = tinymce.DOM;
|
| | |
|
| | | tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
|
| | |
| | | },
|
| | |
|
| | | renderHTML : function() {
|
| | | var cp = this.classPrefix, s = this.settings, h = '<a id="' + this.id + '" href="javascript:;" class="' + cp + ' ' + cp + 'Enabled ' + s['class'] + '" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">';
|
| | | var cp = this.classPrefix, s = this.settings, h, l;
|
| | |
|
| | | l = DOM.encode(s.label || '');
|
| | | h = '<a id="' + this.id + '" href="javascript:;" class="' + cp + ' ' + cp + 'Enabled ' + s['class'] + (l ? ' ' + cp + 'Labeled' : '') +'" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">';
|
| | |
|
| | | if (s.image)
|
| | | h += '<img class="mceIcon" src="' + s.image + '" /></a>';
|
| | | h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>';
|
| | | else
|
| | | h += '<span class="mceIcon ' + s['class'] + '"></span></a>';
|
| | | h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>';
|
| | |
|
| | | return h;
|
| | | },
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/ListBox.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
|
| | |
|
| | | tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
|
| | |
| | | t.classPrefix = 'mceListBox';
|
| | | },
|
| | |
|
| | | select : function(v) {
|
| | | var t = this, e, fv;
|
| | | select : function(va) {
|
| | | var t = this, fv, f;
|
| | |
|
| | | if (va == undefined)
|
| | | return t.selectByIndex(-1);
|
| | |
|
| | | // Is string or number make function selector
|
| | | if (va && va.call)
|
| | | f = va;
|
| | | else {
|
| | | f = function(v) {
|
| | | return v == va;
|
| | | };
|
| | | }
|
| | |
|
| | | // Do we need to do something?
|
| | | if (v != t.selectedValue) {
|
| | | e = DOM.get(t.id + '_text');
|
| | | t.selectedValue = v;
|
| | |
|
| | | if (va != t.selectedValue) {
|
| | | // Find item
|
| | | each(t.items, function(o) {
|
| | | if (o.value == v) {
|
| | | DOM.setHTML(e, DOM.encode(o.title));
|
| | | each(t.items, function(o, i) {
|
| | | if (f(o.value)) {
|
| | | fv = 1;
|
| | | t.selectByIndex(i);
|
| | | return false;
|
| | | }
|
| | | });
|
| | |
|
| | | // If no item was found then present title
|
| | | if (!fv) {
|
| | | if (!fv)
|
| | | t.selectByIndex(-1);
|
| | | }
|
| | | },
|
| | |
|
| | | selectByIndex : function(idx) {
|
| | | var t = this, e, o;
|
| | |
|
| | | if (idx != t.selectedIndex) {
|
| | | e = DOM.get(t.id + '_text');
|
| | | o = t.items[idx];
|
| | |
|
| | | if (o) {
|
| | | t.selectedValue = o.value;
|
| | | t.selectedIndex = idx;
|
| | | DOM.setHTML(e, DOM.encode(o.title));
|
| | | DOM.removeClass(e, 'mceTitle');
|
| | | } else {
|
| | | DOM.setHTML(e, DOM.encode(t.settings.title));
|
| | | DOM.addClass(e, 'mceTitle');
|
| | | e = 0;
|
| | | return;
|
| | | } else
|
| | | DOM.removeClass(e, 'mceTitle');
|
| | | }
|
| | | t.selectedValue = t.selectedIndex = null;
|
| | | }
|
| | |
|
| | | e = 0;
|
| | | e = 0;
|
| | | }
|
| | | },
|
| | |
|
| | | add : function(n, v, o) {
|
| | |
| | | if (t.isDisabled() || t.items.length == 0)
|
| | | return;
|
| | |
|
| | | if (t.menu && t.menu.isMenuVisible)
|
| | | return t.hideMenu();
|
| | |
|
| | | if (!t.isMenuRendered) {
|
| | | t.renderMenu();
|
| | | t.isMenuRendered = true;
|
| | |
| | | m = t.menu;
|
| | | m.settings.offset_x = p2.x;
|
| | | m.settings.offset_y = p2.y;
|
| | | m.settings.keyboard_focus = t._focused;
|
| | | m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
|
| | |
|
| | | // Select in menu
|
| | | if (t.oldID)
|
| | |
| | |
|
| | | Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
|
| | | DOM.addClass(t.id, t.classPrefix + 'Selected');
|
| | |
|
| | | //DOM.get(t.id + '_text').focus();
|
| | | },
|
| | |
|
| | | hideMenu : function(e) {
|
| | | var t = this;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
|
| | | // Prevent double toogles by canceling the mouse click event to the button
|
| | | if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
|
| | | return;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, '.mceMenu')) {
|
| | | DOM.removeClass(t.id, t.classPrefix + 'Selected');
|
| | | Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
|
| | |
|
| | |
| | |
|
| | | m.add({
|
| | | title : t.settings.title,
|
| | | 'class' : 'mceMenuItemTitle'
|
| | | }).setDisabled(1);
|
| | | 'class' : 'mceMenuItemTitle',
|
| | | onclick : function() {
|
| | | if (t.settings.onselect('') !== false)
|
| | | t.select(''); // Must be runned after
|
| | | }
|
| | | });
|
| | |
|
| | | each(t.items, function(o) {
|
| | | o.id = DOM.uniqueId();
|
| | |
| | | var t = this, cp = t.classPrefix;
|
| | |
|
| | | Event.add(t.id, 'click', t.showMenu, t);
|
| | | Event.add(t.id + '_text', 'focus', function() {t._focused = 1;});
|
| | | Event.add(t.id + '_text', 'blur', function() {t._focused = 0;});
|
| | | Event.add(t.id + '_text', 'focus', function(e) {
|
| | | if (!t._focused) {
|
| | | t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
|
| | | var idx = -1, v, kc = e.keyCode;
|
| | |
|
| | | // Find current index
|
| | | each(t.items, function(v, i) {
|
| | | if (t.selectedValue == v.value)
|
| | | idx = i;
|
| | | });
|
| | |
|
| | | // Move up/down
|
| | | if (kc == 38)
|
| | | v = t.items[idx - 1];
|
| | | else if (kc == 40)
|
| | | v = t.items[idx + 1];
|
| | | else if (kc == 13) {
|
| | | // Fake select on enter
|
| | | v = t.selectedValue;
|
| | | t.selectedValue = null; // Needs to be null to fake change
|
| | | t.settings.onselect(v);
|
| | | return Event.cancel(e);
|
| | | }
|
| | |
|
| | | if (v) {
|
| | | t.hideMenu();
|
| | | t.select(v.value);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | t._focused = 1;
|
| | | });
|
| | | Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
|
| | |
|
| | | // Old IE doesn't have hover on all elements
|
| | | if (tinymce.isIE6 || !DOM.boxModel) {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);(function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
|
| | |
|
| | | tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
|
| | |
| | | return DOM.get(this.id).disabled;
|
| | | },
|
| | |
|
| | | select : function(v) {
|
| | | var e = DOM.get(this.id), ol = e.options;
|
| | | select : function(va) {
|
| | | var t = this, fv, f;
|
| | |
|
| | | v = '' + (v || '');
|
| | | if (va == undefined)
|
| | | return t.selectByIndex(-1);
|
| | |
|
| | | e.selectedIndex = 0;
|
| | | each(ol, function(o, i) {
|
| | | if (o.value == v) {
|
| | | e.selectedIndex = i;
|
| | | return false;
|
| | | }
|
| | | });
|
| | | // Is string or number make function selector
|
| | | if (va && va.call)
|
| | | f = va;
|
| | | else {
|
| | | f = function(v) {
|
| | | return v == va;
|
| | | };
|
| | | }
|
| | |
|
| | | // Do we need to do something?
|
| | | if (va != t.selectedValue) {
|
| | | // Find item
|
| | | each(t.items, function(o, i) {
|
| | | if (f(o.value)) {
|
| | | fv = 1;
|
| | | t.selectByIndex(i);
|
| | | return false;
|
| | | }
|
| | | });
|
| | |
|
| | | if (!fv)
|
| | | t.selectByIndex(-1);
|
| | | }
|
| | | },
|
| | |
|
| | | selectByIndex : function(idx) {
|
| | | DOM.get(this.id).selectedIndex = idx + 1;
|
| | | this.selectedValue = this.items[idx] ? this.items[idx].value : null;
|
| | | },
|
| | |
|
| | | add : function(n, v, a) {
|
| | |
| | | t.rendered = true;
|
| | |
|
| | | function onChange(e) {
|
| | | var v = e.target.options[e.target.selectedIndex].value;
|
| | | var v = t.items[e.target.selectedIndex - 1];
|
| | |
|
| | | t.onChange.dispatch(t, v);
|
| | | if (v && (v = v.value)) {
|
| | | t.onChange.dispatch(t, v);
|
| | |
|
| | | if (t.settings.onselect)
|
| | | t.settings.onselect(v);
|
| | | if (t.settings.onselect)
|
| | | t.settings.onselect(v);
|
| | | }
|
| | | };
|
| | |
|
| | | Event.add(t.id, 'change', onChange);
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | | /* file:jscripts/tiny_mce/classes/ui/MenuButton.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);(function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
|
| | |
|
| | | tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
|
| | |
| | | t.isMenuRendered = true;
|
| | | }
|
| | |
|
| | | if (t.isMenuVisible)
|
| | | return t.hideMenu();
|
| | |
|
| | | p1 = DOM.getPos(t.settings.menu_container);
|
| | | p2 = DOM.getPos(e);
|
| | |
|
| | |
| | |
|
| | | Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
|
| | | t.setState('Selected', 1);
|
| | |
|
| | | t.isMenuVisible = 1;
|
| | | },
|
| | |
|
| | | renderMenu : function() {
|
| | |
| | | hideMenu : function(e) {
|
| | | var t = this;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
|
| | | // Prevent double toogles by canceling the mouse click event to the button
|
| | | if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
|
| | | return;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, '.mceMenu')) {
|
| | | t.setState('Selected', 0);
|
| | | Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
|
| | | if (t.menu)
|
| | | t.menu.hideMenu();
|
| | | }
|
| | |
|
| | | t.isMenuVisible = 0;
|
| | | },
|
| | |
|
| | | postRender : function() {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/SplitButton.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
|
| | |
|
| | | tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
|
| | |
|
| | | tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
|
| | |
| | | default_color : '#888888'
|
| | | }, t.settings);
|
| | |
|
| | | t.onShowMenu = new tinymce.util.Dispatcher(t);
|
| | | t.onHideMenu = new tinymce.util.Dispatcher(t);
|
| | |
|
| | | t.value = s.default_color;
|
| | | },
|
| | |
|
| | |
| | | t.renderMenu();
|
| | | t.isMenuRendered = true;
|
| | | }
|
| | |
|
| | | if (t.isMenuVisible)
|
| | | return t.hideMenu();
|
| | |
|
| | | e = DOM.get(t.id);
|
| | | DOM.show(t.id + '_menu');
|
| | |
| | |
|
| | | DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
|
| | | }
|
| | |
|
| | | t.onShowMenu.dispatch(t);
|
| | |
|
| | | t.isMenuVisible = 1;
|
| | | },
|
| | |
|
| | | hideMenu : function(e) {
|
| | | var t = this;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
|
| | | // Prevent double toogles by canceling the mouse click event to the button
|
| | | if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
|
| | | return;
|
| | |
|
| | | if (!e || !DOM.getParent(e.target, '.mceSplitButtonMenu')) {
|
| | | DOM.removeClass(t.id, 'mceSplitButtonSelected');
|
| | | Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
|
| | | Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
|
| | | DOM.hide(t.id + '_menu');
|
| | | }
|
| | |
|
| | | t.onHideMenu.dispatch(t);
|
| | |
|
| | | t.isMenuVisible = 0;
|
| | | },
|
| | |
|
| | | renderMenu : function() {
|
| | |
| | |
|
| | | if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
|
| | | t.setColor(c);
|
| | |
|
| | | return Event.cancel(e); // Prevent IE auto save warning
|
| | | });
|
| | |
|
| | | return w;
|
| | |
| | |
|
| | | t.parent();
|
| | | DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
|
| | | DOM.setStyle(t.id + '_preview', 'backgroundColor', t.value);
|
| | | },
|
| | |
|
| | | destroy : function() {
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */
|
| | |
|
| | | })(tinymce);
|
| | | tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
|
| | | renderHTML : function() {
|
| | | var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl;
|
| | |
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/AddOnManager.js */
|
| | |
|
| | | (function() {
|
| | | (function(tinymce) {
|
| | | var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
|
| | |
|
| | | tinymce.create('tinymce.AddOnManager', {
|
| | |
| | | },
|
| | |
|
| | | requireLangPack : function(n) {
|
| | | var u, s;
|
| | | var u, s = tinymce.EditorManager.settings;
|
| | |
|
| | | if (tinymce.EditorManager.settings) {
|
| | | u = this.urls[n] + '/langs/' + tinymce.EditorManager.settings.language + '.js';
|
| | | s = tinymce.EditorManager.settings;
|
| | | if (s && s.language) {
|
| | | u = this.urls[n] + '/langs/' + s.language + '.js';
|
| | |
|
| | | if (s) {
|
| | | if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
|
| | | tinymce.ScriptLoader.load(u);
|
| | | else
|
| | | tinymce.ScriptLoader.add(u);
|
| | | }
|
| | | if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
|
| | | tinymce.ScriptLoader.load(u);
|
| | | else
|
| | | tinymce.ScriptLoader.add(u);
|
| | | }
|
| | | },
|
| | |
|
| | |
| | | // Create plugin and theme managers
|
| | | tinymce.PluginManager = new tinymce.AddOnManager();
|
| | | tinymce.ThemeManager = new tinymce.AddOnManager();
|
| | | }());
|
| | | /* file:jscripts/tiny_mce/classes/EditorManager.js */
|
| | |
|
| | | (function() {
|
| | | }(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;
|
| | |
|
| | |
| | | tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
|
| | | tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
|
| | |
|
| | | // Setup document domain
|
| | | if (tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)
|
| | | document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1');
|
| | | // User specified a document.domain value
|
| | | if (document.domain && lo.hostname != document.domain)
|
| | | tinymce.relaxedDomain = document.domain;
|
| | |
|
| | | // Add before unload listener
|
| | | // This was required since IE was leaking memory if you added and removed beforeunload listeners
|
| | |
| | | },
|
| | |
|
| | | init : function(s) {
|
| | | var t = this, pl, sl = tinymce.ScriptLoader, c;
|
| | | var t = this, pl, sl = tinymce.ScriptLoader, c, e, el = [], ed;
|
| | |
|
| | | function execCallback(se, n, s) {
|
| | | var f = se[n];
|
| | |
| | |
|
| | | if(l.length > 0) {
|
| | | each(explode(l), function(v) {
|
| | | if (DOM.get(v))
|
| | | new tinymce.Editor(v, s).render(1);
|
| | | else {
|
| | | if (DOM.get(v)) {
|
| | | ed = new tinymce.Editor(v, s);
|
| | | el.push(ed);
|
| | | ed.render(1);
|
| | | } else {
|
| | | c = 0;
|
| | |
|
| | | each(document.forms, function(f) {
|
| | |
| | | if (e.name === v) {
|
| | | v = 'mce_editor_' + c;
|
| | | DOM.setAttrib(e, 'id', v);
|
| | | new tinymce.Editor(v, s).render(1);
|
| | |
|
| | | ed = new tinymce.Editor(v, s);
|
| | | el.push(ed);
|
| | | ed.render(1);
|
| | | }
|
| | | });
|
| | | });
|
| | |
| | | case "textareas":
|
| | | case "specific_textareas":
|
| | | function hasClass(n, c) {
|
| | | return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
|
| | | return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c);
|
| | | };
|
| | |
|
| | | each(DOM.select('textarea'), function(v) {
|
| | |
| | | return;
|
| | |
|
| | | if (!s.editor_selector || hasClass(v, s.editor_selector)) {
|
| | | v.id = v.id || v.name;
|
| | | // Can we use the name
|
| | | e = DOM.get(v.name);
|
| | | if (!v.id && !e)
|
| | | v.id = v.name;
|
| | |
|
| | | // Generate unique name if missing or already exists
|
| | | if (!v.id || t.get(v.id))
|
| | | v.id = DOM.uniqueId();
|
| | |
|
| | | new tinymce.Editor(v.id, s).render(1);
|
| | | ed = new tinymce.Editor(v.id, s);
|
| | | el.push(ed);
|
| | | ed.render(1);
|
| | | }
|
| | | });
|
| | | break;
|
| | |
| | | if (s.oninit) {
|
| | | l = co = 0;
|
| | |
|
| | | each (t.editors, function(ed) {
|
| | | each (el, function(ed) {
|
| | | co++;
|
| | |
|
| | | if (!ed.initialized) {
|
| | |
| | |
|
| | | case "mceAddEditor":
|
| | | case "mceAddControl":
|
| | | new tinymce.Editor(v, t.settings).render();
|
| | | if (!t.get(v))
|
| | | new tinymce.Editor(v, t.settings).render();
|
| | |
|
| | | return true;
|
| | |
|
| | | case "mceAddFrameControl":
|
| | |
| | |
|
| | | case "mceRemoveEditor":
|
| | | case "mceRemoveControl":
|
| | | ed.remove();
|
| | | if (ed)
|
| | | ed.remove();
|
| | |
|
| | | return true;
|
| | |
|
| | | case 'mceToggleEditor':
|
| | |
| | | });
|
| | |
|
| | | tinymce.EditorManager.preInit();
|
| | | })();
|
| | | })(tinymce);
|
| | |
|
| | | // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call
|
| | | var tinyMCE = window.tinyMCE = tinymce.EditorManager;
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/Editor.js */
|
| | |
|
| | | (function() {
|
| | | (function(tinymce) {
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher;
|
| | | var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit;
|
| | | var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager;
|
| | |
| | | apply_source_formatting : 1,
|
| | | directionality : 'ltr',
|
| | | forced_root_block : 'p',
|
| | | valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
|
| | | valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
|
| | | hidden_input : 1,
|
| | | padd_empty_editor : 1,
|
| | | render_ui : 1,
|
| | | init_theme : 1,
|
| | | force_p_newlines : 1,
|
| | | indentation : '30px'
|
| | | indentation : '30px',
|
| | | keep_styles : 1,
|
| | | fix_table_elements : 1,
|
| | | removeformat_selector : 'span,b,strong,em,i,font,u,strike'
|
| | | }, s);
|
| | |
|
| | | // Setup URIs
|
| | |
| | | if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form'))
|
| | | DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
|
| | |
|
| | | t.windowManager = new tinymce.WindowManager(t);
|
| | | if (tinymce.WindowManager)
|
| | | t.windowManager = new tinymce.WindowManager(t);
|
| | |
|
| | | if (s.encoding == 'xml') {
|
| | | t.onGetContent.add(function(ed, o) {
|
| | | if (o.get)
|
| | | if (o.save)
|
| | | o.content = DOM.encode(o.content);
|
| | | });
|
| | | }
|
| | |
| | |
|
| | | if (s.add_unload_trigger) {
|
| | | t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
|
| | | if (t.initialized && !t.destroyed)
|
| | | if (t.initialized && !t.destroyed && !t.isHidden())
|
| | | t.save({format : 'raw', no_events : true});
|
| | | });
|
| | | }
|
| | |
| | | EditorManager.triggerSave();
|
| | | t.isNotDirty = 1;
|
| | |
|
| | | return this._mceOldSubmit(this);
|
| | | return t.formElement._mceOldSubmit(t.formElement);
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | if (s.language)
|
| | | sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
|
| | |
|
| | | if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
|
| | | if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
|
| | | ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
|
| | |
|
| | | each(explode(s.plugins), function(p) {
|
| | |
| | |
|
| | | // Init when que is loaded
|
| | | sl.loadQueue(function() {
|
| | | if (s.ask) {
|
| | | function ask() {
|
| | | t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
|
| | | if (s)
|
| | | t.init();
|
| | | else
|
| | | Event.remove(t.id, 'focus', ask);
|
| | | });
|
| | | };
|
| | |
|
| | | Event.add(t.id, 'focus', ask);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!t.removed)
|
| | | t.init();
|
| | | });
|
| | |
| | | EditorManager.add(t);
|
| | |
|
| | | // Create theme
|
| | | s.theme = s.theme.replace(/-/, '');
|
| | | o = ThemeManager.get(s.theme);
|
| | | t.theme = new o();
|
| | | if (s.theme) {
|
| | | s.theme = s.theme.replace(/-/, '');
|
| | | o = ThemeManager.get(s.theme);
|
| | | t.theme = new o();
|
| | |
|
| | | if (t.theme.init && s.init_theme)
|
| | | t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
|
| | | if (t.theme.init && s.init_theme)
|
| | | t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
|
| | | }
|
| | |
|
| | | // Create all plugins
|
| | | each(explode(s.plugins.replace(/\-/g, '')), function(p) {
|
| | |
| | | });
|
| | |
|
| | | // Setup popup CSS path(s)
|
| | | if (s.popup_css)
|
| | | s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
|
| | | else
|
| | | s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
|
| | | if (s.popup_css !== false) {
|
| | | if (s.popup_css)
|
| | | s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
|
| | | else
|
| | | s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
|
| | | }
|
| | |
|
| | | if (s.popup_css_add)
|
| | | s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add);
|
| | |
| | |
|
| | | // Pass through
|
| | | t.undoManager.onAdd.add(function(um, l) {
|
| | | return t.onChange.dispatch(t, l, um);
|
| | | if (!l.initial)
|
| | | return t.onChange.dispatch(t, l, um);
|
| | | });
|
| | |
|
| | | t.undoManager.onUndo.add(function(um, l) {
|
| | |
| | |
|
| | | // Measure box
|
| | | if (s.render_ui) {
|
| | | w = s.width || e.style.width || e.clientWidth;
|
| | | h = s.height || e.style.height || e.clientHeight;
|
| | | w = s.width || e.style.width || e.offsetWidth;
|
| | | h = s.height || e.style.height || e.offsetHeight;
|
| | | t.orgDisplay = e.style.display;
|
| | | re = /^[0-9\.]+(|px)$/i;
|
| | |
|
| | |
| | | t.editorContainer = o.editorContainer;
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | // Resize editor
|
| | | DOM.setStyles(o.sizeContainer || o.editorContainer, {
|
| | | width : w,
|
| | | height : h
|
| | | });
|
| | |
|
| | | h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : '');
|
| | | h = (o.iframeHeight || h) + (typeof(h) == 'number' ? (o.deltaHeight || 0) : '');
|
| | | if (h < 100)
|
| | | h = 100;
|
| | |
|
| | | t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '"></base>';
|
| | | t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />';
|
| | | t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
|
| | |
|
| | | if (tinymce.relaxedDomain)
|
| | |
| | | // Domain relaxing enabled, then set document domain
|
| | | if (tinymce.relaxedDomain) {
|
| | | // We need to write the contents here in IE since multiple writes messes up refresh button and back button
|
| | | if (isIE)
|
| | | if (isIE || (tinymce.isOpera && parseFloat(opera.version()) >= 9.5))
|
| | | u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
|
| | | else if (tinymce.isOpera)
|
| | | u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
|
| | |
| | | DOM.get(o.editorContainer).style.display = t.orgDisplay;
|
| | | DOM.get(t.id).style.display = 'none';
|
| | |
|
| | | // Safari 2.x requires us to wait for the load event and load a real HTML doc
|
| | | if (tinymce.isOldWebKit) {
|
| | | Event.add(n, 'load', t.setupIframe, t);
|
| | | n.src = tinymce.baseURL + '/plugins/safari/blank.htm';
|
| | | } else {
|
| | | if (!isIE || !tinymce.relaxedDomain)
|
| | | t.setupIframe();
|
| | | if (!isIE || !tinymce.relaxedDomain)
|
| | | t.setupIframe();
|
| | |
|
| | | e = n = o = null; // Cleanup
|
| | | }
|
| | | e = n = o = null; // Cleanup
|
| | | },
|
| | |
|
| | | setupIframe : function() {
|
| | |
| | | // Design mode needs to be added here Ctrl+A will fail otherwise
|
| | | if (!isIE) {
|
| | | try {
|
| | | d.designMode = 'On';
|
| | | if (!s.readonly)
|
| | | d.designMode = 'On';
|
| | | } catch (ex) {
|
| | | // Will fail on Gecko if the editor is placed in an hidden container element
|
| | | // The design mode will be set ones the editor is focused
|
| | |
| | | // It will not steal focus if we hide it while setting contentEditable
|
| | | b = t.getBody();
|
| | | DOM.hide(b);
|
| | | b.contentEditable = true;
|
| | |
|
| | | if (!s.readonly)
|
| | | b.contentEditable = true;
|
| | |
|
| | | DOM.show(b);
|
| | | }
|
| | |
|
| | |
| | | font_size_style_values : s.font_size_style_values,
|
| | | apply_source_formatting : s.apply_source_formatting,
|
| | | remove_linebreaks : s.remove_linebreaks,
|
| | | element_format : s.element_format,
|
| | | dom : t.dom
|
| | | });
|
| | |
|
| | |
| | | if (!s.gecko_spellcheck)
|
| | | t.getBody().spellcheck = 0;
|
| | |
|
| | | t._addEvents();
|
| | | if (!s.readonly)
|
| | | t._addEvents();
|
| | |
|
| | | t.controlManager.onPostRender.dispatch(t, t.controlManager);
|
| | | t.onPostRender.dispatch(t);
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | // Add visual aids when new contents is added
|
| | | t.onSetContent.add(function() {
|
| | | // Safari needs some time, it will crash the browser when a link is created otherwise
|
| | | // I think this crash issue is resolved in the latest 3.0.4
|
| | | //window.setTimeout(function() {
|
| | | t.addVisual(t.getBody());
|
| | | //}, 1);
|
| | | t.addVisual(t.getBody());
|
| | | });
|
| | |
|
| | | // Remove empty contents
|
| | | if (s.padd_empty_editor) {
|
| | | t.onPostProcess.add(function(ed, o) {
|
| | | o.content = o.content.replace(/^<p>( |#160;|\s|\u00a0)<\/p>$/, '');
|
| | | o.content = o.content.replace(/^(<p[^>]*>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, '');
|
| | | });
|
| | | }
|
| | |
|
| | | if (isGecko) {
|
| | | try {
|
| | | // Design mode must be set here once again to fix a bug where
|
| | | // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
|
| | | d.designMode = 'Off';
|
| | | d.designMode = 'On';
|
| | | } catch (ex) {
|
| | | // Will fail on Gecko if the editor is placed in an hidden container element
|
| | | // The design mode will be set ones the editor is focused
|
| | | // Fix gecko link bug, when a link is placed at the end of block elements there is
|
| | | // no way to move the caret behind the link. This fix adds a bogus br element after the link
|
| | | function fixLinks(ed, o) {
|
| | | each(ed.dom.select('a'), function(n) {
|
| | | var pn = n.parentNode;
|
| | |
|
| | | if (ed.dom.isBlock(pn) && pn.lastChild === n)
|
| | | ed.dom.add(pn, 'br', {'mce_bogus' : 1});
|
| | | });
|
| | | };
|
| | |
|
| | | t.onExecCommand.add(function(ed, cmd) {
|
| | | if (cmd === 'CreateLink')
|
| | | fixLinks(ed);
|
| | | });
|
| | |
|
| | | t.onSetContent.add(t.selection.onSetContent.add(fixLinks));
|
| | |
|
| | | if (!s.readonly) {
|
| | | try {
|
| | | // Design mode must be set here once again to fix a bug where
|
| | | // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
|
| | | d.designMode = 'Off';
|
| | | d.designMode = 'On';
|
| | | } catch (ex) {
|
| | | // Will fail on Gecko if the editor is placed in an hidden container element
|
| | | // The design mode will be set ones the editor is focused
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | e = null;
|
| | | },
|
| | |
|
| | | |
| | |
|
| | | focus : function(sf) {
|
| | | var oed, t = this;
|
| | | var oed, t = this, ce = t.settings.content_editable;
|
| | |
|
| | | if (!sf) {
|
| | | t.getWin().focus();
|
| | | // Is not content editable or the selection is outside the area in IE
|
| | | // the IE statement is needed to avoid bluring if element selections inside layers since
|
| | | // the layer is like it's own document in IE
|
| | | if (!ce && (!isIE || t.selection.getNode().ownerDocument != t.getDoc()))
|
| | | t.getWin().focus();
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | if (EditorManager.activeEditor != t) {
|
| | | if ((oed = EditorManager.activeEditor) != null)
|
| | |
| | | },
|
| | |
|
| | | translate : function(s) {
|
| | | var c = this.settings.language, i18n = EditorManager.i18n;
|
| | | var c = this.settings.language || 'en', i18n = EditorManager.i18n;
|
| | |
|
| | | if (!s)
|
| | | return '';
|
| | |
| | | },
|
| | |
|
| | | getLang : function(n, dv) {
|
| | | return EditorManager.i18n[this.settings.language + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
|
| | | return EditorManager.i18n[(this.settings.language || 'en') + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
|
| | | },
|
| | |
|
| | | getParam : function(n, dv, ty) {
|
| | |
| | | },
|
| | |
|
| | | execCommand : function(cmd, ui, val, a) {
|
| | | var t = this, s = 0, o;
|
| | | var t = this, s = 0, o, st;
|
| | |
|
| | | if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus))
|
| | | t.focus();
|
| | |
| | | if (o.terminate)
|
| | | return false;
|
| | |
|
| | | // Comamnd callback
|
| | | // Command callback
|
| | | if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
|
| | | t.onExecCommand.dispatch(t, cmd, ui, val, a);
|
| | | return true;
|
| | |
| | |
|
| | | // Registred commands
|
| | | if (o = t.execCommands[cmd]) {
|
| | | s = o.func.call(o.scope, ui, val);
|
| | | t.onExecCommand.dispatch(t, cmd, ui, val, a);
|
| | | return s;
|
| | | st = o.func.call(o.scope, ui, val);
|
| | |
|
| | | // Fall through on true
|
| | | if (st !== true) {
|
| | | t.onExecCommand.dispatch(t, cmd, ui, val, a);
|
| | | return st;
|
| | | }
|
| | | }
|
| | |
|
| | | // Plugin commands
|
| | |
| | | return true;
|
| | |
|
| | | // Theme commands
|
| | | if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
|
| | | if (t.theme && t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
|
| | | t.onExecCommand.dispatch(t, cmd, ui, val, a);
|
| | | return true;
|
| | | }
|
| | |
|
| | | // Execute global commands
|
| | | if (tinymce.GlobalCommands.execCommand(t, cmd, ui, val)) {
|
| | | t.onExecCommand.dispatch(t, cmd, ui, val, a);
|
| | | return true;
|
| | | }
|
| | |
| | | },
|
| | |
|
| | | queryCommandState : function(c) {
|
| | | var t = this, o;
|
| | | var t = this, o, s;
|
| | |
|
| | | // Is hidden then return undefined
|
| | | if (t._isHidden())
|
| | | return;
|
| | |
|
| | | // Registred commands
|
| | | if (o = t.queryStateCommands[c])
|
| | | return o.func.call(o.scope);
|
| | | if (o = t.queryStateCommands[c]) {
|
| | | s = o.func.call(o.scope);
|
| | |
|
| | | // Fall though on true
|
| | | if (s !== true)
|
| | | return s;
|
| | | }
|
| | |
|
| | | // Registred commands
|
| | | o = t.editorCommands.queryCommandState(c);
|
| | |
| | | },
|
| | |
|
| | | queryCommandValue : function(c) {
|
| | | var t = this, o;
|
| | | var t = this, o, s;
|
| | |
|
| | | // Is hidden then return undefined
|
| | | if (t._isHidden())
|
| | | return;
|
| | |
|
| | | // Registred commands
|
| | | if (o = t.queryValueCommands[c])
|
| | | return o.func.call(o.scope);
|
| | | if (o = t.queryValueCommands[c]) {
|
| | | s = o.func.call(o.scope);
|
| | |
|
| | | // Fall though on true
|
| | | if (s !== true)
|
| | | return s;
|
| | | }
|
| | |
|
| | | // Registred commands
|
| | | o = t.editorCommands.queryCommandValue(c);
|
| | |
| | | load : function(o) {
|
| | | var t = this, e = t.getElement(), h;
|
| | |
|
| | | o = o || {};
|
| | | o.load = true;
|
| | | if (e) {
|
| | | o = o || {};
|
| | | o.load = true;
|
| | |
|
| | | h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
|
| | | o.element = e;
|
| | | // Double encode existing entities in the value
|
| | | h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
|
| | | o.element = e;
|
| | |
|
| | | if (!o.no_events)
|
| | | t.onLoadContent.dispatch(t, o);
|
| | | if (!o.no_events)
|
| | | t.onLoadContent.dispatch(t, o);
|
| | |
|
| | | o.element = e = null;
|
| | | o.element = e = null;
|
| | |
|
| | | return h;
|
| | | return h;
|
| | | }
|
| | | },
|
| | |
|
| | | save : function(o) {
|
| | | var t = this, e = t.getElement(), h, f;
|
| | |
|
| | | if (!t.initialized)
|
| | | if (!e || !t.initialized)
|
| | | return;
|
| | |
|
| | | o = o || {};
|
| | | o.save = true;
|
| | |
|
| | | // Add undo level will trigger onchange event
|
| | | if (!o.no_events) {
|
| | | t.undoManager.typing = 0;
|
| | | t.undoManager.add();
|
| | | }
|
| | |
|
| | | o.element = e;
|
| | | h = o.content = t.getContent(o);
|
| | |
| | | // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
|
| | | // It will also be impossible to place the caret in the editor unless there is a BR element present
|
| | | if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
|
| | | o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />', 1);
|
| | | o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />');
|
| | | o.format = 'raw';
|
| | | }
|
| | |
|
| | |
| | | h = t.getBody().innerHTML;
|
| | |
|
| | | h = h.replace(/^\s*|\s*$/g, '');
|
| | | o = {content : h};
|
| | | t.onGetContent.dispatch(t, o);
|
| | | o.content = h;
|
| | |
|
| | | if (!o.no_events)
|
| | | t.onGetContent.dispatch(t, o);
|
| | |
|
| | | return o.content;
|
| | | },
|
| | |
| | | tinyMCE.onBeforeUnload.remove(t._beforeUnload);
|
| | |
|
| | | // Manual destroy
|
| | | if (t.theme.destroy)
|
| | | if (t.theme && t.theme.destroy)
|
| | | t.theme.destroy();
|
| | |
|
| | | // Destroy controls, selection and dom
|
| | |
| | | t.dom.destroy();
|
| | |
|
| | | // Remove all events
|
| | | Event.clear(t.getWin());
|
| | | Event.clear(t.getDoc());
|
| | |
|
| | | // Don't clear the window or document if content editable
|
| | | // is enabled since other instances might still be present
|
| | | if (!t.settings.content_editable) {
|
| | | Event.clear(t.getWin());
|
| | | Event.clear(t.getDoc());
|
| | | }
|
| | |
|
| | | Event.clear(t.getBody());
|
| | | Event.clear(t.formElement);
|
| | | }
|
| | |
| | | case 'contextmenu':
|
| | | if (tinymce.isOpera) {
|
| | | // Fake contextmenu on Opera
|
| | | Event.add(t.getDoc(), 'mousedown', function(e) {
|
| | | Event.add(t.getBody(), 'mousedown', function(e) {
|
| | | if (e.ctrlKey) {
|
| | | e.fakeType = 'contextmenu';
|
| | | eventHandler(e);
|
| | | }
|
| | | });
|
| | | } else
|
| | | Event.add(t.getDoc(), k, eventHandler);
|
| | | Event.add(t.getBody(), k, eventHandler);
|
| | | break;
|
| | |
|
| | | case 'paste':
|
| | | Event.add(t.getBody(), k, function(e) {
|
| | | var tx, h, el, r;
|
| | |
|
| | | // Get plain text data
|
| | | if (e.clipboardData)
|
| | | tx = e.clipboardData.getData('text/plain');
|
| | | else if (tinymce.isIE)
|
| | | tx = t.getWin().clipboardData.getData('Text');
|
| | |
|
| | | // Get HTML data
|
| | | /*if (tinymce.isIE) {
|
| | | el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
|
| | | r = DOM.doc.body.createTextRange();
|
| | | r.moveToElementText(el);
|
| | | r.execCommand('Paste');
|
| | | h = el.innerHTML;
|
| | | DOM.remove(el);
|
| | | }*/
|
| | |
|
| | | eventHandler(e, {text : tx, html : h});
|
| | | eventHandler(e);
|
| | | });
|
| | | break;
|
| | |
|
| | |
| | | t.focus(true);
|
| | | });
|
| | |
|
| | | |
| | |
|
| | | // Fixes bug where a specified document_base_uri could result in broken images
|
| | | // This will also fix drag drop of images in Gecko
|
| | | if (tinymce.isGecko) {
|
| | |
| | | function setOpts() {
|
| | | var t = this, d = t.getDoc(), s = t.settings;
|
| | |
|
| | | if (isGecko) {
|
| | | if (isGecko && !s.readonly) {
|
| | | if (t._isHidden()) {
|
| | | try {
|
| | | if (!s.content_editable)
|
| | |
| | | } catch (ex) {
|
| | | // Use old method
|
| | | if (!t._isHidden())
|
| | | d.execCommand("useCSS", 0, true);
|
| | | try {d.execCommand("useCSS", 0, true);} catch (ex) {}
|
| | | }
|
| | |
|
| | | if (!s.table_inline_editing)
|
| | |
| | | t.onMouseUp.add(t.nodeChanged);
|
| | | t.onClick.add(t.nodeChanged);
|
| | | t.onKeyUp.add(function(ed, e) {
|
| | | if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.keyCode == 46 || e.keyCode == 8 || e.ctrlKey)
|
| | | var c = e.keyCode;
|
| | |
|
| | | if ((c >= 33 && c <= 36) || (c >= 37 && c <= 40) || c == 13 || c == 45 || c == 46 || c == 8 || (tinymce.isMac && (c == 91 || c == 93)) || e.ctrlKey)
|
| | | t.nodeChanged();
|
| | | });
|
| | |
|
| | |
| | | t.onReset.add(function() {
|
| | | t.setContent(t.startContent, {format : 'raw'});
|
| | | });
|
| | |
|
| | | if (t.getParam('tab_focus')) {
|
| | | function tabCancel(ed, e) {
|
| | | if (e.keyCode === 9)
|
| | | return Event.cancel(e);
|
| | | };
|
| | |
|
| | | function tabHandler(ed, e) {
|
| | | var x, i, f, el, v;
|
| | |
|
| | | function find(d) {
|
| | | f = DOM.getParent(ed.id, 'form');
|
| | | el = f.elements;
|
| | |
|
| | | if (f) {
|
| | | each(el, function(e, i) {
|
| | | if (e.id == ed.id) {
|
| | | x = i;
|
| | | return false;
|
| | | }
|
| | | });
|
| | |
|
| | | if (d > 0) {
|
| | | for (i = x + 1; i < el.length; i++) {
|
| | | if (el[i].type != 'hidden')
|
| | | return el[i];
|
| | | }
|
| | | } else {
|
| | | for (i = x - 1; i >= 0; i--) {
|
| | | if (el[i].type != 'hidden')
|
| | | return el[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return null;
|
| | | };
|
| | |
|
| | | if (e.keyCode === 9) {
|
| | | v = explode(ed.getParam('tab_focus'));
|
| | |
|
| | | if (v.length == 1) {
|
| | | v[1] = v[0];
|
| | | v[0] = ':prev';
|
| | | }
|
| | |
|
| | | // Find element to focus
|
| | | if (e.shiftKey) {
|
| | | if (v[0] == ':prev')
|
| | | el = find(-1);
|
| | | else
|
| | | el = DOM.get(v[0]);
|
| | | } else {
|
| | | if (v[1] == ':next')
|
| | | el = find(1);
|
| | | else
|
| | | el = DOM.get(v[1]);
|
| | | }
|
| | |
|
| | | if (el) {
|
| | | if (ed = EditorManager.get(el.id || el.name))
|
| | | ed.focus();
|
| | | else
|
| | | window.setTimeout(function() {window.focus();el.focus();}, 10);
|
| | |
|
| | | return Event.cancel(e);
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | t.onKeyUp.add(tabCancel);
|
| | |
|
| | | if (isGecko) {
|
| | | t.onKeyPress.add(tabHandler);
|
| | | t.onKeyDown.add(tabCancel);
|
| | | } else
|
| | | t.onKeyDown.add(tabHandler);
|
| | | }
|
| | |
|
| | | // Add shortcuts
|
| | | if (s.custom_shortcuts) {
|
| | |
| | | return v;
|
| | |
|
| | | each(t.shortcuts, function(o) {
|
| | | if (o.ctrl != e.ctrlKey && (!tinymce.isMac || o.ctrl == e.metaKey))
|
| | | if (tinymce.isMac && o.ctrl != e.metaKey)
|
| | | return;
|
| | | else if (!tinymce.isMac && o.ctrl != e.ctrlKey)
|
| | | return;
|
| | |
|
| | | if (o.alt != e.altKey)
|
| | |
| | | var re = t.resizeInfo, cb;
|
| | |
|
| | | e = e.target;
|
| | | e.removeAttribute('mce_style'); // Remove this one since it might change
|
| | |
|
| | | // Don't do this action for non image elements
|
| | | if (e.nodeName !== 'IMG')
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | /*if (t.dom.boxModel) {
|
| | | t.getBody().style.height = '100%';
|
| | |
|
| | | Event.add(t.getWin(), 'resize', function(e) {
|
| | | var docElm = t.getDoc().documentElement;
|
| | |
|
| | | docElm.style.height = (docElm.offsetHeight - 10) + 'px';
|
| | | });
|
| | | }*/
|
| | | }
|
| | |
|
| | | if (tinymce.isOpera) {
|
| | |
| | |
|
| | | case 'U':
|
| | | case 'STRIKE':
|
| | | sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
|
| | | sp.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
|
| | | dom.setAttrib(sp, 'mce_style', '');
|
| | | dom.replace(sp, n, 1);
|
| | | //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
|
| | | n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
|
| | | dom.setAttrib(n, 'mce_style', '');
|
| | | dom.setAttrib(n, 'mce_name', 'span');
|
| | | break;
|
| | | }
|
| | | });
|
| | | } else if (o.set) {
|
| | | each(t.dom.select('table,span', o.node), function(n) {
|
| | | each(t.dom.select('table,span', o.node).reverse(), function(n) {
|
| | | if (n.nodeName == 'TABLE') {
|
| | | if (v = dom.getStyle(n, 'height'))
|
| | | dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, ''));
|
| | |
| | | t.onPreProcess.add(convert);
|
| | |
|
| | | if (!s.cleanup_on_startup) {
|
| | | t.onInit.add(function() {
|
| | | convert(t, {node : t.getBody(), set : 1});
|
| | | t.onSetContent.add(function(ed, o) {
|
| | | if (o.initial)
|
| | | convert(t, {node : t.getBody(), set : 1});
|
| | | });
|
| | | }
|
| | | },
|
| | |
| | | if (cl = s.font_size_classes)
|
| | | cl = explode(cl);
|
| | |
|
| | | function convertToFonts(no) {
|
| | | var n, f, nl, x, i, v, st;
|
| | |
|
| | | // Convert spans to fonts on non WebKit browsers
|
| | | if (tinymce.isWebKit || !s.inline_styles)
|
| | | return;
|
| | |
|
| | | nl = t.dom.select('span', no);
|
| | | for (x = nl.length - 1; x >= 0; x--) {
|
| | | n = nl[x];
|
| | |
|
| | | f = dom.create('font', {
|
| | | color : dom.toHex(dom.getStyle(n, 'color')),
|
| | | face : dom.getStyle(n, 'fontFamily'),
|
| | | style : dom.getAttrib(n, 'style'),
|
| | | 'class' : dom.getAttrib(n, 'class')
|
| | | });
|
| | |
|
| | | // Clear color and font family
|
| | | st = f.style;
|
| | | if (st.color || st.fontFamily) {
|
| | | st.color = st.fontFamily = '';
|
| | | dom.setAttrib(f, 'mce_style', ''); // Remove cached style data
|
| | | }
|
| | |
|
| | | if (sl) {
|
| | | i = inArray(sl, dom.getStyle(n, 'fontSize'));
|
| | |
|
| | | if (i != -1) {
|
| | | dom.setAttrib(f, 'size', '' + (i + 1 || 1));
|
| | | f.style.fontSize = '';
|
| | | }
|
| | | } else if (cl) {
|
| | | i = inArray(cl, dom.getAttrib(n, 'class'));
|
| | | v = dom.getStyle(n, 'fontSize');
|
| | |
|
| | | if (i == -1 && v.indexOf('pt') > 0)
|
| | | i = inArray(fz, parseInt(v));
|
| | |
|
| | | if (i == -1)
|
| | | i = inArray(fzn, v);
|
| | |
|
| | | if (i != -1) {
|
| | | dom.setAttrib(f, 'size', '' + (i + 1 || 1));
|
| | | f.style.fontSize = '';
|
| | | }
|
| | | }
|
| | |
|
| | | if (f.color || f.face || f.size) {
|
| | | f.style.fontFamily = '';
|
| | | dom.setAttrib(f, 'mce_style', '');
|
| | | dom.replace(f, n, 1);
|
| | | }
|
| | |
|
| | | f = n = null;
|
| | | }
|
| | | };
|
| | |
|
| | | // Run on setup
|
| | | t.onSetContent.add(function(ed, o) {
|
| | | convertToFonts(ed.getBody());
|
| | | });
|
| | |
|
| | | // Run on cleanup
|
| | | t.onPreProcess.add(function(ed, o) {
|
| | | function process(no) {
|
| | | var n, sp, nl, x;
|
| | |
|
| | | // Keep unit tests happy
|
| | | if (!s.inline_styles)
|
| | | return;
|
| | |
|
| | | if (o.get) {
|
| | | nl = t.dom.select('font', o.node);
|
| | | for (x = nl.length - 1; x >= 0; x--) {
|
| | | n = nl[x];
|
| | | nl = t.dom.select('font', no);
|
| | | for (x = nl.length - 1; x >= 0; x--) {
|
| | | n = nl[x];
|
| | |
|
| | | sp = dom.create('span', {
|
| | | style : dom.getAttrib(n, 'style'),
|
| | | 'class' : dom.getAttrib(n, 'class')
|
| | | });
|
| | | sp = dom.create('span', {
|
| | | style : dom.getAttrib(n, 'style'),
|
| | | 'class' : dom.getAttrib(n, 'class')
|
| | | });
|
| | |
|
| | | dom.setStyles(sp, {
|
| | | fontFamily : dom.getAttrib(n, 'face'),
|
| | | color : dom.getAttrib(n, 'color'),
|
| | | backgroundColor : n.style.backgroundColor
|
| | | });
|
| | | dom.setStyles(sp, {
|
| | | fontFamily : dom.getAttrib(n, 'face'),
|
| | | color : dom.getAttrib(n, 'color'),
|
| | | backgroundColor : n.style.backgroundColor
|
| | | });
|
| | |
|
| | | if (n.size) {
|
| | | if (sl)
|
| | | dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
|
| | | else
|
| | | dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
|
| | | }
|
| | |
|
| | | dom.setAttrib(sp, 'mce_style', '');
|
| | | dom.replace(sp, n, 1);
|
| | | if (n.size) {
|
| | | if (sl)
|
| | | dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
|
| | | else
|
| | | dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
|
| | | }
|
| | |
|
| | | dom.setAttrib(sp, 'mce_style', '');
|
| | | dom.replace(sp, n, 1);
|
| | | }
|
| | | };
|
| | |
|
| | | // Run on cleanup
|
| | | t.onPreProcess.add(function(ed, o) {
|
| | | if (o.get)
|
| | | process(o.node);
|
| | | });
|
| | |
|
| | | t.onSetContent.add(function(ed, o) {
|
| | | if (o.initial)
|
| | | process(o.node);
|
| | | });
|
| | | },
|
| | |
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/EditorCommands.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit;
|
| | |
|
| | | tinymce.create('tinymce.EditorCommands', {
|
| | |
| | | var t = this, ed = t.editor, f;
|
| | |
|
| | | switch (cmd) {
|
| | | case 'Cut':
|
| | | case 'Copy':
|
| | | case 'Paste':
|
| | | try {
|
| | | ed.getDoc().execCommand(cmd, ui, val);
|
| | | } catch (ex) {
|
| | | if (isGecko) {
|
| | | ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
|
| | | if (s)
|
| | | window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
|
| | | });
|
| | | } else
|
| | | ed.windowManager.alert(ed.getLang('clipboard_no_support'));
|
| | | }
|
| | |
|
| | | return true;
|
| | |
|
| | | // Ignore these
|
| | | case 'mceResetDesignMode':
|
| | | case 'mceBeginUndoLevel':
|
| | |
| | | case 'JustifyRight':
|
| | | case 'JustifyFull':
|
| | | t.mceJustify(cmd, cmd.substring(7).toLowerCase());
|
| | | return true;
|
| | |
|
| | | case 'mceEndUndoLevel':
|
| | | case 'mceAddUndoLevel':
|
| | | ed.undoManager.add();
|
| | | return true;
|
| | |
|
| | | default:
|
| | |
| | | iv = parseInt(iv);
|
| | |
|
| | | if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
|
| | | each(this._getSelectedBlocks(), function(e) {
|
| | | each(s.getSelectedBlocks(), function(e) {
|
| | | d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu);
|
| | | });
|
| | |
|
| | |
| | | iv = parseInt(iv);
|
| | |
|
| | | if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
|
| | | each(this._getSelectedBlocks(), function(e) {
|
| | | each(s.getSelectedBlocks(), function(e) {
|
| | | v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv);
|
| | | d.setStyle(e, 'paddingLeft', v ? v + iu : '');
|
| | | });
|
| | |
| | | ed.getDoc().execCommand('Outdent', false, null);
|
| | | },
|
| | |
|
| | | /*
|
| | | mceSetAttribute : function(u, v) {
|
| | | var ed = this.editor, d = ed.dom, e;
|
| | |
|
| | | if (e = d.getParent(ed.selection.getNode(), d.isBlock))
|
| | | d.setAttrib(e, v.name, v.value);
|
| | | },
|
| | |
|
| | | */
|
| | | mceSetContent : function(u, v) {
|
| | | this.editor.setContent(v);
|
| | | },
|
| | |
| | | },
|
| | |
|
| | | mceInsertLink : function(u, v) {
|
| | | var ed = this.editor, e = ed.dom.getParent(ed.selection.getNode(), 'A');
|
| | | var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'a');
|
| | |
|
| | | if (tinymce.is(v, 'string'))
|
| | | v = {href : v};
|
| | |
| | |
|
| | | if (!e) {
|
| | | ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
|
| | | each(ed.dom.select('a'), function(e) {
|
| | | if (e.href == 'javascript:mctmp(0);')
|
| | | set(e);
|
| | | each(ed.dom.select('a[href=javascript:mctmp(0);]'), function(e) {
|
| | | set(e);
|
| | | });
|
| | | } else {
|
| | | if (v.href)
|
| | |
| | | if (!v) {
|
| | | if (s.isCollapsed())
|
| | | s.select(s.getNode());
|
| | | } else {
|
| | | if (ed.settings.convert_fonts_to_spans)
|
| | | t._applyInlineStyle('span', {style : {fontFamily : v}});
|
| | | else
|
| | | ed.getDoc().execCommand('FontName', false, v);
|
| | | }
|
| | | },
|
| | |
|
| | | t.RemoveFormat();
|
| | | } else
|
| | | ed.getDoc().execCommand('FontName', false, v);
|
| | | FontSize : function(u, v) {
|
| | | var ed = this.editor, s = ed.settings, fc, fs;
|
| | |
|
| | | // Use style options instead
|
| | | if (s.convert_fonts_to_spans && v >= 1 && v <= 7) {
|
| | | fs = tinymce.explode(s.font_size_style_values);
|
| | | fc = tinymce.explode(s.font_size_classes);
|
| | |
|
| | | if (fc)
|
| | | v = fc[v - 1] || v;
|
| | | else
|
| | | v = fs[v - 1] || v;
|
| | | }
|
| | |
|
| | | if (v >= 1 && v <= 7)
|
| | | ed.getDoc().execCommand('FontSize', false, v);
|
| | | else
|
| | | this._applyInlineStyle('span', {style : {fontSize : v}});
|
| | | },
|
| | |
|
| | | queryCommandValue : function(c) {
|
| | |
| | | queryValueFontSize : function() {
|
| | | var ed = this.editor, v = 0, p;
|
| | |
|
| | | if (isOpera || isWebKit) {
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'span'))
|
| | | v = p.style.fontSize;
|
| | |
|
| | | if (!v && (isOpera || isWebKit)) {
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'font'))
|
| | | v = p.size;
|
| | |
|
| | | return v;
|
| | | }
|
| | |
|
| | | return this._queryVal('FontSize');
|
| | | return v || this._queryVal('FontSize');
|
| | | },
|
| | |
|
| | | queryValueFontName : function() {
|
| | | var ed = this.editor, v = 0, p;
|
| | |
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'font'))
|
| | | v = p.face;
|
| | |
|
| | | if (p = ed.dom.getParent(ed.selection.getNode(), 'span'))
|
| | | v = p.style.fontFamily.replace(/, /g, ',').replace(/[\'\"]/g, '').toLowerCase();
|
| | |
|
| | | if (!v)
|
| | | v = this._queryVal('FontName');
|
| | |
| | |
|
| | | if (rm) {
|
| | | if (v == 'center')
|
| | | dom.setStyle(n.parentNode, 'textAlign', '');
|
| | | dom.setStyle(bl || n.parentNode, 'textAlign', '');
|
| | |
|
| | | dom.setStyle(n, 'float', '');
|
| | | this.mceRepaint();
|
| | |
| | |
|
| | | if (v == 'center') {
|
| | | // Do not change table elements
|
| | | if (/^(TD|TH)$/.test(bl.nodeName))
|
| | | if (bl && /^(TD|TH)$/.test(bl.nodeName))
|
| | | bl = 0;
|
| | |
|
| | | if (!bl || bl.childNodes.length > 1) {
|
| | |
| | | dom.setStyle(n, 'float', '');
|
| | | } else {
|
| | | dom.setStyle(n, 'float', v);
|
| | | dom.setStyle(n.parentNode, 'textAlign', '');
|
| | | dom.setStyle(bl || n.parentNode, 'textAlign', '');
|
| | | }
|
| | |
|
| | | this.mceRepaint();
|
| | |
| | | if (rm)
|
| | | v = '';
|
| | |
|
| | | each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
|
| | | each(se.getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
|
| | | dom.setAttrib(e, 'align', '');
|
| | | dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v);
|
| | | });
|
| | |
| | | }
|
| | | } else {
|
| | | function getParent(n) {
|
| | | return dom.getParent(n, function(n) {return n.nodeType == 1;});
|
| | | return dom.getParent(n, '*');
|
| | | };
|
| | |
|
| | | sc = r.startContainer;
|
| | |
| | | return null;
|
| | | },
|
| | |
|
| | | InsertHorizontalRule : function() {
|
| | | // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
| | | if (isGecko || isIE)
|
| | | this.editor.selection.setContent('<hr />');
|
| | | else
|
| | | this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
|
| | | },
|
| | |
|
| | | RemoveFormat : function() {
|
| | | var t = this, ed = t.editor, s = ed.selection, b;
|
| | |
|
| | | // Safari breaks tables
|
| | | if (isWebKit)
|
| | | s.setContent(s.getContent({format : 'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g, ''), {format : 'raw'});
|
| | | else
|
| | | ed.getDoc().execCommand('RemoveFormat', false, null);
|
| | |
|
| | | t.mceSetStyleInfo(0, {command : 'removeformat'});
|
| | | ed.addVisual();
|
| | | },
|
| | |
|
| | | mceSetStyleInfo : function(u, v) {
|
| | | var t = this, ed = t.editor, d = ed.getDoc(), dom = ed.dom, e, b, s = ed.selection, nn = v.wrapper || 'span', b = s.getBookmark(), re;
|
| | |
|
| | |
| | | re = new RegExp(re, 'i');
|
| | |
|
| | | // Set style info on selected element
|
| | | if (e = t.getSelectedElement())
|
| | | if ((e = t.getSelectedElement()) && !ed.settings.force_span_wrappers)
|
| | | set(e, 1);
|
| | | else {
|
| | | // Generate wrappers and set styles on them
|
| | | d.execCommand('FontName', false, '__');
|
| | | each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
|
| | | each(dom.select('span,font'), function(n) {
|
| | | var sp, e;
|
| | |
|
| | | if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
|
| | |
| | | // Check if it's an old span in a new wrapper
|
| | | if (!dom.getAttrib(n, 'mce_new')) {
|
| | | // Find new wrapper
|
| | | p = dom.getParent(n, function(n) {
|
| | | return n.nodeType == 1 && dom.getAttrib(n, 'mce_new');
|
| | | });
|
| | | p = dom.getParent(n, '*[mce_new]');
|
| | |
|
| | | if (p)
|
| | | dom.remove(n, 1);
|
| | |
| | | var p = n.parentNode;
|
| | |
|
| | | if (!p || !dom.getAttrib(n, 'mce_new'))
|
| | | return;
|
| | |
|
| | | if (ed.settings.force_span_wrappers && p.nodeName != 'SPAN')
|
| | | return;
|
| | |
|
| | | // Has parent of the same type and only child
|
| | |
| | | return this._queryState(c);
|
| | | },
|
| | |
|
| | | ForeColor : function(ui, v) {
|
| | | var ed = this.editor;
|
| | |
|
| | | if (ed.settings.convert_fonts_to_spans) {
|
| | | this._applyInlineStyle('span', {style : {color : v}});
|
| | | return;
|
| | | } else
|
| | | ed.getDoc().execCommand('ForeColor', false, v);
|
| | | },
|
| | |
|
| | | HiliteColor : function(ui, val) {
|
| | | var t = this, ed = t.editor, d = ed.getDoc();
|
| | |
|
| | | if (ed.settings.convert_fonts_to_spans) {
|
| | | this._applyInlineStyle('span', {style : {backgroundColor : val}});
|
| | | return;
|
| | | }
|
| | |
|
| | | function set(s) {
|
| | | if (!isGecko)
|
| | |
| | | d.execCommand('BackColor', false, val);
|
| | | },
|
| | |
|
| | | Undo : function() {
|
| | | var ed = this.editor;
|
| | |
|
| | | if (ed.settings.custom_undo_redo) {
|
| | | ed.undoManager.undo();
|
| | | ed.nodeChanged();
|
| | | } else
|
| | | ed.getDoc().execCommand('Undo', false, null);
|
| | | },
|
| | |
|
| | | Redo : function() {
|
| | | var ed = this.editor;
|
| | |
|
| | | if (ed.settings.custom_undo_redo) {
|
| | | ed.undoManager.redo();
|
| | | ed.nodeChanged();
|
| | | } else
|
| | | ed.getDoc().execCommand('Redo', false, null);
|
| | | },
|
| | |
|
| | | FormatBlock : function(ui, val) {
|
| | | var t = this, ed = t.editor;
|
| | | var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b;
|
| | |
|
| | | function isBlock(n) {
|
| | | return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);
|
| | | };
|
| | |
|
| | | bl = dom.getParent(s.getNode(), function(n) {
|
| | | return isBlock(n);
|
| | | });
|
| | |
|
| | | // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div>
|
| | | // FF and Opera doesn't change parent DIV elements if you switch format
|
| | | if (bl) {
|
| | | if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
|
| | | // Rename block element
|
| | | nb = ed.dom.create(val);
|
| | |
|
| | | each(dom.getAttribs(bl), function(v) {
|
| | | dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName));
|
| | | });
|
| | |
|
| | | b = s.getBookmark();
|
| | | dom.replace(nb, bl, 1);
|
| | | s.moveToBookmark(b);
|
| | | ed.nodeChanged();
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | val = ed.settings.forced_root_block ? (val || '<p>') : val;
|
| | |
|
| | | if (/^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(ed.selection.getNode().nodeName))
|
| | | t.mceRemoveNode();
|
| | |
|
| | | if (val.indexOf('<') == -1)
|
| | | val = '<' + val + '>';
|
| | |
| | | },
|
| | |
|
| | | queryStateUnderline : function() {
|
| | | var ed = this.editor, n;
|
| | | var ed = this.editor, n = ed.selection.getNode();
|
| | |
|
| | | if (n && n.nodeName == 'A')
|
| | | return false;
|
| | |
| | |
|
| | | if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
|
| | | return true;
|
| | | } else
|
| | | return !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE');
|
| | | }
|
| | |
|
| | | return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList();
|
| | | return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList() || (!ed.settings.inline_styles && !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE'));
|
| | | },
|
| | |
|
| | | queryStateInsertUnorderedList : function() {
|
| | |
| | | return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
| | | },
|
| | |
|
| | | mceBlockQuote : function() {
|
| | | var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
|
| | | _applyInlineStyle : function(na, at, op) {
|
| | | var t = this, ed = t.editor, dom = ed.dom, bm, lo = {}, kh, found;
|
| | |
|
| | | function getBQ(e) {
|
| | | return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
| | | };
|
| | | na = na.toUpperCase();
|
| | |
|
| | | // Get start/end block
|
| | | sb = dom.getParent(s.getStart(), dom.isBlock);
|
| | | eb = dom.getParent(s.getEnd(), dom.isBlock);
|
| | | if (op && op.check_classes && at['class'])
|
| | | op.check_classes.push(at['class']);
|
| | |
|
| | | // Remove blockquote(s)
|
| | | if (bq = getBQ(sb)) {
|
| | | if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
|
| | | bm = s.getBookmark();
|
| | | function removeEmpty() {
|
| | | each(dom.select(na).reverse(), function(n) {
|
| | | var c = 0;
|
| | |
|
| | | // Move all elements after the end block into new bq
|
| | | if (getBQ(eb)) {
|
| | | bq2 = bq.cloneNode(false);
|
| | |
|
| | | while (n = eb.nextSibling)
|
| | | bq2.appendChild(n.parentNode.removeChild(n));
|
| | | }
|
| | |
|
| | | // Add new bq after
|
| | | if (bq2)
|
| | | dom.insertAfter(bq2, bq);
|
| | |
|
| | | // Move all selected blocks after the current bq
|
| | | nl = t._getSelectedBlocks(sb, eb);
|
| | | for (i = nl.length - 1; i >= 0; i--) {
|
| | | dom.insertAfter(nl[i], bq);
|
| | | }
|
| | |
|
| | | // Empty bq, then remove it
|
| | | if (/^\s*$/.test(bq.innerHTML))
|
| | | dom.remove(bq, 1); // Keep children so boomark restoration works correctly
|
| | |
|
| | | // Empty bq, then remote it
|
| | | if (bq2 && /^\s*$/.test(bq2.innerHTML))
|
| | | dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
|
| | |
|
| | | if (!bm) {
|
| | | // Move caret inside empty block element
|
| | | if (!isIE) {
|
| | | r = ed.getDoc().createRange();
|
| | | r.setStart(sb, 0);
|
| | | r.setEnd(sb, 0);
|
| | | s.setRng(r);
|
| | | } else {
|
| | | s.select(sb);
|
| | | s.collapse(0);
|
| | |
|
| | | // IE misses the empty block some times element so we must move back the caret
|
| | | if (dom.getParent(s.getStart(), dom.isBlock) != sb) {
|
| | | r = s.getRng();
|
| | | r.move('character', -1);
|
| | | r.select();
|
| | | // Check if there is any attributes
|
| | | each(dom.getAttribs(n), function(an) {
|
| | | if (an.nodeName.substring(0, 1) != '_' && dom.getAttrib(n, an.nodeName) != '') {
|
| | | //console.log(dom.getOuterHTML(n), dom.getAttrib(n, an.nodeName));
|
| | | c++;
|
| | | }
|
| | | }
|
| | | } else
|
| | | t.editor.selection.moveToBookmark(bm);
|
| | | });
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // Since IE can start with a totally empty document we need to add the first bq and paragraph
|
| | | if (isIE && !sb && !eb) {
|
| | | t.editor.getDoc().execCommand('Indent');
|
| | | n = getBQ(s.getNode());
|
| | | n.style.margin = n.dir = ''; // IE adds margin and dir to bq
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!sb || !eb)
|
| | | return;
|
| | |
|
| | | // If empty paragraph node then do not use bookmark
|
| | | if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
|
| | | bm = s.getBookmark();
|
| | |
|
| | | // Move selected block elements into a bq
|
| | | each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
|
| | | // Found existing BQ add to this one
|
| | | if (e.nodeName == 'BLOCKQUOTE' && !bq) {
|
| | | bq = e;
|
| | | return;
|
| | | }
|
| | |
|
| | | // No BQ found, create one
|
| | | if (!bq) {
|
| | | bq = dom.create('blockquote');
|
| | | e.parentNode.insertBefore(bq, e);
|
| | | }
|
| | |
|
| | | // Add children from existing BQ
|
| | | if (e.nodeName == 'BLOCKQUOTE' && bq) {
|
| | | n = e.firstChild;
|
| | |
|
| | | while (n) {
|
| | | bq.appendChild(n.cloneNode(true));
|
| | | n = n.nextSibling;
|
| | | }
|
| | |
|
| | | dom.remove(e);
|
| | | return;
|
| | | }
|
| | |
|
| | | // Add non BQ element to BQ
|
| | | bq.appendChild(dom.remove(e));
|
| | | });
|
| | |
|
| | | if (!bm) {
|
| | | // Move caret inside empty block element
|
| | | if (!isIE) {
|
| | | r = ed.getDoc().createRange();
|
| | | r.setStart(sb, 0);
|
| | | r.setEnd(sb, 0);
|
| | | s.setRng(r);
|
| | | } else {
|
| | | s.select(sb);
|
| | | s.collapse(1);
|
| | | }
|
| | | } else
|
| | | s.moveToBookmark(bm);
|
| | | },
|
| | | /*
|
| | | _mceBlockQuote : function() {
|
| | | var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom;
|
| | |
|
| | | function findBQ(e) {
|
| | | return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
| | | // No attributes then remove the element and keep the children
|
| | | if (c == 0)
|
| | | dom.remove(n, 1);
|
| | | });
|
| | | };
|
| | |
|
| | | // Remove blockquote(s)
|
| | | if (findBQ(s.getStart())) {
|
| | | each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
|
| | | // Found BQ lets remove it
|
| | | if (e.nodeName == 'BLOCKQUOTE')
|
| | | dom.remove(e, 1);
|
| | | function replaceFonts() {
|
| | | var bm;
|
| | |
|
| | | each(dom.select('span,font'), function(n) {
|
| | | if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline') {
|
| | | if (!bm)
|
| | | bm = ed.selection.getBookmark();
|
| | |
|
| | | at._mce_new = '1';
|
| | | dom.replace(dom.create(na, at), n, 1);
|
| | | }
|
| | | });
|
| | |
|
| | | t.editor.selection.moveToBookmark(b);
|
| | | return;
|
| | | // Remove redundant elements
|
| | | each(dom.select(na + '[_mce_new]'), function(n) {
|
| | | function removeStyle(n) {
|
| | | if (n.nodeType == 1) {
|
| | | each(at.style, function(v, k) {
|
| | | dom.setStyle(n, k, '');
|
| | | });
|
| | |
|
| | | // Remove spans with the same class or marked classes
|
| | | if (at['class'] && n.className && op) {
|
| | | each(op.check_classes, function(c) {
|
| | | if (dom.hasClass(n, c))
|
| | | dom.removeClass(n, c);
|
| | | });
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | // Remove specified style information from child elements
|
| | | each(dom.select(na, n), removeStyle);
|
| | |
|
| | | // Remove the specified style information on parent if current node is only child (IE)
|
| | | if (n.parentNode && n.parentNode.nodeType == 1 && n.parentNode.childNodes.length == 1)
|
| | | removeStyle(n.parentNode);
|
| | |
|
| | | // Remove the child elements style info if a parent already has it
|
| | | dom.getParent(n.parentNode, function(pn) {
|
| | | if (pn.nodeType == 1) {
|
| | | if (at.style) {
|
| | | each(at.style, function(v, k) {
|
| | | var sv;
|
| | |
|
| | | if (!lo[k] && (sv = dom.getStyle(pn, k))) {
|
| | | if (sv === v)
|
| | | dom.setStyle(n, k, '');
|
| | |
|
| | | lo[k] = 1;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | // Remove spans with the same class or marked classes
|
| | | if (at['class'] && pn.className && op) {
|
| | | each(op.check_classes, function(c) {
|
| | | if (dom.hasClass(pn, c))
|
| | | dom.removeClass(n, c);
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | });
|
| | |
|
| | | n.removeAttribute('_mce_new');
|
| | | });
|
| | |
|
| | | removeEmpty();
|
| | | ed.selection.moveToBookmark(bm);
|
| | |
|
| | | return !!bm;
|
| | | };
|
| | |
|
| | | // Create inline elements
|
| | | ed.focus();
|
| | | ed.getDoc().execCommand('FontName', false, 'mceinline');
|
| | | replaceFonts();
|
| | |
|
| | | if (kh = t._applyInlineStyle.keyhandler) {
|
| | | ed.onKeyUp.remove(kh);
|
| | | ed.onKeyPress.remove(kh);
|
| | | ed.onKeyDown.remove(kh);
|
| | | ed.onSetContent.remove(t._applyInlineStyle.chandler);
|
| | | }
|
| | |
|
| | | each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
|
| | | var n;
|
| | | if (ed.selection.isCollapsed()) {
|
| | | // IE will format the current word so this code can't be executed on that browser
|
| | | if (!isIE) {
|
| | | each(dom.getParents(ed.selection.getNode(), 'span'), function(n) {
|
| | | each(at.style, function(v, k) {
|
| | | var kv;
|
| | |
|
| | | // Found existing BQ add to this one
|
| | | if (e.nodeName == 'BLOCKQUOTE' && !bq) {
|
| | | bq = e;
|
| | | return;
|
| | | if (kv = dom.getStyle(n, k)) {
|
| | | if (kv == v) {
|
| | | dom.setStyle(n, k, '');
|
| | | found = 2;
|
| | | return false;
|
| | | }
|
| | |
|
| | | found = 1;
|
| | | return false;
|
| | | }
|
| | | });
|
| | |
|
| | | if (found)
|
| | | return false;
|
| | | });
|
| | |
|
| | | if (found == 2) {
|
| | | bm = ed.selection.getBookmark();
|
| | |
|
| | | removeEmpty();
|
| | |
|
| | | ed.selection.moveToBookmark(bm);
|
| | |
|
| | | // Node change needs to be detached since the onselect event
|
| | | // for the select box will run the onclick handler after onselect call. Todo: Add a nicer fix!
|
| | | window.setTimeout(function() {
|
| | | ed.nodeChanged();
|
| | | }, 1);
|
| | |
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | // No BQ found, create one
|
| | | if (!bq) {
|
| | | bq = dom.create('blockquote');
|
| | | e.parentNode.insertBefore(bq, e);
|
| | | }
|
| | | // Start collecting styles
|
| | | t._pendingStyles = tinymce.extend(t._pendingStyles || {}, at.style);
|
| | |
|
| | | // Add children from existing BQ
|
| | | if (e.nodeName == 'BLOCKQUOTE' && bq) {
|
| | | n = e.firstChild;
|
| | | t._applyInlineStyle.chandler = ed.onSetContent.add(function() {
|
| | | delete t._pendingStyles;
|
| | | });
|
| | |
|
| | | while (n) {
|
| | | bq.appendChild(n.cloneNode(true));
|
| | | n = n.nextSibling;
|
| | | t._applyInlineStyle.keyhandler = kh = function(e) {
|
| | | // Use pending styles
|
| | | if (t._pendingStyles) {
|
| | | at.style = t._pendingStyles;
|
| | | delete t._pendingStyles;
|
| | | }
|
| | |
|
| | | dom.remove(e);
|
| | | if (replaceFonts()) {
|
| | | ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);
|
| | | ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);
|
| | | }
|
| | |
|
| | | return;
|
| | | }
|
| | | if (e.type == 'keyup')
|
| | | ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);
|
| | | };
|
| | |
|
| | | // Add non BQ element to BQ
|
| | | bq.appendChild(dom.remove(e));
|
| | | });
|
| | | ed.onKeyDown.add(kh);
|
| | | ed.onKeyPress.add(kh);
|
| | | ed.onKeyUp.add(kh);
|
| | | } else
|
| | | t._pendingStyles = 0;
|
| | | }
|
| | | });
|
| | | })(tinymce);(function(tinymce) {
|
| | | tinymce.create('tinymce.UndoManager', {
|
| | | index : 0,
|
| | | data : null,
|
| | | typing : 0,
|
| | |
|
| | | t.editor.selection.moveToBookmark(b);
|
| | | UndoManager : function(ed) {
|
| | | var t = this, Dispatcher = tinymce.util.Dispatcher;
|
| | |
|
| | | t.editor = ed;
|
| | | t.data = [];
|
| | | t.onAdd = new Dispatcher(this);
|
| | | t.onUndo = new Dispatcher(this);
|
| | | t.onRedo = new Dispatcher(this);
|
| | | },
|
| | | */
|
| | | _getSelectedBlocks : function(st, en) {
|
| | | var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = [];
|
| | |
|
| | | sb = dom.getParent(st || s.getStart(), dom.isBlock);
|
| | | eb = dom.getParent(en || s.getEnd(), dom.isBlock);
|
| | | add : function(l) {
|
| | | var t = this, i, ed = t.editor, b, s = ed.settings, la;
|
| | |
|
| | | if (sb)
|
| | | bl.push(sb);
|
| | | l = l || {};
|
| | | l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
|
| | |
|
| | | if (sb && eb && sb != eb) {
|
| | | n = sb;
|
| | | // Add undo level if needed
|
| | | l.content = l.content.replace(/^\s*|\s*$/g, '');
|
| | | la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index];
|
| | | if (!l.initial && la && l.content == la.content)
|
| | | return null;
|
| | |
|
| | | while ((n = n.nextSibling) && n != eb) {
|
| | | if (dom.isBlock(n))
|
| | | bl.push(n);
|
| | | // Time to compress
|
| | | if (s.custom_undo_redo_levels) {
|
| | | if (t.data.length > s.custom_undo_redo_levels) {
|
| | | for (i = 0; i < t.data.length - 1; i++)
|
| | | t.data[i] = t.data[i + 1];
|
| | |
|
| | | t.data.length--;
|
| | | t.index = t.data.length;
|
| | | }
|
| | | }
|
| | |
|
| | | if (eb && sb != eb)
|
| | | bl.push(eb);
|
| | | if (s.custom_undo_redo_restore_selection && !l.initial)
|
| | | l.bookmark = b = l.bookmark || ed.selection.getBookmark();
|
| | |
|
| | | return bl;
|
| | | }
|
| | | });
|
| | | })();
|
| | | if (t.index < t.data.length)
|
| | | t.index++;
|
| | |
|
| | | // Only initial marked undo levels should be allowed as first item
|
| | | // This to workaround a bug with Firefox and the blur event
|
| | | if (t.data.length === 0 && !l.initial)
|
| | | return null;
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/UndoManager.js */
|
| | | // Add level
|
| | | t.data.length = t.index + 1;
|
| | | t.data[t.index++] = l;
|
| | |
|
| | | tinymce.create('tinymce.UndoManager', {
|
| | | index : 0,
|
| | | data : null,
|
| | | typing : 0,
|
| | | if (l.initial)
|
| | | t.index = 0;
|
| | |
|
| | | UndoManager : function(ed) {
|
| | | var t = this, Dispatcher = tinymce.util.Dispatcher;
|
| | | // Set initial bookmark use first real undo level
|
| | | if (t.data.length == 2 && t.data[0].initial)
|
| | | t.data[0].bookmark = b;
|
| | |
|
| | | t.editor = ed;
|
| | | t.data = [];
|
| | | t.onAdd = new Dispatcher(this);
|
| | | t.onUndo = new Dispatcher(this);
|
| | | t.onRedo = new Dispatcher(this);
|
| | | },
|
| | | t.onAdd.dispatch(t, l);
|
| | | ed.isNotDirty = 0;
|
| | |
|
| | | add : function(l) {
|
| | | var t = this, i, ed = t.editor, b, s = ed.settings, la;
|
| | | //console.dir(t.data);
|
| | |
|
| | | l = l || {};
|
| | | l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
|
| | | return l;
|
| | | },
|
| | |
|
| | | // Add undo level if needed
|
| | | l.content = l.content.replace(/^\s*|\s*$/g, '');
|
| | | la = t.data[t.index > 0 ? t.index - 1 : 0];
|
| | | if (!l.initial && la && l.content == la.content)
|
| | | return null;
|
| | | undo : function() {
|
| | | var t = this, ed = t.editor, l = l, i;
|
| | |
|
| | | // Time to compress
|
| | | if (s.custom_undo_redo_levels) {
|
| | | if (t.data.length > s.custom_undo_redo_levels) {
|
| | | for (i = 0; i < t.data.length - 1; i++)
|
| | | t.data[i] = t.data[i + 1];
|
| | |
|
| | | t.data.length--;
|
| | | t.index = t.data.length;
|
| | | }
|
| | | }
|
| | |
|
| | | if (s.custom_undo_redo_restore_selection && !l.initial)
|
| | | l.bookmark = b = l.bookmark || ed.selection.getBookmark();
|
| | |
|
| | | if (t.index < t.data.length && t.data[t.index].initial)
|
| | | t.index++;
|
| | |
|
| | | // Add level
|
| | | t.data.length = t.index + 1;
|
| | | t.data[t.index++] = l;
|
| | |
|
| | | if (l.initial)
|
| | | t.index = 0;
|
| | |
|
| | | // Set initial bookmark use first real undo level
|
| | | if (t.data.length == 2 && t.data[0].initial)
|
| | | t.data[0].bookmark = b;
|
| | |
|
| | | t.onAdd.dispatch(t, l);
|
| | | ed.isNotDirty = 0;
|
| | |
|
| | | //console.dir(t.data);
|
| | |
|
| | | return l;
|
| | | },
|
| | |
|
| | | undo : function() {
|
| | | var t = this, ed = t.editor, l = l, i;
|
| | |
|
| | | if (t.typing) {
|
| | | t.add();
|
| | | t.typing = 0;
|
| | | }
|
| | |
|
| | | if (t.index > 0) {
|
| | | // If undo on last index then take snapshot
|
| | | if (t.index == t.data.length && t.index > 1) {
|
| | | i = t.index;
|
| | | if (t.typing) {
|
| | | t.add();
|
| | | t.typing = 0;
|
| | |
|
| | | if (!t.add())
|
| | | t.index = i;
|
| | |
|
| | | --t.index;
|
| | | }
|
| | |
|
| | | l = t.data[--t.index];
|
| | | ed.setContent(l.content, {format : 'raw'});
|
| | | ed.selection.moveToBookmark(l.bookmark);
|
| | | if (t.index > 0) {
|
| | | // If undo on last index then take snapshot
|
| | | if (t.index == t.data.length && t.index > 1) {
|
| | | i = t.index;
|
| | | t.typing = 0;
|
| | |
|
| | | t.onUndo.dispatch(t, l);
|
| | | if (!t.add())
|
| | | t.index = i;
|
| | |
|
| | | --t.index;
|
| | | }
|
| | |
|
| | | l = t.data[--t.index];
|
| | | ed.setContent(l.content, {format : 'raw'});
|
| | | ed.selection.moveToBookmark(l.bookmark);
|
| | |
|
| | | t.onUndo.dispatch(t, l);
|
| | | }
|
| | |
|
| | | return l;
|
| | | },
|
| | |
|
| | | redo : function() {
|
| | | var t = this, ed = t.editor, l = null;
|
| | |
|
| | | if (t.index < t.data.length - 1) {
|
| | | l = t.data[++t.index];
|
| | | ed.setContent(l.content, {format : 'raw'});
|
| | | ed.selection.moveToBookmark(l.bookmark);
|
| | |
|
| | | t.onRedo.dispatch(t, l);
|
| | | }
|
| | |
|
| | | return l;
|
| | | },
|
| | |
|
| | | clear : function() {
|
| | | var t = this;
|
| | |
|
| | | t.data = [];
|
| | | t.index = 0;
|
| | | t.typing = 0;
|
| | | t.add({initial : true});
|
| | | },
|
| | |
|
| | | hasUndo : function() {
|
| | | return this.index != 0 || this.typing;
|
| | | },
|
| | |
|
| | | hasRedo : function() {
|
| | | return this.index < this.data.length - 1;
|
| | | }
|
| | |
|
| | | return l;
|
| | | },
|
| | |
|
| | | redo : function() {
|
| | | var t = this, ed = t.editor, l = null;
|
| | |
|
| | | if (t.index < t.data.length - 1) {
|
| | | l = t.data[++t.index];
|
| | | ed.setContent(l.content, {format : 'raw'});
|
| | | ed.selection.moveToBookmark(l.bookmark);
|
| | |
|
| | | t.onRedo.dispatch(t, l);
|
| | | }
|
| | |
|
| | | return l;
|
| | | },
|
| | |
|
| | | clear : function() {
|
| | | var t = this;
|
| | |
|
| | | t.data = [];
|
| | | t.index = 0;
|
| | | t.typing = 0;
|
| | | t.add({initial : true});
|
| | | },
|
| | |
|
| | | hasUndo : function() {
|
| | | return this.index != 0 || this.typing;
|
| | | },
|
| | |
|
| | | hasRedo : function() {
|
| | | return this.index < this.data.length - 1;
|
| | | }
|
| | |
|
| | | });
|
| | | /* file:jscripts/tiny_mce/classes/ForceBlocks.js */
|
| | |
|
| | | (function() {
|
| | | });
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | // Shorten names
|
| | | var Event, isIE, isGecko, isOpera, each, extend;
|
| | |
|
| | |
| | | isOpera = tinymce.isOpera;
|
| | | each = tinymce.each;
|
| | | extend = tinymce.extend;
|
| | |
|
| | | function isEmpty(n) {
|
| | | n = n.innerHTML;
|
| | | n = n.replace(/<\w+ .*?mce_\w+\"?=.*?>/gi, '-'); // Keep tags with mce_ attribs
|
| | | n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
|
| | | n = n.replace(/<[^>]+>/g, ''); // Remove all tags
|
| | |
|
| | | return n.replace(/[ \t\r\n]+/g, '') == '';
|
| | | };
|
| | |
|
| | | tinymce.create('tinymce.ForceBlocks', {
|
| | | ForceBlocks : function(ed) {
|
| | |
| | | t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi');
|
| | | t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
|
| | | t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
|
| | | t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi');
|
| | | t.reNbsp2BR2 = new RegExp('<%p()([^>]+)>( | )<\\\/%p>|<%p>( | )<\\\/%p>'.replace(/%p/g, elm), 'gi');
|
| | | t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
|
| | | t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
|
| | |
|
| | | function padd(ed, o) {
|
| | | if (isOpera)
|
| | |
| | | // Use instead of BR in padded paragraphs
|
| | | o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>');
|
| | | o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>');
|
| | | } else {
|
| | | } else
|
| | | o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>');
|
| | | o.content = o.content.replace(t.reTrailBr, '</' + elm + '>');
|
| | | }
|
| | | };
|
| | |
|
| | | ed.onBeforeSetContent.add(padd);
|
| | |
| | | return ne;
|
| | | };
|
| | |
|
| | | // Replaces IE:s auto generated paragraphs with the specified element name
|
| | | if (isIE && s.element != 'P') {
|
| | | ed.onKeyPress.add(function(ed, e) {
|
| | | t.lastElm = ed.selection.getNode().nodeName;
|
| | | // IE specific fixes
|
| | | if (isIE) {
|
| | | // Remove empty inline elements within block elements
|
| | | // For example: <p><strong><em></em></strong></p>
|
| | | ed.onPreProcess.add(function(ed, o) {
|
| | | each(ed.dom.select('p,h1,h2,h3,h4,h5,h6,div', o.node), function(p) {
|
| | | if (isEmpty(p))
|
| | | p.innerHTML = '';
|
| | | });
|
| | | });
|
| | |
|
| | | ed.onKeyUp.add(function(ed, e) {
|
| | | var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
|
| | | // Replaces IE:s auto generated paragraphs with the specified element name
|
| | | if (s.element != 'P') {
|
| | | ed.onKeyPress.add(function(ed, e) {
|
| | | t.lastElm = ed.selection.getNode().nodeName;
|
| | | });
|
| | |
|
| | | if (b.childNodes.length === 1 && n.nodeName == 'P') {
|
| | | n = ren(n, s.element);
|
| | | sel.select(n);
|
| | | sel.collapse();
|
| | | ed.nodeChanged();
|
| | | } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
|
| | | bl = ed.dom.getParent(n, 'P');
|
| | | ed.onKeyUp.add(function(ed, e) {
|
| | | var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
|
| | |
|
| | | if (bl) {
|
| | | ren(bl, s.element);
|
| | | if (b.childNodes.length === 1 && n.nodeName == 'P') {
|
| | | n = ren(n, s.element);
|
| | | sel.select(n);
|
| | | sel.collapse();
|
| | | ed.nodeChanged();
|
| | | } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
|
| | | bl = ed.dom.getParent(n, 'p');
|
| | |
|
| | | if (bl) {
|
| | | ren(bl, s.element);
|
| | | ed.nodeChanged();
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | | }
|
| | | },
|
| | |
|
| | |
| | |
|
| | | 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;
|
| | | var nx, bl, bp, sp, le, nl = b.childNodes, i, n, eid;
|
| | |
|
| | | // Fix for bug #1863847
|
| | | if (e && e.keyCode == 13)
|
| | | return true;
|
| | | //if (e && e.keyCode == 13)
|
| | | // return true;
|
| | |
|
| | | // Wrap non blocks into blocks
|
| | | for (i = nl.length - 1; i >= 0; i--) {
|
| | |
| | | // Store selection
|
| | | if (si == -2 && r) {
|
| | | if (!isIE) {
|
| | | so = r.startOffset;
|
| | | eo = r.endOffset;
|
| | | si = t.find(b, 0, r.startContainer);
|
| | | ei = t.find(b, 0, r.endContainer);
|
| | | // 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;})) {
|
| | | so = r.startOffset;
|
| | | eo = r.endOffset;
|
| | | si = t.find(b, 0, r.startContainer);
|
| | | ei = t.find(b, 0, r.endContainer);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | tr = d.body.createTextRange();
|
| | | tr.moveToElementText(b);
|
| | |
| | | // Restore selection
|
| | | if (si != -2) {
|
| | | if (!isIE) {
|
| | | bl = d.getElementsByTagName(ed.settings.element)[0];
|
| | | bl = b.getElementsByTagName(ed.settings.element)[0];
|
| | | r = d.createRange();
|
| | |
|
| | | // Select last location or generated block
|
| | |
| | | // Ignore
|
| | | }
|
| | | }
|
| | | } else if (!isIE && (n = ed.dom.get('__mce'))) {
|
| | | // Restore the id of the selected element
|
| | | if (eid)
|
| | | n.setAttribute('id', eid);
|
| | | else
|
| | | n.removeAttribute('id');
|
| | |
|
| | | // Move caret before selected element
|
| | | r = d.createRange();
|
| | | r.setStartBefore(n);
|
| | | r.setEndBefore(n);
|
| | | se.setRng(r);
|
| | | }
|
| | | },
|
| | |
|
| | |
| | | },
|
| | |
|
| | | insertPara : function(e) {
|
| | | var t = this, ed = t.editor, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body;
|
| | | var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = ed.dom.getViewPort(ed.getWin()), y, ch;
|
| | |
|
| | | function isEmpty(n) {
|
| | | n = n.innerHTML;
|
| | | n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
|
| | | n = n.replace(/<[^>]+>/g, ''); // Remove all tags
|
| | |
|
| | | return n.replace(/[ \t\r\n]+/g, '') == '';
|
| | | };
|
| | | var t = this, ed = t.editor, dom = ed.dom, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body;
|
| | | var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch, car;
|
| | |
|
| | | // If root blocks are forced then use Operas default behavior since it's really good
|
| | | // Removed due to bug: #1853816
|
| | |
| | | en = dir ? s.focusNode : s.anchorNode;
|
| | | eo = dir ? s.focusOffset : s.anchorOffset;
|
| | |
|
| | | // If selection is in empty table cell
|
| | | if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
|
| | | dom.remove(sn.firstChild); // Remove BR
|
| | |
|
| | | // Create two new block elements
|
| | | ed.dom.add(sn, se.element, null, '<br />');
|
| | | aft = ed.dom.add(sn, se.element, null, '<br />');
|
| | |
|
| | | // Move caret into the last one
|
| | | r = d.createRange();
|
| | | r.selectNodeContents(aft);
|
| | | r.collapse(1);
|
| | | ed.selection.setRng(r);
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | // If the caret is in an invalid location in FF we need to move it into the first block
|
| | | if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
|
| | | sn = en = sn.firstChild;
|
| | |
| | | bn = sb ? sb.nodeName : se.element; // Get block name to create
|
| | |
|
| | | // Return inside list use default browser behavior
|
| | | if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
|
| | | if (t.dom.getParent(sb, 'ol,ul,pre'))
|
| | | return true;
|
| | |
|
| | | // If caption or absolute layers then always generate new blocks within
|
| | | if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
|
| | | if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|fixed/gi.test(dom.getStyle(sb, 'position', 1)))) {
|
| | | bn = se.element;
|
| | | sb = null;
|
| | | }
|
| | |
|
| | | // If caption or absolute layers then always generate new blocks within
|
| | | if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
|
| | | if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|fixed/gi.test(dom.getStyle(sb, 'position', 1)))) {
|
| | | bn = se.element;
|
| | | eb = null;
|
| | | }
|
| | |
|
| | | // Use P instead
|
| | | if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
|
| | | if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(dom.getStyle(sb, 'float', 1)))) {
|
| | | bn = se.element;
|
| | | sb = eb = null;
|
| | | }
|
| | |
| | | if (isEmpty(bef))
|
| | | bef.innerHTML = '<br />';
|
| | |
|
| | | if (isEmpty(aft))
|
| | | aft.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
|
| | | function appendStyles(e, en) {
|
| | | var nl = [], nn, n, i;
|
| | |
|
| | | // Opera needs this one backwards
|
| | | if (isOpera) {
|
| | | e.innerHTML = '';
|
| | |
|
| | | // Make clones of style elements
|
| | | if (se.keep_styles) {
|
| | | n = en;
|
| | | do {
|
| | | // We only want style specific elements
|
| | | if (/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)) {
|
| | | nn = n.cloneNode(false);
|
| | | dom.setAttrib(nn, 'id', ''); // Remove ID since it needs to be unique
|
| | | nl.push(nn);
|
| | | }
|
| | | } while (n = n.parentNode);
|
| | | }
|
| | |
|
| | | // Append style elements to aft
|
| | | if (nl.length > 0) {
|
| | | for (i = nl.length - 1, nn = e; i >= 0; i--)
|
| | | nn = nn.appendChild(nl[i]);
|
| | |
|
| | | // Padd most inner style element
|
| | | nl[0].innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
|
| | | return nl[0]; // Move caret to most inner element
|
| | | } else
|
| | | e.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
|
| | | };
|
| | |
|
| | | // Fill empty afterblook with current style
|
| | | if (isEmpty(aft))
|
| | | car = appendStyles(aft, en);
|
| | |
|
| | | // Opera needs this one backwards for older versions
|
| | | if (isOpera && parseFloat(opera.version()) < 9.5) {
|
| | | r.insertNode(bef);
|
| | | r.insertNode(aft);
|
| | | } else {
|
| | |
| | | aft.normalize();
|
| | | bef.normalize();
|
| | |
|
| | | function first(n) {
|
| | | return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n;
|
| | | };
|
| | |
|
| | | // Move cursor and scroll into view
|
| | | r = d.createRange();
|
| | | r.selectNodeContents(aft);
|
| | | r.selectNodeContents(isGecko ? first(car || aft) : car || aft);
|
| | | r.collapse(1);
|
| | | s.removeAllRanges();
|
| | | s.addRange(r);
|
| | |
| | |
|
| | | // Is element within viewport
|
| | | if (y < vp.y || y + ch > vp.y + vp.h) {
|
| | | ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + ch);
|
| | | ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + 25); // Needs to be hardcoded to roughly one line of text if a huge text block is broken into two blocks
|
| | | //console.debug('SCROLL!', 'vp.y: ' + vp.y, 'y' + y, 'vp.h' + vp.h, 'clientHeight' + aft.clientHeight, 'yyy: ' + (y < vp.y ? y : y - vp.h + aft.clientHeight));
|
| | | }
|
| | |
|
| | |
| | |
|
| | | // Gecko generates BR elements here and there, we don't like those so lets remove them
|
| | | function handler(e) {
|
| | | var pr;
|
| | |
|
| | | e = e.target;
|
| | |
|
| | | // A new BR was created in a block element, remove it
|
| | | if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
|
| | | pr = e.previousSibling;
|
| | |
|
| | | Event.remove(b, 'DOMNodeInserted', handler);
|
| | |
|
| | | // Is there whitespace at the end of the node before then we might need the pesky BR
|
| | | // to place the caret at a correct location see bug: #2013943
|
| | | if (pr && pr.nodeType == 3 && /\s+$/.test(pr.nodeValue))
|
| | | return;
|
| | |
|
| | | // Only remove BR elements that got inserted in the middle of the text
|
| | | if (e.previousSibling || e.nextSibling)
|
| | |
| | | }, 1);
|
| | | }
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/ControlManager.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | // Shorten names
|
| | | var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend;
|
| | |
|
| | |
| | | // Fix for bug #1897785, #1898007
|
| | | if (tinymce.isIE) {
|
| | | c.onShowMenu.add(function() {
|
| | | var s = ed.selection, n = s.getNode();
|
| | | // IE 8 needs focus in order to store away a range with the current collapsed caret location
|
| | | ed.focus();
|
| | |
|
| | | if (n.nodeName == 'IMG')
|
| | | bm = s.getBookmark();
|
| | | else
|
| | | bm = 0;
|
| | | bm = ed.selection.getBookmark(1);
|
| | | });
|
| | |
|
| | | c.onHideMenu.add(function() {
|
| | | if (bm)
|
| | | if (bm) {
|
| | | ed.selection.moveToBookmark(bm);
|
| | | bm = 0;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | return null;
|
| | |
|
| | | s.title = ed.translate(s.title);
|
| | | s.label = ed.translate(s.label);
|
| | | s.scope = s.scope || ed;
|
| | |
|
| | | if (!s.onclick && !s.menu_button) {
|
| | |
| | | return t.add(c);
|
| | | },
|
| | |
|
| | | createMenuButton : function(id, s) {
|
| | | createMenuButton : function(id, s, cc) {
|
| | | s = s || {};
|
| | | s.menu_button = 1;
|
| | |
|
| | | return this.createButton(id, s);
|
| | | return this.createButton(id, s, cc);
|
| | | },
|
| | |
|
| | | createSplitButton : function(id, s, cc) {
|
| | |
| | | },
|
| | |
|
| | | createColorSplitButton : function(id, s, cc) {
|
| | | var t = this, ed = t.editor, cmd, c, cls;
|
| | | var t = this, ed = t.editor, cmd, c, cls, bm;
|
| | |
|
| | | if (t.get(id))
|
| | | return null;
|
| | |
| | |
|
| | | if (!s.onclick) {
|
| | | s.onclick = function(v) {
|
| | | if (tinymce.isIE)
|
| | | bm = ed.selection.getBookmark(1);
|
| | | |
| | | ed.execCommand(s.cmd, s.ui || false, v || s.value);
|
| | | };
|
| | | }
|
| | |
| | | ed.onRemove.add(function() {
|
| | | c.destroy();
|
| | | });
|
| | |
|
| | | // Fix for bug #1897785, #1898007
|
| | | if (tinymce.isIE) {
|
| | | c.onHideMenu.add(function() {
|
| | | if (bm) {
|
| | | ed.selection.moveToBookmark(bm);
|
| | | bm = 0;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | return t.add(c);
|
| | | },
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | })();
|
| | |
|
| | | /* file:jscripts/tiny_mce/classes/WindowManager.js */
|
| | |
|
| | | (function() {
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera;
|
| | |
|
| | | tinymce.create('tinymce.WindowManager', {
|
| | |
| | | s.dialogWidth = s.width + 'px';
|
| | | s.dialogHeight = s.height + 'px';
|
| | | s.scroll = s.scrollbars || false;
|
| | | } else
|
| | | s.modal = s.alwaysRaised = s.dialog = s.centerscreen = s.dependent = true;
|
| | | }
|
| | | }
|
| | |
|
| | | // Build features string
|
| | |
| | | t.onOpen.dispatch(t, s, p);
|
| | |
|
| | | u = s.url || s.file;
|
| | | if (tinymce.relaxedDomain)
|
| | | u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
|
| | | u = tinymce._addVer(u);
|
| | |
|
| | | try {
|
| | | if (isIE && mo) {
|
| | | w = 1;
|
| | | window.showModalDialog(s.url || s.file, window, f);
|
| | | window.showModalDialog(u, window, f);
|
| | | } else
|
| | | w = window.open(u, s.name, f);
|
| | | } catch (ex) {
|
| | |
| | | return new f(a, b, c, d, e);
|
| | | },
|
| | |
|
| | | confirm : function(t, cb, s) {
|
| | | cb.call(s || this, confirm(this._decode(this.editor.getLang(t, t))));
|
| | | confirm : function(t, cb, s, w) {
|
| | | w = w || window;
|
| | |
|
| | | cb.call(s || this, w.confirm(this._decode(this.editor.getLang(t, t))));
|
| | | },
|
| | |
|
| | | alert : function(tx, cb, s) {
|
| | | alert : function(tx, cb, s, w) {
|
| | | var t = this;
|
| | | |
| | | alert(t._decode(t.editor.getLang(tx, tx)));
|
| | |
|
| | | w = w || window;
|
| | | w.alert(t._decode(t.editor.getLang(tx, tx)));
|
| | |
|
| | | if (cb)
|
| | | cb.call(s || t);
|
| | |
| | | }
|
| | |
|
| | | });
|
| | | }()); |
| | | }(tinymce));(function(tinymce) {
|
| | | tinymce.CommandManager = function() {
|
| | | var execCommands = {}, queryStateCommands = {}, queryValueCommands = {};
|
| | |
|
| | | function add(collection, cmd, func, scope) {
|
| | | if (typeof(cmd) == 'string')
|
| | | cmd = [cmd];
|
| | |
|
| | | tinymce.each(cmd, function(cmd) {
|
| | | collection[cmd.toLowerCase()] = {func : func, scope : scope};
|
| | | });
|
| | | };
|
| | |
|
| | | tinymce.extend(this, {
|
| | | add : function(cmd, func, scope) {
|
| | | add(execCommands, cmd, func, scope);
|
| | | },
|
| | |
|
| | | addQueryStateHandler : function(cmd, func, scope) {
|
| | | add(queryStateCommands, cmd, func, scope);
|
| | | },
|
| | |
|
| | | addQueryValueHandler : function(cmd, func, scope) {
|
| | | add(queryValueCommands, cmd, func, scope);
|
| | | },
|
| | |
|
| | | execCommand : function(scope, cmd, ui, value, args) {
|
| | | if (cmd = execCommands[cmd.toLowerCase()]) {
|
| | | if (cmd.func.call(scope || cmd.scope, ui, value, args) !== false)
|
| | | return true;
|
| | | }
|
| | | },
|
| | |
|
| | | queryCommandValue : function() {
|
| | | if (cmd = queryValueCommands[cmd.toLowerCase()])
|
| | | return cmd.func.call(scope || cmd.scope, ui, value, args);
|
| | | },
|
| | |
|
| | | queryCommandState : function() {
|
| | | if (cmd = queryStateCommands[cmd.toLowerCase()])
|
| | | return cmd.func.call(scope || cmd.scope, ui, value, args);
|
| | | }
|
| | | });
|
| | | };
|
| | |
|
| | | tinymce.GlobalCommands = new tinymce.CommandManager();
|
| | | })(tinymce);(function(tinymce) {
|
| | | function processRange(dom, start, end, callback) {
|
| | | var ancestor, n, startPoint, endPoint, sib;
|
| | |
|
| | | function findEndPoint(n, c) {
|
| | | do {
|
| | | if (n.parentNode == c)
|
| | | return n;
|
| | |
|
| | | n = n.parentNode;
|
| | | } while(n);
|
| | | };
|
| | |
|
| | | function process(n) {
|
| | | callback(n);
|
| | | tinymce.walk(n, callback, 'childNodes');
|
| | | };
|
| | |
|
| | | // Find common ancestor and end points
|
| | | ancestor = dom.findCommonAncestor(start, end);
|
| | | startPoint = findEndPoint(start, ancestor) || start;
|
| | | endPoint = findEndPoint(end, ancestor) || end;
|
| | |
|
| | | // Process left leaf
|
| | | for (n = start; n && n != startPoint; n = n.parentNode) {
|
| | | for (sib = n.nextSibling; sib; sib = sib.nextSibling)
|
| | | process(sib);
|
| | | }
|
| | |
|
| | | // Process middle from start to end point
|
| | | if (startPoint != endPoint) {
|
| | | for (n = startPoint.nextSibling; n && n != endPoint; n = n.nextSibling)
|
| | | process(n);
|
| | | } else
|
| | | process(startPoint);
|
| | |
|
| | | // Process right leaf
|
| | | for (n = end; n && n != endPoint; n = n.parentNode) {
|
| | | for (sib = n.previousSibling; sib; sib = sib.previousSibling)
|
| | | process(sib);
|
| | | }
|
| | | };
|
| | |
|
| | | tinymce.GlobalCommands.add('RemoveFormat', function() {
|
| | | var ed = this, dom = ed.dom, s = ed.selection, r = s.getRng(1), nodes = [], bm, start, end, sc, so, ec, eo, n;
|
| | |
|
| | | function findFormatRoot(n) {
|
| | | var sp;
|
| | |
|
| | | dom.getParent(n, function(n) {
|
| | | if (dom.is(n, ed.getParam('removeformat_selector')))
|
| | | sp = n;
|
| | |
|
| | | return dom.isBlock(n);
|
| | | }, ed.getBody());
|
| | |
|
| | | return sp;
|
| | | };
|
| | |
|
| | | function collect(n) {
|
| | | if (dom.is(n, ed.getParam('removeformat_selector')))
|
| | | nodes.push(n);
|
| | | };
|
| | |
|
| | | function walk(n) {
|
| | | collect(n);
|
| | | tinymce.walk(n, collect, 'childNodes');
|
| | | };
|
| | |
|
| | | bm = s.getBookmark();
|
| | | sc = r.startContainer;
|
| | | ec = r.endContainer;
|
| | | so = r.startOffset;
|
| | | eo = r.endOffset;
|
| | | sc = sc.nodeType == 1 ? sc.childNodes[Math.min(so, sc.childNodes.length - 1)] : sc;
|
| | | ec = ec.nodeType == 1 ? ec.childNodes[Math.min(so == eo ? eo : eo - 1, ec.childNodes.length - 1)] : ec;
|
| | |
|
| | | // Same container
|
| | | if (sc == ec) { // TEXT_NODE
|
| | | start = findFormatRoot(sc);
|
| | |
|
| | | // Handle single text node
|
| | | if (sc.nodeType == 3) {
|
| | | if (start && start.nodeType == 1) { // ELEMENT
|
| | | n = sc.splitText(so);
|
| | | n.splitText(eo - so);
|
| | | dom.split(start, n);
|
| | |
|
| | | s.moveToBookmark(bm);
|
| | | }
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // Handle single element
|
| | | walk(dom.split(start, sc) || sc);
|
| | | } else {
|
| | | // Find start/end format root
|
| | | start = findFormatRoot(sc);
|
| | | end = findFormatRoot(ec);
|
| | |
|
| | | // Split start text node
|
| | | if (start) {
|
| | | if (sc.nodeType == 3) { // TEXT
|
| | | // Since IE doesn't support white space nodes in the DOM we need to
|
| | | // add this invisible character so that the splitText function can split the contents
|
| | | if (so == sc.nodeValue.length)
|
| | | sc.nodeValue += '\uFEFF'; // Yet another pesky IE fix
|
| | |
|
| | | sc = sc.splitText(so);
|
| | | }
|
| | | }
|
| | |
|
| | | // Split end text node
|
| | | if (end) {
|
| | | if (ec.nodeType == 3) // TEXT
|
| | | ec.splitText(eo);
|
| | | }
|
| | |
|
| | | // If the start and end format root is the same then we need to wrap
|
| | | // the end node in a span since the split calls might change the reference
|
| | | // Example: <p><b><em>x[yz<span>---</span>12]3</em></b></p>
|
| | | if (start && start == end)
|
| | | dom.replace(dom.create('span', {id : '__end'}, ec.cloneNode(true)), ec);
|
| | |
|
| | | // Split all start containers down to the format root
|
| | | if (start)
|
| | | start = dom.split(start, sc);
|
| | | else
|
| | | start = sc;
|
| | |
|
| | | // If there is a span wrapper use that one instead
|
| | | if (n = dom.get('__end')) {
|
| | | ec = n;
|
| | | end = findFormatRoot(ec);
|
| | | }
|
| | |
|
| | | // Split all end containers down to the format root
|
| | | if (end)
|
| | | end = dom.split(end, ec);
|
| | | else
|
| | | end = ec;
|
| | |
|
| | | // Collect nodes in between
|
| | | processRange(dom, start, end, collect);
|
| | |
|
| | | // Remove invisible character for IE workaround if we find it
|
| | | if (sc.nodeValue == '\uFEFF')
|
| | | sc.nodeValue = '';
|
| | |
|
| | | // Process start/end container elements
|
| | | walk(ec);
|
| | | walk(sc);
|
| | | }
|
| | |
|
| | | // Remove all collected nodes
|
| | | tinymce.each(nodes, function(n) {
|
| | | dom.remove(n, 1);
|
| | | });
|
| | |
|
| | | // Remove leftover wrapper
|
| | | dom.remove('__end', 1);
|
| | |
|
| | | s.moveToBookmark(bm);
|
| | | });
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | tinymce.GlobalCommands.add('mceBlockQuote', function() {
|
| | | var ed = this, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
|
| | |
|
| | | function getBQ(e) {
|
| | | return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
| | | };
|
| | |
|
| | | // Get start/end block
|
| | | sb = dom.getParent(s.getStart(), dom.isBlock);
|
| | | eb = dom.getParent(s.getEnd(), dom.isBlock);
|
| | |
|
| | | // Remove blockquote(s)
|
| | | if (bq = getBQ(sb)) {
|
| | | if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
|
| | | bm = s.getBookmark();
|
| | |
|
| | | // Move all elements after the end block into new bq
|
| | | if (getBQ(eb)) {
|
| | | bq2 = bq.cloneNode(false);
|
| | |
|
| | | while (n = eb.nextSibling)
|
| | | bq2.appendChild(n.parentNode.removeChild(n));
|
| | | }
|
| | |
|
| | | // Add new bq after
|
| | | if (bq2)
|
| | | dom.insertAfter(bq2, bq);
|
| | |
|
| | | // Move all selected blocks after the current bq
|
| | | nl = s.getSelectedBlocks(sb, eb);
|
| | | for (i = nl.length - 1; i >= 0; i--) {
|
| | | dom.insertAfter(nl[i], bq);
|
| | | }
|
| | |
|
| | | // Empty bq, then remove it
|
| | | if (/^\s*$/.test(bq.innerHTML))
|
| | | dom.remove(bq, 1); // Keep children so boomark restoration works correctly
|
| | |
|
| | | // Empty bq, then remote it
|
| | | if (bq2 && /^\s*$/.test(bq2.innerHTML))
|
| | | dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
|
| | |
|
| | | if (!bm) {
|
| | | // Move caret inside empty block element
|
| | | if (!tinymce.isIE) {
|
| | | r = ed.getDoc().createRange();
|
| | | r.setStart(sb, 0);
|
| | | r.setEnd(sb, 0);
|
| | | s.setRng(r);
|
| | | } else {
|
| | | s.select(sb);
|
| | | s.collapse(0);
|
| | |
|
| | | // IE misses the empty block some times element so we must move back the caret
|
| | | if (dom.getParent(s.getStart(), dom.isBlock) != sb) {
|
| | | r = s.getRng();
|
| | | r.move('character', -1);
|
| | | r.select();
|
| | | }
|
| | | }
|
| | | } else
|
| | | ed.selection.moveToBookmark(bm);
|
| | |
|
| | | return;
|
| | | }
|
| | |
|
| | | // Since IE can start with a totally empty document we need to add the first bq and paragraph
|
| | | if (tinymce.isIE && !sb && !eb) {
|
| | | ed.getDoc().execCommand('Indent');
|
| | | n = getBQ(s.getNode());
|
| | | n.style.margin = n.dir = ''; // IE adds margin and dir to bq
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!sb || !eb)
|
| | | return;
|
| | |
|
| | | // If empty paragraph node then do not use bookmark
|
| | | if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
|
| | | bm = s.getBookmark();
|
| | |
|
| | | // Move selected block elements into a bq
|
| | | tinymce.each(s.getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
|
| | | // Found existing BQ add to this one
|
| | | if (e.nodeName == 'BLOCKQUOTE' && !bq) {
|
| | | bq = e;
|
| | | return;
|
| | | }
|
| | |
|
| | | // No BQ found, create one
|
| | | if (!bq) {
|
| | | bq = dom.create('blockquote');
|
| | | e.parentNode.insertBefore(bq, e);
|
| | | }
|
| | |
|
| | | // Add children from existing BQ
|
| | | if (e.nodeName == 'BLOCKQUOTE' && bq) {
|
| | | n = e.firstChild;
|
| | |
|
| | | while (n) {
|
| | | bq.appendChild(n.cloneNode(true));
|
| | | n = n.nextSibling;
|
| | | }
|
| | |
|
| | | dom.remove(e);
|
| | | return;
|
| | | }
|
| | |
|
| | | // Add non BQ element to BQ
|
| | | bq.appendChild(dom.remove(e));
|
| | | });
|
| | |
|
| | | if (!bm) {
|
| | | // Move caret inside empty block element
|
| | | if (!tinymce.isIE) {
|
| | | r = ed.getDoc().createRange();
|
| | | r.setStart(sb, 0);
|
| | | r.setEnd(sb, 0);
|
| | | s.setRng(r);
|
| | | } else {
|
| | | s.select(sb);
|
| | | s.collapse(1);
|
| | | }
|
| | | } else
|
| | | s.moveToBookmark(bm);
|
| | | });
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | tinymce.each(['Cut', 'Copy', 'Paste'], function(cmd) {
|
| | | tinymce.GlobalCommands.add(cmd, function() {
|
| | | var ed = this, doc = ed.getDoc();
|
| | |
|
| | | try {
|
| | | doc.execCommand(cmd, false, null);
|
| | |
|
| | | // On WebKit the command will just be ignored if it's not enabled
|
| | | if (!doc.queryCommandSupported(cmd))
|
| | | throw 'Error';
|
| | | } catch (ex) {
|
| | | ed.windowManager.alert(ed.getLang('clipboard_no_support'));
|
| | | }
|
| | | });
|
| | | });
|
| | | })(tinymce);
|
| | | (function(tinymce) {
|
| | | tinymce.GlobalCommands.add('InsertHorizontalRule', function() {
|
| | | if (tinymce.isOpera)
|
| | | return this.getDoc().execCommand('InsertHorizontalRule', false, '');
|
| | |
|
| | | this.selection.setContent('<hr />');
|
| | | });
|
| | | })(tinymce);
|
| | | (function() {
|
| | | var cmds = tinymce.GlobalCommands;
|
| | |
|
| | | cmds.add(['mceEndUndoLevel', 'mceAddUndoLevel'], function() {
|
| | | this.undoManager.add();
|
| | | });
|
| | |
|
| | | cmds.add('Undo', function() {
|
| | | var ed = this;
|
| | |
|
| | | if (ed.settings.custom_undo_redo) {
|
| | | ed.undoManager.undo();
|
| | | ed.nodeChanged();
|
| | | return true;
|
| | | }
|
| | |
|
| | | return false; // Run browser command
|
| | | });
|
| | |
|
| | | cmds.add('Redo', function() {
|
| | | var ed = this;
|
| | |
|
| | | if (ed.settings.custom_undo_redo) {
|
| | | ed.undoManager.redo();
|
| | | ed.nodeChanged();
|
| | | return true;
|
| | | }
|
| | |
|
| | | return false; // Run browser command
|
| | | });
|
| | | })();
|