2 /* file:jscripts/tiny_mce/classes/tinymce.js */
\r
6 minorVersion : '1.0.1',
\r
7 releaseDate : '2008-06-18',
\r
10 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
\r
13 t.isOpera = w.opera && opera.buildNumber;
\r
14 t.isWebKit = /WebKit/.test(ua);
\r
15 t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt;
\r
16 t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
\r
17 t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
\r
18 t.isGecko = !t.isWebKit && /Gecko/.test(ua);
\r
19 t.isMac = ua.indexOf('Mac') != -1;
\r
21 // TinyMCE .NET webcontrol might be setting the values for TinyMCE
\r
22 if (w.tinyMCEPreInit) {
\r
23 t.suffix = tinyMCEPreInit.suffix;
\r
24 t.baseURL = tinyMCEPreInit.base;
\r
25 t.query = tinyMCEPreInit.query;
\r
29 // Get suffix and base
\r
32 // If base element found, add that infront of baseURL
\r
33 nl = d.getElementsByTagName('base');
\r
34 for (i=0; i<nl.length; i++) {
\r
35 if (v = nl[i].href) {
\r
36 // Host only value like http://site.com or http://site.com:8008
\r
37 if (/^https?:\/\/[^\/]+$/.test(v))
\r
40 base = v ? v.match(/.*\//)[0] : ''; // Get only directory
\r
44 function getBase(n) {
\r
45 if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
\r
46 if (/_(src|dev)\.js/g.test(n.src))
\r
49 if ((p = n.src.indexOf('?')) != -1)
\r
50 t.query = n.src.substring(p + 1);
\r
52 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
\r
54 // If path to script is relative and a base href was found add that one infront
\r
55 if (base && t.baseURL.indexOf('://') == -1)
\r
56 t.baseURL = base + t.baseURL;
\r
65 nl = d.getElementsByTagName('script');
\r
66 for (i=0; i<nl.length; i++) {
\r
72 n = d.getElementsByTagName('head')[0];
\r
74 nl = n.getElementsByTagName('script');
\r
75 for (i=0; i<nl.length; i++) {
\r
84 is : function(o, t) {
\r
88 return n != 'undefined';
\r
90 if (t == 'array' && (o instanceof Array))
\r
98 each : function(o, cb, s) {
\r
106 if (typeof(o.length) != 'undefined') {
\r
107 // Indexed arrays, needed for Safari
\r
108 for (n=0, l = o.length; n<l; n++) {
\r
109 if (cb.call(s, o[n], n, o) === false)
\r
115 if (o.hasOwnProperty(n)) {
\r
116 if (cb.call(s, o[n], n, o) === false)
\r
125 map : function(a, f) {
\r
128 tinymce.each(a, function(v) {
\r
135 grep : function(a, f) {
\r
138 tinymce.each(a, function(v) {
\r
146 inArray : function(a, v) {
\r
150 for (i = 0, l = a.length; i < l; i++) {
\r
159 extend : function(o, e) {
\r
160 var i, a = arguments;
\r
162 for (i=1; i<a.length; i++) {
\r
165 tinymce.each(e, function(v, n) {
\r
166 if (typeof(v) !== 'undefined')
\r
174 trim : function(s) {
\r
175 return (s ? '' + s : '').replace(/^\s*|\s*$/g, '');
\r
180 create : function(s, p) {
\r
181 var t = this, sp, ns, cn, scn, c, de = 0;
\r
183 // Parse : <prefix> <class>:<super class>
\r
184 s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);
\r
185 cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name
\r
187 // Create namespace for new class
\r
188 ns = t.createNS(s[3].replace(/\.\w+$/, ''));
\r
190 // Class already exists
\r
194 // Make pure static class
\r
195 if (s[2] == 'static') {
\r
199 this.onCreate(s[2], s[3], ns[cn]);
\r
204 // Create default constructor
\r
206 p[cn] = function() {};
\r
210 // Add constructor and methods
\r
212 t.extend(ns[cn].prototype, p);
\r
216 sp = t.resolve(s[5]).prototype;
\r
217 scn = s[5].match(/\.(\w+)$/i)[1]; // Class name
\r
219 // Extend constructor
\r
222 // Add passthrough constructor
\r
223 ns[cn] = function() {
\r
224 return sp[scn].apply(this, arguments);
\r
227 // Add inherit constructor
\r
228 ns[cn] = function() {
\r
229 this.parent = sp[scn];
\r
230 return c.apply(this, arguments);
\r
233 ns[cn].prototype[cn] = ns[cn];
\r
235 // Add super methods
\r
236 t.each(sp, function(f, n) {
\r
237 ns[cn].prototype[n] = sp[n];
\r
240 // Add overridden methods
\r
241 t.each(p, function(f, n) {
\r
242 // Extend methods if needed
\r
244 ns[cn].prototype[n] = function() {
\r
245 this.parent = sp[n];
\r
246 return f.apply(this, arguments);
\r
250 ns[cn].prototype[n] = f;
\r
255 // Add static methods
\r
256 t.each(p['static'], function(f, n) {
\r
261 this.onCreate(s[2], s[3], ns[cn].prototype);
\r
264 walk : function(o, f, n, s) {
\r
271 tinymce.each(o, function(o, i) {
\r
272 if (f.call(s, o, i, n) === false)
\r
275 tinymce.walk(o, f, n, s);
\r
280 createNS : function(n, o) {
\r
286 for (i=0; i<n.length; i++) {
\r
298 resolve : function(n, o) {
\r
304 for (i=0, l = n.length; i<l; i++) {
\r
314 addUnload : function(f, s) {
\r
315 var t = this, w = window;
\r
317 f = {func : f, scope : s || this};
\r
320 function unload() {
\r
321 var li = t.unloads, o, n;
\r
324 // Call unload handlers
\r
329 o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
\r
332 // Detach unload function
\r
333 if (w.detachEvent) {
\r
334 w.detachEvent('onbeforeunload', fakeUnload);
\r
335 w.detachEvent('onunload', unload);
\r
336 } else if (w.removeEventListener)
\r
337 w.removeEventListener('unload', unload, false);
\r
339 // Destroy references
\r
340 t.unloads = o = li = w = unload = null;
\r
342 // Run garbarge collector on IE
\r
343 if (window.CollectGarbage)
\r
344 window.CollectGarbage();
\r
348 function fakeUnload() {
\r
351 // Is there things still loading, then do some magic
\r
352 if (d.readyState == 'interactive') {
\r
354 // Prevent memory leak
\r
355 d.detachEvent('onstop', stop);
\r
357 // Call unload handler
\r
363 // Fire unload when the currently loading page is stopped
\r
364 d.attachEvent('onstop', stop);
\r
366 // Remove onstop listener after a while to prevent the unload function
\r
367 // to execute if the user presses cancel in an onbeforeunload
\r
368 // confirm dialog and then presses the browser stop button
\r
369 window.setTimeout(function() {
\r
370 d.detachEvent('onstop', stop);
\r
375 // Attach unload handler
\r
376 if (w.attachEvent) {
\r
377 w.attachEvent('onunload', unload);
\r
378 w.attachEvent('onbeforeunload', fakeUnload);
\r
379 } else if (w.addEventListener)
\r
380 w.addEventListener('unload', unload, false);
\r
382 // Setup initial unload handler array
\r
390 removeUnload : function(f) {
\r
391 var u = this.unloads, r = null;
\r
393 tinymce.each(u, function(o, i) {
\r
394 if (o && o.func == f) {
\r
404 explode : function(s, d) {
\r
405 return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s;
\r
408 _addVer : function(u) {
\r
414 v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
\r
416 if (u.indexOf('#') == -1)
\r
419 return u.replace('#', v + '#');
\r
424 // Required for GZip AJAX loading
\r
425 window.tinymce = tinymce;
\r
427 // Initialize the API
\r
430 /* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */
\r
433 /* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */
\r
436 /* file:jscripts/tiny_mce/classes/util/Dispatcher.js */
\r
438 tinymce.create('tinymce.util.Dispatcher', {
\r
442 Dispatcher : function(s) {
\r
443 this.scope = s || this;
\r
444 this.listeners = [];
\r
447 add : function(cb, s) {
\r
448 this.listeners.push({cb : cb, scope : s || this.scope});
\r
453 addToTop : function(cb, s) {
\r
454 this.listeners.unshift({cb : cb, scope : s || this.scope});
\r
459 remove : function(cb) {
\r
460 var l = this.listeners, o = null;
\r
462 tinymce.each(l, function(c, i) {
\r
473 dispatch : function() {
\r
474 var s, a = arguments, i, li = this.listeners, c;
\r
476 // Needs to be a real loop since the listener count might change while looping
\r
477 // And this is also more efficient
\r
478 for (i = 0; i<li.length; i++) {
\r
480 s = c.cb.apply(c.scope, a);
\r
491 /* file:jscripts/tiny_mce/classes/util/URI.js */
\r
494 var each = tinymce.each;
\r
496 tinymce.create('tinymce.util.URI', {
\r
497 URI : function(u, s) {
\r
498 var t = this, o, a, b;
\r
500 // Default settings
\r
501 s = t.settings = s || {};
\r
503 // Strange app protocol or local anchor
\r
504 if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
\r
509 // Absolute path with no host, fake host and protocol
\r
510 if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
\r
511 u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
\r
514 if (u.indexOf('://') === -1 && u.indexOf('//') !== 0)
\r
515 u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u);
\r
517 // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
\r
518 u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
\r
519 u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
\r
520 each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
\r
523 // Zope 3 workaround, they use @@something
\r
525 s = s.replace(/\(mce_at\)/g, '@@');
\r
530 if (b = s.base_uri) {
\r
532 t.protocol = b.protocol;
\r
535 t.userInfo = b.userInfo;
\r
537 if (!t.port && t.host == 'mce_host')
\r
540 if (!t.host || t.host == 'mce_host')
\r
546 //t.path = t.path || '/';
\r
549 setPath : function(p) {
\r
552 p = /^(.*?)\/?(\w+)?$/.exec(p);
\r
554 // Update path parts
\r
556 t.directory = p[1];
\r
564 toRelative : function(u) {
\r
567 u = new tinymce.util.URI(u, {base_uri : t});
\r
569 // Not on same domain/port or protocol
\r
570 if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
\r
573 o = t.toRelPath(t.path, u.path);
\r
577 o += '?' + u.query;
\r
581 o += '#' + u.anchor;
\r
586 toAbsolute : function(u, nh) {
\r
587 var u = new tinymce.util.URI(u, {base_uri : this});
\r
589 return u.getURI(this.host == u.host ? nh : 0);
\r
592 toRelPath : function(base, path) {
\r
593 var items, bp = 0, out = '', i;
\r
596 base = base.substring(0, base.lastIndexOf('/'));
\r
597 base = base.split('/');
\r
598 items = path.split('/');
\r
600 if (base.length >= items.length) {
\r
601 for (i = 0; i < base.length; i++) {
\r
602 if (i >= items.length || base[i] != items[i]) {
\r
609 if (base.length < items.length) {
\r
610 for (i = 0; i < items.length; i++) {
\r
611 if (i >= base.length || base[i] != items[i]) {
\r
621 for (i = 0; i < base.length - (bp - 1); i++)
\r
624 for (i = bp - 1; i < items.length; i++) {
\r
626 out += "/" + items[i];
\r
634 toAbsPath : function(base, path) {
\r
635 var i, nb = 0, o = [];
\r
638 base = base.split('/');
\r
639 path = path.split('/');
\r
641 // Remove empty chunks
\r
642 each(base, function(k) {
\r
649 // Merge relURLParts chunks
\r
650 for (i = path.length - 1, o = []; i >= 0; i--) {
\r
651 // Ignore empty or .
\r
652 if (path[i].length == 0 || path[i] == ".")
\r
656 if (path[i] == '..') {
\r
670 i = base.length - nb;
\r
674 return '/' + o.reverse().join('/');
\r
676 return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
\r
679 getURI : function(nh) {
\r
683 if (!t.source || nh) {
\r
688 s += t.protocol + '://';
\r
691 s += t.userInfo + '@';
\r
704 s += '?' + t.query;
\r
707 s += '#' + t.anchor;
\r
718 /* file:jscripts/tiny_mce/classes/util/Cookie.js */
\r
721 var each = tinymce.each;
\r
723 tinymce.create('static tinymce.util.Cookie', {
\r
724 getHash : function(n) {
\r
725 var v = this.get(n), h;
\r
728 each(v.split('&'), function(v) {
\r
731 h[unescape(v[0])] = unescape(v[1]);
\r
738 setHash : function(n, v, e, p, d, s) {
\r
741 each(v, function(v, k) {
\r
742 o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
\r
745 this.set(n, o, e, p, d, s);
\r
748 get : function(n) {
\r
749 var c = document.cookie, e, p = n + "=", b;
\r
755 b = c.indexOf("; " + p);
\r
765 e = c.indexOf(";", b);
\r
770 return unescape(c.substring(b + p.length, e));
\r
773 set : function(n, v, e, p, d, s) {
\r
774 document.cookie = n + "=" + escape(v) +
\r
775 ((e) ? "; expires=" + e.toGMTString() : "") +
\r
776 ((p) ? "; path=" + escape(p) : "") +
\r
777 ((d) ? "; domain=" + d : "") +
\r
778 ((s) ? "; secure" : "");
\r
781 remove : function(n, p) {
\r
782 var d = new Date();
\r
784 d.setTime(d.getTime() - 1000);
\r
786 this.set(n, '', d, p, d);
\r
792 /* file:jscripts/tiny_mce/classes/util/JSON.js */
\r
794 tinymce.create('static tinymce.util.JSON', {
\r
795 serialize : function(o) {
\r
796 var i, v, s = tinymce.util.JSON.serialize, t;
\r
803 if (t == 'string') {
\r
804 v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
\r
806 return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'])/g, function(a, b) {
\r
810 return '\\' + v.charAt(i + 1);
\r
812 a = b.charCodeAt().toString(16);
\r
814 return '\\u' + '0000'.substring(a.length) + a;
\r
818 if (t == 'object') {
\r
819 if (o instanceof Array) {
\r
820 for (i=0, v = '['; i<o.length; i++)
\r
821 v += (i > 0 ? ',' : '') + s(o[i]);
\r
829 v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
\r
837 parse : function(s) {
\r
839 return eval('(' + s + ')');
\r
847 /* file:jscripts/tiny_mce/classes/util/XHR.js */
\r
849 tinymce.create('static tinymce.util.XHR', {
\r
850 send : function(o) {
\r
851 var x, t, w = window, c = 0;
\r
853 // Default settings
\r
854 o.scope = o.scope || this;
\r
855 o.success_scope = o.success_scope || o.scope;
\r
856 o.error_scope = o.error_scope || o.scope;
\r
857 o.async = o.async === false ? false : true;
\r
858 o.data = o.data || '';
\r
864 x = new ActiveXObject(s);
\r
871 x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
\r
874 if (x.overrideMimeType)
\r
875 x.overrideMimeType(o.content_type);
\r
877 x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
\r
879 if (o.content_type)
\r
880 x.setRequestHeader('Content-Type', o.content_type);
\r
885 if (!o.async || x.readyState == 4 || c++ > 10000) {
\r
886 if (o.success && c < 10000 && x.status == 200)
\r
887 o.success.call(o.success_scope, '' + x.responseText, x, o);
\r
889 o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
\r
893 w.setTimeout(ready, 10);
\r
896 // Syncronous request
\r
900 // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
\r
901 t = w.setTimeout(ready, 10);
\r
907 /* file:jscripts/tiny_mce/classes/util/JSONRequest.js */
\r
910 var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
\r
912 tinymce.create('tinymce.util.JSONRequest', {
\r
913 JSONRequest : function(s) {
\r
914 this.settings = extend({
\r
919 send : function(o) {
\r
920 var ecb = o.error, scb = o.success;
\r
922 o = extend(this.settings, o);
\r
924 o.success = function(c, x) {
\r
927 if (typeof(c) == 'undefined') {
\r
929 error : 'JSON Parse error.'
\r
934 ecb.call(o.error_scope || o.scope, c.error, x);
\r
936 scb.call(o.success_scope || o.scope, c.result);
\r
939 o.error = function(ty, x) {
\r
940 ecb.call(o.error_scope || o.scope, ty, x);
\r
943 o.data = JSON.serialize({
\r
944 id : o.id || 'c' + (this.count++),
\r
949 // JSON content type for Ruby on rails. Bug: #1883287
\r
950 o.content_type = 'application/json';
\r
956 sendRPC : function(o) {
\r
957 return new tinymce.util.JSONRequest().send(o);
\r
963 /* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */
\r
967 var each = tinymce.each, is = tinymce.is;
\r
968 var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE;
\r
970 tinymce.create('tinymce.dom.DOMUtils', {
\r
975 pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/,
\r
977 idPattern : /^#[\w]+$/,
\r
978 elmPattern : /^[\w_*]+$/,
\r
979 elmClassPattern : /^([\w_]*)\.([\w_]+)$/,
\r
981 DOMUtils : function(d, s) {
\r
987 t.cssFlicker = false;
\r
989 t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat";
\r
990 t.stdMode = d.documentMode === 8;
\r
992 this.settings = s = tinymce.extend({
\r
993 keep_values : false,
\r
998 // Fix IE6SP2 flicker and check it failed for pre SP2
\r
999 if (tinymce.isIE6) {
\r
1001 d.execCommand('BackgroundImageCache', false, true);
\r
1003 t.cssFlicker = true;
\r
1007 tinymce.addUnload(t.destroy, t);
\r
1010 getRoot : function() {
\r
1011 var t = this, s = t.settings;
\r
1013 return (s && t.get(s.root_element)) || t.doc.body;
\r
1016 getViewPort : function(w) {
\r
1019 w = !w ? this.win : w;
\r
1021 b = this.boxModel ? d.documentElement : d.body;
\r
1023 // Returns viewport size excluding scrollbars
\r
1025 x : w.pageXOffset || b.scrollLeft,
\r
1026 y : w.pageYOffset || b.scrollTop,
\r
1027 w : w.innerWidth || b.clientWidth,
\r
1028 h : w.innerHeight || b.clientHeight
\r
1032 getRect : function(e) {
\r
1033 var p, t = this, w, h;
\r
1037 w = t.getStyle(e, 'width');
\r
1038 h = t.getStyle(e, 'height');
\r
1040 // Non pixel value, then force offset/clientWidth
\r
1041 if (w.indexOf('px') === -1)
\r
1044 // Non pixel value, then force offset/clientWidth
\r
1045 if (h.indexOf('px') === -1)
\r
1051 w : parseInt(w) || e.offsetWidth || e.clientWidth,
\r
1052 h : parseInt(h) || e.offsetHeight || e.clientHeight
\r
1056 getParent : function(n, f, r) {
\r
1057 var na, se = this.settings;
\r
1061 if (se.strict_root)
\r
1062 r = r || this.getRoot();
\r
1064 // Wrap node name as func
\r
1065 if (is(f, 'string')) {
\r
1066 na = f.toUpperCase();
\r
1072 if (n.nodeType == 1 && na === '*') {
\r
1077 each(na.split(','), function(v) {
\r
1078 if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName.toUpperCase() == v)) {
\r
1080 return false; // Break loop
\r
1101 get : function(e) {
\r
1104 if (e && this.doc && typeof(e) == 'string') {
\r
1106 e = this.doc.getElementById(e);
\r
1108 // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick
\r
1109 if (e && e.id !== n)
\r
1110 return this.doc.getElementsByName(n)[1];
\r
1118 select : function(pa, s) {
\r
1119 var t = this, cs, c, pl, o = [], x, i, l, n;
\r
1121 s = t.get(s) || t.doc;
\r
1123 // Look for native support and use that if it's found
\r
1124 if (s.querySelectorAll) {
\r
1125 // Element scope then use temp id
\r
1126 // We need to do this to be compatible with other implementations
\r
1127 // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461
\r
1131 pa = '#_mc_tmp ' + pa;
\r
1134 // Select elements
\r
1135 l = tinymce.grep(s.querySelectorAll(pa));
\r
1143 if (t.settings.strict) {
\r
1144 function get(s, n) {
\r
1145 return s.getElementsByTagName(n.toLowerCase());
\r
1148 function get(s, n) {
\r
1149 return s.getElementsByTagName(n);
\r
1153 // Simple element pattern. For example: "p" or "*"
\r
1154 if (t.elmPattern.test(pa)) {
\r
1157 for (i = 0, l = x.length; i<l; i++)
\r
1163 // Simple class pattern. For example: "p.class" or ".class"
\r
1164 if (t.elmClassPattern.test(pa)) {
\r
1165 pl = t.elmClassPattern.exec(pa);
\r
1166 x = get(s, pl[1] || '*');
\r
1167 c = ' ' + pl[2] + ' ';
\r
1169 for (i = 0, l = x.length; i<l; i++) {
\r
1172 if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
\r
1179 function collect(n) {
\r
1180 if (!n.mce_save) {
\r
1186 function collectIE(n) {
\r
1187 if (!n.getAttribute('mce_save')) {
\r
1188 n.setAttribute('mce_save', '1');
\r
1193 function find(n, f, r) {
\r
1194 var i, l, nl = get(r, n);
\r
1196 for (i = 0, l = nl.length; i < l; i++)
\r
1200 each(pa.split(','), function(v, i) {
\r
1201 v = tinymce.trim(v);
\r
1203 // Simple element pattern, most common in TinyMCE
\r
1204 if (t.elmPattern.test(v)) {
\r
1205 each(get(s, v), function(n) {
\r
1212 // Simple element pattern with class, fairly common in TinyMCE
\r
1213 if (t.elmClassPattern.test(v)) {
\r
1214 x = t.elmClassPattern.exec(v);
\r
1216 each(get(s, x[1]), function(n) {
\r
1217 if (t.hasClass(n, x[2]))
\r
1224 if (!(cs = t.cache[pa])) {
\r
1225 cs = 'x=(function(cf, s) {';
\r
1226 pl = v.split(' ');
\r
1228 each(pl, function(v) {
\r
1229 var p = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i.exec(v);
\r
1232 p[1] = p[1] || '*';
\r
1233 cs += 'find("' + p[1] + '", function(n) {';
\r
1237 cs += 'if (n.id !== "' + p[2] + '") return;';
\r
1241 cs += 'var c = " " + n.className + " ";';
\r
1244 each(p[3].split('.'), function(v) {
\r
1246 c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
\r
1248 cs += c + ') return;';
\r
1254 for (i = pl.length - 1; i >= 0; i--)
\r
1255 cs += '}, ' + (i ? 'n' : 's') + ');';
\r
1259 // Compile CSS pattern function
\r
1260 t.cache[pa] = cs = eval(cs);
\r
1263 // Run selector function
\r
1264 cs(isIE ? collectIE : collect, s);
\r
1268 each(o, function(n) {
\r
1270 n.removeAttribute('mce_save');
\r
1272 delete n.mce_save;
\r
1280 add : function(p, n, a, h, c) {
\r
1283 return this.run(p, function(p) {
\r
1286 e = is(n, 'string') ? t.doc.createElement(n) : n;
\r
1290 if (a.hasOwnProperty(k) && !is(a[k], 'object'))
\r
1291 t.setAttrib(e, k, '' + a[k]);
\r
1294 if (a.style && !is(a.style, 'string')) {
\r
1295 each(a.style, function(v, n) {
\r
1296 t.setStyle(e, n, v);
\r
1308 return !c ? p.appendChild(e) : e;
\r
1312 create : function(n, a, h) {
\r
1313 return this.add(this.doc.createElement(n), n, a, h, 1);
\r
1316 createHTML : function(n, a, h) {
\r
1317 var o = '', t = this, k;
\r
1322 if (a.hasOwnProperty(k))
\r
1323 o += ' ' + k + '="' + t.encode(a[k]) + '"';
\r
1326 if (tinymce.is(h))
\r
1327 return o + '>' + h + '</' + n + '>';
\r
1332 remove : function(n, k) {
\r
1333 return this.run(n, function(n) {
\r
1342 each (n.childNodes, function(c) {
\r
1343 p.insertBefore(c.cloneNode(true), n);
\r
1347 // Fix IE psuedo leak
\r
1349 p = n.cloneNode(true);
\r
1355 return p.removeChild(n);
\r
1361 setStyle : function(n, na, v) {
\r
1364 return t.run(n, function(e) {
\r
1369 // Camelcase it, if needed
\r
1370 na = na.replace(/-(\D)/g, function(a, b){
\r
1371 return b.toUpperCase();
\r
1374 // Default px suffix on these
\r
1375 if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v)))
\r
1380 // IE specific opacity
\r
1382 s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")";
\r
1384 if (!n.currentStyle || !n.currentStyle.hasLayout)
\r
1385 s.display = 'inline-block';
\r
1388 // Fix for older browsers
\r
1389 s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || '';
\r
1393 isIE ? s.styleFloat = v : s.cssFloat = v;
\r
1400 // Force update of the style data
\r
1401 if (t.settings.update_styles)
\r
1402 t.setAttrib(e, 'mce_style');
\r
1406 getStyle : function(n, na, c) {
\r
1413 if (this.doc.defaultView && c) {
\r
1414 // Remove camelcase
\r
1415 na = na.replace(/[A-Z]/g, function(a){
\r
1420 return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na);
\r
1422 // Old safari might fail
\r
1427 // Camelcase it, if needed
\r
1428 na = na.replace(/-(\D)/g, function(a, b){
\r
1429 return b.toUpperCase();
\r
1432 if (na == 'float')
\r
1433 na = isIE ? 'styleFloat' : 'cssFloat';
\r
1436 if (n.currentStyle && c)
\r
1437 return n.currentStyle[na];
\r
1439 return n.style[na];
\r
1442 setStyles : function(e, o) {
\r
1443 var t = this, s = t.settings, ol;
\r
1445 ol = s.update_styles;
\r
1446 s.update_styles = 0;
\r
1448 each(o, function(v, n) {
\r
1449 t.setStyle(e, n, v);
\r
1452 // Update style info
\r
1453 s.update_styles = ol;
\r
1454 if (s.update_styles)
\r
1455 t.setAttrib(e, s.cssText);
\r
1458 setAttrib : function(e, n, v) {
\r
1461 // Strict XML mode
\r
1462 if (t.settings.strict)
\r
1463 n = n.toLowerCase();
\r
1465 return this.run(e, function(e) {
\r
1466 var s = t.settings;
\r
1470 // No mce_style for elements with these since they might get resized by the user
\r
1471 if (s.keep_values) {
\r
1472 if (v && !t._isRes(v))
\r
1473 e.setAttribute('mce_style', v, 2);
\r
1475 e.removeAttribute('mce_style', 2);
\r
1478 e.style.cssText = v;
\r
1482 e.className = v || ''; // Fix IE null bug
\r
1487 if (s.keep_values) {
\r
1488 if (s.url_converter)
\r
1489 v = s.url_converter.call(s.url_converter_scope || t, v, n, e);
\r
1491 t.setAttrib(e, 'mce_' + n, v, 2);
\r
1497 e.setAttribute('mce_style', v);
\r
1501 if (is(v) && v !== null && v.length !== 0)
\r
1502 e.setAttribute(n, '' + v, 2);
\r
1504 e.removeAttribute(n, 2);
\r
1508 setAttribs : function(e, o) {
\r
1511 return this.run(e, function(e) {
\r
1512 each(o, function(v, n) {
\r
1513 t.setAttrib(e, n, v);
\r
1520 getAttrib : function(e, n, dv) {
\r
1525 if (!e || e.nodeType !== 1)
\r
1531 // Try the mce variant for these
\r
1532 if (/^(src|href|style|coords|shape)$/.test(n)) {
\r
1533 v = e.getAttribute("mce_" + n);
\r
1539 v = e.getAttribute(n, 2);
\r
1548 // Fix for IE crash Bug: #1884376 probably due to invalid DOM structure
\r
1549 if (isIE && n === 'name' && e.nodeName === 'A') {
\r
1554 v = e.attributes[n];
\r
1555 v = v && is(v.nodeValue) ? v.nodeValue : v;
\r
1561 v = v || e.style.cssText;
\r
1564 v = t.serializeStyle(t.parseStyle(v));
\r
1566 if (t.settings.keep_values && !t._isRes(v))
\r
1567 e.setAttribute('mce_style', v);
\r
1573 // Remove Apple and WebKit stuff
\r
1574 if (isWebKit && n === "class" && v)
\r
1575 v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, '');
\r
1577 // Handle IE issues
\r
1582 // IE returns 1 as default value
\r
1589 // IE returns +0 as default value for size
\r
1596 // IE returns -1 as default value
\r
1603 // IE returns default value
\r
1610 // IE returns default value
\r
1611 if (v === 2147483647)
\r
1617 v = v.toLowerCase();
\r
1621 // IE has odd anonymous function for event attributes
\r
1622 if (n.indexOf('on') === 0 && v)
\r
1623 v = ('' + v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/, '$1');
\r
1627 return (v && v != '') ? '' + v : dv;
\r
1630 getPos : function(n) {
\r
1631 var t = this, x = 0, y = 0, e, d = t.doc, r;
\r
1635 // Use getBoundingClientRect on IE, Opera has it but it's not perfect
\r
1637 n = n.getBoundingClientRect();
\r
1638 e = t.boxModel ? d.documentElement : d.body;
\r
1639 x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
\r
1640 x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
\r
1641 n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
\r
1643 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
\r
1648 x += r.offsetLeft || 0;
\r
1649 y += r.offsetTop || 0;
\r
1650 r = r.offsetParent;
\r
1655 // Opera 9.25 bug fix, fixed in 9.50
\r
1656 if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
\r
1657 x -= r.scrollLeft || 0;
\r
1658 y -= r.scrollTop || 0;
\r
1667 return {x : x, y : y};
\r
1670 parseStyle : function(st) {
\r
1671 var t = this, s = t.settings, o = {};
\r
1676 function compress(p, s, ot) {
\r
1679 // Get values and check it it needs compressing
\r
1680 t = o[p + '-top' + s];
\r
1684 r = o[p + '-right' + s];
\r
1688 b = o[p + '-bottom' + s];
\r
1692 l = o[p + '-left' + s];
\r
1698 delete o[p + '-top' + s];
\r
1699 delete o[p + '-right' + s];
\r
1700 delete o[p + '-bottom' + s];
\r
1701 delete o[p + '-left' + s];
\r
1704 function compress2(ta, a, b, c) {
\r
1720 o[ta] = o[a] + ' ' + o[b] + ' ' + o[c];
\r
1726 st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities
\r
1728 each(st.split(';'), function(v) {
\r
1732 v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities
\r
1733 v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
\r
1735 sv = tinymce.trim(v[1]);
\r
1736 sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];});
\r
1738 sv = sv.replace(/rgb\([^\)]+\)/g, function(v) {
\r
1739 return t.toHex(v);
\r
1742 if (s.url_converter) {
\r
1743 sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
\r
1744 return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')';
\r
1748 o[tinymce.trim(v[0]).toLowerCase()] = sv;
\r
1752 compress("border", "", "border");
\r
1753 compress("border", "-width", "border-width");
\r
1754 compress("border", "-color", "border-color");
\r
1755 compress("border", "-style", "border-style");
\r
1756 compress("padding", "", "padding");
\r
1757 compress("margin", "", "margin");
\r
1758 compress2('border', 'border-width', 'border-style', 'border-color');
\r
1761 // Remove pointless border
\r
1762 if (o.border == 'medium none')
\r
1769 serializeStyle : function(o) {
\r
1772 each(o, function(v, k) {
\r
1774 if (tinymce.isGecko && k.indexOf('-moz-') === 0)
\r
1779 case 'background-color':
\r
1780 v = v.toLowerCase();
\r
1784 s += (s ? ' ' : '') + k + ': ' + v + ';';
\r
1791 loadCSS : function(u) {
\r
1792 var t = this, d = t.doc;
\r
1797 each(u.split(','), function(u) {
\r
1801 t.files[u] = true;
\r
1802 t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
\r
1808 addClass : function(e, c) {
\r
1809 return this.run(e, function(e) {
\r
1815 if (this.hasClass(e, c))
\r
1816 return e.className;
\r
1818 o = this.removeClass(e, c);
\r
1820 return e.className = (o != '' ? (o + ' ') : '') + c;
\r
1824 removeClass : function(e, c) {
\r
1827 return t.run(e, function(e) {
\r
1830 if (t.hasClass(e, c)) {
\r
1832 re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
\r
1834 v = e.className.replace(re, ' ');
\r
1836 return e.className = tinymce.trim(v != ' ' ? v : '');
\r
1839 return e.className;
\r
1843 hasClass : function(n, c) {
\r
1849 return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1;
\r
1852 show : function(e) {
\r
1853 return this.setStyle(e, 'display', 'block');
\r
1856 hide : function(e) {
\r
1857 return this.setStyle(e, 'display', 'none');
\r
1860 isHidden : function(e) {
\r
1863 return e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
\r
1868 uniqueId : function(p) {
\r
1869 return (!p ? 'mce_' : p) + (this.counter++);
\r
1872 setHTML : function(e, h) {
\r
1875 return this.run(e, function(e) {
\r
1876 var x, i, nl, n, p, x;
\r
1878 h = t.processHTML(h);
\r
1883 // IE will remove comments from the beginning
\r
1884 // unless you padd the contents with something
\r
1885 e.innerHTML = '<br />' + h;
\r
1886 e.removeChild(e.firstChild);
\r
1888 // IE sometimes produces an unknown runtime error on innerHTML if it's an block element within a block element for example a div inside a p
\r
1889 // This seems to fix this problem
\r
1891 // Remove all child nodes
\r
1892 while (e.firstChild)
\r
1893 e.firstChild.removeNode();
\r
1895 // Create new div with HTML contents and a BR infront to keep comments
\r
1896 x = t.create('div');
\r
1897 x.innerHTML = '<br />' + h;
\r
1899 // Add all children from div to target
\r
1900 each (x.childNodes, function(n, i) {
\r
1901 // Skip br element
\r
1908 // IE has a serious bug when it comes to paragraphs it can produce an invalid
\r
1909 // DOM tree if contents like this <p><ul><li>Item 1</li></ul></p> is inserted
\r
1910 // It seems to be that IE doesn't like a root block element placed inside another root block element
\r
1911 if (t.settings.fix_ie_paragraphs)
\r
1912 h = h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi, '<p$1 mce_keep="true"> </p>');
\r
1916 if (t.settings.fix_ie_paragraphs) {
\r
1917 // Check for odd paragraphs this is a sign of a broken DOM
\r
1918 nl = e.getElementsByTagName("p");
\r
1919 for (i = nl.length - 1, x = 0; i >= 0; i--) {
\r
1922 if (!n.hasChildNodes()) {
\r
1923 if (!n.mce_keep) {
\r
1924 x = 1; // Is broken
\r
1928 n.removeAttribute('mce_keep');
\r
1933 // Time to fix the madness IE left us
\r
1935 // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
\r
1936 // after we use innerHTML we can fix the DOM tree
\r
1937 h = h.replace(/<p([^>]+)>|<p>/g, '<div$1 mce_tmp="1">');
\r
1938 h = h.replace(/<\/p>/g, '</div>');
\r
1940 // Set the new HTML with DIVs
\r
1943 // Replace all DIV elements with he mce_tmp attibute back to paragraphs
\r
1944 // This is needed since IE has a annoying bug see above for details
\r
1945 // This is a slow process but it has to be done. :(
\r
1946 if (t.settings.fix_ie_paragraphs) {
\r
1947 nl = e.getElementsByTagName("DIV");
\r
1948 for (i = nl.length - 1; i >= 0; i--) {
\r
1951 // Is it a temp div
\r
1953 // Create new paragraph
\r
1954 p = t.doc.createElement('p');
\r
1956 // Copy all attributes
\r
1957 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
\r
1960 if (b !== 'mce_tmp') {
\r
1961 v = n.getAttribute(b);
\r
1963 if (!v && b === 'class')
\r
1966 p.setAttribute(b, v);
\r
1970 // Append all children to new paragraph
\r
1971 for (x = 0; x<n.childNodes.length; x++)
\r
1972 p.appendChild(n.childNodes[x].cloneNode(true));
\r
1974 // Replace div with new paragraph
\r
1987 processHTML : function(h) {
\r
1988 var t = this, s = t.settings;
\r
1990 if (!s.process_html)
\r
1993 // Convert strong and em to b and i in FF since it can't handle them
\r
1994 if (tinymce.isGecko) {
\r
1995 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
\r
1996 h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
\r
1998 h = h.replace(/'/g, '''); // IE can't handle apos
\r
2000 // Fix some issues
\r
2001 h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open
\r
2003 // Store away src and href in mce_src and mce_href since browsers mess them up
\r
2004 if (s.keep_values) {
\r
2005 // Wrap scripts and styles in comments for serialization purposes
\r
2006 if (/<script|style/.test(h)) {
\r
2007 function trim(s) {
\r
2008 // Remove prefix and suffix code for element
\r
2009 s = s.replace(/^[\r\n]*|[\r\n]*$/g, '');
\r
2010 s = s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<\[CDATA\[|<!--|<\[CDATA\[)[\r\n]*/g, '');
\r
2011 s = s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->)\s*$/g, '');
\r
2016 // Preserve script elements
\r
2017 h = h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g, function(v, a, b) {
\r
2018 // Remove prefix and suffix code for script element
\r
2021 // Force type attribute
\r
2023 a = ' type="text/javascript"';
\r
2025 // Wrap contents in a comment
\r
2027 b = '<!--\n' + b + '\n// -->';
\r
2029 // Output fake element
\r
2030 return '<mce:script' + a + '>' + b + '</mce:script>';
\r
2033 // Preserve style elements
\r
2034 h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g, function(v, a, b) {
\r
2036 return '<mce:style' + a + '><!--\n' + b + '\n--></mce:style><style' + a + ' mce_bogus="1">' + b + '</style>';
\r
2040 // Process all tags with src, href or style
\r
2041 h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
\r
2042 function handle(m, b, c) {
\r
2045 // Tag already got a mce_ version
\r
2046 if (a.indexOf('mce_' + b) != -1)
\r
2049 if (b == 'style') {
\r
2050 // Why did I need this one?
\r
2052 // u = t.serializeStyle(t.parseStyle(u));
\r
2054 // No mce_style for elements with these since they might get resized by the user
\r
2058 if (s.hex_colors) {
\r
2059 u = u.replace(/rgb\([^\)]+\)/g, function(v) {
\r
2060 return t.toHex(v);
\r
2064 if (s.url_converter) {
\r
2065 u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
\r
2066 return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
\r
2069 } else if (b != 'coords' && b != 'shape') {
\r
2070 if (s.url_converter)
\r
2071 u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
\r
2074 return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
\r
2077 a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C
\r
2078 a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C
\r
2080 return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
\r
2087 getOuterHTML : function(e) {
\r
2096 return e.outerHTML;
\r
2098 d = (e.ownerDocument || this.doc).createElement("body");
\r
2099 d.appendChild(e.cloneNode(true));
\r
2101 return d.innerHTML;
\r
2104 setOuterHTML : function(e, h, d) {
\r
2107 return this.run(e, function(e) {
\r
2111 d = d || e.ownerDocument || t.doc;
\r
2113 if (isIE && e.nodeType == 1)
\r
2116 tp = d.createElement("body");
\r
2121 t.insertAfter(n.cloneNode(true), e);
\r
2122 n = n.previousSibling;
\r
2130 decode : function(s) {
\r
2133 // Look for entities to decode
\r
2134 if (/&[^;]+;/.test(s)) {
\r
2135 // Decode the entities using a div element not super efficient but less code
\r
2136 e = this.doc.createElement("div");
\r
2139 return !e.firstChild ? s : e.firstChild.nodeValue;
\r
2145 encode : function(s) {
\r
2146 return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
\r
2167 insertAfter : function(n, r) {
\r
2172 return this.run(n, function(n) {
\r
2176 ns = r.nextSibling;
\r
2179 p.insertBefore(n, ns);
\r
2189 isBlock : function(n) {
\r
2190 if (n.nodeType && n.nodeType !== 1)
\r
2193 n = n.nodeName || n;
\r
2195 return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
\r
2200 replace : function(n, o, k) {
\r
2201 if (is(o, 'array'))
\r
2202 n = n.cloneNode(true);
\r
2204 return this.run(o, function(o) {
\r
2206 each(o.childNodes, function(c) {
\r
2207 n.appendChild(c.cloneNode(true));
\r
2211 // Fix IE psuedo leak for elements since replacing elements if fairly common
\r
2212 // Will break parentNode for some unknown reason
\r
2213 /* if (isIE && o.nodeType === 1) {
\r
2214 o.parentNode.insertBefore(n, o);
\r
2219 return o.parentNode.replaceChild(n, o);
\r
2225 toHex : function(s) {
\r
2226 var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
\r
2229 s = parseInt(s).toString(16);
\r
2231 return s.length > 1 ? s : '0' + s; // 0 -> 00
\r
2235 s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
\r
2243 getClasses : function() {
\r
2244 var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
\r
2249 function addClasses(s) {
\r
2250 // IE style imports
\r
2251 each(s.imports, function(r) {
\r
2255 each(s.cssRules || s.rules, function(r) {
\r
2256 // Real type or fake it on IE
\r
2257 switch (r.type || 1) {
\r
2260 if (r.selectorText) {
\r
2261 each(r.selectorText.split(','), function(v) {
\r
2262 v = v.replace(/^\s*|\s*$|^\s\./g, "");
\r
2264 // Is internal or it doesn't contain a class
\r
2265 if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v))
\r
2268 // Remove everything but class name
\r
2270 v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1');
\r
2273 if (f && !(v = f(v, ov)))
\r
2277 cl.push({'class' : v});
\r
2286 addClasses(r.styleSheet);
\r
2293 each(t.doc.styleSheets, addClasses);
\r
2298 if (cl.length > 0)
\r
2304 run : function(e, f, s) {
\r
2307 if (t.doc && typeof(e) === 'string')
\r
2308 e = t.doc.getElementById(e);
\r
2314 if (!e.nodeType && (e.length || e.length === 0)) {
\r
2317 each(e, function(e, i) {
\r
2319 if (typeof(e) == 'string')
\r
2320 e = t.doc.getElementById(e);
\r
2322 o.push(f.call(s, e, i));
\r
2329 return f.call(s, e);
\r
2332 getAttribs : function(n) {
\r
2343 // Object will throw exception in IE
\r
2344 if (n.nodeName == 'OBJECT')
\r
2345 return n.attributes;
\r
2347 // It's crazy that this is faster in IE but it's because it returns all attributes all the time
\r
2348 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
\r
2349 o.push({specified : 1, nodeName : b});
\r
2355 return n.attributes;
\r
2358 destroy : function(s) {
\r
2361 t.win = t.doc = t.root = null;
\r
2363 // Manual destroy then remove unload handler
\r
2365 tinymce.removeUnload(t.destroy);
\r
2368 _isRes : function(c) {
\r
2369 // Is live resizble element
\r
2370 return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c);
\r
2374 walk : function(n, f, s) {
\r
2375 var d = this.doc, w;
\r
2377 if (d.createTreeWalker) {
\r
2378 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
2380 while ((n = w.nextNode()) != null)
\r
2381 f.call(s || this, n);
\r
2383 tinymce.walk(n, f, 'childNodes', s);
\r
2388 toRGB : function(s) {
\r
2389 var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
\r
2392 // #FFF -> #FFFFFF
\r
2394 c[3] = c[2] = c[1];
\r
2396 return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
\r
2406 tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
\r
2409 /* file:jscripts/tiny_mce/classes/dom/Event.js */
\r
2413 var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
\r
2415 tinymce.create('static tinymce.dom.Event', {
\r
2421 add : function(o, n, f, s) {
\r
2422 var cb, t = this, el = t.events, r;
\r
2425 if (o && o instanceof Array) {
\r
2428 each(o, function(o) {
\r
2430 r.push(t.add(o, n, f, s));
\r
2441 // Setup event callback
\r
2442 cb = function(e) {
\r
2443 e = e || window.event;
\r
2445 // Patch in target in IE it's W3C valid
\r
2446 if (e && !e.target && isIE)
\r
2447 e.target = e.srcElement;
\r
2452 return f.call(s, e);
\r
2455 if (n == 'unload') {
\r
2456 tinymce.unloads.unshift({func : cb});
\r
2460 if (n == 'init') {
\r
2469 // Store away listener reference
\r
2483 remove : function(o, n, f) {
\r
2484 var t = this, a = t.events, s = false, r;
\r
2487 if (o && o instanceof Array) {
\r
2490 each(o, function(o) {
\r
2492 r.push(t.remove(o, n, f));
\r
2500 each(a, function(e, i) {
\r
2501 if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
\r
2503 t._remove(o, n, e.cfunc);
\r
2512 clear : function(o) {
\r
2513 var t = this, a = t.events, i, e;
\r
2518 for (i = a.length - 1; i >= 0; i--) {
\r
2521 if (e.obj === o) {
\r
2522 t._remove(e.obj, e.name, e.cfunc);
\r
2523 e.obj = e.cfunc = null;
\r
2532 cancel : function(e) {
\r
2537 return this.prevent(e);
\r
2540 stop : function(e) {
\r
2541 if (e.stopPropagation)
\r
2542 e.stopPropagation();
\r
2544 e.cancelBubble = true;
\r
2549 prevent : function(e) {
\r
2550 if (e.preventDefault)
\r
2551 e.preventDefault();
\r
2553 e.returnValue = false;
\r
2558 _unload : function() {
\r
2561 each(t.events, function(e, i) {
\r
2562 t._remove(e.obj, e.name, e.cfunc);
\r
2563 e.obj = e.cfunc = null;
\r
2570 _add : function(o, n, f) {
\r
2571 if (o.attachEvent)
\r
2572 o.attachEvent('on' + n, f);
\r
2573 else if (o.addEventListener)
\r
2574 o.addEventListener(n, f, false);
\r
2579 _remove : function(o, n, f) {
\r
2582 if (o.detachEvent)
\r
2583 o.detachEvent('on' + n, f);
\r
2584 else if (o.removeEventListener)
\r
2585 o.removeEventListener(n, f, false);
\r
2587 o['on' + n] = null;
\r
2589 // Might fail with permission denined on IE so we just ignore that
\r
2594 _pageInit : function() {
\r
2597 e._remove(window, 'DOMContentLoaded', e._pageInit);
\r
2598 e.domLoaded = true;
\r
2600 each(e.inits, function(c) {
\r
2607 _wait : function() {
\r
2610 // No need since the document is already loaded
\r
2611 if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
\r
2612 Event.domLoaded = 1;
\r
2616 if (isIE && document.location.protocol != 'https:') {
\r
2617 // Fake DOMContentLoaded on IE
\r
2618 document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
\r
2619 DOM.get("__ie_onload").onreadystatechange = function() {
\r
2620 if (this.readyState == "complete") {
\r
2621 Event._pageInit();
\r
2622 DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
\r
2626 Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
\r
2628 if (isIE || isWebKit) {
\r
2629 t = setInterval(function() {
\r
2630 if (/loaded|complete/.test(document.readyState)) {
\r
2632 Event._pageInit();
\r
2642 Event = tinymce.dom.Event;
\r
2644 // Dispatch DOM content loaded event for IE and Safari
\r
2646 tinymce.addUnload(Event._unload);
\r
2649 /* file:jscripts/tiny_mce/classes/dom/Element.js */
\r
2652 var each = tinymce.each;
\r
2654 tinymce.create('tinymce.dom.Element', {
\r
2655 Element : function(id, s) {
\r
2656 var t = this, dom, el;
\r
2660 t.dom = dom = s.dom || tinymce.DOM;
\r
2663 // Only IE leaks DOM references, this is a lot faster
\r
2664 if (!tinymce.isIE)
\r
2665 el = t.dom.get(t.id);
\r
2690 t[k] = function() {
\r
2691 var a = arguments, o;
\r
2694 if (tinymce.isOpera) {
\r
2697 each(arguments, function(v) {
\r
2701 Array.prototype.unshift.call(a, el || id);
\r
2703 o = dom[k].apply(dom, a);
\r
2711 on : function(n, f, s) {
\r
2712 return tinymce.dom.Event.add(this.id, n, f, s);
\r
2715 getXY : function() {
\r
2717 x : parseInt(this.getStyle('left')),
\r
2718 y : parseInt(this.getStyle('top'))
\r
2722 getSize : function() {
\r
2723 var n = this.dom.get(this.id);
\r
2726 w : parseInt(this.getStyle('width') || n.clientWidth),
\r
2727 h : parseInt(this.getStyle('height') || n.clientHeight)
\r
2731 moveTo : function(x, y) {
\r
2732 this.setStyles({left : x, top : y});
\r
2735 moveBy : function(x, y) {
\r
2736 var p = this.getXY();
\r
2738 this.moveTo(p.x + x, p.y + y);
\r
2741 resizeTo : function(w, h) {
\r
2742 this.setStyles({width : w, height : h});
\r
2745 resizeBy : function(w, h) {
\r
2746 var s = this.getSize();
\r
2748 this.resizeTo(s.w + w, s.h + h);
\r
2751 update : function(k) {
\r
2752 var t = this, b, dom = t.dom;
\r
2754 if (tinymce.isIE6 && t.settings.blocker) {
\r
2758 if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0)
\r
2761 // Remove blocker on remove
\r
2762 if (k == 'remove') {
\r
2763 dom.remove(t.blocker);
\r
2768 t.blocker = dom.uniqueId();
\r
2769 b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'});
\r
2770 dom.setStyle(b, 'opacity', 0);
\r
2772 b = dom.get(t.blocker);
\r
2774 dom.setStyle(b, 'left', t.getStyle('left', 1));
\r
2775 dom.setStyle(b, 'top', t.getStyle('top', 1));
\r
2776 dom.setStyle(b, 'width', t.getStyle('width', 1));
\r
2777 dom.setStyle(b, 'height', t.getStyle('height', 1));
\r
2778 dom.setStyle(b, 'display', t.getStyle('display', 1));
\r
2779 dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1);
\r
2786 /* file:jscripts/tiny_mce/classes/dom/Selection.js */
\r
2789 function trimNl(s) {
\r
2790 return s.replace(/[\n\r]+/g, '');
\r
2794 var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each;
\r
2796 tinymce.create('tinymce.dom.Selection', {
\r
2797 Selection : function(dom, win, serializer) {
\r
2802 t.serializer = serializer;
\r
2805 tinymce.addUnload(t.destroy, t);
\r
2808 getContent : function(s) {
\r
2809 var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n;
\r
2814 s.format = s.format || 'html';
\r
2816 if (s.format == 'text')
\r
2817 return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : ''));
\r
2819 if (r.cloneContents) {
\r
2820 n = r.cloneContents();
\r
2824 } else if (is(r.item) || is(r.htmlText))
\r
2825 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
\r
2827 e.innerHTML = r.toString();
\r
2829 // Keep whitespace before and after
\r
2830 if (/^\s/.test(e.innerHTML))
\r
2833 if (/\s+$/.test(e.innerHTML))
\r
2836 s.getInner = true;
\r
2838 return t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
\r
2841 setContent : function(h, s) {
\r
2842 var t = this, r = t.getRng(), d = t.win.document;
\r
2844 s = s || {format : 'html'};
\r
2846 h = t.dom.processHTML(h);
\r
2848 if (r.insertNode) {
\r
2849 // Gecko has a bug where if you insert using InsertHTML it will insert a space instead
\r
2850 // So we simply check if the input is HTML or text and then insert text using the insertNode method
\r
2851 if (tinymce.isGecko && h.indexOf('<') == -1) {
\r
2852 r.deleteContents();
\r
2853 r.insertNode(t.getRng().createContextualFragment(h + '<span id="__caret">_</span>'));
\r
2854 t.select(t.dom.get('__caret'));
\r
2855 t.getRng().deleteContents();
\r
2859 // Use insert HTML if it exists (places cursor after content)
\r
2861 // This might fail with an exception see bug #1893736
\r
2862 if (d.queryCommandEnabled('InsertHTML'))
\r
2863 return d.execCommand('InsertHTML', false, h);
\r
2865 // Use old school method
\r
2866 r.deleteContents();
\r
2867 r.insertNode(t.getRng().createContextualFragment(h));
\r
2871 // Delete content and get caret text selection
\r
2872 d.execCommand('Delete', false, null);
\r
2880 getStart : function() {
\r
2881 var t = this, r = t.getRng(), e;
\r
2887 r = r.duplicate();
\r
2889 e = r.parentElement();
\r
2891 if (e && e.nodeName == 'BODY')
\r
2892 return e.firstChild;
\r
2896 e = r.startContainer;
\r
2898 if (e.nodeName == 'BODY')
\r
2899 return e.firstChild;
\r
2901 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
\r
2905 getEnd : function() {
\r
2906 var t = this, r = t.getRng(), e;
\r
2912 r = r.duplicate();
\r
2914 e = r.parentElement();
\r
2916 if (e && e.nodeName == 'BODY')
\r
2917 return e.lastChild;
\r
2921 e = r.endContainer;
\r
2923 if (e.nodeName == 'BODY')
\r
2924 return e.lastChild;
\r
2926 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
\r
2930 getBookmark : function(si) {
\r
2931 var t = this, r = t.getRng(), tr, sx, sy, vp = t.dom.getViewPort(t.win), e, sp, bp, le, c = -0xFFFFFF, s, ro = t.dom.getRoot(), wb = 0, wa = 0, nv;
\r
2935 // Simple bookmark fast but not as persistent
\r
2936 if (si == 'simple')
\r
2937 return {rng : r, scrollX : sx, scrollY : sy};
\r
2941 // Control selection
\r
2945 each(t.dom.select(e.nodeName), function(n, i) {
\r
2961 tr = t.dom.doc.body.createTextRange();
\r
2962 tr.moveToElementText(ro);
\r
2963 tr.collapse(true);
\r
2964 bp = Math.abs(tr.move('character', c));
\r
2966 tr = r.duplicate();
\r
2967 tr.collapse(true);
\r
2968 sp = Math.abs(tr.move('character', c));
\r
2970 tr = r.duplicate();
\r
2971 tr.collapse(false);
\r
2972 le = Math.abs(tr.move('character', c)) - sp;
\r
2989 // Image selection
\r
2990 if (e && e.nodeName == 'IMG') {
\r
2999 function getPos(r, sn, en) {
\r
3000 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
\r
3002 while ((n = w.nextNode()) != null) {
\r
3011 p += trimNl(n.nodeValue || '').length;
\r
3017 // Caret or selection
\r
3018 if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
\r
3019 e = getPos(ro, s.anchorNode, s.focusNode);
\r
3022 return {scrollX : sx, scrollY : sy};
\r
3024 // Count whitespace before
\r
3025 trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
\r
3028 start : Math.max(e.start + s.anchorOffset - wb, 0),
\r
3029 end : Math.max(e.end + s.focusOffset - wb, 0),
\r
3032 beg : s.anchorOffset - wb == 0
\r
3035 e = getPos(ro, r.startContainer, r.endContainer);
\r
3037 // Count whitespace before start and end container
\r
3038 //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
\r
3039 //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
\r
3042 return {scrollX : sx, scrollY : sy};
\r
3045 start : Math.max(e.start + r.startOffset - wb, 0),
\r
3046 end : Math.max(e.end + r.endOffset - wa, 0),
\r
3049 beg : r.startOffset - wb == 0
\r
3054 moveToBookmark : function(b) {
\r
3055 var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv;
\r
3057 function getPos(r, sp, ep) {
\r
3058 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb;
\r
3060 while ((n = w.nextNode()) != null) {
\r
3063 nv = n.nodeValue || '';
\r
3064 //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
\r
3065 //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
\r
3067 nvl = trimNl(nv).length;
\r
3070 if (p >= sp && !d.startNode) {
\r
3071 o = sp - (p - nvl);
\r
3073 // Fix for odd quirk in FF
\r
3074 if (b.beg && o >= nvl)
\r
3078 d.startOffset = o + wb;
\r
3083 d.endOffset = ep - (p - nvl) + wb;
\r
3094 t.win.scrollTo(b.scrollX, b.scrollY);
\r
3096 // Handle explorer
\r
3111 // Handle control bookmark
\r
3113 r = ro.createControlRange();
\r
3115 each(t.dom.select(b.tag), function(n, i) {
\r
3120 // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
\r
3122 // Incorrect bookmark
\r
3126 r = s.createRange();
\r
3127 r.moveToElementText(ro);
\r
3129 r.moveStart('character', b.start);
\r
3130 r.moveEnd('character', b.length);
\r
3139 // Needed for some odd IE bug #1843306
\r
3151 s.removeAllRanges();
\r
3152 s.addRange(b.rng);
\r
3154 if (is(b.start) && is(b.end)) {
\r
3156 sd = getPos(ro, b.start, b.end);
\r
3159 r = t.dom.doc.createRange();
\r
3160 r.setStart(sd.startNode, sd.startOffset);
\r
3161 r.setEnd(sd.endNode, sd.endOffset);
\r
3162 s.removeAllRanges();
\r
3166 if (!tinymce.isOpera)
\r
3175 select : function(n, c) {
\r
3176 var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document;
\r
3178 function first(n) {
\r
3179 return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null;
\r
3182 function last(n) {
\r
3188 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
3189 while (c = w.nextNode())
\r
3199 if (/^(IMG|TABLE)$/.test(n.nodeName)) {
\r
3200 r = b.createControlRange();
\r
3203 r = b.createTextRange();
\r
3204 r.moveToElementText(n);
\r
3209 // Throws illigal agrument in IE some times
\r
3217 //console.debug(fn, ln);
\r
3218 r = d.createRange();
\r
3219 r.setStart(fn, 0);
\r
3220 r.setEnd(ln, ln.nodeValue.length);
\r
3232 isCollapsed : function() {
\r
3233 var t = this, r = t.getRng(), s = t.getSel();
\r
3238 return !s || r.boundingWidth == 0 || s.isCollapsed;
\r
3241 collapse : function(b) {
\r
3242 var t = this, r = t.getRng(), n;
\r
3244 // Control range on IE
\r
3247 r = this.win.document.body.createTextRange();
\r
3248 r.moveToElementText(n);
\r
3255 getSel : function() {
\r
3256 var t = this, w = this.win;
\r
3258 return w.getSelection ? w.getSelection() : w.document.selection;
\r
3261 getRng : function() {
\r
3262 var t = this, s = t.getSel(), r;
\r
3266 r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange());
\r
3268 // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
\r
3271 // No range found then create an empty one
\r
3272 // This can occur when the editor is placed in a hidden container element on Gecko
\r
3273 // Or on IE when there was an exception
\r
3275 r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange();
\r
3280 setRng : function(r) {
\r
3284 s = this.getSel();
\r
3287 s.removeAllRanges();
\r
3294 // Needed for some odd IE bug #1843306
\r
3299 setNode : function(n) {
\r
3302 t.setContent(t.dom.getOuterHTML(n));
\r
3307 getNode : function() {
\r
3308 var t = this, r = t.getRng(), s = t.getSel(), e;
\r
3311 // Range maybe lost after the editor is made visible again
\r
3313 return t.dom.getRoot();
\r
3315 e = r.commonAncestorContainer;
\r
3317 // Handle selection a image or other control like element such as anchors
\r
3318 if (!r.collapsed) {
\r
3319 if (r.startContainer == r.endContainer || (tinymce.isWebKit && r.startContainer == r.endContainer.parentNode)) {
\r
3320 if (r.startOffset - r.endOffset < 2 || tinymce.isWebKit) {
\r
3321 if (r.startContainer.hasChildNodes())
\r
3322 e = r.startContainer.childNodes[r.startOffset];
\r
3327 return t.dom.getParent(e, function(n) {
\r
3328 return n.nodeType == 1;
\r
3332 return r.item ? r.item(0) : r.parentElement();
\r
3335 destroy : function(s) {
\r
3340 // Manual destroy then remove unload handler
\r
3342 tinymce.removeUnload(t.destroy);
\r
3348 /* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */
\r
3351 tinymce.create('tinymce.dom.XMLWriter', {
\r
3354 XMLWriter : function(s) {
\r
3355 // Get XML document
\r
3356 function getXML() {
\r
3357 var i = document.implementation;
\r
3359 if (!i || !i.createDocument) {
\r
3361 try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
\r
3362 try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
\r
3364 return i.createDocument('', '', null);
\r
3367 this.doc = getXML();
\r
3369 // Since Opera and WebKit doesn't escape > into > we need to do it our self to normalize the output for all browsers
\r
3370 this.valid = tinymce.isOpera || tinymce.isWebKit;
\r
3375 reset : function() {
\r
3376 var t = this, d = t.doc;
\r
3379 d.removeChild(d.firstChild);
\r
3381 t.node = d.appendChild(d.createElement("html"));
\r
3384 writeStartElement : function(n) {
\r
3387 t.node = t.node.appendChild(t.doc.createElement(n));
\r
3390 writeAttribute : function(n, v) {
\r
3392 v = v.replace(/>/g, '%MCGT%');
\r
3394 this.node.setAttribute(n, v);
\r
3397 writeEndElement : function() {
\r
3398 this.node = this.node.parentNode;
\r
3401 writeFullEndElement : function() {
\r
3402 var t = this, n = t.node;
\r
3404 n.appendChild(t.doc.createTextNode(""));
\r
3405 t.node = n.parentNode;
\r
3408 writeText : function(v) {
\r
3410 v = v.replace(/>/g, '%MCGT%');
\r
3412 this.node.appendChild(this.doc.createTextNode(v));
\r
3415 writeCDATA : function(v) {
\r
3416 this.node.appendChild(this.doc.createCDATA(v));
\r
3419 writeComment : function(v) {
\r
3420 this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' ')));
\r
3423 getContent : function() {
\r
3426 h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);
\r
3427 h = h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g, '');
\r
3428 h = h.replace(/ ?\/>/g, ' />');
\r
3431 h = h.replace(/\%MCGT%/g, '>');
\r
3439 /* file:jscripts/tiny_mce/classes/dom/StringWriter.js */
\r
3442 tinymce.create('tinymce.dom.StringWriter', {
\r
3449 StringWriter : function(s) {
\r
3450 this.settings = tinymce.extend({
\r
3451 indent_char : ' ',
\r
3458 reset : function() {
\r
3465 writeStartElement : function(n) {
\r
3466 this._writeAttributesEnd();
\r
3467 this.writeRaw('<' + n);
\r
3468 this.tags.push(n);
\r
3469 this.inAttr = true;
\r
3471 this.elementCount = this.count;
\r
3474 writeAttribute : function(n, v) {
\r
3477 t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"');
\r
3480 writeEndElement : function() {
\r
3483 if (this.tags.length > 0) {
\r
3484 n = this.tags.pop();
\r
3486 if (this._writeAttributesEnd(1))
\r
3487 this.writeRaw('</' + n + '>');
\r
3489 if (this.settings.indentation > 0)
\r
3490 this.writeRaw('\n');
\r
3494 writeFullEndElement : function() {
\r
3495 if (this.tags.length > 0) {
\r
3496 this._writeAttributesEnd();
\r
3497 this.writeRaw('</' + this.tags.pop() + '>');
\r
3499 if (this.settings.indentation > 0)
\r
3500 this.writeRaw('\n');
\r
3504 writeText : function(v) {
\r
3505 this._writeAttributesEnd();
\r
3506 this.writeRaw(this.encode(v));
\r
3510 writeCDATA : function(v) {
\r
3511 this._writeAttributesEnd();
\r
3512 this.writeRaw('<![CDATA[' + v + ']]>');
\r
3516 writeComment : function(v) {
\r
3517 this._writeAttributesEnd();
\r
3518 this.writeRaw('<!-- ' + v + '-->');
\r
3522 writeRaw : function(v) {
\r
3526 encode : function(s) {
\r
3527 return s.replace(/[<>&"]/g, function(v) {
\r
3546 getContent : function() {
\r
3550 _writeAttributesEnd : function(s) {
\r
3554 this.inAttr = false;
\r
3556 if (s && this.elementCount == this.count) {
\r
3557 this.writeRaw(' />');
\r
3561 this.writeRaw('>');
\r
3569 /* file:jscripts/tiny_mce/classes/dom/Serializer.js */
\r
3573 var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko;
\r
3575 // Returns only attribites that have values not all attributes in IE
\r
3576 function getIEAtts(n) {
\r
3579 // Object will throw exception in IE
\r
3580 if (n.nodeName == 'OBJECT')
\r
3581 return n.attributes;
\r
3583 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
\r
3584 o.push({specified : 1, nodeName : b});
\r
3590 function wildcardToRE(s) {
\r
3591 return s.replace(/([?+*])/g, '.$1');
\r
3594 tinymce.create('tinymce.dom.Serializer', {
\r
3595 Serializer : function(s) {
\r
3599 t.onPreProcess = new Dispatcher(t);
\r
3600 t.onPostProcess = new Dispatcher(t);
\r
3602 if (tinymce.relaxedDomain && tinymce.isGecko) {
\r
3603 // Gecko has a bug where we can't create a new XML document if domain relaxing is used
\r
3604 t.writer = new tinymce.dom.StringWriter();
\r
3607 t.writer = new tinymce.dom.XMLWriter();
\r
3609 // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
\r
3610 t.writer = new tinymce.dom.StringWriter();
\r
3614 // Default settings
\r
3615 t.settings = s = extend({
\r
3616 dom : tinymce.DOM,
\r
3620 invalid_attrs : /^(mce_|_moz_)/,
\r
3621 closed : /(br|hr|input|meta|img|link|param)/,
\r
3622 entity_encoding : 'named',
\r
3623 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',
\r
3624 valid_elements : '*[*]',
\r
3625 extended_valid_elements : 0,
\r
3626 valid_child_elements : 0,
\r
3627 invalid_elements : 0,
\r
3628 fix_table_elements : 0,
\r
3629 fix_list_elements : true,
\r
3630 fix_content_duplication : true,
\r
3631 convert_fonts_to_spans : false,
\r
3632 font_size_classes : 0,
\r
3633 font_size_style_values : 0,
\r
3634 apply_source_formatting : 0,
\r
3635 indent_mode : 'simple',
\r
3636 indent_char : '\t',
\r
3637 indent_levels : 1,
\r
3638 remove_linebreaks : 1
\r
3643 if (s.fix_list_elements) {
\r
3644 t.onPreProcess.add(function(se, o) {
\r
3645 var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np;
\r
3647 function prevNode(e, n) {
\r
3648 var a = n.split(','), i;
\r
3650 while ((e = e.previousSibling) != null) {
\r
3651 for (i=0; i<a.length; i++) {
\r
3652 if (e.nodeName == a[i])
\r
3660 for (x=0; x<a.length; x++) {
\r
3661 nl = t.dom.select(a[x], o.node);
\r
3663 for (i=0; i<nl.length; i++) {
\r
3667 if (r.test(p.nodeName)) {
\r
3668 np = prevNode(n, 'LI');
\r
3671 np = t.dom.create('li');
\r
3672 np.innerHTML = ' ';
\r
3673 np.appendChild(n);
\r
3674 p.insertBefore(np, p.firstChild);
\r
3676 np.appendChild(n);
\r
3683 if (s.fix_table_elements) {
\r
3684 t.onPreProcess.add(function(se, o) {
\r
3685 each(t.dom.select('table', o.node), function(e) {
\r
3686 var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns;
\r
3689 pa2 = pa.cloneNode(false);
\r
3692 for (n = e; n = n.parentNode;) {
\r
3700 for (i = pl.length - 1; i >= 0; i--) {
\r
3701 if (i == pl.length - 1) {
\r
3702 while (ns = pl[i - 1].nextSibling)
\r
3703 tm.appendChild(ns.parentNode.removeChild(ns));
\r
3705 n = pl[i].cloneNode(false);
\r
3708 while (ns = pl[i - 1].nextSibling)
\r
3709 n.appendChild(ns.parentNode.removeChild(ns));
\r
3712 tm = tm.appendChild(n);
\r
3716 e = t.dom.insertAfter(e.parentNode.removeChild(e), pa);
\r
3717 t.dom.insertAfter(e, pa);
\r
3718 t.dom.insertAfter(pa2, e);
\r
3725 setEntities : function(s) {
\r
3726 var t = this, a, i, l = {}, re = '', v;
\r
3728 // No need to setup more than once
\r
3729 if (t.entityLookup)
\r
3732 // Build regex and lookup array
\r
3734 for (i = 0; i < a.length; i += 2) {
\r
3737 // Don't add default & " etc.
\r
3738 if (v == 34 || v == 38 || v == 60 || v == 62)
\r
3741 l[String.fromCharCode(a[i])] = a[i + 1];
\r
3743 v = parseInt(a[i]).toString(16);
\r
3744 re += '\\u' + '0000'.substring(v.length) + v;
\r
3748 t.settings.entity_encoding = 'raw';
\r
3752 t.entitiesRE = new RegExp('[' + re + ']', 'g');
\r
3753 t.entityLookup = l;
\r
3756 setValidChildRules : function(s) {
\r
3757 this.childRules = null;
\r
3758 this.addValidChildRules(s);
\r
3761 addValidChildRules : function(s) {
\r
3762 var t = this, inst, intr, bloc;
\r
3767 inst = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
\r
3768 intr = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
\r
3769 bloc = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
\r
3771 each(s.split(','), function(s) {
\r
3772 var p = s.split(/\[|\]/), re;
\r
3775 each(p[1].split('|'), function(v) {
\r
3784 case '%itrans_na':
\r
3785 v = intr.substring(2);
\r
3792 case '%istrict_na':
\r
3793 v = inst.substring(2);
\r
3807 re = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
\r
3809 each(p[0].split('/'), function(s) {
\r
3810 t.childRules = t.childRules || {};
\r
3811 t.childRules[s] = re;
\r
3817 each(t.childRules, function(v, k) {
\r
3824 t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
\r
3826 /*console.debug(t.parentElementsRE.toString());
\r
3827 each(t.childRules, function(v) {
\r
3828 console.debug(v.toString());
\r
3832 setRules : function(s) {
\r
3838 t.validElements = {};
\r
3840 return t.addRules(s);
\r
3843 addRules : function(s) {
\r
3851 each(s.split(','), function(s) {
\r
3852 var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = [];
\r
3854 // Extend with default rules
\r
3856 at = tinymce.extend([], dr.attribs);
\r
3858 // Parse attributes
\r
3859 if (p.length > 1) {
\r
3860 each(p[1].split('|'), function(s) {
\r
3865 // Parse attribute rule
\r
3866 s = s.replace(/::/g, '~');
\r
3867 s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);
\r
3868 s[2] = s[2].replace(/~/g, ':');
\r
3870 // Add required attributes
\r
3871 if (s[1] == '!') {
\r
3876 // Remove inherited attributes
\r
3877 if (s[1] == '-') {
\r
3878 for (i = 0; i <at.length; i++) {
\r
3879 if (at[i].name == s[2]) {
\r
3887 // Add default attrib values
\r
3889 ar.defaultVal = s[4] || '';
\r
3892 // Add forced attrib values
\r
3894 ar.forcedVal = s[4];
\r
3897 // Add validation values
\r
3899 ar.validVals = s[4].split('?');
\r
3903 if (/[*.?]/.test(s[2])) {
\r
3905 ar.nameRE = new RegExp('^' + wildcardToRE(s[2]) + '$');
\r
3916 // Handle element names
\r
3917 each(tn, function(s, i) {
\r
3918 var pr = s.charAt(0), x = 1, ru = {};
\r
3920 // Extend with default rule data
\r
3923 ru.noEmpty = dr.noEmpty;
\r
3926 ru.fullEnd = dr.fullEnd;
\r
3929 ru.padd = dr.padd;
\r
3932 // Handle prefixes
\r
3935 ru.noEmpty = true;
\r
3939 ru.fullEnd = true;
\r
3950 tn[i] = s = s.substring(x);
\r
3951 t.validElements[s] = 1;
\r
3953 // Add element name or element regex
\r
3954 if (/[*.?]/.test(tn[0])) {
\r
3955 ru.nameRE = new RegExp('^' + wildcardToRE(tn[0]) + '$');
\r
3956 t.wildRules = t.wildRules || {};
\r
3957 t.wildRules.push(ru);
\r
3961 // Store away default rule
\r
3971 ru.requiredAttribs = ra;
\r
3974 // Build valid attributes regexp
\r
3976 each(va, function(v) {
\r
3980 s += '(' + wildcardToRE(v) + ')';
\r
3982 ru.validAttribsRE = new RegExp('^' + s.toLowerCase() + '$');
\r
3983 ru.wildAttribs = wat;
\r
3988 // Build valid elements regexp
\r
3990 each(t.validElements, function(v, k) {
\r
3997 t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$');
\r
3999 //console.debug(t.validElementsRE.toString());
\r
4000 //console.dir(t.rules);
\r
4001 //console.dir(t.wildRules);
\r
4004 findRule : function(n) {
\r
4005 var t = this, rl = t.rules, i, r;
\r
4016 for (i = 0; i < rl.length; i++) {
\r
4017 if (rl[i].nameRE.test(n))
\r
4024 findAttribRule : function(ru, n) {
\r
4025 var i, wa = ru.wildAttribs;
\r
4027 for (i = 0; i < wa.length; i++) {
\r
4028 if (wa[i].nameRE.test(n))
\r
4035 serialize : function(n, o) {
\r
4040 o.format = o.format || 'html';
\r
4042 n = n.cloneNode(true);
\r
4043 t.key = '' + (parseInt(t.key) + 1);
\r
4046 if (!o.no_events) {
\r
4048 t.onPreProcess.dispatch(t, o);
\r
4051 // Serialize HTML DOM into a string
\r
4053 t._serializeNode(n, o.getInner);
\r
4056 o.content = t.writer.getContent();
\r
4059 t.onPostProcess.dispatch(t, o);
\r
4061 t._postProcess(o);
\r
4064 return tinymce.trim(o.content);
\r
4067 // Internal functions
\r
4069 _postProcess : function(o) {
\r
4070 var t = this, s = t.settings, h = o.content, sc = [], p;
\r
4072 if (o.format == 'html') {
\r
4073 // Protect some elements
\r
4077 {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
\r
4078 {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
\r
4079 {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1}
\r
4086 if (s.entity_encoding !== 'raw')
\r
4089 // Use BR instead of padded P elements inside editor and use <p> </p> outside editor
\r
4091 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>');
\r
4093 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/
\r
4095 // Since Gecko and Safari keeps whitespace in the DOM we need to
\r
4096 // remove it inorder to match other browsers. But I think Gecko and Safari is right.
\r
4097 // This process is only done when getting contents out from the editor.
\r
4099 // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char
\r
4100 h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1> </p>' : '<p$1> </p>');
\r
4102 if (s.remove_linebreaks) {
\r
4103 h = h.replace(/\r?\n|\r/g, ' ');
\r
4104 h = h.replace(/(<[^>]+>)\s+/g, '$1 ');
\r
4105 h = h.replace(/\s+(<\/[^>]+>)/g, ' $1');
\r
4106 h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g, '<$1 $2>'); // Trim block start
\r
4107 h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g, '<$1>'); // Trim block start
\r
4108 h = h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g, '</$1>'); // Trim block end
\r
4111 // Simple indentation
\r
4112 if (s.apply_source_formatting && s.indent_mode == 'simple') {
\r
4113 // Add line breaks before and after block elements
\r
4114 h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n');
\r
4115 h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>');
\r
4116 h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '</$1>\n');
\r
4117 h = h.replace(/\n\n/g, '\n');
\r
4121 h = t._unprotect(h, p);
\r
4123 // Restore the \u00a0 character if raw mode is enabled
\r
4124 if (s.entity_encoding == 'raw')
\r
4125 h = h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g, '<p$1>\u00a0</p>');
\r
4131 _serializeNode : function(n, inn) {
\r
4132 var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv;
\r
4134 if (!s.node_filter || s.node_filter(n)) {
\r
4135 switch (n.nodeType) {
\r
4136 case 1: // Element
\r
4137 if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus'))
\r
4141 hc = n.hasChildNodes();
\r
4142 nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase();
\r
4144 // Add correct prefix on IE
\r
4146 if (n.scopeName !== 'HTML' && n.scopeName !== 'html')
\r
4147 nn = n.scopeName + ':' + nn;
\r
4150 // Remove mce prefix on IE needed for the abbr element
\r
4151 if (nn.indexOf('mce:') === 0)
\r
4152 nn = nn.substring(4);
\r
4155 if (!t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) {
\r
4161 // Fix IE content duplication (DOM can have multiple copies of the same node)
\r
4162 if (s.fix_content_duplication) {
\r
4163 if (n.mce_serialized == t.key)
\r
4166 n.mce_serialized = t.key;
\r
4169 // IE sometimes adds a / infront of the node name
\r
4170 if (nn.charAt(0) == '/')
\r
4171 nn = nn.substring(1);
\r
4172 } else if (isGecko) {
\r
4173 // Ignore br elements
\r
4174 if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz')
\r
4178 // Check if valid child
\r
4179 if (t.childRules) {
\r
4180 if (t.parentElementsRE.test(t.elementName)) {
\r
4181 if (!t.childRules[t.elementName].test(nn)) {
\r
4187 t.elementName = nn;
\r
4190 ru = t.findRule(nn);
\r
4191 nn = ru.name || nn;
\r
4193 // Skip empty nodes or empty node name in IE
\r
4194 if ((!hc && ru.noEmpty) || (isIE && !nn)) {
\r
4200 if (ru.requiredAttribs) {
\r
4201 a = ru.requiredAttribs;
\r
4203 for (i = a.length - 1; i >= 0; i--) {
\r
4204 if (this.dom.getAttrib(n, a[i]) !== '')
\r
4208 // None of the required was there
\r
4215 w.writeStartElement(nn);
\r
4217 // Add ordered attributes
\r
4219 for (i=0, at = ru.attribs, l = at.length; i<l; i++) {
\r
4221 v = t._getAttrib(n, a);
\r
4224 w.writeAttribute(a.name, v);
\r
4228 // Add wild attributes
\r
4229 if (ru.validAttribsRE) {
\r
4230 at = isIE ? getIEAtts(n) : n.attributes;
\r
4231 for (i=at.length-1; i>-1; i--) {
\r
4234 if (no.specified) {
\r
4235 a = no.nodeName.toLowerCase();
\r
4237 if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a))
\r
4240 ar = t.findAttribRule(ru, a);
\r
4241 v = t._getAttrib(n, ar, a);
\r
4244 w.writeAttribute(a, v);
\r
4249 // Padd empty nodes with a
\r
4250 if (!hc && ru.padd)
\r
4251 w.writeText('\u00a0');
\r
4256 // Check if valid child
\r
4257 if (t.childRules && t.parentElementsRE.test(t.elementName)) {
\r
4258 if (!t.childRules[t.elementName].test(n.nodeName))
\r
4262 return w.writeText(n.nodeValue);
\r
4265 return w.writeCDATA(n.nodeValue);
\r
4267 case 8: // Comment
\r
4268 return w.writeComment(n.nodeValue);
\r
4270 } else if (n.nodeType == 1)
\r
4271 hc = n.hasChildNodes();
\r
4274 cn = n.firstChild;
\r
4277 t._serializeNode(cn);
\r
4278 t.elementName = nn;
\r
4279 cn = cn.nextSibling;
\r
4283 // Write element end
\r
4285 if (hc || !s.closed.test(nn))
\r
4286 w.writeFullEndElement();
\r
4288 w.writeEndElement();
\r
4292 _protect : function(o) {
\r
4295 o.items = o.items || [];
\r
4298 return s.replace(/[\r\n\\]/g, function(c) {
\r
4301 else if (c === '\\')
\r
4309 return s.replace(/\\[\\rn]/g, function(c) {
\r
4312 else if (c === '\\\\')
\r
4319 each(o.patterns, function(p) {
\r
4320 o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
\r
4327 return a + '<!--mce:' + (o.items.length - 1) + '-->' + c;
\r
4334 _unprotect : function(h, o) {
\r
4335 h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) {
\r
4336 return o.items[parseInt(b)];
\r
4344 _encode : function(h) {
\r
4345 var t = this, s = t.settings, l;
\r
4348 if (s.entity_encoding !== 'raw') {
\r
4349 if (s.entity_encoding.indexOf('named') != -1) {
\r
4350 t.setEntities(s.entities);
\r
4351 l = t.entityLookup;
\r
4353 h = h.replace(t.entitiesRE, function(a) {
\r
4357 a = '&' + v + ';';
\r
4363 if (s.entity_encoding.indexOf('numeric') != -1) {
\r
4364 h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
\r
4365 return '&#' + a.charCodeAt(0) + ';';
\r
4373 _setup : function() {
\r
4374 var t = this, s = this.settings;
\r
4381 t.setRules(s.valid_elements);
\r
4382 t.addRules(s.extended_valid_elements);
\r
4383 t.addValidChildRules(s.valid_child_elements);
\r
4385 if (s.invalid_elements)
\r
4386 t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
\r
4388 if (s.attrib_value_filter)
\r
4389 t.attribValueFilter = s.attribValueFilter;
\r
4392 _getAttrib : function(n, a, na) {
\r
4395 na = na || a.name;
\r
4397 if (a.forcedVal && (v = a.forcedVal)) {
\r
4398 if (v === '{$uid}')
\r
4399 return this.dom.uniqueId();
\r
4404 v = this.dom.getAttrib(n, na);
\r
4409 // Whats the point? Remove usless attribute value
\r
4416 if (this.attribValueFilter)
\r
4417 v = this.attribValueFilter(na, v, n);
\r
4419 if (a.validVals) {
\r
4420 for (i = a.validVals.length - 1; i >= 0; i--) {
\r
4421 if (v == a.validVals[i])
\r
4429 if (v === '' && typeof(a.defaultVal) != 'undefined') {
\r
4432 if (v === '{$uid}')
\r
4433 return this.dom.uniqueId();
\r
4437 // Remove internal mceItemXX classes when content is extracted from editor
\r
4438 if (na == 'class' && this.processObj.get)
\r
4439 v = v.replace(/\s?mceItem\w+\s?/g, '');
\r
4452 /* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */
\r
4455 var each = tinymce.each;
\r
4457 tinymce.create('tinymce.dom.ScriptLoader', {
\r
4458 ScriptLoader : function(s) {
\r
4459 this.settings = s || {};
\r
4464 isDone : function(u) {
\r
4465 return this.lookup[u] ? this.lookup[u].state == 2 : 0;
\r
4468 markDone : function(u) {
\r
4469 this.lookup[u] = {state : 2, url : u};
\r
4472 add : function(u, cb, s, pr) {
\r
4473 var t = this, lo = t.lookup, o;
\r
4476 // Is loaded fire callback
\r
4477 if (cb && o.state == 2)
\r
4478 cb.call(s || this);
\r
4483 o = {state : 0, url : u, func : cb, scope : s || this};
\r
4486 t.queue.unshift(o);
\r
4495 load : function(u, cb, s) {
\r
4498 if (o = t.lookup[u]) {
\r
4499 // Is loaded fire callback
\r
4500 if (cb && o.state == 2)
\r
4506 function loadScript(u) {
\r
4507 if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) {
\r
4508 tinymce.util.XHR.send({
\r
4509 url : tinymce._addVer(u),
\r
4510 error : t.settings.error,
\r
4512 success : function(co) {
\r
4517 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
\r
4520 if (!tinymce.is(u, 'string')) {
\r
4521 each(u, function(u) {
\r
4535 loadQueue : function(cb, s) {
\r
4538 if (!t.queueLoading) {
\r
4539 t.queueLoading = 1;
\r
4540 t.queueCallbacks = [];
\r
4542 t.loadScripts(t.queue, function() {
\r
4543 t.queueLoading = 0;
\r
4548 each(t.queueCallbacks, function(o) {
\r
4549 o.func.call(o.scope);
\r
4553 t.queueCallbacks.push({func : cb, scope : s || t});
\r
4556 eval : function(co) {
\r
4559 // Evaluate script
\r
4560 if (!w.execScript) {
\r
4564 eval(co, w); // Firefox 3.0a8
\r
4567 w.execScript(co); // IE
\r
4570 loadScripts : function(sc, cb, s) {
\r
4571 var t = this, lo = t.lookup;
\r
4573 function done(o) {
\r
4574 o.state = 2; // Has been loaded
\r
4578 o.func.call(o.scope || t);
\r
4581 function allDone() {
\r
4584 // Check if all files are loaded
\r
4586 each(sc, function(o) {
\r
4589 if (o.state === 2) {// It has finished loading
\r
4596 // They are all loaded
\r
4597 if (l === 0 && cb) {
\r
4603 function load(o) {
\r
4607 o.state = 1; // Is loading
\r
4609 tinymce.util.XHR.send({
\r
4611 error : t.settings.error,
\r
4612 success : function(co) {
\r
4620 each(sc, function(o) {
\r
4623 // Add to queue if needed
\r
4630 // Is already loading or has been loaded
\r
4634 if (!tinymce.dom.Event.domLoaded && !t.settings.strict_mode) {
\r
4637 // Add onload events
\r
4638 if (cb || o.func) {
\r
4639 o.state = 1; // Is loading
\r
4641 ix = tinymce.dom.ScriptLoader._addOnLoad(function() {
\r
4647 ol = ' onreadystatechange="';
\r
4651 ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"';
\r
4654 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
\r
4667 _addOnLoad : function(f) {
\r
4670 t._funcs = t._funcs || [];
\r
4673 return t._funcs.length - 1;
\r
4676 _onLoad : function(e, u, ix) {
\r
4677 if (!tinymce.isIE || e.readyState == 'complete')
\r
4678 this._funcs[ix].call(this);
\r
4684 // Global script loader
\r
4685 tinymce.ScriptLoader = new tinymce.dom.ScriptLoader();
\r
4688 /* file:jscripts/tiny_mce/classes/ui/Control.js */
\r
4691 // Shorten class names
\r
4692 var DOM = tinymce.DOM, is = tinymce.is;
\r
4694 tinymce.create('tinymce.ui.Control', {
\r
4695 Control : function(id, s) {
\r
4697 this.settings = s = s || {};
\r
4698 this.rendered = false;
\r
4699 this.onRender = new tinymce.util.Dispatcher(this);
\r
4700 this.classPrefix = '';
\r
4701 this.scope = s.scope || this;
\r
4702 this.disabled = 0;
\r
4706 setDisabled : function(s) {
\r
4709 if (s != this.disabled) {
\r
4710 e = DOM.get(this.id);
\r
4712 // Add accessibility title for unavailable actions
\r
4713 if (e && this.settings.unavailable_prefix) {
\r
4715 this.prevTitle = e.title;
\r
4716 e.title = this.settings.unavailable_prefix + ": " + e.title;
\r
4718 e.title = this.prevTitle;
\r
4721 this.setState('Disabled', s);
\r
4722 this.setState('Enabled', !s);
\r
4723 this.disabled = s;
\r
4727 isDisabled : function() {
\r
4728 return this.disabled;
\r
4731 setActive : function(s) {
\r
4732 if (s != this.active) {
\r
4733 this.setState('Active', s);
\r
4738 isActive : function() {
\r
4739 return this.active;
\r
4742 setState : function(c, s) {
\r
4743 var n = DOM.get(this.id);
\r
4745 c = this.classPrefix + c;
\r
4748 DOM.addClass(n, c);
\r
4750 DOM.removeClass(n, c);
\r
4753 isRendered : function() {
\r
4754 return this.rendered;
\r
4757 renderHTML : function() {
\r
4760 renderTo : function(n) {
\r
4761 DOM.setHTML(n, this.renderHTML());
\r
4764 postRender : function() {
\r
4767 // Set pending states
\r
4768 if (is(t.disabled)) {
\r
4774 if (is(t.active)) {
\r
4781 remove : function() {
\r
4782 DOM.remove(this.id);
\r
4786 destroy : function() {
\r
4787 tinymce.dom.Event.clear(this.id);
\r
4792 /* file:jscripts/tiny_mce/classes/ui/Container.js */
\r
4794 tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
\r
4795 Container : function(id, s) {
\r
4796 this.parent(id, s);
\r
4797 this.controls = [];
\r
4801 add : function(c) {
\r
4802 this.lookup[c.id] = c;
\r
4803 this.controls.push(c);
\r
4808 get : function(n) {
\r
4809 return this.lookup[n];
\r
4815 /* file:jscripts/tiny_mce/classes/ui/Separator.js */
\r
4817 tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
\r
4818 Separator : function(id, s) {
\r
4819 this.parent(id, s);
\r
4820 this.classPrefix = 'mceSeparator';
\r
4823 renderHTML : function() {
\r
4824 return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
\r
4829 /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */
\r
4832 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
\r
4834 tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
\r
4835 MenuItem : function(id, s) {
\r
4836 this.parent(id, s);
\r
4837 this.classPrefix = 'mceMenuItem';
\r
4840 setSelected : function(s) {
\r
4841 this.setState('Selected', s);
\r
4842 this.selected = s;
\r
4845 isSelected : function() {
\r
4846 return this.selected;
\r
4849 postRender : function() {
\r
4854 // Set pending state
\r
4855 if (is(t.selected))
\r
4856 t.setSelected(t.selected);
\r
4862 /* file:jscripts/tiny_mce/classes/ui/Menu.js */
\r
4865 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
\r
4867 tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
\r
4868 Menu : function(id, s) {
\r
4873 t.collapsed = false;
\r
4875 t.onAddItem = new tinymce.util.Dispatcher(this);
\r
4878 expand : function(d) {
\r
4882 walk(t, function(o) {
\r
4888 t.collapsed = false;
\r
4891 collapse : function(d) {
\r
4895 walk(t, function(o) {
\r
4901 t.collapsed = true;
\r
4904 isCollapsed : function() {
\r
4905 return this.collapsed;
\r
4908 add : function(o) {
\r
4910 o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
\r
4912 this.onAddItem.dispatch(this, o);
\r
4914 return this.items[o.id] = o;
\r
4917 addSeparator : function() {
\r
4918 return this.add({separator : true});
\r
4921 addMenu : function(o) {
\r
4923 o = this.createMenu(o);
\r
4927 return this.add(o);
\r
4930 hasMenus : function() {
\r
4931 return this.menuCount !== 0;
\r
4934 remove : function(o) {
\r
4935 delete this.items[o.id];
\r
4938 removeAll : function() {
\r
4941 walk(t, function(o) {
\r
4953 createMenu : function(o) {
\r
4954 var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
\r
4956 m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
\r
4963 /* file:jscripts/tiny_mce/classes/ui/DropMenu.js */
\r
4966 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
\r
4968 tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
\r
4969 DropMenu : function(id, s) {
\r
4971 s.container = s.container || DOM.doc.body;
\r
4972 s.offset_x = s.offset_x || 0;
\r
4973 s.offset_y = s.offset_y || 0;
\r
4974 s.vp_offset_x = s.vp_offset_x || 0;
\r
4975 s.vp_offset_y = s.vp_offset_y || 0;
\r
4977 if (is(s.icons) && !s.icons)
\r
4978 s['class'] += ' mceNoIcons';
\r
4980 this.parent(id, s);
\r
4981 this.onShowMenu = new tinymce.util.Dispatcher(this);
\r
4982 this.onHideMenu = new tinymce.util.Dispatcher(this);
\r
4983 this.classPrefix = 'mceMenu';
\r
4986 createMenu : function(s) {
\r
4987 var t = this, cs = t.settings, m;
\r
4989 s.container = s.container || cs.container;
\r
4991 s.constrain = s.constrain || cs.constrain;
\r
4992 s['class'] = s['class'] || cs['class'];
\r
4993 s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
\r
4994 s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
\r
4995 m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
\r
4997 m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
\r
5002 update : function() {
\r
5003 var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
\r
5005 tw = s.max_width ? Math.min(tb.clientWidth, s.max_width) : tb.clientWidth;
\r
5006 th = s.max_height ? Math.min(tb.clientHeight, s.max_height) : tb.clientHeight;
\r
5008 if (!DOM.boxModel)
\r
5009 t.element.setStyles({width : tw + 2, height : th + 2});
\r
5011 t.element.setStyles({width : tw, height : th});
\r
5014 DOM.setStyle(co, 'width', tw);
\r
5016 if (s.max_height) {
\r
5017 DOM.setStyle(co, 'height', th);
\r
5019 if (tb.clientHeight < s.max_height)
\r
5020 DOM.setStyle(co, 'overflow', 'hidden');
\r
5024 showMenu : function(x, y, px) {
\r
5025 var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
\r
5029 if (t.isMenuVisible)
\r
5032 if (!t.rendered) {
\r
5033 co = DOM.add(t.settings.container, t.renderNode());
\r
5035 each(t.items, function(o) {
\r
5039 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
\r
5041 co = DOM.get('menu_' + t.id);
\r
5043 // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
\r
5044 if (!tinymce.isOpera)
\r
5045 DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
\r
5050 x += s.offset_x || 0;
\r
5051 y += s.offset_y || 0;
\r
5055 // Move inside viewport if not submenu
\r
5056 if (s.constrain) {
\r
5057 w = co.clientWidth - ot;
\r
5058 h = co.clientHeight - ot;
\r
5062 if ((x + s.vp_offset_x + w) > mx)
\r
5063 x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
\r
5065 if ((y + s.vp_offset_y + h) > my)
\r
5066 y = Math.max(0, (my - s.vp_offset_y) - h);
\r
5069 DOM.setStyles(co, {left : x , top : y});
\r
5070 t.element.update();
\r
5072 t.isMenuVisible = 1;
\r
5073 t.mouseClickFunc = Event.add(co, 'click', function(e) {
\r
5078 if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
\r
5079 m = t.items[e.id];
\r
5081 if (m.isDisabled())
\r
5090 dm = dm.settings.parent;
\r
5093 if (m.settings.onclick)
\r
5094 m.settings.onclick(e);
\r
5096 return Event.cancel(e); // Cancel to fix onbeforeunload problem
\r
5100 if (t.hasMenus()) {
\r
5101 t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
\r
5105 if (e && (e = DOM.getParent(e, 'TR'))) {
\r
5106 m = t.items[e.id];
\r
5109 t.lastMenu.collapse(1);
\r
5111 if (m.isDisabled())
\r
5114 if (e && DOM.hasClass(e, cp + 'ItemSub')) {
\r
5115 //p = DOM.getPos(s.container);
\r
5116 r = DOM.getRect(e);
\r
5117 m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
\r
5119 DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
\r
5125 t.onShowMenu.dispatch(t);
\r
5127 if (s.keyboard_focus) {
\r
5128 Event.add(co, 'keydown', t._keyHandler, t);
\r
5129 DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
\r
5134 hideMenu : function(c) {
\r
5135 var t = this, co = DOM.get('menu_' + t.id), e;
\r
5137 if (!t.isMenuVisible)
\r
5140 Event.remove(co, 'mouseover', t.mouseOverFunc);
\r
5141 Event.remove(co, 'click', t.mouseClickFunc);
\r
5142 Event.remove(co, 'keydown', t._keyHandler);
\r
5144 t.isMenuVisible = 0;
\r
5152 if (e = DOM.get(t.id))
\r
5153 DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
\r
5155 t.onHideMenu.dispatch(t);
\r
5158 add : function(o) {
\r
5163 if (t.isRendered && (co = DOM.get('menu_' + t.id)))
\r
5164 t._add(DOM.select('tbody', co)[0], o);
\r
5169 collapse : function(d) {
\r
5174 remove : function(o) {
\r
5178 return this.parent(o);
\r
5181 destroy : function() {
\r
5182 var t = this, co = DOM.get('menu_' + t.id);
\r
5184 Event.remove(co, 'mouseover', t.mouseOverFunc);
\r
5185 Event.remove(co, 'click', t.mouseClickFunc);
\r
5188 t.element.remove();
\r
5193 renderNode : function() {
\r
5194 var t = this, s = t.settings, n, tb, co, w;
\r
5196 w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'});
\r
5197 co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
\r
5198 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
\r
5201 DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
\r
5203 // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
\r
5204 n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
\r
5205 tb = DOM.add(n, 'tbody');
\r
5207 each(t.items, function(o) {
\r
5211 t.rendered = true;
\r
5216 // Internal functions
\r
5218 _keyHandler : function(e) {
\r
5219 var t = this, kc = e.keyCode;
\r
5221 function focus(d) {
\r
5222 var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
\r
5232 focus(-1); // Select first link
\r
5243 return this.hideMenu();
\r
5247 _add : function(tb, o) {
\r
5248 var n, s = o.settings, a, ro, it, cp = this.classPrefix;
\r
5250 if (s.separator) {
\r
5251 ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
\r
5252 DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
\r
5254 if (n = ro.previousSibling)
\r
5255 DOM.addClass(n, 'mceLast');
\r
5260 n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
\r
5261 n = it = DOM.add(n, 'td');
\r
5262 n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
\r
5264 DOM.addClass(it, s['class']);
\r
5265 // n = DOM.add(n, 'span', {'class' : 'item'});
\r
5266 DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
\r
5267 n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
\r
5269 if (o.settings.style)
\r
5270 DOM.setAttrib(n, 'style', o.settings.style);
\r
5272 if (tb.childNodes.length == 1)
\r
5273 DOM.addClass(ro, 'mceFirst');
\r
5275 if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
\r
5276 DOM.addClass(ro, 'mceFirst');
\r
5279 DOM.addClass(ro, cp + 'ItemSub');
\r
5281 if (n = ro.previousSibling)
\r
5282 DOM.removeClass(n, 'mceLast');
\r
5284 DOM.addClass(ro, 'mceLast');
\r
5289 /* file:jscripts/tiny_mce/classes/ui/Button.js */
\r
5292 var DOM = tinymce.DOM;
\r
5294 tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
\r
5295 Button : function(id, s) {
\r
5296 this.parent(id, s);
\r
5297 this.classPrefix = 'mceButton';
\r
5300 renderHTML : function() {
\r
5301 var cp = this.classPrefix, s = this.settings, h, l;
\r
5303 l = DOM.encode(s.label || '');
\r
5304 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) + '">';
\r
5307 h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>';
\r
5309 h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>';
\r
5314 postRender : function() {
\r
5315 var t = this, s = t.settings;
\r
5317 tinymce.dom.Event.add(t.id, 'click', function(e) {
\r
5318 if (!t.isDisabled())
\r
5319 return s.onclick.call(s.scope, e);
\r
5326 /* file:jscripts/tiny_mce/classes/ui/ListBox.js */
\r
5329 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
\r
5331 tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
\r
5332 ListBox : function(id, s) {
\r
5337 t.onChange = new Dispatcher(t);
\r
5338 t.onPostRender = new Dispatcher(t);
\r
5339 t.onAdd = new Dispatcher(t);
\r
5340 t.onRenderMenu = new tinymce.util.Dispatcher(this);
\r
5341 t.classPrefix = 'mceListBox';
\r
5344 select : function(v) {
\r
5345 var t = this, e, fv;
\r
5347 // Do we need to do something?
\r
5348 if (v != t.selectedValue) {
\r
5349 e = DOM.get(t.id + '_text');
\r
5350 t.selectedValue = v;
\r
5353 each(t.items, function(o) {
\r
5354 if (o.value == v) {
\r
5355 DOM.setHTML(e, DOM.encode(o.title));
\r
5361 // If no item was found then present title
\r
5363 DOM.setHTML(e, DOM.encode(t.settings.title));
\r
5364 DOM.addClass(e, 'mceTitle');
\r
5368 DOM.removeClass(e, 'mceTitle');
\r
5374 add : function(n, v, o) {
\r
5378 o = tinymce.extend(o, {
\r
5384 t.onAdd.dispatch(t, o);
\r
5387 getLength : function() {
\r
5388 return this.items.length;
\r
5391 renderHTML : function() {
\r
5392 var h = '', t = this, s = t.settings, cp = t.classPrefix;
\r
5394 h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>';
\r
5395 h += '<td>' + DOM.createHTML('a', {id : t.id + '_text', href : 'javascript:;', 'class' : 'mceText', onclick : "return false;", onmousedown : 'return false;'}, DOM.encode(t.settings.title)) + '</td>';
\r
5396 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>';
\r
5397 h += '</tr></tbody></table>';
\r
5402 showMenu : function() {
\r
5403 var t = this, p1, p2, e = DOM.get(this.id), m;
\r
5405 if (t.isDisabled() || t.items.length == 0)
\r
5408 if (t.menu && t.menu.isMenuVisible)
\r
5409 return t.hideMenu();
\r
5411 if (!t.isMenuRendered) {
\r
5413 t.isMenuRendered = true;
\r
5416 p1 = DOM.getPos(this.settings.menu_container);
\r
5417 p2 = DOM.getPos(e);
\r
5420 m.settings.offset_x = p2.x;
\r
5421 m.settings.offset_y = p2.y;
\r
5422 m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
\r
5426 m.items[t.oldID].setSelected(0);
\r
5428 each(t.items, function(o) {
\r
5429 if (o.value === t.selectedValue) {
\r
5430 m.items[o.id].setSelected(1);
\r
5435 m.showMenu(0, e.clientHeight);
\r
5437 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5438 DOM.addClass(t.id, t.classPrefix + 'Selected');
\r
5440 //DOM.get(t.id + '_text').focus();
\r
5443 hideMenu : function(e) {
\r
5446 // Prevent double toogles by canceling the mouse click event to the button
\r
5447 if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
\r
5450 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
\r
5451 DOM.removeClass(t.id, t.classPrefix + 'Selected');
\r
5452 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5455 t.menu.hideMenu();
\r
5459 renderMenu : function() {
\r
5462 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
\r
5464 'class' : t.classPrefix + 'Menu mceNoIcons',
\r
5469 m.onHideMenu.add(t.hideMenu, t);
\r
5472 title : t.settings.title,
\r
5473 'class' : 'mceMenuItemTitle',
\r
5474 onclick : function() {
\r
5475 if (t.settings.onselect('') !== false)
\r
5476 t.select(''); // Must be runned after
\r
5480 each(t.items, function(o) {
\r
5481 o.id = DOM.uniqueId();
\r
5482 o.onclick = function() {
\r
5483 if (t.settings.onselect(o.value) !== false)
\r
5484 t.select(o.value); // Must be runned after
\r
5490 t.onRenderMenu.dispatch(t, m);
\r
5494 postRender : function() {
\r
5495 var t = this, cp = t.classPrefix;
\r
5497 Event.add(t.id, 'click', t.showMenu, t);
\r
5498 Event.add(t.id + '_text', 'focus', function(e) {
\r
5499 if (!t._focused) {
\r
5500 t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
\r
5501 var idx = -1, v, kc = e.keyCode;
\r
5503 // Find current index
\r
5504 each(t.items, function(v, i) {
\r
5505 if (t.selectedValue == v.value)
\r
5511 v = t.items[idx - 1];
\r
5512 else if (kc == 40)
\r
5513 v = t.items[idx + 1];
\r
5514 else if (kc == 13) {
\r
5515 // Fake select on enter
\r
5516 v = t.selectedValue;
\r
5517 t.selectedValue = null; // Needs to be null to fake change
\r
5518 t.settings.onselect(v);
\r
5519 return Event.cancel(e);
\r
5524 t.select(v.value);
\r
5531 Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
\r
5533 // Old IE doesn't have hover on all elements
\r
5534 if (tinymce.isIE6 || !DOM.boxModel) {
\r
5535 Event.add(t.id, 'mouseover', function() {
\r
5536 if (!DOM.hasClass(t.id, cp + 'Disabled'))
\r
5537 DOM.addClass(t.id, cp + 'Hover');
\r
5540 Event.add(t.id, 'mouseout', function() {
\r
5541 if (!DOM.hasClass(t.id, cp + 'Disabled'))
\r
5542 DOM.removeClass(t.id, cp + 'Hover');
\r
5546 t.onPostRender.dispatch(t, DOM.get(t.id));
\r
5549 destroy : function() {
\r
5552 Event.clear(this.id + '_text');
\r
5557 /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */
\r
5560 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
\r
5562 tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
\r
5563 NativeListBox : function(id, s) {
\r
5564 this.parent(id, s);
\r
5565 this.classPrefix = 'mceNativeListBox';
\r
5568 setDisabled : function(s) {
\r
5569 DOM.get(this.id).disabled = s;
\r
5572 isDisabled : function() {
\r
5573 return DOM.get(this.id).disabled;
\r
5576 select : function(v) {
\r
5577 var e = DOM.get(this.id), ol = e.options;
\r
5579 v = '' + (v || '');
\r
5581 e.selectedIndex = 0;
\r
5582 each(ol, function(o, i) {
\r
5583 if (o.value == v) {
\r
5584 e.selectedIndex = i;
\r
5590 add : function(n, v, a) {
\r
5596 if (t.isRendered())
\r
5597 DOM.add(DOM.get(this.id), 'option', a, n);
\r
5606 t.onAdd.dispatch(t, o);
\r
5609 getLength : function() {
\r
5610 return DOM.get(this.id).options.length - 1;
\r
5613 renderHTML : function() {
\r
5616 h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
\r
5618 each(t.items, function(it) {
\r
5619 h += DOM.createHTML('option', {value : it.value}, it.title);
\r
5622 h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox'}, h);
\r
5627 postRender : function() {
\r
5630 t.rendered = true;
\r
5632 function onChange(e) {
\r
5633 var v = e.target.options[e.target.selectedIndex].value;
\r
5635 t.onChange.dispatch(t, v);
\r
5637 if (t.settings.onselect)
\r
5638 t.settings.onselect(v);
\r
5641 Event.add(t.id, 'change', onChange);
\r
5643 // Accessibility keyhandler
\r
5644 Event.add(t.id, 'keydown', function(e) {
\r
5647 Event.remove(t.id, 'change', ch);
\r
5649 bf = Event.add(t.id, 'blur', function() {
\r
5650 Event.add(t.id, 'change', onChange);
\r
5651 Event.remove(t.id, 'blur', bf);
\r
5654 if (e.keyCode == 13 || e.keyCode == 32) {
\r
5656 return Event.cancel(e);
\r
5660 t.onPostRender.dispatch(t, DOM.get(t.id));
\r
5665 /* file:jscripts/tiny_mce/classes/ui/MenuButton.js */
\r
5668 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
\r
5670 tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
\r
5671 MenuButton : function(id, s) {
\r
5672 this.parent(id, s);
\r
5673 this.onRenderMenu = new tinymce.util.Dispatcher(this);
\r
5674 s.menu_container = s.menu_container || DOM.doc.body;
\r
5677 showMenu : function() {
\r
5678 var t = this, p1, p2, e = DOM.get(t.id), m;
\r
5680 if (t.isDisabled())
\r
5683 if (!t.isMenuRendered) {
\r
5685 t.isMenuRendered = true;
\r
5688 if (t.isMenuVisible)
\r
5689 return t.hideMenu();
\r
5691 p1 = DOM.getPos(t.settings.menu_container);
\r
5692 p2 = DOM.getPos(e);
\r
5695 m.settings.offset_x = p2.x;
\r
5696 m.settings.offset_y = p2.y;
\r
5697 m.settings.vp_offset_x = p2.x;
\r
5698 m.settings.vp_offset_y = p2.y;
\r
5699 m.settings.keyboard_focus = t._focused;
\r
5700 m.showMenu(0, e.clientHeight);
\r
5702 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5703 t.setState('Selected', 1);
\r
5705 t.isMenuVisible = 1;
\r
5708 renderMenu : function() {
\r
5711 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
\r
5713 'class' : this.classPrefix + 'Menu',
\r
5714 icons : t.settings.icons
\r
5717 m.onHideMenu.add(t.hideMenu, t);
\r
5719 t.onRenderMenu.dispatch(t, m);
\r
5723 hideMenu : function(e) {
\r
5726 // Prevent double toogles by canceling the mouse click event to the button
\r
5727 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
\r
5730 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
\r
5731 t.setState('Selected', 0);
\r
5732 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5734 t.menu.hideMenu();
\r
5737 t.isMenuVisible = 0;
\r
5740 postRender : function() {
\r
5741 var t = this, s = t.settings;
\r
5743 Event.add(t.id, 'click', function() {
\r
5744 if (!t.isDisabled()) {
\r
5746 s.onclick(t.value);
\r
5756 /* file:jscripts/tiny_mce/classes/ui/SplitButton.js */
\r
5759 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
\r
5761 tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
\r
5762 SplitButton : function(id, s) {
\r
5763 this.parent(id, s);
\r
5764 this.classPrefix = 'mceSplitButton';
\r
5767 renderHTML : function() {
\r
5768 var h, t = this, s = t.settings, h1;
\r
5770 h = '<tbody><tr>';
\r
5773 h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']});
\r
5775 h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, '');
\r
5777 h += '<td>' + DOM.createHTML('a', {id : t.id + '_action', href : 'javascript:;', 'class' : 'mceAction ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
\r
5779 h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']});
\r
5780 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', href : 'javascript:;', 'class' : 'mceOpen ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
\r
5782 h += '</tr></tbody>';
\r
5784 return DOM.createHTML('table', {id : t.id, 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', onmousedown : 'return false;', title : s.title}, h);
\r
5787 postRender : function() {
\r
5788 var t = this, s = t.settings;
\r
5791 Event.add(t.id + '_action', 'click', function() {
\r
5792 if (!t.isDisabled())
\r
5793 s.onclick(t.value);
\r
5797 Event.add(t.id + '_open', 'click', t.showMenu, t);
\r
5798 Event.add(t.id + '_open', 'focus', function() {t._focused = 1;});
\r
5799 Event.add(t.id + '_open', 'blur', function() {t._focused = 0;});
\r
5801 // Old IE doesn't have hover on all elements
\r
5802 if (tinymce.isIE6 || !DOM.boxModel) {
\r
5803 Event.add(t.id, 'mouseover', function() {
\r
5804 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
\r
5805 DOM.addClass(t.id, 'mceSplitButtonHover');
\r
5808 Event.add(t.id, 'mouseout', function() {
\r
5809 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
\r
5810 DOM.removeClass(t.id, 'mceSplitButtonHover');
\r
5815 destroy : function() {
\r
5818 Event.clear(this.id + '_action');
\r
5819 Event.clear(this.id + '_open');
\r
5825 /* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */
\r
5828 var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
\r
5830 tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
\r
5831 ColorSplitButton : function(id, s) {
\r
5836 t.settings = s = tinymce.extend({
\r
5837 colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',
\r
5839 default_color : '#888888'
\r
5842 t.onShowMenu = new tinymce.util.Dispatcher(t);
\r
5843 t.onHideMenu = new tinymce.util.Dispatcher(t);
\r
5845 t.value = s.default_color;
\r
5848 showMenu : function() {
\r
5849 var t = this, r, p, e, p2;
\r
5851 if (t.isDisabled())
\r
5854 if (!t.isMenuRendered) {
\r
5856 t.isMenuRendered = true;
\r
5859 if (t.isMenuVisible)
\r
5860 return t.hideMenu();
\r
5862 e = DOM.get(t.id);
\r
5863 DOM.show(t.id + '_menu');
\r
5864 DOM.addClass(e, 'mceSplitButtonSelected');
\r
5865 p2 = DOM.getPos(e);
\r
5866 DOM.setStyles(t.id + '_menu', {
\r
5868 top : p2.y + e.clientHeight,
\r
5873 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5876 t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
\r
5877 if (e.keyCode == 27)
\r
5881 DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
\r
5884 t.onShowMenu.dispatch(t);
\r
5886 t.isMenuVisible = 1;
\r
5889 hideMenu : function(e) {
\r
5892 // Prevent double toogles by canceling the mouse click event to the button
\r
5893 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
\r
5896 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
\r
5897 DOM.removeClass(t.id, 'mceSplitButtonSelected');
\r
5898 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5899 Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
\r
5900 DOM.hide(t.id + '_menu');
\r
5903 t.onHideMenu.dispatch(t);
\r
5905 t.isMenuVisible = 0;
\r
5908 renderMenu : function() {
\r
5909 var t = this, m, i = 0, s = t.settings, n, tb, tr, w;
\r
5911 w = DOM.add(s.menu_container, 'div', {id : t.id + '_menu', 'class' : s['menu_class'] + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
\r
5912 m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
\r
5913 DOM.add(m, 'span', {'class' : 'mceMenuLine'});
\r
5915 n = DOM.add(m, 'table', {'class' : 'mceColorSplitMenu'});
\r
5916 tb = DOM.add(n, 'tbody');
\r
5918 // Generate color grid
\r
5920 each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
\r
5921 c = c.replace(/^#/, '');
\r
5924 tr = DOM.add(tb, 'tr');
\r
5925 i = s.grid_width - 1;
\r
5928 n = DOM.add(tr, 'td');
\r
5930 n = DOM.add(n, 'a', {
\r
5931 href : 'javascript:;',
\r
5933 backgroundColor : '#' + c
\r
5935 mce_color : '#' + c
\r
5939 if (s.more_colors_func) {
\r
5940 n = DOM.add(tb, 'tr');
\r
5941 n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
\r
5942 n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
\r
5944 Event.add(n, 'click', function(e) {
\r
5945 s.more_colors_func.call(s.more_colors_scope || this);
\r
5946 return Event.cancel(e); // Cancel to fix onbeforeunload problem
\r
5950 DOM.addClass(m, 'mceColorSplitMenu');
\r
5952 Event.add(t.id + '_menu', 'click', function(e) {
\r
5957 if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
\r
5960 return Event.cancel(e); // Prevent IE auto save warning
\r
5966 setColor : function(c) {
\r
5969 DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
\r
5973 t.settings.onselect(c);
\r
5976 postRender : function() {
\r
5977 var t = this, id = t.id;
\r
5980 DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
\r
5983 destroy : function() {
\r
5986 Event.clear(this.id + '_menu');
\r
5987 Event.clear(this.id + '_more');
\r
5988 DOM.remove(this.id + '_menu');
\r
5994 /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */
\r
5996 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
\r
5997 renderHTML : function() {
\r
5998 var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl;
\r
6001 for (i=0; i<cl.length; i++) {
\r
6002 // Get current control, prev control, next control and if the control is a list box or not
\r
6007 // Add toolbar start
\r
6009 c = 'mceToolbarStart';
\r
6012 c += ' mceToolbarStartButton';
\r
6013 else if (co.SplitButton)
\r
6014 c += ' mceToolbarStartSplitButton';
\r
6015 else if (co.ListBox)
\r
6016 c += ' mceToolbarStartListBox';
\r
6018 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6021 // Add toolbar end before list box and after the previous button
\r
6022 // This is to fix the o2k7 editor skins
\r
6023 if (pr && co.ListBox) {
\r
6024 if (pr.Button || pr.SplitButton)
\r
6025 h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6028 // Render control HTML
\r
6030 // IE 8 quick fix, needed to propertly generate a hit area for anchors
\r
6032 h += '<td style="position: relative">' + co.renderHTML() + '</td>';
\r
6034 h += '<td>' + co.renderHTML() + '</td>';
\r
6036 // Add toolbar start after list box and before the next button
\r
6037 // This is to fix the o2k7 editor skins
\r
6038 if (nx && co.ListBox) {
\r
6039 if (nx.Button || nx.SplitButton)
\r
6040 h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6044 c = 'mceToolbarEnd';
\r
6047 c += ' mceToolbarEndButton';
\r
6048 else if (co.SplitButton)
\r
6049 c += ' mceToolbarEndSplitButton';
\r
6050 else if (co.ListBox)
\r
6051 c += ' mceToolbarEndListBox';
\r
6053 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6055 return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || ''}, '<tbody><tr>' + h + '</tr></tbody>');
\r
6060 /* file:jscripts/tiny_mce/classes/AddOnManager.js */
\r
6063 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
\r
6065 tinymce.create('tinymce.AddOnManager', {
\r
6069 onAdd : new Dispatcher(this),
\r
6071 get : function(n) {
\r
6072 return this.lookup[n];
\r
6075 requireLangPack : function(n) {
\r
6078 if (tinymce.EditorManager.settings) {
\r
6079 u = this.urls[n] + '/langs/' + tinymce.EditorManager.settings.language + '.js';
\r
6080 s = tinymce.EditorManager.settings;
\r
6083 if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
\r
6084 tinymce.ScriptLoader.load(u);
\r
6086 tinymce.ScriptLoader.add(u);
\r
6091 add : function(id, o) {
\r
6092 this.items.push(o);
\r
6093 this.lookup[id] = o;
\r
6094 this.onAdd.dispatch(this, id, o);
\r
6099 load : function(n, u, cb, s) {
\r
6105 if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
\r
6106 u = tinymce.baseURL + '/' + u;
\r
6108 t.urls[n] = u.substring(0, u.lastIndexOf('/'));
\r
6109 tinymce.ScriptLoader.add(u, cb, s);
\r
6114 // Create plugin and theme managers
\r
6115 tinymce.PluginManager = new tinymce.AddOnManager();
\r
6116 tinymce.ThemeManager = new tinymce.AddOnManager();
\r
6118 /* file:jscripts/tiny_mce/classes/EditorManager.js */
\r
6122 var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode;
\r
6124 tinymce.create('static tinymce.EditorManager', {
\r
6127 activeEditor : null,
\r
6129 preInit : function() {
\r
6130 var t = this, lo = window.location;
\r
6132 // Setup some URLs where the editor API is located and where the document is
\r
6133 tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
\r
6134 if (!/[\/\\]$/.test(tinymce.documentBaseURL))
\r
6135 tinymce.documentBaseURL += '/';
\r
6137 tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
\r
6138 tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
\r
6140 // Setup document domain
\r
6141 if (tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)
\r
6142 document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1');
\r
6144 // Add before unload listener
\r
6145 // This was required since IE was leaking memory if you added and removed beforeunload listeners
\r
6146 // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event
\r
6147 t.onBeforeUnload = new tinymce.util.Dispatcher(t);
\r
6149 // Must be on window or IE will leak if the editor is placed in frame or iframe
\r
6150 Event.add(window, 'beforeunload', function(e) {
\r
6151 t.onBeforeUnload.dispatch(t, e);
\r
6155 init : function(s) {
\r
6156 var t = this, pl, sl = tinymce.ScriptLoader, c, e;
\r
6158 function execCallback(se, n, s) {
\r
6164 if (tinymce.is(f, 'string')) {
\r
6165 s = f.replace(/\.\w+$/, '');
\r
6166 s = s ? tinymce.resolve(s) : 0;
\r
6167 f = tinymce.resolve(f);
\r
6170 return f.apply(s || this, Array.prototype.slice.call(arguments, 2));
\r
6176 strict_loading_mode : document.contentType == 'application/xhtml+xml'
\r
6181 // If page not loaded and strict mode isn't enabled then load them
\r
6182 if (!Event.domLoaded && !s.strict_loading_mode) {
\r
6185 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
\r
6188 if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
\r
6189 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
\r
6193 pl = explode(s.plugins);
\r
6195 // Load compat2x first
\r
6196 if (tinymce.inArray(pl, 'compat2x') != -1)
\r
6197 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
\r
6199 // Load rest if plugins
\r
6200 each(pl, function(v) {
\r
6201 if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) {
\r
6202 // Skip safari plugin for other browsers
\r
6203 if (!tinymce.isWebKit && v == 'safari')
\r
6206 PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js');
\r
6215 Event.add(document, 'init', function() {
\r
6218 execCallback(s, 'onpageload');
\r
6220 // Verify that it's a valid browser
\r
6224 each(explode(s.browsers), function(v) {
\r
6233 if (tinymce.isGecko)
\r
6239 if (tinymce.isWebKit)
\r
6244 if (tinymce.isOpera)
\r
6251 // Not a valid one
\r
6258 l = s.elements || '';
\r
6260 if(l.length > 0) {
\r
6261 each(explode(l), function(v) {
\r
6263 new tinymce.Editor(v, s).render(1);
\r
6267 each(document.forms, function(f) {
\r
6268 each(f.elements, function(e) {
\r
6269 if (e.name === v) {
\r
6270 v = 'mce_editor_' + c;
\r
6271 DOM.setAttrib(e, 'id', v);
\r
6272 new tinymce.Editor(v, s).render(1);
\r
6282 case "specific_textareas":
\r
6283 function hasClass(n, c) {
\r
6284 return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c);
\r
6287 each(DOM.select('textarea'), function(v) {
\r
6288 if (s.editor_deselector && hasClass(v, s.editor_deselector))
\r
6291 if (!s.editor_selector || hasClass(v, s.editor_selector)) {
\r
6292 // Can we use the name
\r
6293 e = DOM.get(v.name);
\r
6297 // Generate unique name if missing or already exists
\r
6298 if (!v.id || t.get(v.id))
\r
6299 v.id = DOM.uniqueId();
\r
6301 new tinymce.Editor(v.id, s).render(1);
\r
6307 // Call onInit when all editors are initialized
\r
6311 each (t.editors, function(ed) {
\r
6314 if (!ed.initialized) {
\r
6316 ed.onInit.add(function() {
\r
6321 execCallback(s, 'oninit');
\r
6328 execCallback(s, 'oninit');
\r
6334 get : function(id) {
\r
6335 return this.editors[id];
\r
6338 getInstanceById : function(id) {
\r
6339 return this.get(id);
\r
6342 add : function(e) {
\r
6343 this.editors[e.id] = e;
\r
6344 this._setActive(e);
\r
6349 remove : function(e) {
\r
6352 // Not in the collection
\r
6353 if (!t.editors[e.id])
\r
6356 delete t.editors[e.id];
\r
6358 // Select another editor since the active one was removed
\r
6359 if (t.activeEditor == e) {
\r
6360 each(t.editors, function(e) {
\r
6362 return false; // Break
\r
6371 execCommand : function(c, u, v) {
\r
6372 var t = this, ed = t.get(v), w;
\r
6374 // Manager commands
\r
6380 case "mceAddEditor":
\r
6381 case "mceAddControl":
\r
6383 new tinymce.Editor(v, t.settings).render();
\r
6387 case "mceAddFrameControl":
\r
6390 // Add tinyMCE global instance and tinymce namespace to specified window
\r
6391 w.tinyMCE = tinyMCE;
\r
6392 w.tinymce = tinymce;
\r
6394 tinymce.DOM.doc = w.document;
\r
6395 tinymce.DOM.win = w;
\r
6397 ed = new tinymce.Editor(v.element_id, v);
\r
6400 // Fix IE memory leaks
\r
6401 if (tinymce.isIE) {
\r
6404 w.detachEvent('onunload', clr);
\r
6405 w = w.tinyMCE = w.tinymce = null; // IE leak
\r
6408 w.attachEvent('onunload', clr);
\r
6411 v.page_window = null;
\r
6415 case "mceRemoveEditor":
\r
6416 case "mceRemoveControl":
\r
6420 case 'mceToggleEditor':
\r
6422 t.execCommand('mceAddControl', 0, v);
\r
6426 if (ed.isHidden())
\r
6434 // Run command on active editor
\r
6435 if (t.activeEditor)
\r
6436 return t.activeEditor.execCommand(c, u, v);
\r
6441 execInstanceCommand : function(id, c, u, v) {
\r
6442 var ed = this.get(id);
\r
6445 return ed.execCommand(c, u, v);
\r
6450 triggerSave : function() {
\r
6451 each(this.editors, function(e) {
\r
6456 addI18n : function(p, o) {
\r
6457 var lo, i18n = this.i18n;
\r
6459 if (!tinymce.is(p, 'string')) {
\r
6460 each(p, function(o, lc) {
\r
6461 each(o, function(o, g) {
\r
6462 each(o, function(o, k) {
\r
6463 if (g === 'common')
\r
6464 i18n[lc + '.' + k] = o;
\r
6466 i18n[lc + '.' + g + '.' + k] = o;
\r
6471 each(o, function(o, k) {
\r
6472 i18n[p + '.' + k] = o;
\r
6477 // Private methods
\r
6479 _setActive : function(e) {
\r
6480 this.selectedInstance = this.activeEditor = e;
\r
6485 tinymce.EditorManager.preInit();
\r
6488 // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call
\r
6489 var tinyMCE = window.tinyMCE = tinymce.EditorManager;
\r
6491 /* file:jscripts/tiny_mce/classes/Editor.js */
\r
6494 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher;
\r
6495 var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit;
\r
6496 var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager;
\r
6497 var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode;
\r
6499 tinymce.create('tinymce.Editor', {
\r
6500 Editor : function(id, s) {
\r
6503 t.id = t.editorId = id;
\r
6504 t.execCommands = {};
\r
6505 t.queryStateCommands = {};
\r
6506 t.queryValueCommands = {};
\r
6509 // Add events to the editor
\r
6512 'onBeforeRenderUI',
\r
6532 'onBeforeSetContent',
\r
6533 'onBeforeGetContent',
\r
6540 'onBeforeExecCommand',
\r
6545 'onSetProgressState'
\r
6547 t[e] = new Dispatcher(t);
\r
6550 // Default editor config
\r
6551 t.settings = s = extend({
\r
6554 docs_language : 'en',
\r
6561 document_base_url : tinymce.documentBaseURL,
\r
6562 add_form_submit_trigger : 1,
\r
6564 add_unload_trigger : 1,
\r
6566 relative_urls : 1,
\r
6567 remove_script_host : 1,
\r
6568 table_inline_editing : 0,
\r
6569 object_resizing : 1,
\r
6571 accessibility_focus : 1,
\r
6572 custom_shortcuts : 1,
\r
6573 custom_undo_redo_keyboard_shortcuts : 1,
\r
6574 custom_undo_redo_restore_selection : 1,
\r
6575 custom_undo_redo : 1,
\r
6576 doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
\r
6577 visual_table_class : 'mceItemTable',
\r
6579 inline_styles : true,
\r
6580 convert_fonts_to_spans : true,
\r
6581 font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large',
\r
6582 apply_source_formatting : 1,
\r
6583 directionality : 'ltr',
\r
6584 forced_root_block : 'p',
\r
6585 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],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',
\r
6587 padd_empty_editor : 1,
\r
6590 force_p_newlines : 1,
\r
6591 indentation : '30px'
\r
6595 t.documentBaseURI = new tinymce.util.URI(s.document_base_url || tinymce.documentBaseURL, {
\r
6596 base_uri : tinyMCE.baseURI
\r
6598 t.baseURI = EditorManager.baseURI;
\r
6601 t.execCallback('setup', t);
\r
6604 render : function(nst) {
\r
6605 var t = this, s = t.settings, id = t.id, sl = tinymce.ScriptLoader;
\r
6607 // Page is not loaded yet, wait for it
\r
6608 if (!Event.domLoaded) {
\r
6609 Event.add(document, 'init', function() {
\r
6615 // Force strict loading mode if render us called by user and not internally
\r
6617 s.strict_loading_mode = 1;
\r
6618 tinyMCE.settings = s;
\r
6621 // Element not found, then skip initialization
\r
6622 if (!t.getElement())
\r
6625 if (s.strict_loading_mode) {
\r
6626 sl.settings.strict_mode = s.strict_loading_mode;
\r
6627 tinymce.DOM.settings.strict = 1;
\r
6630 // Add hidden input for non input elements inside form elements
\r
6631 if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form'))
\r
6632 DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
\r
6634 t.windowManager = new tinymce.WindowManager(t);
\r
6636 if (s.encoding == 'xml') {
\r
6637 t.onGetContent.add(function(ed, o) {
\r
6639 o.content = DOM.encode(o.content);
\r
6643 if (s.add_form_submit_trigger) {
\r
6644 t.onSubmit.addToTop(function() {
\r
6645 if (t.initialized) {
\r
6652 if (s.add_unload_trigger && !s.ask) {
\r
6653 t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
\r
6654 if (t.initialized && !t.destroyed && !t.isHidden())
\r
6655 t.save({format : 'raw', no_events : true});
\r
6659 tinymce.addUnload(t.destroy, t);
\r
6661 if (s.submit_patch) {
\r
6662 t.onBeforeRenderUI.add(function() {
\r
6663 var n = t.getElement().form;
\r
6668 // Already patched
\r
6669 if (n._mceOldSubmit)
\r
6672 // Check page uses id="submit" or name="submit" for it's submit button
\r
6673 if (!n.submit.nodeType && !n.submit.length) {
\r
6674 t.formElement = n;
\r
6675 n._mceOldSubmit = n.submit;
\r
6676 n.submit = function() {
\r
6677 // Save all instances
\r
6678 EditorManager.triggerSave();
\r
6681 return this._mceOldSubmit(this);
\r
6690 function loadScripts() {
\r
6692 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
\r
6694 if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
\r
6695 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
\r
6697 each(explode(s.plugins), function(p) {
\r
6698 if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
\r
6699 // Skip safari plugin for other browsers
\r
6700 if (!isWebKit && p == 'safari')
\r
6703 PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js');
\r
6707 // Init when que is loaded
\r
6708 sl.loadQueue(function() {
\r
6711 // Yield for awhile to avoid focus bug on FF 3 when cancel is pressed
\r
6712 window.setTimeout(function() {
\r
6713 Event.remove(t.id, 'focus', ask);
\r
6715 t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
\r
6722 Event.add(t.id, 'focus', ask);
\r
6731 // Load compat2x first
\r
6732 if (s.plugins.indexOf('compat2x') != -1) {
\r
6733 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
\r
6734 sl.loadQueue(loadScripts);
\r
6739 init : function() {
\r
6740 var n, t = this, s = t.settings, w, h, e = t.getElement(), o, ti, u, bi, bc, re;
\r
6742 EditorManager.add(t);
\r
6745 s.theme = s.theme.replace(/-/, '');
\r
6746 o = ThemeManager.get(s.theme);
\r
6747 t.theme = new o();
\r
6749 if (t.theme.init && s.init_theme)
\r
6750 t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
\r
6752 // Create all plugins
\r
6753 each(explode(s.plugins.replace(/\-/g, '')), function(p) {
\r
6754 var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po;
\r
6759 t.plugins[p] = po;
\r
6766 // Setup popup CSS path(s)
\r
6768 s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
\r
6770 s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
\r
6772 if (s.popup_css_add)
\r
6773 s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add);
\r
6775 // Setup control factory
\r
6776 t.controlManager = new tinymce.ControlManager(t);
\r
6777 t.undoManager = new tinymce.UndoManager(t);
\r
6780 t.undoManager.onAdd.add(function(um, l) {
\r
6782 return t.onChange.dispatch(t, l, um);
\r
6785 t.undoManager.onUndo.add(function(um, l) {
\r
6786 return t.onUndo.dispatch(t, l, um);
\r
6789 t.undoManager.onRedo.add(function(um, l) {
\r
6790 return t.onRedo.dispatch(t, l, um);
\r
6793 if (s.custom_undo_redo) {
\r
6794 t.onExecCommand.add(function(ed, cmd, ui, val, a) {
\r
6795 if (cmd != 'Undo' && cmd != 'Redo' && cmd != 'mceRepaint' && (!a || !a.skip_undo))
\r
6796 t.undoManager.add();
\r
6800 t.onExecCommand.add(function(ed, c) {
\r
6801 // Don't refresh the select lists until caret move
\r
6802 if (!/^(FontName|FontSize)$/.test(c))
\r
6806 // Remove ghost selections on images and tables in Gecko
\r
6808 function repaint(a, o) {
\r
6809 if (!o || !o.initial)
\r
6810 t.execCommand('mceRepaint');
\r
6813 t.onUndo.add(repaint);
\r
6814 t.onRedo.add(repaint);
\r
6815 t.onSetContent.add(repaint);
\r
6818 // Enables users to override the control factory
\r
6819 t.onBeforeRenderUI.dispatch(t, t.controlManager);
\r
6822 if (s.render_ui) {
\r
6823 w = s.width || e.style.width || e.offsetWidth;
\r
6824 h = s.height || e.style.height || e.offsetHeight;
\r
6825 t.orgDisplay = e.style.display;
\r
6826 re = /^[0-9\.]+(|px)$/i;
\r
6828 if (re.test('' + w))
\r
6829 w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100);
\r
6831 if (re.test('' + h))
\r
6832 h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100);
\r
6835 o = t.theme.renderUI({
\r
6839 deltaWidth : s.delta_width,
\r
6840 deltaHeight : s.delta_height
\r
6843 t.editorContainer = o.editorContainer;
\r
6848 DOM.setStyles(o.sizeContainer || o.editorContainer, {
\r
6853 h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : '');
\r
6857 t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />';
\r
6858 t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
\r
6860 if (tinymce.relaxedDomain)
\r
6861 t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>';
\r
6863 bi = s.body_id || 'tinymce';
\r
6864 if (bi.indexOf('=') != -1) {
\r
6865 bi = t.getParam('body_id', '', 'hash');
\r
6866 bi = bi[t.id] || bi;
\r
6869 bc = s.body_class || '';
\r
6870 if (bc.indexOf('=') != -1) {
\r
6871 bc = t.getParam('body_class', '', 'hash');
\r
6872 bc = bc[t.id] || '';
\r
6875 t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>';
\r
6877 // Domain relaxing enabled, then set document domain
\r
6878 if (tinymce.relaxedDomain) {
\r
6879 // We need to write the contents here in IE since multiple writes messes up refresh button and back button
\r
6881 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();})()';
\r
6882 else if (tinymce.isOpera)
\r
6883 u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
\r
6887 n = DOM.add(o.iframeContainer, 'iframe', {
\r
6888 id : t.id + "_ifr",
\r
6889 src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7
\r
6890 frameBorder : '0',
\r
6897 t.contentAreaContainer = o.iframeContainer;
\r
6898 DOM.get(o.editorContainer).style.display = t.orgDisplay;
\r
6899 DOM.get(t.id).style.display = 'none';
\r
6901 // Safari 2.x requires us to wait for the load event and load a real HTML doc
\r
6902 if (tinymce.isOldWebKit) {
\r
6903 Event.add(n, 'load', t.setupIframe, t);
\r
6904 n.src = tinymce.baseURL + '/plugins/safari/blank.htm';
\r
6906 if (!isIE || !tinymce.relaxedDomain)
\r
6909 e = n = o = null; // Cleanup
\r
6913 setupIframe : function() {
\r
6914 var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b;
\r
6916 // Setup iframe body
\r
6917 if (!isIE || !tinymce.relaxedDomain) {
\r
6919 d.write(t.iframeHTML);
\r
6923 // Design mode needs to be added here Ctrl+A will fail otherwise
\r
6926 d.designMode = 'On';
\r
6928 // Will fail on Gecko if the editor is placed in an hidden container element
\r
6929 // The design mode will be set ones the editor is focused
\r
6933 // IE needs to use contentEditable or it will display non secure items for HTTPS
\r
6935 // It will not steal focus if we hide it while setting contentEditable
\r
6938 b.contentEditable = true;
\r
6943 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), {
\r
6944 keep_values : true,
\r
6945 url_converter : t.convertURL,
\r
6946 url_converter_scope : t,
\r
6947 hex_colors : s.force_hex_style_colors,
\r
6948 class_filter : s.class_filter,
\r
6949 update_styles : 1,
\r
6950 fix_ie_paragraphs : 1
\r
6953 t.serializer = new tinymce.dom.Serializer({
\r
6954 entity_encoding : s.entity_encoding,
\r
6955 entities : s.entities,
\r
6956 valid_elements : s.verify_html === false ? '*[*]' : s.valid_elements,
\r
6957 extended_valid_elements : s.extended_valid_elements,
\r
6958 valid_child_elements : s.valid_child_elements,
\r
6959 invalid_elements : s.invalid_elements,
\r
6960 fix_table_elements : s.fix_table_elements,
\r
6961 fix_list_elements : s.fix_list_elements,
\r
6962 fix_content_duplication : s.fix_content_duplication,
\r
6963 convert_fonts_to_spans : s.convert_fonts_to_spans,
\r
6964 font_size_classes : s.font_size_classes,
\r
6965 font_size_style_values : s.font_size_style_values,
\r
6966 apply_source_formatting : s.apply_source_formatting,
\r
6967 remove_linebreaks : s.remove_linebreaks,
\r
6971 t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer);
\r
6972 t.forceBlocks = new tinymce.ForceBlocks(t, {
\r
6973 forced_root_block : s.forced_root_block
\r
6975 t.editorCommands = new tinymce.EditorCommands(t);
\r
6978 t.serializer.onPreProcess.add(function(se, o) {
\r
6979 return t.onPreProcess.dispatch(t, o, se);
\r
6982 t.serializer.onPostProcess.add(function(se, o) {
\r
6983 return t.onPostProcess.dispatch(t, o, se);
\r
6986 t.onPreInit.dispatch(t);
\r
6988 if (!s.gecko_spellcheck)
\r
6989 t.getBody().spellcheck = 0;
\r
6993 t.controlManager.onPostRender.dispatch(t, t.controlManager);
\r
6994 t.onPostRender.dispatch(t);
\r
6996 if (s.directionality)
\r
6997 t.getBody().dir = s.directionality;
\r
7000 t.getBody().style.whiteSpace = "nowrap";
\r
7002 if (s.auto_resize)
\r
7003 t.onNodeChange.add(t.resizeToContent, t);
\r
7005 if (s.custom_elements) {
\r
7006 function handleCustom(ed, o) {
\r
7007 each(explode(s.custom_elements), function(v) {
\r
7010 if (v.indexOf('~') === 0) {
\r
7011 v = v.substring(1);
\r
7016 o.content = o.content.replace(new RegExp('<(' + v + ')([^>]*)>', 'g'), '<' + n + ' mce_name="$1"$2>');
\r
7017 o.content = o.content.replace(new RegExp('</(' + v + ')>', 'g'), '</' + n + '>');
\r
7021 t.onBeforeSetContent.add(handleCustom);
\r
7022 t.onPostProcess.add(function(ed, o) {
\r
7024 handleCustom(ed, o)
\r
7028 if (s.handle_node_change_callback) {
\r
7029 t.onNodeChange.add(function(ed, cm, n) {
\r
7030 t.execCallback('handle_node_change_callback', t.id, n, -1, -1, true, t.selection.isCollapsed());
\r
7034 if (s.save_callback) {
\r
7035 t.onSaveContent.add(function(ed, o) {
\r
7036 var h = t.execCallback('save_callback', t.id, o.content, t.getBody());
\r
7043 if (s.onchange_callback) {
\r
7044 t.onChange.add(function(ed, l) {
\r
7045 t.execCallback('onchange_callback', t, l);
\r
7049 if (s.convert_newlines_to_brs) {
\r
7050 t.onBeforeSetContent.add(function(ed, o) {
\r
7052 o.content = o.content.replace(/\r?\n/g, '<br />');
\r
7056 if (s.fix_nesting && isIE) {
\r
7057 t.onBeforeSetContent.add(function(ed, o) {
\r
7058 o.content = t._fixNesting(o.content);
\r
7062 if (s.preformatted) {
\r
7063 t.onPostProcess.add(function(ed, o) {
\r
7064 o.content = o.content.replace(/^\s*<pre.*?>/, '');
\r
7065 o.content = o.content.replace(/<\/pre>\s*$/, '');
\r
7068 o.content = '<pre class="mceItemHidden">' + o.content + '</pre>';
\r
7072 if (s.verify_css_classes) {
\r
7073 t.serializer.attribValueFilter = function(n, v) {
\r
7076 if (n == 'class') {
\r
7077 // Build regexp for classes
\r
7078 if (!t.classesRE) {
\r
7079 cl = t.dom.getClasses();
\r
7081 if (cl.length > 0) {
\r
7084 each (cl, function(o) {
\r
7085 s += (s ? '|' : '') + o['class'];
\r
7088 t.classesRE = new RegExp('(' + s + ')', 'gi');
\r
7092 return !t.classesRE || /(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v) || t.classesRE.test(v) ? v : '';
\r
7099 if (s.convert_fonts_to_spans)
\r
7100 t._convertFonts();
\r
7102 if (s.inline_styles)
\r
7103 t._convertInlineElements();
\r
7105 if (s.cleanup_callback) {
\r
7106 t.onBeforeSetContent.add(function(ed, o) {
\r
7107 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
\r
7110 t.onPreProcess.add(function(ed, o) {
\r
7112 t.execCallback('cleanup_callback', 'insert_to_editor_dom', o.node, o);
\r
7115 t.execCallback('cleanup_callback', 'get_from_editor_dom', o.node, o);
\r
7118 t.onPostProcess.add(function(ed, o) {
\r
7120 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
\r
7123 o.content = t.execCallback('cleanup_callback', 'get_from_editor', o.content, o);
\r
7127 if (s.save_callback) {
\r
7128 t.onGetContent.add(function(ed, o) {
\r
7130 o.content = t.execCallback('save_callback', t.id, o.content, t.getBody());
\r
7134 if (s.handle_event_callback) {
\r
7135 t.onEvent.add(function(ed, e, o) {
\r
7136 if (t.execCallback('handle_event_callback', e, ed, o) === false)
\r
7141 t.onSetContent.add(function() {
\r
7142 // Safari needs some time, it will crash the browser when a link is created otherwise
\r
7143 // I think this crash issue is resolved in the latest 3.0.4
\r
7144 //window.setTimeout(function() {
\r
7145 t.addVisual(t.getBody());
\r
7149 // Remove empty contents
\r
7150 if (s.padd_empty_editor) {
\r
7151 t.onPostProcess.add(function(ed, o) {
\r
7152 o.content = o.content.replace(/^(<p>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, '');
\r
7158 // Design mode must be set here once again to fix a bug where
\r
7159 // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
\r
7160 d.designMode = 'Off';
\r
7161 d.designMode = 'On';
\r
7163 // Will fail on Gecko if the editor is placed in an hidden container element
\r
7164 // The design mode will be set ones the editor is focused
\r
7168 // A small timeout was needed since firefox will remove. Bug: #1838304
\r
7169 setTimeout(function () {
\r
7173 t.load({initial : true, format : (s.cleanup_on_startup ? 'html' : 'raw')});
\r
7174 t.startContent = t.getContent({format : 'raw'});
\r
7175 t.undoManager.add({initial : true});
\r
7176 t.initialized = true;
\r
7178 t.onInit.dispatch(t);
\r
7179 t.execCallback('setupcontent_callback', t.id, t.getBody(), t.getDoc());
\r
7180 t.execCallback('init_instance_callback', t);
\r
7182 t.nodeChanged({initial : 1});
\r
7184 // Load specified content CSS last
\r
7185 if (s.content_css) {
\r
7186 tinymce.each(explode(s.content_css), function(u) {
\r
7187 t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));
\r
7191 // Handle auto focus
\r
7192 if (s.auto_focus) {
\r
7193 setTimeout(function () {
\r
7194 var ed = EditorManager.get(s.auto_focus);
\r
7196 ed.selection.select(ed.getBody(), 1);
\r
7197 ed.selection.collapse(1);
\r
7198 ed.getWin().focus();
\r
7207 focus : function(sf) {
\r
7208 var oed, t = this, ce = t.settings.content_editable;
\r
7211 // Is not content editable or the selection is outside the area in IE
\r
7212 // the IE statement is needed to avoid bluring if element selections inside layers since
\r
7213 // the layer is like it's own document in IE
\r
7214 if (!ce && (!isIE || t.selection.getNode().ownerDocument != t.getDoc()))
\r
7215 t.getWin().focus();
\r
7219 if (EditorManager.activeEditor != t) {
\r
7220 if ((oed = EditorManager.activeEditor) != null)
\r
7221 oed.onDeactivate.dispatch(oed, t);
\r
7223 t.onActivate.dispatch(t, oed);
\r
7226 EditorManager._setActive(t);
\r
7229 execCallback : function(n) {
\r
7230 var t = this, f = t.settings[n], s;
\r
7235 // Look through lookup
\r
7236 if (t.callbackLookup && (s = t.callbackLookup[n])) {
\r
7241 if (is(f, 'string')) {
\r
7242 s = f.replace(/\.\w+$/, '');
\r
7243 s = s ? tinymce.resolve(s) : 0;
\r
7244 f = tinymce.resolve(f);
\r
7245 t.callbackLookup = t.callbackLookup || {};
\r
7246 t.callbackLookup[n] = {func : f, scope : s};
\r
7249 return f.apply(s || t, Array.prototype.slice.call(arguments, 1));
\r
7252 translate : function(s) {
\r
7253 var c = this.settings.language, i18n = EditorManager.i18n;
\r
7258 return i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
\r
7259 return i18n[c + '.' + b] || '{#' + b + '}';
\r
7263 getLang : function(n, dv) {
\r
7264 return EditorManager.i18n[this.settings.language + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
\r
7267 getParam : function(n, dv, ty) {
\r
7268 var tr = tinymce.trim, v = is(this.settings[n]) ? this.settings[n] : dv, o;
\r
7270 if (ty === 'hash') {
\r
7273 if (is(v, 'string')) {
\r
7274 each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) {
\r
7278 o[tr(v[0])] = tr(v[1]);
\r
7280 o[tr(v[0])] = tr(v);
\r
7291 nodeChanged : function(o) {
\r
7292 var t = this, s = t.selection, n = s.getNode() || t.getBody();
\r
7294 // Fix for bug #1896577 it seems that this can not be fired while the editor is loading
\r
7295 if (t.initialized) {
\r
7296 t.onNodeChange.dispatch(
\r
7298 o ? o.controlManager || t.controlManager : t.controlManager,
\r
7299 isIE && n.ownerDocument != t.getDoc() ? t.getBody() : n, // Fix for IE initial state
\r
7306 addButton : function(n, s) {
\r
7309 t.buttons = t.buttons || {};
\r
7313 addCommand : function(n, f, s) {
\r
7314 this.execCommands[n] = {func : f, scope : s || this};
\r
7317 addQueryStateHandler : function(n, f, s) {
\r
7318 this.queryStateCommands[n] = {func : f, scope : s || this};
\r
7321 addQueryValueHandler : function(n, f, s) {
\r
7322 this.queryValueCommands[n] = {func : f, scope : s || this};
\r
7325 addShortcut : function(pa, desc, cmd_func, sc) {
\r
7328 if (!t.settings.custom_shortcuts)
\r
7331 t.shortcuts = t.shortcuts || {};
\r
7333 if (is(cmd_func, 'string')) {
\r
7336 cmd_func = function() {
\r
7337 t.execCommand(c, false, null);
\r
7341 if (is(cmd_func, 'object')) {
\r
7344 cmd_func = function() {
\r
7345 t.execCommand(c[0], c[1], c[2]);
\r
7349 each(explode(pa), function(pa) {
\r
7352 scope : sc || this,
\r
7359 each(explode(pa, '+'), function(v) {
\r
7368 o.charCode = v.charCodeAt(0);
\r
7369 o.keyCode = v.toUpperCase().charCodeAt(0);
\r
7373 t.shortcuts[(o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode] = o;
\r
7379 execCommand : function(cmd, ui, val, a) {
\r
7380 var t = this, s = 0, o, st;
\r
7382 if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus))
\r
7386 t.onBeforeExecCommand.dispatch(t, cmd, ui, val, o);
\r
7390 // Command callback
\r
7391 if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
\r
7392 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7396 // Registred commands
\r
7397 if (o = t.execCommands[cmd]) {
\r
7398 st = o.func.call(o.scope, ui, val);
\r
7400 // Fall through on true
\r
7401 if (st !== true) {
\r
7402 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7407 // Plugin commands
\r
7408 each(t.plugins, function(p) {
\r
7409 if (p.execCommand && p.execCommand(cmd, ui, val)) {
\r
7410 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7420 if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
\r
7421 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7425 // Editor commands
\r
7426 if (t.editorCommands.execCommand(cmd, ui, val)) {
\r
7427 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7431 // Browser commands
\r
7432 t.getDoc().execCommand(cmd, ui, val);
\r
7433 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7436 queryCommandState : function(c) {
\r
7437 var t = this, o, s;
\r
7439 // Is hidden then return undefined
\r
7440 if (t._isHidden())
\r
7443 // Registred commands
\r
7444 if (o = t.queryStateCommands[c]) {
\r
7445 s = o.func.call(o.scope);
\r
7447 // Fall though on true
\r
7452 // Registred commands
\r
7453 o = t.editorCommands.queryCommandState(c);
\r
7457 // Browser commands
\r
7459 return this.getDoc().queryCommandState(c);
\r
7461 // Fails sometimes see bug: 1896577
\r
7465 queryCommandValue : function(c) {
\r
7466 var t = this, o, s;
\r
7468 // Is hidden then return undefined
\r
7469 if (t._isHidden())
\r
7472 // Registred commands
\r
7473 if (o = t.queryValueCommands[c]) {
\r
7474 s = o.func.call(o.scope);
\r
7476 // Fall though on true
\r
7481 // Registred commands
\r
7482 o = t.editorCommands.queryCommandValue(c);
\r
7486 // Browser commands
\r
7488 return this.getDoc().queryCommandValue(c);
\r
7490 // Fails sometimes see bug: 1896577
\r
7494 show : function() {
\r
7497 DOM.show(t.getContainer());
\r
7502 hide : function() {
\r
7503 var t = this, d = t.getDoc();
\r
7505 // Fixed bug where IE has a blinking cursor left from the editor
\r
7507 d.execCommand('SelectAll');
\r
7509 // We must save before we hide so Safari doesn't crash
\r
7511 DOM.hide(t.getContainer());
\r
7512 DOM.setStyle(t.id, 'display', t.orgDisplay);
\r
7515 isHidden : function() {
\r
7516 return !DOM.isHidden(this.id);
\r
7519 setProgressState : function(b, ti, o) {
\r
7520 this.onSetProgressState.dispatch(this, b, ti, o);
\r
7525 resizeToContent : function() {
\r
7528 DOM.setStyle(t.id + "_ifr", 'height', t.getBody().scrollHeight);
\r
7531 load : function(o) {
\r
7532 var t = this, e = t.getElement(), h;
\r
7537 h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
\r
7541 t.onLoadContent.dispatch(t, o);
\r
7543 o.element = e = null;
\r
7548 save : function(o) {
\r
7549 var t = this, e = t.getElement(), h, f;
\r
7551 if (!t.initialized)
\r
7557 // Add undo level will trigger onchange event
\r
7558 if (!o.no_events) {
\r
7559 t.undoManager.typing = 0;
\r
7560 t.undoManager.add();
\r
7564 h = o.content = t.getContent(o);
\r
7567 t.onSaveContent.dispatch(t, o);
\r
7571 if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
\r
7574 // Update hidden form element
\r
7575 if (f = DOM.getParent(t.id, 'form')) {
\r
7576 each(f.elements, function(e) {
\r
7577 if (e.name == t.id) {
\r
7586 o.element = e = null;
\r
7591 setContent : function(h, o) {
\r
7595 o.format = o.format || 'html';
\r
7600 t.onBeforeSetContent.dispatch(t, o);
\r
7602 // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
\r
7603 // It will also be impossible to place the caret in the editor unless there is a BR element present
\r
7604 if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
\r
7605 o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />');
\r
7609 o.content = t.dom.setHTML(t.getBody(), tinymce.trim(o.content));
\r
7611 if (o.format != 'raw' && t.settings.cleanup) {
\r
7612 o.getInner = true;
\r
7613 o.content = t.dom.setHTML(t.getBody(), t.serializer.serialize(t.getBody(), o));
\r
7617 t.onSetContent.dispatch(t, o);
\r
7622 getContent : function(o) {
\r
7626 o.format = o.format || 'html';
\r
7630 t.onBeforeGetContent.dispatch(t, o);
\r
7632 if (o.format != 'raw' && t.settings.cleanup) {
\r
7633 o.getInner = true;
\r
7634 h = t.serializer.serialize(t.getBody(), o);
\r
7636 h = t.getBody().innerHTML;
\r
7638 h = h.replace(/^\s*|\s*$/g, '');
\r
7642 t.onGetContent.dispatch(t, o);
\r
7647 isDirty : function() {
\r
7650 return tinymce.trim(t.startContent) != tinymce.trim(t.getContent({format : 'raw', no_events : 1})) && !t.isNotDirty;
\r
7653 getContainer : function() {
\r
7657 t.container = DOM.get(t.editorContainer || t.id + '_parent');
\r
7659 return t.container;
\r
7662 getContentAreaContainer : function() {
\r
7663 return this.contentAreaContainer;
\r
7666 getElement : function() {
\r
7667 return DOM.get(this.settings.content_element || this.id);
\r
7670 getWin : function() {
\r
7673 if (!t.contentWindow) {
\r
7674 e = DOM.get(t.id + "_ifr");
\r
7677 t.contentWindow = e.contentWindow;
\r
7680 return t.contentWindow;
\r
7683 getDoc : function() {
\r
7686 if (!t.contentDocument) {
\r
7690 t.contentDocument = w.document;
\r
7693 return t.contentDocument;
\r
7696 getBody : function() {
\r
7697 return this.bodyElement || this.getDoc().body;
\r
7700 convertURL : function(u, n, e) {
\r
7701 var t = this, s = t.settings;
\r
7703 // Use callback instead
\r
7704 if (s.urlconverter_callback)
\r
7705 return t.execCallback('urlconverter_callback', u, e, true, n);
\r
7707 // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
\r
7708 if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
\r
7711 // Convert to relative
\r
7712 if (s.relative_urls)
\r
7713 return t.documentBaseURI.toRelative(u);
\r
7715 // Convert to absolute
\r
7716 u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);
\r
7721 addVisual : function(e) {
\r
7722 var t = this, s = t.settings;
\r
7724 e = e || t.getBody();
\r
7726 if (!is(t.hasVisual))
\r
7727 t.hasVisual = s.visual;
\r
7729 each(t.dom.select('table,a', e), function(e) {
\r
7732 switch (e.nodeName) {
\r
7734 v = t.dom.getAttrib(e, 'border');
\r
7736 if (!v || v == '0') {
\r
7738 t.dom.addClass(e, s.visual_table_class);
\r
7740 t.dom.removeClass(e, s.visual_table_class);
\r
7746 v = t.dom.getAttrib(e, 'name');
\r
7750 t.dom.addClass(e, 'mceItemAnchor');
\r
7752 t.dom.removeClass(e, 'mceItemAnchor');
\r
7759 t.onVisualAid.dispatch(t, e, t.hasVisual);
\r
7762 remove : function() {
\r
7763 var t = this, e = t.getContainer();
\r
7765 t.removed = 1; // Cancels post remove event execution
\r
7768 t.execCallback('remove_instance_callback', t);
\r
7769 t.onRemove.dispatch(t);
\r
7771 // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command
\r
7772 t.onExecCommand.listeners = [];
\r
7774 EditorManager.remove(t);
\r
7778 destroy : function(s) {
\r
7781 // One time is enough
\r
7786 tinymce.removeUnload(t.destroy);
\r
7787 tinyMCE.onBeforeUnload.remove(t._beforeUnload);
\r
7790 if (t.theme.destroy)
\r
7791 t.theme.destroy();
\r
7793 // Destroy controls, selection and dom
\r
7794 t.controlManager.destroy();
\r
7795 t.selection.destroy();
\r
7798 // Remove all events
\r
7800 // Don't clear the window or document if content editable
\r
7801 // is enabled since other instances might still be present
\r
7802 if (!t.settings.content_editable) {
\r
7803 Event.clear(t.getWin());
\r
7804 Event.clear(t.getDoc());
\r
7807 Event.clear(t.getBody());
\r
7808 Event.clear(t.formElement);
\r
7811 if (t.formElement) {
\r
7812 t.formElement.submit = t.formElement._mceOldSubmit;
\r
7813 t.formElement._mceOldSubmit = null;
\r
7816 t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null;
\r
7819 t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null;
\r
7824 // Internal functions
\r
7826 _addEvents : function() {
\r
7827 // 'focus', 'blur', 'dblclick', 'beforedeactivate', submit, reset
\r
7828 var t = this, i, s = t.settings, lo = {
\r
7829 mouseup : 'onMouseUp',
\r
7830 mousedown : 'onMouseDown',
\r
7831 click : 'onClick',
\r
7832 keyup : 'onKeyUp',
\r
7833 keydown : 'onKeyDown',
\r
7834 keypress : 'onKeyPress',
\r
7835 submit : 'onSubmit',
\r
7836 reset : 'onReset',
\r
7837 contextmenu : 'onContextMenu',
\r
7838 dblclick : 'onDblClick',
\r
7839 paste : 'onPaste' // Doesn't work in all browsers yet
\r
7842 function eventHandler(e, o) {
\r
7845 // Don't fire events when it's removed
\r
7849 // Generic event handler
\r
7850 if (t.onEvent.dispatch(t, e, o) !== false) {
\r
7851 // Specific event handler
\r
7852 t[lo[e.fakeType || e.type]].dispatch(t, e, o);
\r
7857 each(lo, function(v, k) {
\r
7859 case 'contextmenu':
\r
7860 if (tinymce.isOpera) {
\r
7861 // Fake contextmenu on Opera
\r
7862 Event.add(t.getBody(), 'mousedown', function(e) {
\r
7864 e.fakeType = 'contextmenu';
\r
7869 Event.add(t.getBody(), k, eventHandler);
\r
7873 Event.add(t.getBody(), k, function(e) {
\r
7876 // Get plain text data
\r
7877 if (e.clipboardData)
\r
7878 tx = e.clipboardData.getData('text/plain');
\r
7879 else if (tinymce.isIE)
\r
7880 tx = t.getWin().clipboardData.getData('Text');
\r
7883 /*if (tinymce.isIE) {
\r
7884 el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
\r
7885 r = DOM.doc.body.createTextRange();
\r
7886 r.moveToElementText(el);
\r
7887 r.execCommand('Paste');
\r
7892 eventHandler(e, {text : tx, html : h});
\r
7898 Event.add(t.getElement().form || DOM.getParent(t.id, 'form'), k, eventHandler);
\r
7902 Event.add(s.content_editable ? t.getBody() : t.getDoc(), k, eventHandler);
\r
7906 Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) {
\r
7911 // Fixes bug where a specified document_base_uri could result in broken images
\r
7912 // This will also fix drag drop of images in Gecko
\r
7913 if (tinymce.isGecko) {
\r
7914 // Convert all images to absolute URLs
\r
7915 /* t.onSetContent.add(function(ed, o) {
\r
7916 each(ed.dom.select('img'), function(e) {
\r
7919 if (v = e.getAttribute('mce_src'))
\r
7920 e.src = t.documentBaseURI.toAbsolute(v);
\r
7924 Event.add(t.getDoc(), 'DOMNodeInserted', function(e) {
\r
7929 if (e.nodeType === 1 && e.nodeName === 'IMG' && (v = e.getAttribute('mce_src')))
\r
7930 e.src = t.documentBaseURI.toAbsolute(v);
\r
7934 // Set various midas options in Gecko
\r
7936 function setOpts() {
\r
7937 var t = this, d = t.getDoc(), s = t.settings;
\r
7940 if (t._isHidden()) {
\r
7942 if (!s.content_editable)
\r
7943 d.designMode = 'On';
\r
7945 // Fails if it's hidden
\r
7950 // Try new Gecko method
\r
7951 d.execCommand("styleWithCSS", 0, false);
\r
7954 if (!t._isHidden())
\r
7955 try {d.execCommand("useCSS", 0, true);} catch (ex) {}
\r
7958 if (!s.table_inline_editing)
\r
7959 try {d.execCommand('enableInlineTableEditing', false, false);} catch (ex) {}
\r
7961 if (!s.object_resizing)
\r
7962 try {d.execCommand('enableObjectResizing', false, false);} catch (ex) {}
\r
7966 t.onBeforeExecCommand.add(setOpts);
\r
7967 t.onMouseDown.add(setOpts);
\r
7970 // Add node change handlers
\r
7971 t.onMouseUp.add(t.nodeChanged);
\r
7972 t.onClick.add(t.nodeChanged);
\r
7973 t.onKeyUp.add(function(ed, e) {
\r
7974 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)
\r
7978 // Add reset handler
\r
7979 t.onReset.add(function() {
\r
7980 t.setContent(t.startContent, {format : 'raw'});
\r
7983 if (t.getParam('tab_focus')) {
\r
7984 function tabCancel(ed, e) {
\r
7985 if (e.keyCode === 9)
\r
7986 return Event.cancel(e);
\r
7989 function tabHandler(ed, e) {
\r
7990 var x, i, f, el, v;
\r
7992 function find(d) {
\r
7993 f = DOM.getParent(ed.id, 'form');
\r
7997 each(el, function(e, i) {
\r
7998 if (e.id == ed.id) {
\r
8005 for (i = x + 1; i < el.length; i++) {
\r
8006 if (el[i].type != 'hidden')
\r
8010 for (i = x - 1; i >= 0; i--) {
\r
8011 if (el[i].type != 'hidden')
\r
8020 if (e.keyCode === 9) {
\r
8021 v = explode(ed.getParam('tab_focus'));
\r
8023 if (v.length == 1) {
\r
8028 // Find element to focus
\r
8030 if (v[0] == ':prev')
\r
8033 el = DOM.get(v[0]);
\r
8035 if (v[1] == ':next')
\r
8038 el = DOM.get(v[1]);
\r
8042 if (ed = EditorManager.get(el.id || el.name))
\r
8045 window.setTimeout(function() {window.focus();el.focus();}, 10);
\r
8047 return Event.cancel(e);
\r
8052 t.onKeyUp.add(tabCancel);
\r
8055 t.onKeyPress.add(tabHandler);
\r
8056 t.onKeyDown.add(tabCancel);
\r
8058 t.onKeyDown.add(tabHandler);
\r
8062 if (s.custom_shortcuts) {
\r
8063 if (s.custom_undo_redo_keyboard_shortcuts) {
\r
8064 t.addShortcut('ctrl+z', t.getLang('undo_desc'), 'Undo');
\r
8065 t.addShortcut('ctrl+y', t.getLang('redo_desc'), 'Redo');
\r
8068 // Add default shortcuts for gecko
\r
8070 t.addShortcut('ctrl+b', t.getLang('bold_desc'), 'Bold');
\r
8071 t.addShortcut('ctrl+i', t.getLang('italic_desc'), 'Italic');
\r
8072 t.addShortcut('ctrl+u', t.getLang('underline_desc'), 'Underline');
\r
8075 // BlockFormat shortcuts keys
\r
8076 for (i=1; i<=6; i++)
\r
8077 t.addShortcut('ctrl+' + i, '', ['FormatBlock', false, '<h' + i + '>']);
\r
8079 t.addShortcut('ctrl+7', '', ['FormatBlock', false, '<p>']);
\r
8080 t.addShortcut('ctrl+8', '', ['FormatBlock', false, '<div>']);
\r
8081 t.addShortcut('ctrl+9', '', ['FormatBlock', false, '<address>']);
\r
8083 function find(e) {
\r
8086 if (!e.altKey && !e.ctrlKey && !e.metaKey)
\r
8089 each(t.shortcuts, function(o) {
\r
8090 if (o.ctrl != e.ctrlKey && (!tinymce.isMac || o.ctrl == e.metaKey))
\r
8093 if (o.alt != e.altKey)
\r
8096 if (o.shift != e.shiftKey)
\r
8099 if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) {
\r
8108 t.onKeyUp.add(function(ed, e) {
\r
8112 return Event.cancel(e);
\r
8115 t.onKeyPress.add(function(ed, e) {
\r
8119 return Event.cancel(e);
\r
8122 t.onKeyDown.add(function(ed, e) {
\r
8126 o.func.call(o.scope);
\r
8127 return Event.cancel(e);
\r
8132 if (tinymce.isIE) {
\r
8133 // Fix so resize will only update the width and height attributes not the styles of an image
\r
8134 // It will also block mceItemNoResize items
\r
8135 Event.add(t.getDoc(), 'controlselect', function(e) {
\r
8136 var re = t.resizeInfo, cb;
\r
8140 // Don't do this action for non image elements
\r
8141 if (e.nodeName !== 'IMG')
\r
8145 Event.remove(re.node, re.ev, re.cb);
\r
8147 if (!t.dom.hasClass(e, 'mceItemNoResize')) {
\r
8149 cb = Event.add(e, ev, function(e) {
\r
8154 if (v = t.dom.getStyle(e, 'width')) {
\r
8155 t.dom.setAttrib(e, 'width', v.replace(/[^0-9%]+/g, ''));
\r
8156 t.dom.setStyle(e, 'width', '');
\r
8159 if (v = t.dom.getStyle(e, 'height')) {
\r
8160 t.dom.setAttrib(e, 'height', v.replace(/[^0-9%]+/g, ''));
\r
8161 t.dom.setStyle(e, 'height', '');
\r
8165 ev = 'resizestart';
\r
8166 cb = Event.add(e, 'resizestart', Event.cancel, Event);
\r
8169 re = t.resizeInfo = {
\r
8176 t.onKeyDown.add(function(ed, e) {
\r
8177 switch (e.keyCode) {
\r
8179 // Fix IE control + backspace browser bug
\r
8180 if (t.selection.getRng().item) {
\r
8181 t.selection.getRng().item(0).removeNode();
\r
8182 return Event.cancel(e);
\r
8188 if (tinymce.isOpera) {
\r
8189 t.onClick.add(function(ed, e) {
\r
8194 // Add custom undo/redo handlers
\r
8195 if (s.custom_undo_redo) {
\r
8196 function addUndo() {
\r
8197 t.undoManager.typing = 0;
\r
8198 t.undoManager.add();
\r
8201 // Add undo level on editor blur
\r
8202 if (tinymce.isIE) {
\r
8203 Event.add(t.getWin(), 'blur', function(e) {
\r
8206 // Check added for fullscreen bug
\r
8207 if (t.selection) {
\r
8208 n = t.selection.getNode();
\r
8210 // Add undo level is selection was lost to another document
\r
8211 if (!t.removed && n.ownerDocument && n.ownerDocument != t.getDoc())
\r
8216 Event.add(t.getDoc(), 'blur', function() {
\r
8217 if (t.selection && !t.removed)
\r
8222 t.onMouseDown.add(addUndo);
\r
8224 t.onKeyUp.add(function(ed, e) {
\r
8225 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.ctrlKey) {
\r
8226 t.undoManager.typing = 0;
\r
8227 t.undoManager.add();
\r
8231 t.onKeyDown.add(function(ed, e) {
\r
8232 // Is caracter positon keys
\r
8233 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45) {
\r
8234 if (t.undoManager.typing) {
\r
8235 t.undoManager.add();
\r
8236 t.undoManager.typing = 0;
\r
8242 if (!t.undoManager.typing) {
\r
8243 t.undoManager.add();
\r
8244 t.undoManager.typing = 1;
\r
8250 _convertInlineElements : function() {
\r
8251 var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp;
\r
8253 function convert(ed, o) {
\r
8254 if (!s.inline_styles)
\r
8258 each(t.dom.select('table,u,strike', o.node), function(n) {
\r
8259 switch (n.nodeName) {
\r
8261 if (v = dom.getAttrib(n, 'height')) {
\r
8262 dom.setStyle(n, 'height', v);
\r
8263 dom.setAttrib(n, 'height', '');
\r
8269 //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
\r
8270 n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
\r
8271 dom.setAttrib(n, 'mce_style', '');
\r
8272 dom.setAttrib(n, 'mce_name', 'span');
\r
8276 } else if (o.set) {
\r
8277 each(t.dom.select('table,span', o.node).reverse(), function(n) {
\r
8278 if (n.nodeName == 'TABLE') {
\r
8279 if (v = dom.getStyle(n, 'height'))
\r
8280 dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, ''));
\r
8282 // Convert spans to elements
\r
8283 if (n.style.textDecoration == 'underline')
\r
8285 else if (n.style.textDecoration == 'line-through')
\r
8291 n.style.textDecoration = '';
\r
8292 dom.setAttrib(n, 'mce_style', '');
\r
8294 e = dom.create(na, {
\r
8295 style : dom.getAttrib(n, 'style')
\r
8298 dom.replace(e, n, 1);
\r
8305 t.onPreProcess.add(convert);
\r
8307 if (!s.cleanup_on_startup) {
\r
8308 t.onSetContent.add(function(ed, o) {
\r
8310 convert(t, {node : t.getBody(), set : 1});
\r
8315 _convertFonts : function() {
\r
8316 var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl;
\r
8319 if (!s.inline_styles)
\r
8322 // Font pt values and font size names
\r
8323 fz = [8, 10, 12, 14, 18, 24, 36];
\r
8324 fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large'];
\r
8326 if (sl = s.font_size_style_values)
\r
8329 if (cl = s.font_size_classes)
\r
8332 function convertToFonts(no) {
\r
8333 var n, f, nl, x, i, v, st;
\r
8335 // Convert spans to fonts on non WebKit browsers
\r
8336 if (tinymce.isWebKit || !s.inline_styles)
\r
8339 nl = t.dom.select('span', no);
\r
8340 for (x = nl.length - 1; x >= 0; x--) {
\r
8343 f = dom.create('font', {
\r
8344 color : dom.toHex(dom.getStyle(n, 'color')),
\r
8345 face : dom.getStyle(n, 'fontFamily'),
\r
8346 style : dom.getAttrib(n, 'style'),
\r
8347 'class' : dom.getAttrib(n, 'class')
\r
8350 // Clear color and font family
\r
8352 if (st.color || st.fontFamily) {
\r
8353 st.color = st.fontFamily = '';
\r
8354 dom.setAttrib(f, 'mce_style', ''); // Remove cached style data
\r
8358 i = inArray(sl, dom.getStyle(n, 'fontSize'));
\r
8361 dom.setAttrib(f, 'size', '' + (i + 1 || 1));
\r
8362 //f.style.fontSize = '';
\r
8365 i = inArray(cl, dom.getAttrib(n, 'class'));
\r
8366 v = dom.getStyle(n, 'fontSize');
\r
8368 if (i == -1 && v.indexOf('pt') > 0)
\r
8369 i = inArray(fz, parseInt(v));
\r
8372 i = inArray(fzn, v);
\r
8375 dom.setAttrib(f, 'size', '' + (i + 1 || 1));
\r
8376 f.style.fontSize = '';
\r
8380 if (f.color || f.face || f.size) {
\r
8381 f.style.fontFamily = '';
\r
8382 dom.setAttrib(f, 'mce_style', '');
\r
8383 dom.replace(f, n, 1);
\r
8391 t.onSetContent.add(function(ed, o) {
\r
8392 convertToFonts(ed.getBody());
\r
8396 t.onPreProcess.add(function(ed, o) {
\r
8399 // Keep unit tests happy
\r
8400 if (!s.inline_styles)
\r
8404 nl = t.dom.select('font', o.node);
\r
8405 for (x = nl.length - 1; x >= 0; x--) {
\r
8408 sp = dom.create('span', {
\r
8409 style : dom.getAttrib(n, 'style'),
\r
8410 'class' : dom.getAttrib(n, 'class')
\r
8413 dom.setStyles(sp, {
\r
8414 fontFamily : dom.getAttrib(n, 'face'),
\r
8415 color : dom.getAttrib(n, 'color'),
\r
8416 backgroundColor : n.style.backgroundColor
\r
8421 dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
\r
8423 dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
\r
8426 dom.setAttrib(sp, 'mce_style', '');
\r
8427 dom.replace(sp, n, 1);
\r
8433 _isHidden : function() {
\r
8439 // Weird, wheres that cursor selection?
\r
8440 s = this.selection.getSel();
\r
8441 return (!s || !s.rangeCount || s.rangeCount == 0);
\r
8444 // Fix for bug #1867292
\r
8445 _fixNesting : function(s) {
\r
8448 s = s.replace(/<(\/)?([^\s>]+)[^>]*?>/g, function(a, b, c) {
\r
8451 // Handle end element
\r
8456 if (c !== d[d.length - 1].tag) {
\r
8457 for (i=d.length - 1; i>=0; i--) {
\r
8458 if (d[i].tag === c) {
\r
8468 if (d.length && d[d.length - 1].close) {
\r
8469 a = a + '</' + d[d.length - 1].tag + '>';
\r
8475 if (/^(br|hr|input|meta|img|link|param)$/i.test(c))
\r
8478 // Ignore closed ones
\r
8479 if (/\/>$/.test(a))
\r
8482 d.push({tag : c}); // Push start element
\r
8488 // End all open tags
\r
8489 for (i=d.length - 1; i>=0; i--)
\r
8490 s += '</' + d[i].tag + '>';
\r
8498 /* file:jscripts/tiny_mce/classes/EditorCommands.js */
\r
8501 var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit;
\r
8503 tinymce.create('tinymce.EditorCommands', {
\r
8504 EditorCommands : function(ed) {
\r
8508 execCommand : function(cmd, ui, val) {
\r
8509 var t = this, ed = t.editor, f;
\r
8516 ed.getDoc().execCommand(cmd, ui, val);
\r
8519 ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
\r
8521 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
\r
8524 ed.windowManager.alert(ed.getLang('clipboard_no_support'));
\r
8530 case 'mceResetDesignMode':
\r
8531 case 'mceBeginUndoLevel':
\r
8539 // Bundle these together
\r
8540 case 'JustifyLeft':
\r
8541 case 'JustifyCenter':
\r
8542 case 'JustifyRight':
\r
8543 case 'JustifyFull':
\r
8544 t.mceJustify(cmd, cmd.substring(7).toLowerCase());
\r
8547 case 'mceEndUndoLevel':
\r
8548 case 'mceAddUndoLevel':
\r
8549 ed.undoManager.add();
\r
8556 f.call(this, ui, val);
\r
8564 Indent : function() {
\r
8565 var ed = this.editor, d = ed.dom, s = ed.selection, e, iv, iu;
\r
8567 // Setup indent level
\r
8568 iv = ed.settings.indentation;
\r
8569 iu = /[a-z%]+$/i.exec(iv);
\r
8570 iv = parseInt(iv);
\r
8572 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
\r
8573 each(this._getSelectedBlocks(), function(e) {
\r
8574 d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu);
\r
8580 ed.getDoc().execCommand('Indent', false, null);
\r
8583 d.getParent(s.getNode(), function(n) {
\r
8584 if (n.nodeName == 'BLOCKQUOTE') {
\r
8585 n.dir = n.style.cssText = '';
\r
8591 Outdent : function() {
\r
8592 var ed = this.editor, d = ed.dom, s = ed.selection, e, v, iv, iu;
\r
8594 // Setup indent level
\r
8595 iv = ed.settings.indentation;
\r
8596 iu = /[a-z%]+$/i.exec(iv);
\r
8597 iv = parseInt(iv);
\r
8599 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
\r
8600 each(this._getSelectedBlocks(), function(e) {
\r
8601 v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv);
\r
8602 d.setStyle(e, 'paddingLeft', v ? v + iu : '');
\r
8608 ed.getDoc().execCommand('Outdent', false, null);
\r
8611 mceSetAttribute : function(u, v) {
\r
8612 var ed = this.editor, d = ed.dom, e;
\r
8614 if (e = d.getParent(ed.selection.getNode(), d.isBlock))
\r
8615 d.setAttrib(e, v.name, v.value);
\r
8618 mceSetContent : function(u, v) {
\r
8619 this.editor.setContent(v);
\r
8622 mceToggleVisualAid : function() {
\r
8623 var ed = this.editor;
\r
8625 ed.hasVisual = !ed.hasVisual;
\r
8629 mceReplaceContent : function(u, v) {
\r
8630 var s = this.editor.selection;
\r
8632 s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'})));
\r
8635 mceInsertLink : function(u, v) {
\r
8636 var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A');
\r
8638 if (tinymce.is(v, 'string'))
\r
8642 each(v, function(v, k) {
\r
8643 ed.dom.setAttrib(e, k, v);
\r
8648 ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
\r
8649 each(ed.dom.select('a'), function(e) {
\r
8650 if (e.href == 'javascript:mctmp(0);')
\r
8657 ed.dom.remove(e, 1);
\r
8661 UnLink : function() {
\r
8662 var ed = this.editor, s = ed.selection;
\r
8664 if (s.isCollapsed())
\r
8665 s.select(s.getNode());
\r
8667 ed.getDoc().execCommand('unlink', false, null);
\r
8671 FontName : function(u, v) {
\r
8672 var t = this, ed = t.editor, s = ed.selection, e;
\r
8675 if (s.isCollapsed())
\r
8676 s.select(s.getNode());
\r
8680 ed.getDoc().execCommand('FontName', false, v);
\r
8683 FontSize : function(u, v) {
\r
8684 var ed = this.editor, s = ed.settings, fz = tinymce.explode(s.font_size_style_values), fzc = tinymce.explode(s.font_size_classes), h, bm;
\r
8686 // Remove style sizes
\r
8687 each(ed.dom.select('font'), function(e) {
\r
8688 e.style.fontSize = '';
\r
8691 // Let the browser add new size it will remove unneded ones in some browsers
\r
8692 ed.getDoc().execCommand('FontSize', false, v);
\r
8694 // Add style values
\r
8695 if (s.inline_styles) {
\r
8696 each(ed.dom.select('font'), function(e) {
\r
8697 // Try remove redundant font elements
\r
8698 if (e.parentNode.nodeName == 'FONT' && e.size == e.parentNode.size) {
\r
8700 bm = ed.selection.getBookmark();
\r
8702 ed.dom.remove(e, 1);
\r
8706 // Setup font size based on font size value
\r
8708 if (fzc && fzc.length > 0)
\r
8709 ed.dom.setAttrib(e, 'class', fzc[parseInt(v) - 1]);
\r
8711 ed.dom.setStyle(e, 'fontSize', fz[parseInt(v) - 1]);
\r
8716 ed.selection.moveToBookmark(bm);
\r
8719 queryCommandValue : function(c) {
\r
8720 var f = this['queryValue' + c];
\r
8723 return f.call(this, c);
\r
8728 queryCommandState : function(cmd) {
\r
8732 // Bundle these together
\r
8733 case 'JustifyLeft':
\r
8734 case 'JustifyCenter':
\r
8735 case 'JustifyRight':
\r
8736 case 'JustifyFull':
\r
8737 return this.queryStateJustify(cmd, cmd.substring(7).toLowerCase());
\r
8740 if (f = this['queryState' + cmd])
\r
8741 return f.call(this, cmd);
\r
8747 _queryState : function(c) {
\r
8749 return this.editor.getDoc().queryCommandState(c);
\r
8751 // Ignore exception
\r
8755 _queryVal : function(c) {
\r
8757 return this.editor.getDoc().queryCommandValue(c);
\r
8759 // Ignore exception
\r
8763 queryValueFontSize : function() {
\r
8764 var ed = this.editor, v = 0, p;
\r
8766 if (isOpera || isWebKit) {
\r
8767 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
\r
8773 return this._queryVal('FontSize');
\r
8776 queryValueFontName : function() {
\r
8777 var ed = this.editor, v = 0, p;
\r
8779 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
\r
8783 v = this._queryVal('FontName');
\r
8788 mceJustify : function(c, v) {
\r
8789 var ed = this.editor, se = ed.selection, n = se.getNode(), nn = n.nodeName, bl, nb, dom = ed.dom, rm;
\r
8791 if (ed.settings.inline_styles && this.queryStateJustify(c, v))
\r
8794 bl = dom.getParent(n, ed.dom.isBlock);
\r
8796 if (nn == 'IMG') {
\r
8801 if (v == 'center')
\r
8802 dom.setStyle(n.parentNode, 'textAlign', '');
\r
8804 dom.setStyle(n, 'float', '');
\r
8805 this.mceRepaint();
\r
8809 if (v == 'center') {
\r
8810 // Do not change table elements
\r
8811 if (/^(TD|TH)$/.test(bl.nodeName))
\r
8814 if (!bl || bl.childNodes.length > 1) {
\r
8815 nb = dom.create('p');
\r
8816 nb.appendChild(n.cloneNode(false));
\r
8819 dom.insertAfter(nb, bl);
\r
8821 dom.insertAfter(nb, n);
\r
8824 n = nb.firstChild;
\r
8828 dom.setStyle(bl, 'textAlign', v);
\r
8829 dom.setStyle(n, 'float', '');
\r
8831 dom.setStyle(n, 'float', v);
\r
8832 dom.setStyle(n.parentNode, 'textAlign', '');
\r
8835 this.mceRepaint();
\r
8839 // Handle the alignment outselfs, less quirks in all browsers
\r
8840 if (ed.settings.inline_styles && ed.settings.forced_root_block) {
\r
8844 each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
\r
8845 dom.setAttrib(e, 'align', '');
\r
8846 dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v);
\r
8851 ed.getDoc().execCommand(c, false, null);
\r
8853 if (ed.settings.inline_styles) {
\r
8855 dom.getParent(ed.selection.getNode(), function(n) {
\r
8856 if (n.style && n.style.textAlign)
\r
8857 dom.setStyle(n, 'textAlign', '');
\r
8863 each(dom.select('*'), function(n) {
\r
8870 dom.setStyle(n, 'textAlign', v);
\r
8871 dom.setAttrib(n, 'align', '');
\r
8877 mceSetCSSClass : function(u, v) {
\r
8878 this.mceSetStyleInfo(0, {command : 'setattrib', name : 'class', value : v});
\r
8881 getSelectedElement : function() {
\r
8882 var t = this, ed = t.editor, dom = ed.dom, se = ed.selection, r = se.getRng(), r1, r2, sc, ec, so, eo, e, sp, ep, re;
\r
8884 if (se.isCollapsed() || r.item)
\r
8885 return se.getNode();
\r
8888 re = ed.settings.merge_styles_invalid_parents;
\r
8889 if (tinymce.is(re, 'string'))
\r
8890 re = new RegExp(re, 'i');
\r
8893 r1 = r.duplicate();
\r
8894 r1.collapse(true);
\r
8895 sc = r1.parentElement();
\r
8897 r2 = r.duplicate();
\r
8898 r2.collapse(false);
\r
8899 ec = r2.parentElement();
\r
8902 r1.move('character', 1);
\r
8903 sc = r1.parentElement();
\r
8907 r1 = r.duplicate();
\r
8908 r1.moveToElementText(sc);
\r
8910 if (r1.compareEndPoints('StartToStart', r) == 0 && r1.compareEndPoints('EndToEnd', r) == 0)
\r
8911 return re && re.test(sc.nodeName) ? null : sc;
\r
8914 function getParent(n) {
\r
8915 return dom.getParent(n, function(n) {return n.nodeType == 1;});
\r
8918 sc = r.startContainer;
\r
8919 ec = r.endContainer;
\r
8920 so = r.startOffset;
\r
8923 if (!r.collapsed) {
\r
8925 if (so - eo < 2) {
\r
8926 if (sc.hasChildNodes()) {
\r
8927 sp = sc.childNodes[so];
\r
8928 return re && re.test(sp.nodeName) ? null : sp;
\r
8934 if (sc.nodeType != 3 || ec.nodeType != 3)
\r
8938 sp = getParent(sc);
\r
8940 if (sp && sp.firstChild != sc)
\r
8944 if (so == sc.nodeValue.length) {
\r
8945 e = sc.nextSibling;
\r
8947 if (e && e.nodeType == 1)
\r
8948 sp = sc.nextSibling;
\r
8952 e = ec.previousSibling;
\r
8954 if (e && e.nodeType == 1)
\r
8958 if (eo == ec.nodeValue.length) {
\r
8959 ep = getParent(ec);
\r
8961 if (ep && ep.lastChild != ec)
\r
8967 return re && sp && re.test(sp.nodeName) ? null : sp;
\r
8973 InsertHorizontalRule : function() {
\r
8974 // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
\r
8975 if (isGecko || isIE)
\r
8976 this.editor.selection.setContent('<hr />');
\r
8978 this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
\r
8981 RemoveFormat : function() {
\r
8982 var t = this, ed = t.editor, s = ed.selection, b;
\r
8984 // Safari breaks tables
\r
8986 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'});
\r
8988 ed.getDoc().execCommand('RemoveFormat', false, null);
\r
8990 t.mceSetStyleInfo(0, {command : 'removeformat'});
\r
8994 mceSetStyleInfo : function(u, v) {
\r
8995 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;
\r
8997 function set(n, e) {
\r
8998 if (n.nodeType == 1) {
\r
8999 switch (v.command) {
\r
9001 return dom.setAttrib(n, v.name, v.value);
\r
9004 return dom.setStyle(n, v.name, v.value);
\r
9006 case 'removeformat':
\r
9007 return dom.setAttrib(n, 'class', '');
\r
9013 re = ed.settings.merge_styles_invalid_parents;
\r
9014 if (tinymce.is(re, 'string'))
\r
9015 re = new RegExp(re, 'i');
\r
9017 // Set style info on selected element
\r
9018 if (e = t.getSelectedElement())
\r
9021 // Generate wrappers and set styles on them
\r
9022 d.execCommand('FontName', false, '__');
\r
9023 each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
\r
9026 if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
\r
9027 sp = dom.create(nn, {mce_new : '1'});
\r
9031 each (n.childNodes, function(n) {
\r
9032 sp.appendChild(n.cloneNode(true));
\r
9035 dom.replace(sp, n);
\r
9040 // Remove wrappers inside new ones
\r
9041 each(dom.select(nn).reverse(), function(n) {
\r
9042 var p = n.parentNode;
\r
9044 // Check if it's an old span in a new wrapper
\r
9045 if (!dom.getAttrib(n, 'mce_new')) {
\r
9046 // Find new wrapper
\r
9047 p = dom.getParent(n, function(n) {
\r
9048 return n.nodeType == 1 && dom.getAttrib(n, 'mce_new');
\r
9056 // Merge wrappers with parent wrappers
\r
9057 each(dom.select(nn).reverse(), function(n) {
\r
9058 var p = n.parentNode;
\r
9060 if (!p || !dom.getAttrib(n, 'mce_new'))
\r
9063 // Has parent of the same type and only child
\r
9064 if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1)
\r
9065 return dom.remove(p, 1);
\r
9067 // Has parent that is more suitable to have the class and only child
\r
9068 if (n.nodeType == 1 && (!re || !re.test(p.nodeName)) && p.childNodes.length == 1) {
\r
9069 set(p); // Set style info on parent instead
\r
9070 dom.setAttrib(n, 'class', '');
\r
9074 // Remove empty wrappers
\r
9075 each(dom.select(nn).reverse(), function(n) {
\r
9076 if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) {
\r
9077 if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style'))
\r
9078 return dom.remove(n, 1);
\r
9080 dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker
\r
9084 s.moveToBookmark(b);
\r
9087 queryStateJustify : function(c, v) {
\r
9088 var ed = this.editor, n = ed.selection.getNode(), dom = ed.dom;
\r
9090 if (n && n.nodeName == 'IMG') {
\r
9091 if (dom.getStyle(n, 'float') == v)
\r
9094 return n.parentNode.style.textAlign == v;
\r
9097 n = dom.getParent(ed.selection.getStart(), function(n) {
\r
9098 return n.nodeType == 1 && n.style.textAlign;
\r
9104 if (ed.settings.inline_styles)
\r
9105 return (n && n.style.textAlign == v);
\r
9107 return this._queryState(c);
\r
9110 HiliteColor : function(ui, val) {
\r
9111 var t = this, ed = t.editor, d = ed.getDoc();
\r
9118 // Try new Gecko method
\r
9119 d.execCommand("styleWithCSS", 0, s);
\r
9122 d.execCommand("useCSS", 0, !s);
\r
9126 if (isGecko || isOpera) {
\r
9128 d.execCommand('hilitecolor', false, val);
\r
9131 d.execCommand('BackColor', false, val);
\r
9134 Undo : function() {
\r
9135 var ed = this.editor;
\r
9137 if (ed.settings.custom_undo_redo) {
\r
9138 ed.undoManager.undo();
\r
9141 ed.getDoc().execCommand('Undo', false, null);
\r
9144 Redo : function() {
\r
9145 var ed = this.editor;
\r
9147 if (ed.settings.custom_undo_redo) {
\r
9148 ed.undoManager.redo();
\r
9151 ed.getDoc().execCommand('Redo', false, null);
\r
9154 FormatBlock : function(ui, val) {
\r
9155 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b;
\r
9157 function isBlock(n) {
\r
9158 return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);
\r
9161 bl = dom.getParent(s.getNode(), function(n) {
\r
9162 return isBlock(n);
\r
9165 // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div>
\r
9166 // FF and Opera doesn't change parent DIV elements if you switch format
\r
9168 if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
\r
9169 // Rename block element
\r
9170 nb = ed.dom.create(val);
\r
9172 each(dom.getAttribs(bl), function(v) {
\r
9173 dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName));
\r
9176 b = s.getBookmark();
\r
9177 dom.replace(nb, bl, 1);
\r
9178 s.moveToBookmark(b);
\r
9184 val = ed.settings.forced_root_block ? (val || '<p>') : val;
\r
9186 if (val.indexOf('<') == -1)
\r
9187 val = '<' + val + '>';
\r
9189 if (tinymce.isGecko)
\r
9190 val = val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi, '$1');
\r
9192 ed.getDoc().execCommand('FormatBlock', false, val);
\r
9195 mceCleanup : function() {
\r
9196 var ed = this.editor, s = ed.selection, b = s.getBookmark();
\r
9197 ed.setContent(ed.getContent());
\r
9198 s.moveToBookmark(b);
\r
9201 mceRemoveNode : function(ui, val) {
\r
9202 var ed = this.editor, s = ed.selection, b, n = val || s.getNode();
\r
9204 // Make sure that the body node isn't removed
\r
9205 if (n == ed.getBody())
\r
9208 b = s.getBookmark();
\r
9209 ed.dom.remove(n, 1);
\r
9210 s.moveToBookmark(b);
\r
9214 mceSelectNodeDepth : function(ui, val) {
\r
9215 var ed = this.editor, s = ed.selection, c = 0;
\r
9217 ed.dom.getParent(s.getNode(), function(n) {
\r
9218 if (n.nodeType == 1 && c++ == val) {
\r
9226 mceSelectNode : function(u, v) {
\r
9227 this.editor.selection.select(v);
\r
9230 mceInsertContent : function(ui, val) {
\r
9231 this.editor.selection.setContent(val);
\r
9234 mceInsertRawHTML : function(ui, val) {
\r
9235 var ed = this.editor;
\r
9237 ed.selection.setContent('tiny_mce_marker');
\r
9238 ed.setContent(ed.getContent().replace(/tiny_mce_marker/g, val));
\r
9241 mceRepaint : function() {
\r
9242 var s, b, e = this.editor;
\r
9244 if (tinymce.isGecko) {
\r
9247 b = s.getBookmark(true);
\r
9250 s.getSel().selectAllChildren(e.getBody());
\r
9253 s.moveToBookmark(b);
\r
9260 queryStateUnderline : function() {
\r
9261 var ed = this.editor, n = ed.selection.getNode();
\r
9263 if (n && n.nodeName == 'A')
\r
9266 return this._queryState('Underline');
\r
9269 queryStateOutdent : function() {
\r
9270 var ed = this.editor, n;
\r
9272 if (ed.settings.inline_styles) {
\r
9273 if ((n = ed.dom.getParent(ed.selection.getStart(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
\r
9276 if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
\r
9279 return !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE');
\r
9281 return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList();
\r
9284 queryStateInsertUnorderedList : function() {
\r
9285 return this.editor.dom.getParent(this.editor.selection.getNode(), 'UL');
\r
9288 queryStateInsertOrderedList : function() {
\r
9289 return this.editor.dom.getParent(this.editor.selection.getNode(), 'OL');
\r
9292 queryStatemceBlockQuote : function() {
\r
9293 return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9296 mceBlockQuote : function() {
\r
9297 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
\r
9299 function getBQ(e) {
\r
9300 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9303 // Get start/end block
\r
9304 sb = dom.getParent(s.getStart(), dom.isBlock);
\r
9305 eb = dom.getParent(s.getEnd(), dom.isBlock);
\r
9307 // Remove blockquote(s)
\r
9308 if (bq = getBQ(sb)) {
\r
9309 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
\r
9310 bm = s.getBookmark();
\r
9312 // Move all elements after the end block into new bq
\r
9314 bq2 = bq.cloneNode(false);
\r
9316 while (n = eb.nextSibling)
\r
9317 bq2.appendChild(n.parentNode.removeChild(n));
\r
9320 // Add new bq after
\r
9322 dom.insertAfter(bq2, bq);
\r
9324 // Move all selected blocks after the current bq
\r
9325 nl = t._getSelectedBlocks(sb, eb);
\r
9326 for (i = nl.length - 1; i >= 0; i--) {
\r
9327 dom.insertAfter(nl[i], bq);
\r
9330 // Empty bq, then remove it
\r
9331 if (/^\s*$/.test(bq.innerHTML))
\r
9332 dom.remove(bq, 1); // Keep children so boomark restoration works correctly
\r
9334 // Empty bq, then remote it
\r
9335 if (bq2 && /^\s*$/.test(bq2.innerHTML))
\r
9336 dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
\r
9339 // Move caret inside empty block element
\r
9341 r = ed.getDoc().createRange();
\r
9342 r.setStart(sb, 0);
\r
9349 // IE misses the empty block some times element so we must move back the caret
\r
9350 if (dom.getParent(s.getStart(), dom.isBlock) != sb) {
\r
9352 r.move('character', -1);
\r
9357 t.editor.selection.moveToBookmark(bm);
\r
9362 // Since IE can start with a totally empty document we need to add the first bq and paragraph
\r
9363 if (isIE && !sb && !eb) {
\r
9364 t.editor.getDoc().execCommand('Indent');
\r
9365 n = getBQ(s.getNode());
\r
9366 n.style.margin = n.dir = ''; // IE adds margin and dir to bq
\r
9373 // If empty paragraph node then do not use bookmark
\r
9374 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
\r
9375 bm = s.getBookmark();
\r
9377 // Move selected block elements into a bq
\r
9378 each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
\r
9379 // Found existing BQ add to this one
\r
9380 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
\r
9385 // No BQ found, create one
\r
9387 bq = dom.create('blockquote');
\r
9388 e.parentNode.insertBefore(bq, e);
\r
9391 // Add children from existing BQ
\r
9392 if (e.nodeName == 'BLOCKQUOTE' && bq) {
\r
9396 bq.appendChild(n.cloneNode(true));
\r
9397 n = n.nextSibling;
\r
9404 // Add non BQ element to BQ
\r
9405 bq.appendChild(dom.remove(e));
\r
9409 // Move caret inside empty block element
\r
9411 r = ed.getDoc().createRange();
\r
9412 r.setStart(sb, 0);
\r
9420 s.moveToBookmark(bm);
\r
9423 _mceBlockQuote : function() {
\r
9424 var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom;
\r
9426 function findBQ(e) {
\r
9427 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9430 // Remove blockquote(s)
\r
9431 if (findBQ(s.getStart())) {
\r
9432 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
\r
9433 // Found BQ lets remove it
\r
9434 if (e.nodeName == 'BLOCKQUOTE')
\r
9438 t.editor.selection.moveToBookmark(b);
\r
9442 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
\r
9445 // Found existing BQ add to this one
\r
9446 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
\r
9451 // No BQ found, create one
\r
9453 bq = dom.create('blockquote');
\r
9454 e.parentNode.insertBefore(bq, e);
\r
9457 // Add children from existing BQ
\r
9458 if (e.nodeName == 'BLOCKQUOTE' && bq) {
\r
9462 bq.appendChild(n.cloneNode(true));
\r
9463 n = n.nextSibling;
\r
9471 // Add non BQ element to BQ
\r
9472 bq.appendChild(dom.remove(e));
\r
9475 t.editor.selection.moveToBookmark(b);
\r
9478 _getSelectedBlocks : function(st, en) {
\r
9479 var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = [];
\r
9481 sb = dom.getParent(st || s.getStart(), dom.isBlock);
\r
9482 eb = dom.getParent(en || s.getEnd(), dom.isBlock);
\r
9487 if (sb && eb && sb != eb) {
\r
9490 while ((n = n.nextSibling) && n != eb) {
\r
9491 if (dom.isBlock(n))
\r
9496 if (eb && sb != eb)
\r
9505 /* file:jscripts/tiny_mce/classes/UndoManager.js */
\r
9507 tinymce.create('tinymce.UndoManager', {
\r
9512 UndoManager : function(ed) {
\r
9513 var t = this, Dispatcher = tinymce.util.Dispatcher;
\r
9517 t.onAdd = new Dispatcher(this);
\r
9518 t.onUndo = new Dispatcher(this);
\r
9519 t.onRedo = new Dispatcher(this);
\r
9522 add : function(l) {
\r
9523 var t = this, i, ed = t.editor, b, s = ed.settings, la;
\r
9526 l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
\r
9528 // Add undo level if needed
\r
9529 l.content = l.content.replace(/^\s*|\s*$/g, '');
\r
9530 la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index];
\r
9531 if (!l.initial && la && l.content == la.content)
\r
9534 // Time to compress
\r
9535 if (s.custom_undo_redo_levels) {
\r
9536 if (t.data.length > s.custom_undo_redo_levels) {
\r
9537 for (i = 0; i < t.data.length - 1; i++)
\r
9538 t.data[i] = t.data[i + 1];
\r
9541 t.index = t.data.length;
\r
9545 if (s.custom_undo_redo_restore_selection && !l.initial)
\r
9546 l.bookmark = b = l.bookmark || ed.selection.getBookmark();
\r
9548 if (t.index < t.data.length)
\r
9551 // Only initial marked undo levels should be allowed as first item
\r
9552 // This to workaround a bug with Firefox and the blur event
\r
9553 if (t.data.length === 0 && !l.initial)
\r
9557 t.data.length = t.index + 1;
\r
9558 t.data[t.index++] = l;
\r
9563 // Set initial bookmark use first real undo level
\r
9564 if (t.data.length == 2 && t.data[0].initial)
\r
9565 t.data[0].bookmark = b;
\r
9567 t.onAdd.dispatch(t, l);
\r
9568 ed.isNotDirty = 0;
\r
9570 //console.dir(t.data);
\r
9575 undo : function() {
\r
9576 var t = this, ed = t.editor, l = l, i;
\r
9583 if (t.index > 0) {
\r
9584 // If undo on last index then take snapshot
\r
9585 if (t.index == t.data.length && t.index > 1) {
\r
9595 l = t.data[--t.index];
\r
9596 ed.setContent(l.content, {format : 'raw'});
\r
9597 ed.selection.moveToBookmark(l.bookmark);
\r
9599 t.onUndo.dispatch(t, l);
\r
9605 redo : function() {
\r
9606 var t = this, ed = t.editor, l = null;
\r
9608 if (t.index < t.data.length - 1) {
\r
9609 l = t.data[++t.index];
\r
9610 ed.setContent(l.content, {format : 'raw'});
\r
9611 ed.selection.moveToBookmark(l.bookmark);
\r
9613 t.onRedo.dispatch(t, l);
\r
9619 clear : function() {
\r
9625 t.add({initial : true});
\r
9628 hasUndo : function() {
\r
9629 return this.index != 0 || this.typing;
\r
9632 hasRedo : function() {
\r
9633 return this.index < this.data.length - 1;
\r
9637 /* file:jscripts/tiny_mce/classes/ForceBlocks.js */
\r
9641 var Event, isIE, isGecko, isOpera, each, extend;
\r
9643 Event = tinymce.dom.Event;
\r
9644 isIE = tinymce.isIE;
\r
9645 isGecko = tinymce.isGecko;
\r
9646 isOpera = tinymce.isOpera;
\r
9647 each = tinymce.each;
\r
9648 extend = tinymce.extend;
\r
9650 tinymce.create('tinymce.ForceBlocks', {
\r
9651 ForceBlocks : function(ed) {
\r
9652 var t = this, s = ed.settings, elm;
\r
9656 elm = (s.forced_root_block || 'p').toLowerCase();
\r
9657 s.element = elm.toUpperCase();
\r
9659 ed.onPreInit.add(t.setup, t);
\r
9661 t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi');
\r
9662 t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
\r
9663 t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
\r
9664 t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi');
\r
9665 t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
\r
9666 t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
\r
9668 function padd(ed, o) {
\r
9670 o.content = o.content.replace(t.reOpera, '</' + elm + '>');
\r
9672 o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>');
\r
9674 if (!isIE && !isOpera && o.set) {
\r
9675 // Use instead of BR in padded paragraphs
\r
9676 o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>');
\r
9677 o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>');
\r
9679 o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>');
\r
9680 o.content = o.content.replace(t.reTrailBr, '</' + elm + '>');
\r
9684 ed.onBeforeSetContent.add(padd);
\r
9685 ed.onPostProcess.add(padd);
\r
9687 if (s.forced_root_block) {
\r
9688 ed.onInit.add(t.forceRoots, t);
\r
9689 ed.onSetContent.add(t.forceRoots, t);
\r
9690 ed.onBeforeGetContent.add(t.forceRoots, t);
\r
9694 setup : function() {
\r
9695 var t = this, ed = t.editor, s = ed.settings;
\r
9697 // Force root blocks when typing and when getting output
\r
9698 if (s.forced_root_block) {
\r
9699 ed.onKeyUp.add(t.forceRoots, t);
\r
9700 ed.onPreProcess.add(t.forceRoots, t);
\r
9703 if (s.force_br_newlines) {
\r
9704 // Force IE to produce BRs on enter
\r
9706 ed.onKeyPress.add(function(ed, e) {
\r
9707 var n, s = ed.selection;
\r
9709 if (e.keyCode == 13 && s.getNode().nodeName != 'LI') {
\r
9710 s.setContent('<br id="__" /> ', {format : 'raw'});
\r
9711 n = ed.dom.get('__');
\r
9712 n.removeAttribute('id');
\r
9715 return Event.cancel(e);
\r
9723 if (!isIE && s.force_p_newlines) {
\r
9724 /* ed.onPreProcess.add(function(ed, o) {
\r
9725 each(ed.dom.select('br', o.node), function(n) {
\r
9726 var p = n.parentNode;
\r
9728 // Replace <p><br /></p> with <p> </p>
\r
9729 if (p && p.nodeName == 'p' && (p.childNodes.length == 1 || p.lastChild == n)) {
\r
9730 p.replaceChild(ed.getDoc().createTextNode('\u00a0'), n);
\r
9735 ed.onKeyPress.add(function(ed, e) {
\r
9736 if (e.keyCode == 13 && !e.shiftKey) {
\r
9737 if (!t.insertPara(e))
\r
9743 ed.onKeyDown.add(function(ed, e) {
\r
9744 if ((e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey)
\r
9745 t.backspaceDelete(e, e.keyCode == 8);
\r
9750 function ren(rn, na) {
\r
9751 var ne = ed.dom.create(na);
\r
9753 each(rn.attributes, function(a) {
\r
9754 if (a.specified && a.nodeValue)
\r
9755 ne.setAttribute(a.nodeName.toLowerCase(), a.nodeValue);
\r
9758 each(rn.childNodes, function(n) {
\r
9759 ne.appendChild(n.cloneNode(true));
\r
9762 rn.parentNode.replaceChild(ne, rn);
\r
9767 // Replaces IE:s auto generated paragraphs with the specified element name
\r
9768 if (isIE && s.element != 'P') {
\r
9769 ed.onKeyPress.add(function(ed, e) {
\r
9770 t.lastElm = ed.selection.getNode().nodeName;
\r
9773 ed.onKeyUp.add(function(ed, e) {
\r
9774 var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
\r
9776 if (b.childNodes.length === 1 && n.nodeName == 'P') {
\r
9777 n = ren(n, s.element);
\r
9781 } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
\r
9782 bl = ed.dom.getParent(n, 'P');
\r
9785 ren(bl, s.element);
\r
9793 find : function(n, t, s) {
\r
9794 var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, false), c = -1;
\r
9796 while (n = w.nextNode()) {
\r
9800 if (t == 0 && n == s)
\r
9804 if (t == 1 && c == s)
\r
9811 forceRoots : function(ed, e) {
\r
9812 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;
\r
9813 var nx, bl, bp, sp, le, nl = b.childNodes, i;
\r
9815 // Fix for bug #1863847
\r
9816 if (e && e.keyCode == 13)
\r
9819 // Wrap non blocks into blocks
\r
9820 for (i = nl.length - 1; i >= 0; i--) {
\r
9823 // Is text or non block element
\r
9824 if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
\r
9826 // Create new block but ignore whitespace
\r
9827 if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
\r
9828 // Store selection
\r
9829 if (si == -2 && r) {
\r
9831 // If element is inside body, might not be the case in contentEdiable mode
\r
9832 if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
\r
9833 so = r.startOffset;
\r
9835 si = t.find(b, 0, r.startContainer);
\r
9836 ei = t.find(b, 0, r.endContainer);
\r
9839 tr = d.body.createTextRange();
\r
9840 tr.moveToElementText(b);
\r
9842 bp = tr.move('character', c) * -1;
\r
9844 tr = r.duplicate();
\r
9846 sp = tr.move('character', c) * -1;
\r
9848 tr = r.duplicate();
\r
9850 le = (tr.move('character', c) * -1) - sp;
\r
9857 bl = ed.dom.create(ed.settings.forced_root_block);
\r
9858 bl.appendChild(nx.cloneNode(1));
\r
9859 nx.parentNode.replaceChild(bl, nx);
\r
9862 if (bl.hasChildNodes())
\r
9863 bl.insertBefore(nx, bl.firstChild);
\r
9865 bl.appendChild(nx);
\r
9868 bl = null; // Time to create new block
\r
9871 // Restore selection
\r
9874 bl = b.getElementsByTagName(ed.settings.element)[0];
\r
9875 r = d.createRange();
\r
9877 // Select last location or generated block
\r
9879 r.setStart(t.find(b, 1, si), so);
\r
9881 r.setStart(bl, 0);
\r
9883 // Select last location or generated block
\r
9885 r.setEnd(t.find(b, 1, ei), eo);
\r
9890 s.removeAllRanges();
\r
9895 r = s.createRange();
\r
9896 r.moveToElementText(b);
\r
9898 r.moveStart('character', si);
\r
9899 r.moveEnd('character', ei);
\r
9908 getParentBlock : function(n) {
\r
9911 return d.getParent(n, d.isBlock);
\r
9914 insertPara : function(e) {
\r
9915 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;
\r
9916 var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch;
\r
9918 function isEmpty(n) {
\r
9920 n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
\r
9921 n = n.replace(/<[^>]+>/g, ''); // Remove all tags
\r
9923 return n.replace(/[ \t\r\n]+/g, '') == '';
\r
9926 // If root blocks are forced then use Operas default behavior since it's really good
\r
9927 // Removed due to bug: #1853816
\r
9928 // if (se.forced_root_block && isOpera)
\r
9931 // Setup before range
\r
9932 rb = d.createRange();
\r
9934 // If is before the first block element and in body, then move it into first block element
\r
9935 rb.setStart(s.anchorNode, s.anchorOffset);
\r
9936 rb.collapse(true);
\r
9938 // Setup after range
\r
9939 ra = d.createRange();
\r
9941 // If is before the first block element and in body, then move it into first block element
\r
9942 ra.setStart(s.focusNode, s.focusOffset);
\r
9943 ra.collapse(true);
\r
9945 // Setup start/end points
\r
9946 dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
\r
9947 sn = dir ? s.anchorNode : s.focusNode;
\r
9948 so = dir ? s.anchorOffset : s.focusOffset;
\r
9949 en = dir ? s.focusNode : s.anchorNode;
\r
9950 eo = dir ? s.focusOffset : s.anchorOffset;
\r
9952 // If selection is in empty table cell
\r
9953 if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
\r
9954 dom.remove(sn.firstChild); // Remove BR
\r
9956 // Create two new block elements
\r
9957 ed.dom.add(sn, se.element, null, '<br />');
\r
9958 aft = ed.dom.add(sn, se.element, null, '<br />');
\r
9960 // Move caret into the last one
\r
9961 r = d.createRange();
\r
9962 r.selectNodeContents(aft);
\r
9964 ed.selection.setRng(r);
\r
9969 // If the caret is in an invalid location in FF we need to move it into the first block
\r
9970 if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
\r
9971 sn = en = sn.firstChild;
\r
9973 rb = d.createRange();
\r
9974 rb.setStart(sn, 0);
\r
9975 ra = d.createRange();
\r
9976 ra.setStart(en, 0);
\r
9979 // Never use body as start or end node
\r
9980 sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
\r
9981 sn = sn.nodeName == "BODY" ? sn.firstChild : sn;
\r
9982 en = en.nodeName == "HTML" ? d.body : en; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
\r
9983 en = en.nodeName == "BODY" ? en.firstChild : en;
\r
9985 // Get start and end blocks
\r
9986 sb = t.getParentBlock(sn);
\r
9987 eb = t.getParentBlock(en);
\r
9988 bn = sb ? sb.nodeName : se.element; // Get block name to create
\r
9990 // Return inside list use default browser behavior
\r
9991 if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
\r
9994 // If caption or absolute layers then always generate new blocks within
\r
9995 if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
\r
10000 // If caption or absolute layers then always generate new blocks within
\r
10001 if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
\r
10007 if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
\r
10012 // Setup new before and after blocks
\r
10013 bef = (sb && sb.nodeName == bn) ? sb.cloneNode(0) : ed.dom.create(bn);
\r
10014 aft = (eb && eb.nodeName == bn) ? eb.cloneNode(0) : ed.dom.create(bn);
\r
10016 // Remove id from after clone
\r
10017 aft.removeAttribute('id');
\r
10019 // Is header and cursor is at the end, then force paragraph under
\r
10020 if (/^(H[1-6])$/.test(bn) && sn.nodeValue && so == sn.nodeValue.length)
\r
10021 aft = ed.dom.create(se.element);
\r
10023 // Find start chop node
\r
10026 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
\r
10030 } while ((n = n.previousSibling ? n.previousSibling : n.parentNode));
\r
10032 // Find end chop node
\r
10035 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
\r
10039 } while ((n = n.nextSibling ? n.nextSibling : n.parentNode));
\r
10041 // Place first chop part into before block element
\r
10042 if (sc.nodeName == bn)
\r
10043 rb.setStart(sc, 0);
\r
10045 rb.setStartBefore(sc);
\r
10047 rb.setEnd(sn, so);
\r
10048 bef.appendChild(rb.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
\r
10050 // Place secnd chop part within new block element
\r
10052 ra.setEndAfter(ec);
\r
10054 //console.debug(s.focusNode, s.focusOffset);
\r
10057 ra.setStart(en, eo);
\r
10058 aft.appendChild(ra.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
\r
10060 // Create range around everything
\r
10061 r = d.createRange();
\r
10062 if (!sc.previousSibling && sc.parentNode.nodeName == bn) {
\r
10063 r.setStartBefore(sc.parentNode);
\r
10065 if (rb.startContainer.nodeName == bn && rb.startOffset == 0)
\r
10066 r.setStartBefore(rb.startContainer);
\r
10068 r.setStart(rb.startContainer, rb.startOffset);
\r
10071 if (!ec.nextSibling && ec.parentNode.nodeName == bn)
\r
10072 r.setEndAfter(ec.parentNode);
\r
10074 r.setEnd(ra.endContainer, ra.endOffset);
\r
10076 // Delete and replace it with new block elements
\r
10077 r.deleteContents();
\r
10080 ed.getWin().scrollTo(0, vp.y);
\r
10082 // Never wrap blocks in blocks
\r
10083 if (bef.firstChild && bef.firstChild.nodeName == bn)
\r
10084 bef.innerHTML = bef.firstChild.innerHTML;
\r
10086 if (aft.firstChild && aft.firstChild.nodeName == bn)
\r
10087 aft.innerHTML = aft.firstChild.innerHTML;
\r
10089 // Padd empty blocks
\r
10090 if (isEmpty(bef))
\r
10091 bef.innerHTML = '<br />';
\r
10093 if (isEmpty(aft))
\r
10094 aft.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
\r
10096 // Opera needs this one backwards for older versions
\r
10097 if (isOpera && parseFloat(opera.version()) < 9.5) {
\r
10098 r.insertNode(bef);
\r
10099 r.insertNode(aft);
\r
10101 r.insertNode(aft);
\r
10102 r.insertNode(bef);
\r
10109 function first(n) {
\r
10110 return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n;
\r
10113 // Move cursor and scroll into view
\r
10114 r = d.createRange();
\r
10115 r.selectNodeContents(isGecko ? first(aft) : aft);
\r
10117 s.removeAllRanges();
\r
10120 // scrollIntoView seems to scroll the parent window in most browsers now including FF 3.0b4 so it's time to stop using it and do it our selfs
\r
10121 y = ed.dom.getPos(aft).y;
\r
10122 ch = aft.clientHeight;
\r
10124 // Is element within viewport
\r
10125 if (y < vp.y || y + ch > vp.y + vp.h) {
\r
10126 ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + ch);
\r
10127 //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));
\r
10133 backspaceDelete : function(e, bs) {
\r
10134 var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn;
\r
10136 // The caret sometimes gets stuck in Gecko if you delete empty paragraphs
\r
10137 // This workaround removes the element by hand and moves the caret to the previous element
\r
10138 if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) {
\r
10139 if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) {
\r
10140 // Find previous block element
\r
10142 while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ;
\r
10145 if (sc != b.firstChild) {
\r
10146 // Find last text node
\r
10147 w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
10148 while (tn = w.nextNode())
\r
10151 // Place caret at the end of last text node
\r
10152 r = ed.getDoc().createRange();
\r
10153 r.setStart(n, n.nodeValue ? n.nodeValue.length : 0);
\r
10154 r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0);
\r
10157 // Remove the target container
\r
10158 ed.dom.remove(sc);
\r
10161 return Event.cancel(e);
\r
10166 // Gecko generates BR elements here and there, we don't like those so lets remove them
\r
10167 function handler(e) {
\r
10170 // A new BR was created in a block element, remove it
\r
10171 if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
\r
10172 Event.remove(b, 'DOMNodeInserted', handler);
\r
10174 // Only remove BR elements that got inserted in the middle of the text
\r
10175 if (e.previousSibling || e.nextSibling)
\r
10176 ed.dom.remove(e);
\r
10180 // Listen for new nodes
\r
10181 Event._add(b, 'DOMNodeInserted', handler);
\r
10183 // Remove listener
\r
10184 window.setTimeout(function() {
\r
10185 Event._remove(b, 'DOMNodeInserted', handler);
\r
10191 /* file:jscripts/tiny_mce/classes/ControlManager.js */
\r
10195 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend;
\r
10197 tinymce.create('tinymce.ControlManager', {
\r
10198 ControlManager : function(ed, s) {
\r
10204 t.onAdd = new tinymce.util.Dispatcher(t);
\r
10205 t.onPostRender = new tinymce.util.Dispatcher(t);
\r
10206 t.prefix = s.prefix || ed.id + '_';
\r
10209 t.onPostRender.add(function() {
\r
10210 each(t.controls, function(c) {
\r
10216 get : function(id) {
\r
10217 return this.controls[this.prefix + id] || this.controls[id];
\r
10220 setActive : function(id, s) {
\r
10223 if (c = this.get(id))
\r
10229 setDisabled : function(id, s) {
\r
10232 if (c = this.get(id))
\r
10233 c.setDisabled(s);
\r
10238 add : function(c) {
\r
10242 t.controls[c.id] = c;
\r
10243 t.onAdd.dispatch(c, t);
\r
10249 createControl : function(n) {
\r
10250 var c, t = this, ed = t.editor;
\r
10252 each(ed.plugins, function(p) {
\r
10253 if (p.createControl) {
\r
10254 c = p.createControl(n, t);
\r
10263 case "separator":
\r
10264 return t.createSeparator();
\r
10267 if (!c && ed.buttons && (c = ed.buttons[n]))
\r
10268 return t.createButton(n, c);
\r
10273 createDropMenu : function(id, s, cc) {
\r
10274 var t = this, ed = t.editor, c, bm, v, cls;
\r
10277 'class' : 'mceDropDown',
\r
10278 constrain : ed.settings.constrain_menus
\r
10281 s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin';
\r
10282 if (v = ed.getParam('skin_variant'))
\r
10283 s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1);
\r
10285 id = t.prefix + id;
\r
10286 cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu;
\r
10287 c = t.controls[id] = new cls(id, s);
\r
10288 c.onAddItem.add(function(c, o) {
\r
10289 var s = o.settings;
\r
10291 s.title = ed.getLang(s.title, s.title);
\r
10293 if (!s.onclick) {
\r
10294 s.onclick = function(v) {
\r
10295 ed.execCommand(s.cmd, s.ui || false, s.value);
\r
10300 ed.onRemove.add(function() {
\r
10304 // Fix for bug #1897785, #1898007
\r
10305 if (tinymce.isIE) {
\r
10306 c.onShowMenu.add(function() {
\r
10307 bm = ed.selection.getBookmark(1);
\r
10310 c.onHideMenu.add(function() {
\r
10312 ed.selection.moveToBookmark(bm);
\r
10319 createListBox : function(id, s, cc) {
\r
10320 var t = this, ed = t.editor, cmd, c, cls;
\r
10325 s.title = ed.translate(s.title);
\r
10326 s.scope = s.scope || ed;
\r
10328 if (!s.onselect) {
\r
10329 s.onselect = function(v) {
\r
10330 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10336 'class' : 'mce_' + id,
\r
10338 control_manager : t
\r
10341 id = t.prefix + id;
\r
10343 if (ed.settings.use_native_selects)
\r
10344 c = new tinymce.ui.NativeListBox(id, s);
\r
10346 cls = cc || t._cls.listbox || tinymce.ui.ListBox;
\r
10347 c = new cls(id, s);
\r
10350 t.controls[id] = c;
\r
10352 // Fix focus problem in Safari
\r
10353 if (tinymce.isWebKit) {
\r
10354 c.onPostRender.add(function(c, n) {
\r
10355 // Store bookmark on mousedown
\r
10356 Event.add(n, 'mousedown', function() {
\r
10357 ed.bookmark = ed.selection.getBookmark('simple');
\r
10360 // Restore on focus, since it might be lost
\r
10361 Event.add(n, 'focus', function() {
\r
10362 ed.selection.moveToBookmark(ed.bookmark);
\r
10363 ed.bookmark = null;
\r
10369 ed.onMouseDown.add(c.hideMenu, c);
\r
10374 createButton : function(id, s, cc) {
\r
10375 var t = this, ed = t.editor, o, c, cls;
\r
10380 s.title = ed.translate(s.title);
\r
10381 s.label = ed.translate(s.label);
\r
10382 s.scope = s.scope || ed;
\r
10384 if (!s.onclick && !s.menu_button) {
\r
10385 s.onclick = function() {
\r
10386 ed.execCommand(s.cmd, s.ui || false, s.value);
\r
10392 'class' : 'mce_' + id,
\r
10393 unavailable_prefix : ed.getLang('unavailable', ''),
\r
10395 control_manager : t
\r
10398 id = t.prefix + id;
\r
10400 if (s.menu_button) {
\r
10401 cls = cc || t._cls.menubutton || tinymce.ui.MenuButton;
\r
10402 c = new cls(id, s);
\r
10403 ed.onMouseDown.add(c.hideMenu, c);
\r
10405 cls = t._cls.button || tinymce.ui.Button;
\r
10406 c = new cls(id, s);
\r
10412 createMenuButton : function(id, s) {
\r
10414 s.menu_button = 1;
\r
10416 return this.createButton(id, s);
\r
10419 createSplitButton : function(id, s, cc) {
\r
10420 var t = this, ed = t.editor, cmd, c, cls;
\r
10425 s.title = ed.translate(s.title);
\r
10426 s.scope = s.scope || ed;
\r
10428 if (!s.onclick) {
\r
10429 s.onclick = function(v) {
\r
10430 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10434 if (!s.onselect) {
\r
10435 s.onselect = function(v) {
\r
10436 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10442 'class' : 'mce_' + id,
\r
10444 control_manager : t
\r
10447 id = t.prefix + id;
\r
10448 cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton;
\r
10449 c = t.add(new cls(id, s));
\r
10450 ed.onMouseDown.add(c.hideMenu, c);
\r
10455 createColorSplitButton : function(id, s, cc) {
\r
10456 var t = this, ed = t.editor, cmd, c, cls, bm;
\r
10461 s.title = ed.translate(s.title);
\r
10462 s.scope = s.scope || ed;
\r
10464 if (!s.onclick) {
\r
10465 s.onclick = function(v) {
\r
10466 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10470 if (!s.onselect) {
\r
10471 s.onselect = function(v) {
\r
10472 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10478 'class' : 'mce_' + id,
\r
10479 'menu_class' : ed.getParam('skin') + 'Skin',
\r
10481 more_colors_title : ed.getLang('more_colors')
\r
10484 id = t.prefix + id;
\r
10485 cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton;
\r
10486 c = new cls(id, s);
\r
10487 ed.onMouseDown.add(c.hideMenu, c);
\r
10489 // Remove the menu element when the editor is removed
\r
10490 ed.onRemove.add(function() {
\r
10494 // Fix for bug #1897785, #1898007
\r
10495 if (tinymce.isIE) {
\r
10496 c.onShowMenu.add(function() {
\r
10497 bm = ed.selection.getBookmark(1);
\r
10500 c.onHideMenu.add(function() {
\r
10502 ed.selection.moveToBookmark(bm);
\r
10511 createToolbar : function(id, s, cc) {
\r
10512 var c, t = this, cls;
\r
10514 id = t.prefix + id;
\r
10515 cls = cc || t._cls.toolbar || tinymce.ui.Toolbar;
\r
10516 c = new cls(id, s);
\r
10524 createSeparator : function(cc) {
\r
10525 var cls = cc || this._cls.separator || tinymce.ui.Separator;
\r
10527 return new cls();
\r
10530 setControlType : function(n, c) {
\r
10531 return this._cls[n.toLowerCase()] = c;
\r
10534 destroy : function() {
\r
10535 each(this.controls, function(c) {
\r
10539 this.controls = null;
\r
10545 /* file:jscripts/tiny_mce/classes/WindowManager.js */
\r
10548 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera;
\r
10550 tinymce.create('tinymce.WindowManager', {
\r
10551 WindowManager : function(ed) {
\r
10555 t.onOpen = new Dispatcher(t);
\r
10556 t.onClose = new Dispatcher(t);
\r
10561 open : function(s, p) {
\r
10562 var t = this, f = '', x, y, mo = t.editor.settings.dialog_type == 'modal', w, sw, sh, vp = tinymce.DOM.getViewPort(), u;
\r
10564 // Default some options
\r
10567 sw = isOpera ? vp.w : screen.width; // Opera uses windows inside the Opera window
\r
10568 sh = isOpera ? vp.h : screen.height;
\r
10569 s.name = s.name || 'mc_' + new Date().getTime();
\r
10570 s.width = parseInt(s.width || 320);
\r
10571 s.height = parseInt(s.height || 240);
\r
10572 s.resizable = true;
\r
10573 s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0);
\r
10574 s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0);
\r
10575 p.inline = false;
\r
10576 p.mce_width = s.width;
\r
10577 p.mce_height = s.height;
\r
10578 p.mce_auto_focus = s.auto_focus;
\r
10584 s.dialogWidth = s.width + 'px';
\r
10585 s.dialogHeight = s.height + 'px';
\r
10586 s.scroll = s.scrollbars || false;
\r
10590 // Build features string
\r
10591 each(s, function(v, k) {
\r
10592 if (tinymce.is(v, 'boolean'))
\r
10593 v = v ? 'yes' : 'no';
\r
10595 if (!/^(name|url)$/.test(k)) {
\r
10597 f += (f ? ';' : '') + k + ':' + v;
\r
10599 f += (f ? ',' : '') + k + '=' + v;
\r
10605 t.onOpen.dispatch(t, s, p);
\r
10607 u = s.url || s.file;
\r
10608 if (tinymce.relaxedDomain)
\r
10609 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
\r
10611 u = tinymce._addVer(u);
\r
10614 if (isIE && mo) {
\r
10616 window.showModalDialog(u, window, f);
\r
10618 w = window.open(u, s.name, f);
\r
10624 alert(t.editor.getLang('popup_blocked'));
\r
10627 close : function(w) {
\r
10629 this.onClose.dispatch(this);
\r
10632 createInstance : function(cl, a, b, c, d, e) {
\r
10633 var f = tinymce.resolve(cl);
\r
10635 return new f(a, b, c, d, e);
\r
10638 confirm : function(t, cb, s) {
\r
10639 cb.call(s || this, confirm(this._decode(this.editor.getLang(t, t))));
\r
10642 alert : function(tx, cb, s) {
\r
10645 alert(t._decode(t.editor.getLang(tx, tx)));
\r
10651 // Internal functions
\r
10653 _decode : function(s) {
\r
10654 return tinymce.DOM.decode(s).replace(/\\n/g, '\n');
\r