2 /* file:jscripts/tiny_mce/classes/tinymce.js */
6 minorVersion : '2.1.1',
7 releaseDate : '2008-11-27',
10 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
13 t.isOpera = w.opera && opera.buildNumber;
14 t.isWebKit = /WebKit/.test(ua);
15 t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt;
16 t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
17 t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
18 t.isGecko = !t.isWebKit && /Gecko/.test(ua);
19 t.isMac = ua.indexOf('Mac') != -1;
20 t.isAir = /adobeair/i.test(ua);
22 // TinyMCE .NET webcontrol might be setting the values for TinyMCE
23 if (w.tinyMCEPreInit) {
24 t.suffix = tinyMCEPreInit.suffix;
25 t.baseURL = tinyMCEPreInit.base;
26 t.query = tinyMCEPreInit.query;
30 // Get suffix and base
33 // If base element found, add that infront of baseURL
34 nl = d.getElementsByTagName('base');
35 for (i=0; i<nl.length; i++) {
37 // Host only value like http://site.com or http://site.com:8008
38 if (/^https?:\/\/[^\/]+$/.test(v))
41 base = v ? v.match(/.*\//)[0] : ''; // Get only directory
46 if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
47 if (/_(src|dev)\.js/g.test(n.src))
50 if ((p = n.src.indexOf('?')) != -1)
51 t.query = n.src.substring(p + 1);
53 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
55 // If path to script is relative and a base href was found add that one infront
56 if (base && t.baseURL.indexOf('://') == -1)
57 t.baseURL = base + t.baseURL;
66 nl = d.getElementsByTagName('script');
67 for (i=0; i<nl.length; i++) {
73 n = d.getElementsByTagName('head')[0];
75 nl = n.getElementsByTagName('script');
76 for (i=0; i<nl.length; i++) {
89 return n != 'undefined';
91 if (t == 'array' && (o instanceof Array))
99 each : function(o, cb, s) {
107 if (typeof(o.length) != 'undefined') {
108 // Indexed arrays, needed for Safari
109 for (n=0, l = o.length; n<l; n++) {
110 if (cb.call(s, o[n], n, o) === false)
116 if (o.hasOwnProperty(n)) {
117 if (cb.call(s, o[n], n, o) === false)
126 map : function(a, f) {
129 tinymce.each(a, function(v) {
136 grep : function(a, f) {
139 tinymce.each(a, function(v) {
147 inArray : function(a, v) {
151 for (i = 0, l = a.length; i < l; i++) {
160 extend : function(o, e) {
161 var i, a = arguments;
163 for (i=1; i<a.length; i++) {
166 tinymce.each(e, function(v, n) {
167 if (typeof(v) !== 'undefined')
176 return (s ? '' + s : '').replace(/^\s*|\s*$/g, '');
181 create : function(s, p) {
182 var t = this, sp, ns, cn, scn, c, de = 0;
184 // Parse : <prefix> <class>:<super class>
185 s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);
186 cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name
188 // Create namespace for new class
189 ns = t.createNS(s[3].replace(/\.\w+$/, ''));
191 // Class already exists
195 // Make pure static class
196 if (s[2] == 'static') {
200 this.onCreate(s[2], s[3], ns[cn]);
205 // Create default constructor
207 p[cn] = function() {};
211 // Add constructor and methods
213 t.extend(ns[cn].prototype, p);
217 sp = t.resolve(s[5]).prototype;
218 scn = s[5].match(/\.(\w+)$/i)[1]; // Class name
220 // Extend constructor
223 // Add passthrough constructor
224 ns[cn] = function() {
225 return sp[scn].apply(this, arguments);
228 // Add inherit constructor
229 ns[cn] = function() {
230 this.parent = sp[scn];
231 return c.apply(this, arguments);
234 ns[cn].prototype[cn] = ns[cn];
237 t.each(sp, function(f, n) {
238 ns[cn].prototype[n] = sp[n];
241 // Add overridden methods
242 t.each(p, function(f, n) {
243 // Extend methods if needed
245 ns[cn].prototype[n] = function() {
247 return f.apply(this, arguments);
251 ns[cn].prototype[n] = f;
256 // Add static methods
257 t.each(p['static'], function(f, n) {
262 this.onCreate(s[2], s[3], ns[cn].prototype);
265 walk : function(o, f, n, s) {
272 tinymce.each(o, function(o, i) {
273 if (f.call(s, o, i, n) === false)
276 tinymce.walk(o, f, n, s);
281 createNS : function(n, o) {
287 for (i=0; i<n.length; i++) {
299 resolve : function(n, o) {
305 for (i=0, l = n.length; i<l; i++) {
315 addUnload : function(f, s) {
316 var t = this, w = window;
318 f = {func : f, scope : s || this};
322 var li = t.unloads, o, n;
325 // Call unload handlers
330 o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
333 // Detach unload function
335 w.detachEvent('onbeforeunload', fakeUnload);
336 w.detachEvent('onunload', unload);
337 } else if (w.removeEventListener)
338 w.removeEventListener('unload', unload, false);
340 // Destroy references
341 t.unloads = o = li = w = unload = null;
343 // Run garbarge collector on IE
344 if (window.CollectGarbage)
345 window.CollectGarbage();
349 function fakeUnload() {
352 // Is there things still loading, then do some magic
353 if (d.readyState == 'interactive') {
355 // Prevent memory leak
356 d.detachEvent('onstop', stop);
358 // Call unload handler
364 // Fire unload when the currently loading page is stopped
365 d.attachEvent('onstop', stop);
367 // Remove onstop listener after a while to prevent the unload function
368 // to execute if the user presses cancel in an onbeforeunload
369 // confirm dialog and then presses the browser stop button
370 window.setTimeout(function() {
371 d.detachEvent('onstop', stop);
376 // Attach unload handler
378 w.attachEvent('onunload', unload);
379 w.attachEvent('onbeforeunload', fakeUnload);
380 } else if (w.addEventListener)
381 w.addEventListener('unload', unload, false);
383 // Setup initial unload handler array
391 removeUnload : function(f) {
392 var u = this.unloads, r = null;
394 tinymce.each(u, function(o, i) {
395 if (o && o.func == f) {
405 explode : function(s, d) {
406 return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s;
409 _addVer : function(u) {
415 v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
417 if (u.indexOf('#') == -1)
420 return u.replace('#', v + '#');
425 // Required for GZip AJAX loading
426 window.tinymce = tinymce;
428 // Initialize the API
431 /* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */
434 /* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */
437 /* file:jscripts/tiny_mce/classes/util/Dispatcher.js */
439 tinymce.create('tinymce.util.Dispatcher', {
443 Dispatcher : function(s) {
444 this.scope = s || this;
448 add : function(cb, s) {
449 this.listeners.push({cb : cb, scope : s || this.scope});
454 addToTop : function(cb, s) {
455 this.listeners.unshift({cb : cb, scope : s || this.scope});
460 remove : function(cb) {
461 var l = this.listeners, o = null;
463 tinymce.each(l, function(c, i) {
474 dispatch : function() {
475 var s, a = arguments, i, li = this.listeners, c;
477 // Needs to be a real loop since the listener count might change while looping
478 // And this is also more efficient
479 for (i = 0; i<li.length; i++) {
481 s = c.cb.apply(c.scope, a);
492 /* file:jscripts/tiny_mce/classes/util/URI.js */
495 var each = tinymce.each;
497 tinymce.create('tinymce.util.URI', {
498 URI : function(u, s) {
499 var t = this, o, a, b;
502 s = t.settings = s || {};
504 // Strange app protocol or local anchor
505 if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
510 // Absolute path with no host, fake host and protocol
511 if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
512 u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
515 if (u.indexOf(':/') === -1 && u.indexOf('//') !== 0)
516 u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u);
518 // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
519 u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
520 u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
521 each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
524 // Zope 3 workaround, they use @@something
526 s = s.replace(/\(mce_at\)/g, '@@');
531 if (b = s.base_uri) {
533 t.protocol = b.protocol;
536 t.userInfo = b.userInfo;
538 if (!t.port && t.host == 'mce_host')
541 if (!t.host || t.host == 'mce_host')
547 //t.path = t.path || '/';
550 setPath : function(p) {
553 p = /^(.*?)\/?(\w+)?$/.exec(p);
565 toRelative : function(u) {
571 u = new tinymce.util.URI(u, {base_uri : t});
573 // Not on same domain/port or protocol
574 if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
577 o = t.toRelPath(t.path, u.path);
590 toAbsolute : function(u, nh) {
591 var u = new tinymce.util.URI(u, {base_uri : this});
593 return u.getURI(this.host == u.host ? nh : 0);
596 toRelPath : function(base, path) {
597 var items, bp = 0, out = '', i, l;
600 base = base.substring(0, base.lastIndexOf('/'));
601 base = base.split('/');
602 items = path.split('/');
604 if (base.length >= items.length) {
605 for (i = 0, l = base.length; i < l; i++) {
606 if (i >= items.length || base[i] != items[i]) {
613 if (base.length < items.length) {
614 for (i = 0, l = items.length; i < l; i++) {
615 if (i >= base.length || base[i] != items[i]) {
625 for (i = 0, l = base.length - (bp - 1); i < l; i++)
628 for (i = bp - 1, l = items.length; i < l; i++) {
630 out += "/" + items[i];
638 toAbsPath : function(base, path) {
639 var i, nb = 0, o = [];
642 base = base.split('/');
643 path = path.split('/');
645 // Remove empty chunks
646 each(base, function(k) {
653 // Merge relURLParts chunks
654 for (i = path.length - 1, o = []; i >= 0; i--) {
656 if (path[i].length == 0 || path[i] == ".")
660 if (path[i] == '..') {
674 i = base.length - nb;
678 return '/' + o.reverse().join('/');
680 return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
683 getURI : function(nh) {
687 if (!t.source || nh) {
692 s += t.protocol + '://';
695 s += t.userInfo + '@';
722 /* file:jscripts/tiny_mce/classes/util/Cookie.js */
725 var each = tinymce.each;
727 tinymce.create('static tinymce.util.Cookie', {
728 getHash : function(n) {
729 var v = this.get(n), h;
732 each(v.split('&'), function(v) {
735 h[unescape(v[0])] = unescape(v[1]);
742 setHash : function(n, v, e, p, d, s) {
745 each(v, function(v, k) {
746 o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
749 this.set(n, o, e, p, d, s);
753 var c = document.cookie, e, p = n + "=", b;
759 b = c.indexOf("; " + p);
769 e = c.indexOf(";", b);
774 return unescape(c.substring(b + p.length, e));
777 set : function(n, v, e, p, d, s) {
778 document.cookie = n + "=" + escape(v) +
779 ((e) ? "; expires=" + e.toGMTString() : "") +
780 ((p) ? "; path=" + escape(p) : "") +
781 ((d) ? "; domain=" + d : "") +
782 ((s) ? "; secure" : "");
785 remove : function(n, p) {
788 d.setTime(d.getTime() - 1000);
790 this.set(n, '', d, p, d);
796 /* file:jscripts/tiny_mce/classes/util/JSON.js */
798 tinymce.create('static tinymce.util.JSON', {
799 serialize : function(o) {
800 var i, v, s = tinymce.util.JSON.serialize, t;
808 v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
810 return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) {
814 return '\\' + v.charAt(i + 1);
816 a = b.charCodeAt().toString(16);
818 return '\\u' + '0000'.substring(a.length) + a;
823 if (o instanceof Array) {
824 for (i=0, v = '['; i<o.length; i++)
825 v += (i > 0 ? ',' : '') + s(o[i]);
833 v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
841 parse : function(s) {
843 return eval('(' + s + ')');
851 /* file:jscripts/tiny_mce/classes/util/XHR.js */
853 tinymce.create('static tinymce.util.XHR', {
855 var x, t, w = window, c = 0;
858 o.scope = o.scope || this;
859 o.success_scope = o.success_scope || o.scope;
860 o.error_scope = o.error_scope || o.scope;
861 o.async = o.async === false ? false : true;
862 o.data = o.data || '';
868 x = new ActiveXObject(s);
875 x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
878 if (x.overrideMimeType)
879 x.overrideMimeType(o.content_type);
881 x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
884 x.setRequestHeader('Content-Type', o.content_type);
889 if (!o.async || x.readyState == 4 || c++ > 10000) {
890 if (o.success && c < 10000 && x.status == 200)
891 o.success.call(o.success_scope, '' + x.responseText, x, o);
893 o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
897 w.setTimeout(ready, 10);
900 // Syncronous request
904 // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
905 t = w.setTimeout(ready, 10);
911 /* file:jscripts/tiny_mce/classes/util/JSONRequest.js */
914 var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
916 tinymce.create('tinymce.util.JSONRequest', {
917 JSONRequest : function(s) {
918 this.settings = extend({
924 var ecb = o.error, scb = o.success;
926 o = extend(this.settings, o);
928 o.success = function(c, x) {
931 if (typeof(c) == 'undefined') {
933 error : 'JSON Parse error.'
938 ecb.call(o.error_scope || o.scope, c.error, x);
940 scb.call(o.success_scope || o.scope, c.result);
943 o.error = function(ty, x) {
944 ecb.call(o.error_scope || o.scope, ty, x);
947 o.data = JSON.serialize({
948 id : o.id || 'c' + (this.count++),
953 // JSON content type for Ruby on rails. Bug: #1883287
954 o.content_type = 'application/json';
960 sendRPC : function(o) {
961 return new tinymce.util.JSONRequest().send(o);
967 /* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */
971 var each = tinymce.each, is = tinymce.is;
972 var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE;
974 tinymce.create('tinymce.dom.DOMUtils', {
979 pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/,
981 idPattern : /^#[\w]+$/,
982 elmPattern : /^[\w_*]+$/,
983 elmClassPattern : /^([\w_]*)\.([\w_]+)$/,
986 "class" : "className",
987 className : "className",
989 disabled : "disabled",
990 maxlength : "maxLength",
991 readonly : "readOnly",
992 selected : "selected",
999 DOMUtils : function(d, s) {
1005 t.cssFlicker = false;
1007 t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat";
1008 t.stdMode = d.documentMode === 8;
1010 this.settings = s = tinymce.extend({
1011 keep_values : false,
1016 // Fix IE6SP2 flicker and check it failed for pre SP2
1017 if (tinymce.isIE6) {
1019 d.execCommand('BackgroundImageCache', false, true);
1021 t.cssFlicker = true;
1025 tinymce.addUnload(t.destroy, t);
1028 getRoot : function() {
1029 var t = this, s = t.settings;
1031 return (s && t.get(s.root_element)) || t.doc.body;
1034 getViewPort : function(w) {
1037 w = !w ? this.win : w;
1039 b = this.boxModel ? d.documentElement : d.body;
1041 // Returns viewport size excluding scrollbars
1043 x : w.pageXOffset || b.scrollLeft,
1044 y : w.pageYOffset || b.scrollTop,
1045 w : w.innerWidth || b.clientWidth,
1046 h : w.innerHeight || b.clientHeight
1050 getRect : function(e) {
1051 var p, t = this, sr;
1065 getSize : function(e) {
1069 w = t.getStyle(e, 'width');
1070 h = t.getStyle(e, 'height');
1072 // Non pixel value, then force offset/clientWidth
1073 if (w.indexOf('px') === -1)
1076 // Non pixel value, then force offset/clientWidth
1077 if (h.indexOf('px') === -1)
1081 w : parseInt(w) || e.offsetWidth || e.clientWidth,
1082 h : parseInt(h) || e.offsetHeight || e.clientHeight
1086 getParent : function(n, f, r) {
1087 var na, se = this.settings;
1092 r = r || this.getRoot();
1094 // Wrap node name as func
1095 if (is(f, 'string')) {
1096 na = f.toUpperCase();
1102 if (n.nodeType == 1 && na === '*') {
1107 each(na.split(','), function(v) {
1108 if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName.toUpperCase() == v)) {
1110 return false; // Break loop
1134 if (e && this.doc && typeof(e) == 'string') {
1136 e = this.doc.getElementById(e);
1138 // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick
1139 if (e && e.id !== n)
1140 return this.doc.getElementsByName(n)[1];
1149 select : function(pa, s) {
1150 var t = this, cs, c, pl, o = [], x, i, l, n, xp;
1152 s = t.get(s) || t.doc;
1154 // Look for native support and use that if it's found
1155 if (s.querySelectorAll) {
1156 // Element scope then use temp id
1157 // We need to do this to be compatible with other implementations
1158 // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461
1162 pa = '#_mc_tmp ' + pa;
1166 l = tinymce.grep(s.querySelectorAll(pa));
1175 t.selectorRe = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i;;
1177 // Air doesn't support eval due to security sandboxing and querySelectorAll isn't supported yet
1178 if (tinymce.isAir) {
1179 each(tinymce.explode(pa), function(v) {
1180 if (!(xp = t.cache[v])) {
1183 each(v.split(' '), function(v) {
1184 v = t.selectorRe.exec(v);
1186 xp += v[1] ? '//' + v[1] : '//*';
1190 xp += "[@id='" + v[2] + "']";
1194 each(v[3].split('.'), function(n) {
1195 xp += "[@class = '" + n + "' or contains(concat(' ', @class, ' '), ' " + n + " ')]";
1203 xp = t.doc.evaluate(xp, s, null, 4, null);
1205 while (n = xp.iterateNext())
1212 if (t.settings.strict) {
1213 function get(s, n) {
1214 return s.getElementsByTagName(n.toLowerCase());
1217 function get(s, n) {
1218 return s.getElementsByTagName(n);
1222 // Simple element pattern. For example: "p" or "*"
1223 if (t.elmPattern.test(pa)) {
1226 for (i = 0, l = x.length; i<l; i++)
1232 // Simple class pattern. For example: "p.class" or ".class"
1233 if (t.elmClassPattern.test(pa)) {
1234 pl = t.elmClassPattern.exec(pa);
1235 x = get(s, pl[1] || '*');
1236 c = ' ' + pl[2] + ' ';
1238 for (i = 0, l = x.length; i<l; i++) {
1241 if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
1248 function collect(n) {
1255 function collectIE(n) {
1256 if (!n.getAttribute('mce_save')) {
1257 n.setAttribute('mce_save', '1');
1262 function find(n, f, r) {
1263 var i, l, nl = get(r, n);
1265 for (i = 0, l = nl.length; i < l; i++)
1269 each(pa.split(','), function(v, i) {
1270 v = tinymce.trim(v);
1272 // Simple element pattern, most common in TinyMCE
1273 if (t.elmPattern.test(v)) {
1274 each(get(s, v), function(n) {
1281 // Simple element pattern with class, fairly common in TinyMCE
1282 if (t.elmClassPattern.test(v)) {
1283 x = t.elmClassPattern.exec(v);
1285 each(get(s, x[1]), function(n) {
1286 if (t.hasClass(n, x[2]))
1293 if (!(cs = t.cache[pa])) {
1294 cs = 'x=(function(cf, s) {';
1297 each(pl, function(v) {
1298 var p = t.selectorRe.exec(v);
1302 cs += 'find("' + p[1] + '", function(n) {';
1306 cs += 'if (n.id !== "' + p[2] + '") return;';
1310 cs += 'var c = " " + n.className + " ";';
1313 each(p[3].split('.'), function(v) {
1315 c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
1317 cs += c + ') return;';
1323 for (i = pl.length - 1; i >= 0; i--)
1324 cs += '}, ' + (i ? 'n' : 's') + ');';
1328 // Compile CSS pattern function
1329 t.cache[pa] = cs = eval(cs);
1332 // Run selector function
1333 cs(isIE ? collectIE : collect, s);
1337 each(o, function(n) {
1339 n.removeAttribute('mce_save');
1349 add : function(p, n, a, h, c) {
1352 return this.run(p, function(p) {
1355 e = is(n, 'string') ? t.doc.createElement(n) : n;
1365 return !c ? p.appendChild(e) : e;
1369 create : function(n, a, h) {
1370 return this.add(this.doc.createElement(n), n, a, h, 1);
1373 createHTML : function(n, a, h) {
1374 var o = '', t = this, k;
1379 if (a.hasOwnProperty(k))
1380 o += ' ' + k + '="' + t.encode(a[k]) + '"';
1384 return o + '>' + h + '</' + n + '>';
1389 remove : function(n, k) {
1390 return this.run(n, function(n) {
1399 each (n.childNodes, function(c) {
1400 p.insertBefore(c.cloneNode(true), n);
1404 // Fix IE psuedo leak
1406 p = n.cloneNode(true);
1412 return p.removeChild(n);
1418 setStyle : function(n, na, v) {
1421 return t.run(n, function(e) {
1426 // Camelcase it, if needed
1427 na = na.replace(/-(\D)/g, function(a, b){
1428 return b.toUpperCase();
1431 // Default px suffix on these
1432 if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v)))
1437 // IE specific opacity
1439 s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")";
1441 if (!n.currentStyle || !n.currentStyle.hasLayout)
1442 s.display = 'inline-block';
1445 // Fix for older browsers
1446 s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || '';
1450 isIE ? s.styleFloat = v : s.cssFloat = v;
1457 // Force update of the style data
1458 if (t.settings.update_styles)
1459 t.setAttrib(e, 'mce_style');
1463 getStyle : function(n, na, c) {
1470 if (this.doc.defaultView && c) {
1472 na = na.replace(/[A-Z]/g, function(a){
1477 return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na);
1479 // Old safari might fail
1484 // Camelcase it, if needed
1485 na = na.replace(/-(\D)/g, function(a, b){
1486 return b.toUpperCase();
1490 na = isIE ? 'styleFloat' : 'cssFloat';
1493 if (n.currentStyle && c)
1494 return n.currentStyle[na];
1499 setStyles : function(e, o) {
1500 var t = this, s = t.settings, ol;
1502 ol = s.update_styles;
1503 s.update_styles = 0;
1505 each(o, function(v, n) {
1506 t.setStyle(e, n, v);
1509 // Update style info
1510 s.update_styles = ol;
1511 if (s.update_styles)
1512 t.setAttrib(e, s.cssText);
1515 setAttrib : function(e, n, v) {
1523 if (t.settings.strict)
1524 n = n.toLowerCase();
1526 return this.run(e, function(e) {
1531 if (!is(v, 'string')) {
1532 each(v, function(v, n) {
1533 t.setStyle(e, n, v);
1539 // No mce_style for elements with these since they might get resized by the user
1540 if (s.keep_values) {
1541 if (v && !t._isRes(v))
1542 e.setAttribute('mce_style', v, 2);
1544 e.removeAttribute('mce_style', 2);
1547 e.style.cssText = v;
1551 e.className = v || ''; // Fix IE null bug
1556 if (s.keep_values) {
1557 if (s.url_converter)
1558 v = s.url_converter.call(s.url_converter_scope || t, v, n, e);
1560 t.setAttrib(e, 'mce_' + n, v, 2);
1566 e.setAttribute('mce_style', v);
1570 if (is(v) && v !== null && v.length !== 0)
1571 e.setAttribute(n, '' + v, 2);
1573 e.removeAttribute(n, 2);
1577 setAttribs : function(e, o) {
1580 return this.run(e, function(e) {
1581 each(o, function(v, n) {
1582 t.setAttrib(e, n, v);
1589 getAttrib : function(e, n, dv) {
1594 if (!e || e.nodeType !== 1)
1600 // Try the mce variant for these
1601 if (/^(src|href|style|coords|shape)$/.test(n)) {
1602 v = e.getAttribute("mce_" + n);
1608 if (isIE && t.props[n]) {
1610 v = v && v.nodeValue ? v.nodeValue : v;
1614 v = e.getAttribute(n, 2);
1616 if (n === 'style') {
1617 v = v || e.style.cssText;
1620 v = t.serializeStyle(t.parseStyle(v));
1622 if (t.settings.keep_values && !t._isRes(v))
1623 e.setAttribute('mce_style', v);
1627 // Remove Apple and WebKit stuff
1628 if (isWebKit && n === "class" && v)
1629 v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, '');
1636 // IE returns 1 as default value
1643 // IE returns +0 as default value for size
1644 if (v === '+0' || v === 20)
1661 // IE returns -1 as default value
1669 // IE returns default value
1670 if (v === 32768 || v === 2147483647 || v === '32768')
1684 v = v.toLowerCase();
1688 // IE has odd anonymous function for event attributes
1689 if (n.indexOf('on') === 0 && v)
1690 v = ('' + v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/, '$1');
1694 return (v !== undefined && v !== null && v !== '') ? '' + v : dv;
1697 getPos : function(n) {
1698 var t = this, x = 0, y = 0, e, d = t.doc, r;
1702 // Use getBoundingClientRect on IE, Opera has it but it's not perfect
1704 n = n.getBoundingClientRect();
1705 e = t.boxModel ? d.documentElement : d.body;
1706 x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
1707 x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
1708 n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
1710 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
1715 x += r.offsetLeft || 0;
1716 y += r.offsetTop || 0;
1722 // Opera 9.25 bug fix, fixed in 9.50
1723 if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
1724 x -= r.scrollLeft || 0;
1725 y -= r.scrollTop || 0;
1734 return {x : x, y : y};
1737 parseStyle : function(st) {
1738 var t = this, s = t.settings, o = {};
1743 function compress(p, s, ot) {
1746 // Get values and check it it needs compressing
1747 t = o[p + '-top' + s];
1751 r = o[p + '-right' + s];
1755 b = o[p + '-bottom' + s];
1759 l = o[p + '-left' + s];
1765 delete o[p + '-top' + s];
1766 delete o[p + '-right' + s];
1767 delete o[p + '-bottom' + s];
1768 delete o[p + '-left' + s];
1771 function compress2(ta, a, b, c) {
1787 o[ta] = o[a] + ' ' + o[b] + ' ' + o[c];
1793 st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities
1795 each(st.split(';'), function(v) {
1799 v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities
1800 v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
1802 sv = tinymce.trim(v[1]);
1803 sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];});
1805 sv = sv.replace(/rgb\([^\)]+\)/g, function(v) {
1809 if (s.url_converter) {
1810 sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
1811 return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')';
1815 o[tinymce.trim(v[0]).toLowerCase()] = sv;
1819 compress("border", "", "border");
1820 compress("border", "-width", "border-width");
1821 compress("border", "-color", "border-color");
1822 compress("border", "-style", "border-style");
1823 compress("padding", "", "padding");
1824 compress("margin", "", "margin");
1825 compress2('border', 'border-width', 'border-style', 'border-color');
1828 // Remove pointless border
1829 if (o.border == 'medium none')
1836 serializeStyle : function(o) {
1839 each(o, function(v, k) {
1841 if (tinymce.isGecko && k.indexOf('-moz-') === 0)
1846 case 'background-color':
1847 v = v.toLowerCase();
1851 s += (s ? ' ' : '') + k + ': ' + v + ';';
1858 loadCSS : function(u) {
1859 var t = this, d = t.doc;
1864 each(u.split(','), function(u) {
1869 t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
1875 addClass : function(e, c) {
1876 return this.run(e, function(e) {
1882 if (this.hasClass(e, c))
1885 o = this.removeClass(e, c);
1887 return e.className = (o != '' ? (o + ' ') : '') + c;
1891 removeClass : function(e, c) {
1894 return t.run(e, function(e) {
1897 if (t.hasClass(e, c)) {
1899 re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
1901 v = e.className.replace(re, ' ');
1903 return e.className = tinymce.trim(v != ' ' ? v : '');
1910 hasClass : function(n, c) {
1916 return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1;
1919 show : function(e) {
1920 return this.setStyle(e, 'display', 'block');
1923 hide : function(e) {
1924 return this.setStyle(e, 'display', 'none');
1927 isHidden : function(e) {
1930 return !e || e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
1935 uniqueId : function(p) {
1936 return (!p ? 'mce_' : p) + (this.counter++);
1939 setHTML : function(e, h) {
1942 return this.run(e, function(e) {
1943 var x, i, nl, n, p, x;
1945 h = t.processHTML(h);
1950 // IE will remove comments from the beginning
1951 // unless you padd the contents with something
1952 e.innerHTML = '<br />' + h;
1953 e.removeChild(e.firstChild);
1955 // 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
1956 // This seems to fix this problem
1958 // Remove all child nodes
1959 while (e.firstChild)
1960 e.firstChild.removeNode();
1962 // Create new div with HTML contents and a BR infront to keep comments
1963 x = t.create('div');
1964 x.innerHTML = '<br />' + h;
1966 // Add all children from div to target
1967 each (x.childNodes, function(n, i) {
1975 // IE has a serious bug when it comes to paragraphs it can produce an invalid
1976 // DOM tree if contents like this <p><ul><li>Item 1</li></ul></p> is inserted
1977 // It seems to be that IE doesn't like a root block element placed inside another root block element
1978 if (t.settings.fix_ie_paragraphs)
1979 h = h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi, '<p$1 mce_keep="true"> </p>');
1983 if (t.settings.fix_ie_paragraphs) {
1984 // Check for odd paragraphs this is a sign of a broken DOM
1985 nl = e.getElementsByTagName("p");
1986 for (i = nl.length - 1, x = 0; i >= 0; i--) {
1989 if (!n.hasChildNodes()) {
1995 n.removeAttribute('mce_keep');
2000 // Time to fix the madness IE left us
2002 // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
2003 // after we use innerHTML we can fix the DOM tree
2004 h = h.replace(/<p ([^>]+)>|<p>/g, '<div $1 mce_tmp="1">');
2005 h = h.replace(/<\/p>/g, '</div>');
2007 // Set the new HTML with DIVs
2010 // Replace all DIV elements with he mce_tmp attibute back to paragraphs
2011 // This is needed since IE has a annoying bug see above for details
2012 // This is a slow process but it has to be done. :(
2013 if (t.settings.fix_ie_paragraphs) {
2014 nl = e.getElementsByTagName("DIV");
2015 for (i = nl.length - 1; i >= 0; i--) {
2020 // Create new paragraph
2021 p = t.doc.createElement('p');
2023 // Copy all attributes
2024 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
2027 if (b !== 'mce_tmp') {
2028 v = n.getAttribute(b);
2030 if (!v && b === 'class')
2033 p.setAttribute(b, v);
2037 // Append all children to new paragraph
2038 for (x = 0; x<n.childNodes.length; x++)
2039 p.appendChild(n.childNodes[x].cloneNode(true));
2041 // Replace div with new paragraph
2054 processHTML : function(h) {
2055 var t = this, s = t.settings;
2057 if (!s.process_html)
2060 // Convert strong and em to b and i in FF since it can't handle them
2061 if (tinymce.isGecko) {
2062 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
2063 h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
2065 h = h.replace(/'/g, '''); // IE can't handle apos
2066 h = h.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi, ''); // IE doesn't handle default values correct
2070 h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open
2072 // Store away src and href in mce_src and mce_href since browsers mess them up
2073 if (s.keep_values) {
2074 // Wrap scripts and styles in comments for serialization purposes
2075 if (/<script|style/.test(h)) {
2077 // Remove prefix and suffix code for element
2078 s = s.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n');
2079 s = s.replace(/^[\r\n]*|[\r\n]*$/g, '');
2080 s = s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<!\[CDATA\[|<!--|<!\[CDATA\[)[\r\n]*/g, '');
2081 s = s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->|\]\]-->)\s*$/g, '');
2086 // Preserve script elements
2087 h = h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g, function(v, a, b) {
2088 // Remove prefix and suffix code for script element
2091 // Force type attribute
2093 a = ' type="text/javascript"';
2095 // Wrap contents in a comment
2097 b = '<!--\n' + b + '\n// -->';
2099 // Output fake element
2100 return '<mce:script' + a + '>' + b + '</mce:script>';
2103 // Preserve style elements
2104 h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g, function(v, a, b) {
2106 return '<mce:style' + a + '><!--\n' + b + '\n--></mce:style><style' + a + ' mce_bogus="1">' + b + '</style>';
2110 h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->');
2112 // Process all tags with src, href or style
2113 h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
2114 function handle(m, b, c) {
2117 // Tag already got a mce_ version
2118 if (a.indexOf('mce_' + b) != -1)
2122 // Why did I need this one?
2124 // u = t.serializeStyle(t.parseStyle(u));
2126 // No mce_style for elements with these since they might get resized by the user
2131 u = u.replace(/rgb\([^\)]+\)/g, function(v) {
2136 if (s.url_converter) {
2137 u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
2138 return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
2141 } else if (b != 'coords' && b != 'shape') {
2142 if (s.url_converter)
2143 u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
2146 return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
2149 a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C
2150 a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C
2152 return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
2159 getOuterHTML : function(e) {
2170 d = (e.ownerDocument || this.doc).createElement("body");
2171 d.appendChild(e.cloneNode(true));
2176 setOuterHTML : function(e, h, d) {
2179 return this.run(e, function(e) {
2183 d = d || e.ownerDocument || t.doc;
2185 if (isIE && e.nodeType == 1)
2188 tp = d.createElement("body");
2193 t.insertAfter(n.cloneNode(true), e);
2194 n = n.previousSibling;
2202 decode : function(s) {
2205 // Look for entities to decode
2206 if (/&[^;]+;/.test(s)) {
2207 // Decode the entities using a div element not super efficient but less code
2208 e = this.doc.createElement("div");
2216 } while (n.nextSibling);
2225 encode : function(s) {
2226 return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
2247 insertAfter : function(n, r) {
2252 return this.run(n, function(n) {
2259 p.insertBefore(n, ns);
2269 isBlock : function(n) {
2270 if (n.nodeType && n.nodeType !== 1)
2273 n = n.nodeName || n;
2275 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);
2280 replace : function(n, o, k) {
2282 n = n.cloneNode(true);
2284 return this.run(o, function(o) {
2286 each(o.childNodes, function(c) {
2287 n.appendChild(c.cloneNode(true));
2291 // Fix IE psuedo leak for elements since replacing elements if fairly common
2292 // Will break parentNode for some unknown reason
2293 /* if (isIE && o.nodeType === 1) {
2294 o.parentNode.insertBefore(n, o);
2299 return o.parentNode.replaceChild(n, o);
2305 toHex : function(s) {
2306 var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
2309 s = parseInt(s).toString(16);
2311 return s.length > 1 ? s : '0' + s; // 0 -> 00
2315 s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
2323 getClasses : function() {
2324 var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
2329 function addClasses(s) {
2331 each(s.imports, function(r) {
2335 each(s.cssRules || s.rules, function(r) {
2336 // Real type or fake it on IE
2337 switch (r.type || 1) {
2340 if (r.selectorText) {
2341 each(r.selectorText.split(','), function(v) {
2342 v = v.replace(/^\s*|\s*$|^\s\./g, "");
2344 // Is internal or it doesn't contain a class
2345 if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v))
2348 // Remove everything but class name
2350 v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1');
2353 if (f && !(v = f(v, ov)))
2357 cl.push({'class' : v});
2366 addClasses(r.styleSheet);
2373 each(t.doc.styleSheets, addClasses);
2384 run : function(e, f, s) {
2387 if (t.doc && typeof(e) === 'string')
2394 if (!e.nodeType && (e.length || e.length === 0)) {
2397 each(e, function(e, i) {
2399 if (typeof(e) == 'string')
2400 e = t.doc.getElementById(e);
2402 o.push(f.call(s, e, i));
2409 return f.call(s, e);
2412 getAttribs : function(n) {
2423 // Object will throw exception in IE
2424 if (n.nodeName == 'OBJECT')
2425 return n.attributes;
2427 // It's crazy that this is faster in IE but it's because it returns all attributes all the time
2428 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
2429 o.push({specified : 1, nodeName : b});
2435 return n.attributes;
2438 destroy : function(s) {
2441 t.win = t.doc = t.root = null;
2443 // Manual destroy then remove unload handler
2445 tinymce.removeUnload(t.destroy);
2448 _isRes : function(c) {
2449 // Is live resizble element
2450 return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c);
2454 walk : function(n, f, s) {
2455 var d = this.doc, w;
2457 if (d.createTreeWalker) {
2458 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
2460 while ((n = w.nextNode()) != null)
2461 f.call(s || this, n);
2463 tinymce.walk(n, f, 'childNodes', s);
2468 toRGB : function(s) {
2469 var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
2476 return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
2486 tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
2489 /* file:jscripts/tiny_mce/classes/dom/Event.js */
2493 var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
2495 tinymce.create('static tinymce.dom.Event', {
2501 add : function(o, n, f, s) {
2502 var cb, t = this, el = t.events, r;
2505 if (o && o instanceof Array) {
2508 each(o, function(o) {
2510 r.push(t.add(o, n, f, s));
2521 // Setup event callback
2523 e = e || window.event;
2525 // Patch in target in IE it's W3C valid
2526 if (e && !e.target && isIE)
2527 e.target = e.srcElement;
2532 return f.call(s, e);
2535 if (n == 'unload') {
2536 tinymce.unloads.unshift({func : cb});
2549 // Store away listener reference
2563 remove : function(o, n, f) {
2564 var t = this, a = t.events, s = false, r;
2567 if (o && o instanceof Array) {
2570 each(o, function(o) {
2572 r.push(t.remove(o, n, f));
2580 each(a, function(e, i) {
2581 if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
2583 t._remove(o, n, e.cfunc);
2592 clear : function(o) {
2593 var t = this, a = t.events, i, e;
2598 for (i = a.length - 1; i >= 0; i--) {
2602 t._remove(e.obj, e.name, e.cfunc);
2603 e.obj = e.cfunc = null;
2612 cancel : function(e) {
2617 return this.prevent(e);
2620 stop : function(e) {
2621 if (e.stopPropagation)
2622 e.stopPropagation();
2624 e.cancelBubble = true;
2629 prevent : function(e) {
2630 if (e.preventDefault)
2633 e.returnValue = false;
2638 _unload : function() {
2641 each(t.events, function(e, i) {
2642 t._remove(e.obj, e.name, e.cfunc);
2643 e.obj = e.cfunc = null;
2650 _add : function(o, n, f) {
2652 o.attachEvent('on' + n, f);
2653 else if (o.addEventListener)
2654 o.addEventListener(n, f, false);
2659 _remove : function(o, n, f) {
2663 o.detachEvent('on' + n, f);
2664 else if (o.removeEventListener)
2665 o.removeEventListener(n, f, false);
2669 // Might fail with permission denined on IE so we just ignore that
2674 _pageInit : function() {
2677 // Safari on Mac fires this twice
2681 e._remove(window, 'DOMContentLoaded', e._pageInit);
2684 each(e.inits, function(c) {
2691 _wait : function() {
2694 // No need since the document is already loaded
2695 if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
2696 Event.domLoaded = 1;
2700 //Sugar bug fix. When using YUI Loader to pull in tinyMCE, IE crashes because of the document.write calls.
2701 var skipInitPhase = (typeof (skipTinyMCEInitPhase) != 'undefined') ? true : false;
2702 if (isIE && document.location.protocol != 'https:' && !skipInitPhase ) {
2704 // Fake DOMContentLoaded on IE
2705 document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
2706 DOM.get("__ie_onload").onreadystatechange = function() {
2707 if (this.readyState == "complete") {
2709 DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
2713 Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
2715 if (isIE || isWebKit) {
2716 t = setInterval(function() {
2717 if (/loaded|complete/.test(document.readyState)) {
2729 Event = tinymce.dom.Event;
2731 // Dispatch DOM content loaded event for IE and Safari
2733 tinymce.addUnload(Event._unload);
2736 /* file:jscripts/tiny_mce/classes/dom/Element.js */
2739 var each = tinymce.each;
2741 tinymce.create('tinymce.dom.Element', {
2742 Element : function(id, s) {
2743 var t = this, dom, el;
2747 t.dom = dom = s.dom || tinymce.DOM;
2750 // Only IE leaks DOM references, this is a lot faster
2752 el = t.dom.get(t.id);
2778 var a = arguments, o;
2781 if (tinymce.isOpera) {
2784 each(arguments, function(v) {
2788 Array.prototype.unshift.call(a, el || id);
2790 o = dom[k].apply(dom, a);
2798 on : function(n, f, s) {
2799 return tinymce.dom.Event.add(this.id, n, f, s);
2802 getXY : function() {
2804 x : parseInt(this.getStyle('left')),
2805 y : parseInt(this.getStyle('top'))
2809 getSize : function() {
2810 var n = this.dom.get(this.id);
2813 w : parseInt(this.getStyle('width') || n.clientWidth),
2814 h : parseInt(this.getStyle('height') || n.clientHeight)
2818 moveTo : function(x, y) {
2819 this.setStyles({left : x, top : y});
2822 moveBy : function(x, y) {
2823 var p = this.getXY();
2825 this.moveTo(p.x + x, p.y + y);
2828 resizeTo : function(w, h) {
2829 this.setStyles({width : w, height : h});
2832 resizeBy : function(w, h) {
2833 var s = this.getSize();
2835 this.resizeTo(s.w + w, s.h + h);
2838 update : function(k) {
2839 var t = this, b, dom = t.dom;
2841 if (tinymce.isIE6 && t.settings.blocker) {
2845 if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0)
2848 // Remove blocker on remove
2849 if (k == 'remove') {
2850 dom.remove(t.blocker);
2855 t.blocker = dom.uniqueId();
2856 b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'});
2857 dom.setStyle(b, 'opacity', 0);
2859 b = dom.get(t.blocker);
2861 dom.setStyle(b, 'left', t.getStyle('left', 1));
2862 dom.setStyle(b, 'top', t.getStyle('top', 1));
2863 dom.setStyle(b, 'width', t.getStyle('width', 1));
2864 dom.setStyle(b, 'height', t.getStyle('height', 1));
2865 dom.setStyle(b, 'display', t.getStyle('display', 1));
2866 dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1);
2873 /* file:jscripts/tiny_mce/classes/dom/Selection.js */
2876 function trimNl(s) {
2877 return s.replace(/[\n\r]+/g, '');
2881 var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each;
2883 tinymce.create('tinymce.dom.Selection', {
2884 Selection : function(dom, win, serializer) {
2889 t.serializer = serializer;
2893 'onBeforeSetContent',
2894 'onBeforeGetContent',
2898 t[e] = new tinymce.util.Dispatcher(t);
2902 tinymce.addUnload(t.destroy, t);
2905 getContent : function(s) {
2906 var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n;
2911 s.format = s.format || 'html';
2912 t.onBeforeGetContent.dispatch(t, s);
2914 if (s.format == 'text')
2915 return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : ''));
2917 if (r.cloneContents) {
2918 n = r.cloneContents();
2922 } else if (is(r.item) || is(r.htmlText))
2923 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
2925 e.innerHTML = r.toString();
2927 // Keep whitespace before and after
2928 if (/^\s/.test(e.innerHTML))
2931 if (/\s+$/.test(e.innerHTML))
2936 s.content = t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
2937 t.onGetContent.dispatch(t, s);
2942 setContent : function(h, s) {
2943 var t = this, r = t.getRng(), c, d = t.win.document;
2945 s = s || {format : 'html'};
2947 h = s.content = t.dom.processHTML(h);
2949 // Dispatch before set content event
2950 t.onBeforeSetContent.dispatch(t, s);
2954 // Make caret marker since insertNode places the caret in the beginning of text after insert
2955 h += '<span id="__caret">_</span>';
2957 // Delete and insert new node
2959 r.insertNode(t.getRng().createContextualFragment(h));
2961 // Move to caret marker
2962 c = t.dom.get('__caret');
2964 // Make sure we wrap it compleatly, Opera fails with a simple select call
2965 r = d.createRange();
2966 r.setStartBefore(c);
2970 // Delete the marker, and hopefully the caret gets placed in the right location
2971 d.execCommand('Delete', false, null);
2973 // In case it's still there
2974 t.dom.remove('__caret');
2977 // Delete content and get caret text selection
2978 d.execCommand('Delete', false, null);
2985 // Dispatch set content event
2986 t.onSetContent.dispatch(t, s);
2989 getStart : function() {
2990 var t = this, r = t.getRng(), e;
2998 e = r.parentElement();
3000 if (e && e.nodeName == 'BODY')
3001 return e.firstChild;
3005 e = r.startContainer;
3007 if (e.nodeName == 'BODY')
3008 return e.firstChild;
3010 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
3014 getEnd : function() {
3015 var t = this, r = t.getRng(), e;
3023 e = r.parentElement();
3025 if (e && e.nodeName == 'BODY')
3032 if (e.nodeName == 'BODY')
3035 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
3039 getBookmark : function(si) {
3040 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;
3044 // Simple bookmark fast but not as persistent
3046 return {rng : r, scrollX : sx, scrollY : sy};
3050 // Control selection
3054 each(t.dom.select(e.nodeName), function(n, i) {
3070 tr = t.dom.doc.body.createTextRange();
3071 tr.moveToElementText(ro);
3073 bp = Math.abs(tr.move('character', c));
3077 sp = Math.abs(tr.move('character', c));
3081 le = Math.abs(tr.move('character', c)) - sp;
3099 if (e && e.nodeName == 'IMG') {
3108 function getPos(r, sn, en) {
3109 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
3111 while ((n = w.nextNode()) != null) {
3120 p += trimNl(n.nodeValue || '').length;
3126 // Caret or selection
3127 if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
3128 e = getPos(ro, s.anchorNode, s.focusNode);
3131 return {scrollX : sx, scrollY : sy};
3133 // Count whitespace before
3134 trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
3137 start : Math.max(e.start + s.anchorOffset - wb, 0),
3138 end : Math.max(e.end + s.focusOffset - wb, 0),
3141 beg : s.anchorOffset - wb == 0
3144 e = getPos(ro, r.startContainer, r.endContainer);
3146 // Count whitespace before start and end container
3147 //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
3148 //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
3151 return {scrollX : sx, scrollY : sy};
3154 start : Math.max(e.start + r.startOffset - wb, 0),
3155 end : Math.max(e.end + r.endOffset - wa, 0),
3158 beg : r.startOffset - wb == 0
3163 moveToBookmark : function(b) {
3164 var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv;
3166 function getPos(r, sp, ep) {
3167 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb;
3169 while ((n = w.nextNode()) != null) {
3172 nv = n.nodeValue || '';
3173 //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
3174 //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
3176 nvl = trimNl(nv).length;
3179 if (p >= sp && !d.startNode) {
3182 // Fix for odd quirk in FF
3183 if (b.beg && o >= nvl)
3187 d.startOffset = o + wb;
3192 d.endOffset = ep - (p - nvl) + wb;
3203 t.win.scrollTo(b.scrollX, b.scrollY);
3220 // Handle control bookmark
3222 r = ro.createControlRange();
3224 each(t.dom.select(b.tag), function(n, i) {
3229 // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
3231 // Incorrect bookmark
3235 r = s.createRange();
3236 r.moveToElementText(ro);
3238 r.moveStart('character', b.start);
3239 r.moveEnd('character', b.length);
3248 // Needed for some odd IE bug #1843306
3260 s.removeAllRanges();
3263 if (is(b.start) && is(b.end)) {
3265 sd = getPos(ro, b.start, b.end);
3268 r = t.dom.doc.createRange();
3269 r.setStart(sd.startNode, sd.startOffset);
3270 r.setEnd(sd.endNode, sd.endOffset);
3271 s.removeAllRanges();
3275 if (!tinymce.isOpera)
3284 select : function(n, c) {
3285 var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document;
3288 return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null;
3297 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
3298 while (c = w.nextNode())
3308 if (/^(IMG|TABLE)$/.test(n.nodeName)) {
3309 r = b.createControlRange();
3312 r = b.createTextRange();
3313 r.moveToElementText(n);
3318 // Throws illigal agrument in IE some times
3326 //console.debug(fn, ln);
3327 r = d.createRange();
3329 r.setEnd(ln, ln.nodeValue.length);
3341 isCollapsed : function() {
3342 var t = this, r = t.getRng(), s = t.getSel();
3347 return !s || r.boundingWidth == 0 || r.collapsed;
3350 collapse : function(b) {
3351 var t = this, r = t.getRng(), n;
3353 // Control range on IE
3356 r = this.win.document.body.createTextRange();
3357 r.moveToElementText(n);
3364 getSel : function() {
3365 var t = this, w = this.win;
3367 return w.getSelection ? w.getSelection() : w.document.selection;
3370 getRng : function() {
3371 var t = this, s = t.getSel(), r;
3375 r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange());
3377 // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
3380 // No range found then create an empty one
3381 // This can occur when the editor is placed in a hidden container element on Gecko
3382 // Or on IE when there was an exception
3384 r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange();
3389 setRng : function(r) {
3396 s.removeAllRanges();
3403 // Needed for some odd IE bug #1843306
3408 setNode : function(n) {
3411 t.setContent(t.dom.getOuterHTML(n));
3416 getNode : function() {
3417 var t = this, r = t.getRng(), s = t.getSel(), e;
3420 // Range maybe lost after the editor is made visible again
3422 return t.dom.getRoot();
3424 e = r.commonAncestorContainer;
3426 // Handle selection a image or other control like element such as anchors
3428 // If the anchor node is a element instead of a text node then return this element
3429 if (tinymce.isWebKit && s.anchorNode && s.anchorNode.nodeType == 1)
3430 return s.anchorNode.childNodes[s.anchorOffset];
3432 if (r.startContainer == r.endContainer) {
3433 if (r.startOffset - r.endOffset < 2) {
3434 if (r.startContainer.hasChildNodes())
3435 e = r.startContainer.childNodes[r.startOffset];
3440 return t.dom.getParent(e, function(n) {
3441 return n.nodeType == 1;
3445 return r.item ? r.item(0) : r.parentElement();
3448 destroy : function(s) {
3453 // Manual destroy then remove unload handler
3455 tinymce.removeUnload(t.destroy);
3461 /* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */
3464 tinymce.create('tinymce.dom.XMLWriter', {
3467 XMLWriter : function(s) {
3470 var i = document.implementation;
3472 if (!i || !i.createDocument) {
3474 try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
3475 try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
3477 return i.createDocument('', '', null);
3480 this.doc = getXML();
3482 // Since Opera and WebKit doesn't escape > into > we need to do it our self to normalize the output for all browsers
3483 this.valid = tinymce.isOpera || tinymce.isWebKit;
3488 reset : function() {
3489 var t = this, d = t.doc;
3492 d.removeChild(d.firstChild);
3494 t.node = d.appendChild(d.createElement("html"));
3497 writeStartElement : function(n) {
3500 t.node = t.node.appendChild(t.doc.createElement(n));
3503 writeAttribute : function(n, v) {
3505 v = v.replace(/>/g, '%MCGT%');
3507 this.node.setAttribute(n, v);
3510 writeEndElement : function() {
3511 this.node = this.node.parentNode;
3514 writeFullEndElement : function() {
3515 var t = this, n = t.node;
3517 n.appendChild(t.doc.createTextNode(""));
3518 t.node = n.parentNode;
3521 writeText : function(v) {
3523 v = v.replace(/>/g, '%MCGT%');
3525 this.node.appendChild(this.doc.createTextNode(v));
3528 writeCDATA : function(v) {
3529 this.node.appendChild(this.doc.createCDATA(v));
3532 writeComment : function(v) {
3533 // Fix for bug #2035694
3535 v = v.replace(/^\-|\-$/g, ' ');
3537 this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' ')));
3540 getContent : function() {
3543 h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);
3544 h = h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g, '');
3545 h = h.replace(/ ?\/>/g, ' />');
3548 h = h.replace(/\%MCGT%/g, '>');
3556 /* file:jscripts/tiny_mce/classes/dom/StringWriter.js */
3559 tinymce.create('tinymce.dom.StringWriter', {
3566 StringWriter : function(s) {
3567 this.settings = tinymce.extend({
3575 reset : function() {
3582 writeStartElement : function(n) {
3583 this._writeAttributesEnd();
3584 this.writeRaw('<' + n);
3588 this.elementCount = this.count;
3591 writeAttribute : function(n, v) {
3594 t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"');
3597 writeEndElement : function() {
3600 if (this.tags.length > 0) {
3601 n = this.tags.pop();
3603 if (this._writeAttributesEnd(1))
3604 this.writeRaw('</' + n + '>');
3606 if (this.settings.indentation > 0)
3607 this.writeRaw('\n');
3611 writeFullEndElement : function() {
3612 if (this.tags.length > 0) {
3613 this._writeAttributesEnd();
3614 this.writeRaw('</' + this.tags.pop() + '>');
3616 if (this.settings.indentation > 0)
3617 this.writeRaw('\n');
3621 writeText : function(v) {
3622 this._writeAttributesEnd();
3623 this.writeRaw(this.encode(v));
3627 writeCDATA : function(v) {
3628 this._writeAttributesEnd();
3629 this.writeRaw('<![CDATA[' + v + ']]>');
3633 writeComment : function(v) {
3634 this._writeAttributesEnd();
3635 this.writeRaw('<!-- ' + v + '-->');
3639 writeRaw : function(v) {
3643 encode : function(s) {
3644 return s.replace(/[<>&"]/g, function(v) {
3663 getContent : function() {
3667 _writeAttributesEnd : function(s) {
3671 this.inAttr = false;
3673 if (s && this.elementCount == this.count) {
3674 this.writeRaw(' />');
3686 /* file:jscripts/tiny_mce/classes/dom/Serializer.js */
3690 var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko;
3692 // Returns only attribites that have values not all attributes in IE
3693 function getIEAtts(n) {
3696 // Object will throw exception in IE
3697 if (n.nodeName == 'OBJECT')
3698 return n.attributes;
3700 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
3701 o.push({specified : 1, nodeName : b});
3707 function wildcardToRE(s) {
3708 return s.replace(/([?+*])/g, '.$1');
3711 tinymce.create('tinymce.dom.Serializer', {
3712 Serializer : function(s) {
3716 t.onPreProcess = new Dispatcher(t);
3717 t.onPostProcess = new Dispatcher(t);
3719 if (tinymce.relaxedDomain && tinymce.isGecko) {
3720 // Gecko has a bug where we can't create a new XML document if domain relaxing is used
3721 t.writer = new tinymce.dom.StringWriter();
3724 t.writer = new tinymce.dom.XMLWriter();
3726 // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
3727 t.writer = new tinymce.dom.StringWriter();
3732 t.settings = s = extend({
3737 invalid_attrs : /^(mce_|_moz_)/,
3738 closed : /(br|hr|input|meta|img|link|param)/,
3739 entity_encoding : 'named',
3740 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',
3741 bool_attrs : /(checked|disabled|readonly|selected|nowrap)/,
3742 valid_elements : '*[*]',
3743 extended_valid_elements : 0,
3744 valid_child_elements : 0,
3745 invalid_elements : 0,
3746 fix_table_elements : 0,
3747 fix_list_elements : true,
3748 fix_content_duplication : true,
3749 convert_fonts_to_spans : false,
3750 font_size_classes : 0,
3751 font_size_style_values : 0,
3752 apply_source_formatting : 0,
3753 indent_mode : 'simple',
3756 remove_linebreaks : 1,
3757 remove_redundant_brs : 1,
3758 element_format : 'xhtml'
3763 if (s.remove_redundant_brs) {
3764 t.onPostProcess.add(function(se, o) {
3765 // Remove BR elements at end of list elements since they get rendered in IE
3766 o.content = o.content.replace(/<br \/>(\s*<\/li>)/g, '$1');
3770 // Remove XHTML element endings i.e. produce crap :) XHTML is better
3771 if (s.element_format == 'html') {
3772 t.onPostProcess.add(function(se, o) {
3773 o.content = o.content.replace(/<([^>]+) \/>/g, '<$1>');
3777 if (s.fix_list_elements) {
3778 t.onPreProcess.add(function(se, o) {
3779 var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np;
3781 function prevNode(e, n) {
3782 var a = n.split(','), i;
3784 while ((e = e.previousSibling) != null) {
3785 for (i=0; i<a.length; i++) {
3786 if (e.nodeName == a[i])
3794 for (x=0; x<a.length; x++) {
3795 nl = t.dom.select(a[x], o.node);
3797 for (i=0; i<nl.length; i++) {
3801 if (r.test(p.nodeName)) {
3802 np = prevNode(n, 'LI');
3805 np = t.dom.create('li');
3806 np.innerHTML = ' ';
3808 p.insertBefore(np, p.firstChild);
3817 if (s.fix_table_elements) {
3818 t.onPreProcess.add(function(se, o) {
3819 each(t.dom.select('table', o.node), function(e) {
3820 var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns;
3823 pa2 = pa.cloneNode(false);
3826 for (n = e; n = n.parentNode;) {
3834 for (i = pl.length - 1; i >= 0; i--) {
3835 if (i == pl.length - 1) {
3836 while (ns = pl[i - 1].nextSibling)
3837 tm.appendChild(ns.parentNode.removeChild(ns));
3839 n = pl[i].cloneNode(false);
3842 while (ns = pl[i - 1].nextSibling)
3843 n.appendChild(ns.parentNode.removeChild(ns));
3846 tm = tm.appendChild(n);
3850 e = t.dom.insertAfter(e.parentNode.removeChild(e), pa);
3851 t.dom.insertAfter(e, pa);
3852 t.dom.insertAfter(pa2, e);
3859 setEntities : function(s) {
3860 var t = this, a, i, l = {}, re = '', v;
3862 // No need to setup more than once
3866 // Build regex and lookup array
3868 for (i = 0; i < a.length; i += 2) {
3871 // Don't add default & " etc.
3872 if (v == 34 || v == 38 || v == 60 || v == 62)
3875 l[String.fromCharCode(a[i])] = a[i + 1];
3877 v = parseInt(a[i]).toString(16);
3878 re += '\\u' + '0000'.substring(v.length) + v;
3882 t.settings.entity_encoding = 'raw';
3886 t.entitiesRE = new RegExp('[' + re + ']', 'g');
3890 setValidChildRules : function(s) {
3891 this.childRules = null;
3892 this.addValidChildRules(s);
3895 addValidChildRules : function(s) {
3896 var t = this, inst, intr, bloc;
3901 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';
3902 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';
3903 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';
3905 each(s.split(','), function(s) {
3906 var p = s.split(/\[|\]/), re;
3909 each(p[1].split('|'), function(v) {
3919 v = intr.substring(2);
3927 v = inst.substring(2);
3941 re = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
3943 each(p[0].split('/'), function(s) {
3944 t.childRules = t.childRules || {};
3945 t.childRules[s] = re;
3951 each(t.childRules, function(v, k) {
3958 t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
3960 /*console.debug(t.parentElementsRE.toString());
3961 each(t.childRules, function(v) {
3962 console.debug(v.toString());
3966 setRules : function(s) {
3972 t.validElements = {};
3974 return t.addRules(s);
3977 addRules : function(s) {
3985 each(s.split(','), function(s) {
3986 var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = [];
3988 // Extend with default rules
3990 at = tinymce.extend([], dr.attribs);
3994 each(p[1].split('|'), function(s) {
3999 // Parse attribute rule
4000 s = s.replace(/::/g, '~');
4001 s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);
4002 s[2] = s[2].replace(/~/g, ':');
4004 // Add required attributes
4010 // Remove inherited attributes
4012 for (i = 0; i <at.length; i++) {
4013 if (at[i].name == s[2]) {
4021 // Add default attrib values
4023 ar.defaultVal = s[4] || '';
4026 // Add forced attrib values
4028 ar.forcedVal = s[4];
4031 // Add validation values
4033 ar.validVals = s[4].split('?');
4037 if (/[*.?]/.test(s[2])) {
4039 ar.nameRE = new RegExp('^' + wildcardToRE(s[2]) + '$');
4050 // Handle element names
4051 each(tn, function(s, i) {
4052 var pr = s.charAt(0), x = 1, ru = {};
4054 // Extend with default rule data
4057 ru.noEmpty = dr.noEmpty;
4060 ru.fullEnd = dr.fullEnd;
4084 tn[i] = s = s.substring(x);
4085 t.validElements[s] = 1;
4087 // Add element name or element regex
4088 if (/[*.?]/.test(tn[0])) {
4089 ru.nameRE = new RegExp('^' + wildcardToRE(tn[0]) + '$');
4090 t.wildRules = t.wildRules || {};
4091 t.wildRules.push(ru);
4095 // Store away default rule
4105 ru.requiredAttribs = ra;
4108 // Build valid attributes regexp
4110 each(va, function(v) {
4114 s += '(' + wildcardToRE(v) + ')';
4116 ru.validAttribsRE = new RegExp('^' + s.toLowerCase() + '$');
4117 ru.wildAttribs = wat;
4122 // Build valid elements regexp
4124 each(t.validElements, function(v, k) {
4131 t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$');
4133 //console.debug(t.validElementsRE.toString());
4134 //console.dir(t.rules);
4135 //console.dir(t.wildRules);
4138 findRule : function(n) {
4139 var t = this, rl = t.rules, i, r;
4150 for (i = 0; i < rl.length; i++) {
4151 if (rl[i].nameRE.test(n))
4158 findAttribRule : function(ru, n) {
4159 var i, wa = ru.wildAttribs;
4161 for (i = 0; i < wa.length; i++) {
4162 if (wa[i].nameRE.test(n))
4169 serialize : function(n, o) {
4174 o.format = o.format || 'html';
4176 n = n.cloneNode(true);
4177 t.key = '' + (parseInt(t.key) + 1);
4182 t.onPreProcess.dispatch(t, o);
4185 // Serialize HTML DOM into a string
4187 t._serializeNode(n, o.getInner);
4190 o.content = t.writer.getContent();
4193 t.onPostProcess.dispatch(t, o);
4198 return tinymce.trim(o.content);
4201 // Internal functions
4203 _postProcess : function(o) {
4204 var t = this, s = t.settings, h = o.content, sc = [], p;
4206 if (o.format == 'html') {
4207 // Protect some elements
4211 {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
4212 {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
4213 {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1},
4214 {pattern : /(<!--\[CDATA\[)(.*?)(\]\]-->)/g}
4221 if (s.entity_encoding !== 'raw')
4224 // Use BR instead of padded P elements inside editor and use <p> </p> outside editor
4226 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>');
4228 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/
4230 // Since Gecko and Safari keeps whitespace in the DOM we need to
4231 // remove it inorder to match other browsers. But I think Gecko and Safari is right.
4232 // This process is only done when getting contents out from the editor.
4234 // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char
4235 h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1> </p>' : '<p$1> </p>');
4237 if (s.remove_linebreaks) {
4238 h = h.replace(/\r?\n|\r/g, ' ');
4239 h = h.replace(/(<[^>]+>)\s+/g, '$1 ');
4240 h = h.replace(/\s+(<\/[^>]+>)/g, ' $1');
4241 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
4242 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
4243 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
4246 // Simple indentation
4247 if (s.apply_source_formatting && s.indent_mode == 'simple') {
4248 // Add line breaks before and after block elements
4249 h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n');
4250 h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>');
4251 h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '</$1>\n');
4252 h = h.replace(/\n\n/g, '\n');
4256 h = t._unprotect(h, p);
4258 // Restore CDATA sections
4259 h = h.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g, '<![CDATA[$1]]>');
4261 // Restore the \u00a0 character if raw mode is enabled
4262 if (s.entity_encoding == 'raw')
4263 h = h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g, '<p$1>\u00a0</p>');
4269 _serializeNode : function(n, inn) {
4270 var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv;
4272 if (!s.node_filter || s.node_filter(n)) {
4273 switch (n.nodeType) {
4275 if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus'))
4279 hc = n.hasChildNodes();
4280 nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase();
4282 // Add correct prefix on IE
4284 if (n.scopeName !== 'HTML' && n.scopeName !== 'html')
4285 nn = n.scopeName + ':' + nn;
4288 // Remove mce prefix on IE needed for the abbr element
4289 if (nn.indexOf('mce:') === 0)
4290 nn = nn.substring(4);
4293 if (!t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) {
4299 // Fix IE content duplication (DOM can have multiple copies of the same node)
4300 if (s.fix_content_duplication) {
4301 if (n.mce_serialized == t.key)
4304 n.mce_serialized = t.key;
4307 // IE sometimes adds a / infront of the node name
4308 if (nn.charAt(0) == '/')
4309 nn = nn.substring(1);
4310 } else if (isGecko) {
4311 // Ignore br elements
4312 if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz')
4316 // Check if valid child
4318 if (t.parentElementsRE.test(t.elementName)) {
4319 if (!t.childRules[t.elementName].test(nn)) {
4328 ru = t.findRule(nn);
4331 // Skip empty nodes or empty node name in IE
4332 if ((!hc && ru.noEmpty) || (isIE && !nn)) {
4338 if (ru.requiredAttribs) {
4339 a = ru.requiredAttribs;
4341 for (i = a.length - 1; i >= 0; i--) {
4342 if (this.dom.getAttrib(n, a[i]) !== '')
4346 // None of the required was there
4353 w.writeStartElement(nn);
4355 // Add ordered attributes
4357 for (i=0, at = ru.attribs, l = at.length; i<l; i++) {
4359 v = t._getAttrib(n, a);
4362 w.writeAttribute(a.name, v);
4366 // Add wild attributes
4367 if (ru.validAttribsRE) {
4368 at = isIE ? getIEAtts(n) : n.attributes;
4369 for (i=at.length-1; i>-1; i--) {
4373 a = no.nodeName.toLowerCase();
4375 if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a))
4378 ar = t.findAttribRule(ru, a);
4379 v = t._getAttrib(n, ar, a);
4382 w.writeAttribute(a, v);
4387 // Padd empty nodes with a
4389 // If it has only one bogus child, padd it anyway workaround for <td><br /></td> bug
4390 if (hc && (cn = n.firstChild) && cn.nodeType === 1 && n.childNodes.length === 1) {
4391 if (cn.hasAttribute ? cn.hasAttribute('mce_bogus') : cn.getAttribute('mce_bogus'))
4392 w.writeText('\u00a0');
4394 w.writeText('\u00a0'); // No children then padd it
4400 // Check if valid child
4401 if (t.childRules && t.parentElementsRE.test(t.elementName)) {
4402 if (!t.childRules[t.elementName].test(n.nodeName))
4406 return w.writeText(n.nodeValue);
4409 return w.writeCDATA(n.nodeValue);
4412 return w.writeComment(n.nodeValue);
4414 } else if (n.nodeType == 1)
4415 hc = n.hasChildNodes();
4421 t._serializeNode(cn);
4423 cn = cn.nextSibling;
4427 // Write element end
4429 if (hc || !s.closed.test(nn))
4430 w.writeFullEndElement();
4432 w.writeEndElement();
4436 _protect : function(o) {
4439 o.items = o.items || [];
4442 return s.replace(/[\r\n\\]/g, function(c) {
4445 else if (c === '\\')
4453 return s.replace(/\\[\\rn]/g, function(c) {
4456 else if (c === '\\\\')
4463 each(o.patterns, function(p) {
4464 o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
4471 return a + '<!--mce:' + (o.items.length - 1) + '-->' + c;
4478 _unprotect : function(h, o) {
4479 h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) {
4480 return o.items[parseInt(b)];
4488 _encode : function(h) {
4489 var t = this, s = t.settings, l;
4492 if (s.entity_encoding !== 'raw') {
4493 if (s.entity_encoding.indexOf('named') != -1) {
4494 t.setEntities(s.entities);
4497 h = h.replace(t.entitiesRE, function(a) {
4507 if (s.entity_encoding.indexOf('numeric') != -1) {
4508 h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
4509 return '&#' + a.charCodeAt(0) + ';';
4517 _setup : function() {
4518 var t = this, s = this.settings;
4525 t.setRules(s.valid_elements);
4526 t.addRules(s.extended_valid_elements);
4527 t.addValidChildRules(s.valid_child_elements);
4529 if (s.invalid_elements)
4530 t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
4532 if (s.attrib_value_filter)
4533 t.attribValueFilter = s.attribValueFilter;
4536 _getAttrib : function(n, a, na) {
4541 if (a.forcedVal && (v = a.forcedVal)) {
4543 return this.dom.uniqueId();
4548 v = this.dom.getAttrib(n, na);
4551 if (this.settings.bool_attrs.test(na) && v) {
4552 v = ('' + v).toLowerCase();
4554 if (v === 'false' || v === '0')
4563 // Whats the point? Remove usless attribute value
4570 if (this.attribValueFilter)
4571 v = this.attribValueFilter(na, v, n);
4574 for (i = a.validVals.length - 1; i >= 0; i--) {
4575 if (v == a.validVals[i])
4583 if (v === '' && typeof(a.defaultVal) != 'undefined') {
4587 return this.dom.uniqueId();
4591 // Remove internal mceItemXX classes when content is extracted from editor
4592 if (na == 'class' && this.processObj.get)
4593 v = v.replace(/\s?mceItem\w+\s?/g, '');
4606 /* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */
4609 var each = tinymce.each, Event = tinymce.dom.Event;
4611 tinymce.create('tinymce.dom.ScriptLoader', {
4612 ScriptLoader : function(s) {
4613 this.settings = s || {};
4618 isDone : function(u) {
4619 return this.lookup[u] ? this.lookup[u].state == 2 : 0;
4622 markDone : function(u) {
4623 this.lookup[u] = {state : 2, url : u};
4626 add : function(u, cb, s, pr) {
4627 var t = this, lo = t.lookup, o;
4630 // Is loaded fire callback
4631 if (cb && o.state == 2)
4637 o = {state : 0, url : u, func : cb, scope : s || this};
4649 load : function(u, cb, s) {
4652 if (o = t.lookup[u]) {
4653 // Is loaded fire callback
4654 if (cb && o.state == 2)
4660 function loadScript(u) {
4661 if (Event.domLoaded || t.settings.strict_mode) {
4662 tinymce.util.XHR.send({
4663 url : tinymce._addVer(u),
4664 error : t.settings.error,
4666 success : function(co) {
4671 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
4674 if (!tinymce.is(u, 'string')) {
4675 each(u, function(u) {
4689 loadQueue : function(cb, s) {
4692 if (!t.queueLoading) {
4694 t.queueCallbacks = [];
4696 t.loadScripts(t.queue, function() {
4702 each(t.queueCallbacks, function(o) {
4703 o.func.call(o.scope);
4707 t.queueCallbacks.push({func : cb, scope : s || t});
4710 eval : function(co) {
4714 if (!w.execScript) {
4718 eval(co, w); // Firefox 3.0a8
4721 w.execScript(co); // IE
4724 loadScripts : function(sc, cb, s) {
4725 var t = this, lo = t.lookup;
4728 o.state = 2; // Has been loaded
4732 o.func.call(o.scope || t);
4735 function allDone() {
4738 // Check if all files are loaded
4740 each(sc, function(o) {
4743 if (o.state === 2) {// It has finished loading
4750 // They are all loaded
4751 if (l === 0 && cb) {
4761 o.state = 1; // Is loading
4763 tinymce.dom.ScriptLoader.loadScript(o.url, function() {
4769 tinymce.util.XHR.send({
4771 error : t.settings.error,
4772 success : function(co) {
4781 each(sc, function(o) {
4784 // Add to queue if needed
4791 // Is already loading or has been loaded
4795 if (!Event.domLoaded && !t.settings.strict_mode) {
4798 // Add onload events
4800 o.state = 1; // Is loading
4802 ix = tinymce.dom.ScriptLoader._addOnLoad(function() {
4808 ol = ' onreadystatechange="';
4812 ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"';
4815 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
4828 _addOnLoad : function(f) {
4831 t._funcs = t._funcs || [];
4834 return t._funcs.length - 1;
4837 _onLoad : function(e, u, ix) {
4838 if (!tinymce.isIE || e.readyState == 'complete')
4839 this._funcs[ix].call(this);
4842 loadScript : function(u, cb) {
4843 var id = tinymce.DOM.uniqueId(), e;
4847 tinymce.DOM.remove(id);
4850 cb.call(document, u);
4856 /* Event.add(e, 'readystatechange', function(e) {
4857 if (e.target && e.target.readyState == 'complete')
4861 tinymce.util.XHR.send({
4862 url : tinymce._addVer(u),
4864 success : function(co) {
4865 window.execScript(co);
4870 e = tinymce.DOM.create('script', {id : id, type : 'text/javascript', src : tinymce._addVer(u)});
4871 Event.add(e, 'load', done);
4873 // Check for head or body
4874 (document.getElementsByTagName('head')[0] || document.body).appendChild(e);
4881 // Global script loader
4882 tinymce.ScriptLoader = new tinymce.dom.ScriptLoader();
4885 /* file:jscripts/tiny_mce/classes/ui/Control.js */
4888 // Shorten class names
4889 var DOM = tinymce.DOM, is = tinymce.is;
4891 tinymce.create('tinymce.ui.Control', {
4892 Control : function(id, s) {
4894 this.settings = s = s || {};
4895 this.rendered = false;
4896 this.onRender = new tinymce.util.Dispatcher(this);
4897 this.classPrefix = '';
4898 this.scope = s.scope || this;
4903 setDisabled : function(s) {
4906 if (s != this.disabled) {
4907 e = DOM.get(this.id);
4909 // Add accessibility title for unavailable actions
4910 if (e && this.settings.unavailable_prefix) {
4912 this.prevTitle = e.title;
4913 e.title = this.settings.unavailable_prefix + ": " + e.title;
4915 e.title = this.prevTitle;
4918 this.setState('Disabled', s);
4919 this.setState('Enabled', !s);
4924 isDisabled : function() {
4925 return this.disabled;
4928 setActive : function(s) {
4929 if (s != this.active) {
4930 this.setState('Active', s);
4935 isActive : function() {
4939 setState : function(c, s) {
4940 var n = DOM.get(this.id);
4942 c = this.classPrefix + c;
4947 DOM.removeClass(n, c);
4950 isRendered : function() {
4951 return this.rendered;
4954 renderHTML : function() {
4957 renderTo : function(n) {
4958 DOM.setHTML(n, this.renderHTML());
4961 postRender : function() {
4964 // Set pending states
4965 if (is(t.disabled)) {
4978 remove : function() {
4979 DOM.remove(this.id);
4983 destroy : function() {
4984 tinymce.dom.Event.clear(this.id);
4989 /* file:jscripts/tiny_mce/classes/ui/Container.js */
4991 tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
4992 Container : function(id, s) {
4999 this.lookup[c.id] = c;
5000 this.controls.push(c);
5006 return this.lookup[n];
5012 /* file:jscripts/tiny_mce/classes/ui/Separator.js */
5014 tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
5015 Separator : function(id, s) {
5017 this.classPrefix = 'mceSeparator';
5020 renderHTML : function() {
5021 return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
5026 /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */
5029 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
5031 tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
5032 MenuItem : function(id, s) {
5034 this.classPrefix = 'mceMenuItem';
5037 setSelected : function(s) {
5038 this.setState('Selected', s);
5042 isSelected : function() {
5043 return this.selected;
5046 postRender : function() {
5051 // Set pending state
5053 t.setSelected(t.selected);
5059 /* file:jscripts/tiny_mce/classes/ui/Menu.js */
5062 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
5064 tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
5065 Menu : function(id, s) {
5070 t.collapsed = false;
5072 t.onAddItem = new tinymce.util.Dispatcher(this);
5075 expand : function(d) {
5079 walk(t, function(o) {
5085 t.collapsed = false;
5088 collapse : function(d) {
5092 walk(t, function(o) {
5101 isCollapsed : function() {
5102 return this.collapsed;
5107 o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
5109 this.onAddItem.dispatch(this, o);
5111 return this.items[o.id] = o;
5114 addSeparator : function() {
5115 return this.add({separator : true});
5118 addMenu : function(o) {
5120 o = this.createMenu(o);
5127 hasMenus : function() {
5128 return this.menuCount !== 0;
5131 remove : function(o) {
5132 delete this.items[o.id];
5135 removeAll : function() {
5138 walk(t, function(o) {
5150 createMenu : function(o) {
5151 var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
5153 m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
5160 /* file:jscripts/tiny_mce/classes/ui/DropMenu.js */
5163 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
5165 tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
5166 DropMenu : function(id, s) {
5168 s.container = s.container || DOM.doc.body;
5169 s.offset_x = s.offset_x || 0;
5170 s.offset_y = s.offset_y || 0;
5171 s.vp_offset_x = s.vp_offset_x || 0;
5172 s.vp_offset_y = s.vp_offset_y || 0;
5174 if (is(s.icons) && !s.icons)
5175 s['class'] += ' mceNoIcons';
5178 this.onShowMenu = new tinymce.util.Dispatcher(this);
5179 this.onHideMenu = new tinymce.util.Dispatcher(this);
5180 this.classPrefix = 'mceMenu';
5183 createMenu : function(s) {
5184 var t = this, cs = t.settings, m;
5186 s.container = s.container || cs.container;
5188 s.constrain = s.constrain || cs.constrain;
5189 s['class'] = s['class'] || cs['class'];
5190 s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
5191 s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
5192 m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
5194 m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
5199 update : function() {
5200 var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
5202 tw = s.max_width ? Math.min(tb.clientWidth, s.max_width) : tb.clientWidth;
5203 th = s.max_height ? Math.min(tb.clientHeight, s.max_height) : tb.clientHeight;
5206 t.element.setStyles({width : tw + 2, height : th + 2});
5208 t.element.setStyles({width : tw, height : th});
5211 DOM.setStyle(co, 'width', tw);
5214 DOM.setStyle(co, 'height', th);
5216 if (tb.clientHeight < s.max_height)
5217 DOM.setStyle(co, 'overflow', 'hidden');
5221 showMenu : function(x, y, px) {
5222 var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
5226 if (t.isMenuVisible)
5230 co = DOM.add(t.settings.container, t.renderNode());
5232 each(t.items, function(o) {
5236 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
5238 co = DOM.get('menu_' + t.id);
5240 // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
5241 if (!tinymce.isOpera)
5242 DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
5247 x += s.offset_x || 0;
5248 y += s.offset_y || 0;
5252 // Move inside viewport if not submenu
5254 w = co.clientWidth - ot;
5255 h = co.clientHeight - ot;
5259 if ((x + s.vp_offset_x + w) > mx)
5260 x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
5262 if ((y + s.vp_offset_y + h) > my)
5263 y = Math.max(0, (my - s.vp_offset_y) - h);
5266 DOM.setStyles(co, {left : x , top : y});
5269 t.isMenuVisible = 1;
5270 t.mouseClickFunc = Event.add(co, 'click', function(e) {
5275 if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
5287 dm = dm.settings.parent;
5290 if (m.settings.onclick)
5291 m.settings.onclick(e);
5293 return Event.cancel(e); // Cancel to fix onbeforeunload problem
5298 t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
5302 if (e && (e = DOM.getParent(e, 'TR'))) {
5306 t.lastMenu.collapse(1);
5311 if (e && DOM.hasClass(e, cp + 'ItemSub')) {
5312 //p = DOM.getPos(s.container);
5314 m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
5316 DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
5322 t.onShowMenu.dispatch(t);
5324 if (s.keyboard_focus) {
5325 Event.add(co, 'keydown', t._keyHandler, t);
5326 DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
5331 hideMenu : function(c) {
5332 var t = this, co = DOM.get('menu_' + t.id), e;
5334 if (!t.isMenuVisible)
5337 Event.remove(co, 'mouseover', t.mouseOverFunc);
5338 Event.remove(co, 'click', t.mouseClickFunc);
5339 Event.remove(co, 'keydown', t._keyHandler);
5341 t.isMenuVisible = 0;
5349 if (e = DOM.get(t.id))
5350 DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
5352 t.onHideMenu.dispatch(t);
5360 if (t.isRendered && (co = DOM.get('menu_' + t.id)))
5361 t._add(DOM.select('tbody', co)[0], o);
5366 collapse : function(d) {
5371 remove : function(o) {
5375 return this.parent(o);
5378 destroy : function() {
5379 var t = this, co = DOM.get('menu_' + t.id);
5381 Event.remove(co, 'mouseover', t.mouseOverFunc);
5382 Event.remove(co, 'click', t.mouseClickFunc);
5390 renderNode : function() {
5391 var t = this, s = t.settings, n, tb, co, w;
5393 w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'});
5394 co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
5395 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
5398 DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
5400 // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
5401 n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
5402 tb = DOM.add(n, 'tbody');
5404 each(t.items, function(o) {
5413 // Internal functions
5415 _keyHandler : function(e) {
5416 var t = this, kc = e.keyCode;
5419 var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
5429 focus(-1); // Select first link
5440 return this.hideMenu();
5444 _add : function(tb, o) {
5445 var n, s = o.settings, a, ro, it, cp = this.classPrefix, ic;
5448 ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
5449 DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
5451 if (n = ro.previousSibling)
5452 DOM.addClass(n, 'mceLast');
5457 n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
5458 n = it = DOM.add(n, 'td');
5459 n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
5461 DOM.addClass(it, s['class']);
5462 // n = DOM.add(n, 'span', {'class' : 'item'});
5464 ic = DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
5467 DOM.add(ic, 'img', {src : s.icon_src});
5469 n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
5471 if (o.settings.style)
5472 DOM.setAttrib(n, 'style', o.settings.style);
5474 if (tb.childNodes.length == 1)
5475 DOM.addClass(ro, 'mceFirst');
5477 if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
5478 DOM.addClass(ro, 'mceFirst');
5481 DOM.addClass(ro, cp + 'ItemSub');
5483 if (n = ro.previousSibling)
5484 DOM.removeClass(n, 'mceLast');
5486 DOM.addClass(ro, 'mceLast');
5491 /* file:jscripts/tiny_mce/classes/ui/Button.js */
5494 var DOM = tinymce.DOM;
5496 tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
5497 Button : function(id, s) {
5499 this.classPrefix = 'mceButton';
5502 renderHTML : function() {
5503 var cp = this.classPrefix, s = this.settings, h, l;
5505 l = DOM.encode(s.label || '');
5506 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) + '">';
5509 h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>';
5511 h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>';
5516 postRender : function() {
5517 var t = this, s = t.settings;
5519 tinymce.dom.Event.add(t.id, 'click', function(e) {
5520 if (!t.isDisabled())
5521 return s.onclick.call(s.scope, e);
5528 /* file:jscripts/tiny_mce/classes/ui/ListBox.js */
5531 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
5533 tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
5534 ListBox : function(id, s) {
5539 t.onChange = new Dispatcher(t);
5540 t.onPostRender = new Dispatcher(t);
5541 t.onAdd = new Dispatcher(t);
5542 t.onRenderMenu = new tinymce.util.Dispatcher(this);
5543 t.classPrefix = 'mceListBox';
5546 select : function(va) {
5547 var t = this, fv, f;
5549 if (va == undefined)
5550 return t.selectByIndex(-1);
5552 // Is string or number make function selector
5561 // Do we need to do something?
5562 if (va != t.selectedValue) {
5564 each(t.items, function(o, i) {
5573 t.selectByIndex(-1);
5577 selectByIndex : function(idx) {
5580 if (idx != t.selectedIndex) {
5581 e = DOM.get(t.id + '_text');
5585 t.selectedValue = o.value;
5586 t.selectedIndex = idx;
5587 DOM.setHTML(e, DOM.encode(o.title));
5588 DOM.removeClass(e, 'mceTitle');
5590 DOM.setHTML(e, DOM.encode(t.settings.title));
5591 DOM.addClass(e, 'mceTitle');
5592 t.selectedValue = t.selectedIndex = null;
5597 t.selectedValue = t.selectedIndex = null;
5600 add : function(n, v, o) {
5604 o = tinymce.extend(o, {
5610 t.onAdd.dispatch(t, o);
5613 getLength : function() {
5614 return this.items.length;
5617 renderHTML : function() {
5618 var h = '', t = this, s = t.settings, cp = t.classPrefix;
5620 h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>';
5621 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>';
5622 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>';
5623 h += '</tr></tbody></table>';
5628 showMenu : function() {
5629 var t = this, p1, p2, e = DOM.get(this.id), m;
5631 if (t.isDisabled() || t.items.length == 0)
5634 if (t.menu && t.menu.isMenuVisible)
5635 return t.hideMenu();
5637 if (!t.isMenuRendered) {
5639 t.isMenuRendered = true;
5642 p1 = DOM.getPos(this.settings.menu_container);
5646 m.settings.offset_x = p2.x;
5647 m.settings.offset_y = p2.y;
5648 m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
5652 m.items[t.oldID].setSelected(0);
5654 each(t.items, function(o) {
5655 if (o.value === t.selectedValue) {
5656 m.items[o.id].setSelected(1);
5661 m.showMenu(0, e.clientHeight);
5663 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
5664 DOM.addClass(t.id, t.classPrefix + 'Selected');
5666 //DOM.get(t.id + '_text').focus();
5669 hideMenu : function(e) {
5672 // Prevent double toogles by canceling the mouse click event to the button
5673 if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
5676 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
5677 DOM.removeClass(t.id, t.classPrefix + 'Selected');
5678 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
5685 renderMenu : function() {
5688 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
5690 'class' : t.classPrefix + 'Menu mceNoIcons',
5695 m.onHideMenu.add(t.hideMenu, t);
5698 title : t.settings.title,
5699 'class' : 'mceMenuItemTitle',
5700 onclick : function() {
5701 if (t.settings.onselect('') !== false)
5702 t.select(''); // Must be runned after
5706 each(t.items, function(o) {
5707 o.id = DOM.uniqueId();
5708 o.onclick = function() {
5709 if (t.settings.onselect(o.value) !== false)
5710 t.select(o.value); // Must be runned after
5716 t.onRenderMenu.dispatch(t, m);
5720 postRender : function() {
5721 var t = this, cp = t.classPrefix;
5723 Event.add(t.id, 'click', t.showMenu, t);
5724 Event.add(t.id + '_text', 'focus', function(e) {
5726 t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
5727 var idx = -1, v, kc = e.keyCode;
5729 // Find current index
5730 each(t.items, function(v, i) {
5731 if (t.selectedValue == v.value)
5737 v = t.items[idx - 1];
5739 v = t.items[idx + 1];
5740 else if (kc == 13) {
5741 // Fake select on enter
5742 v = t.selectedValue;
5743 t.selectedValue = null; // Needs to be null to fake change
5744 t.settings.onselect(v);
5745 return Event.cancel(e);
5757 Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
5759 // Old IE doesn't have hover on all elements
5760 if (tinymce.isIE6 || !DOM.boxModel) {
5761 Event.add(t.id, 'mouseover', function() {
5762 if (!DOM.hasClass(t.id, cp + 'Disabled'))
5763 DOM.addClass(t.id, cp + 'Hover');
5766 Event.add(t.id, 'mouseout', function() {
5767 if (!DOM.hasClass(t.id, cp + 'Disabled'))
5768 DOM.removeClass(t.id, cp + 'Hover');
5772 t.onPostRender.dispatch(t, DOM.get(t.id));
5775 destroy : function() {
5778 Event.clear(this.id + '_text');
5783 /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */
5786 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
5788 tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
5789 NativeListBox : function(id, s) {
5791 this.classPrefix = 'mceNativeListBox';
5794 setDisabled : function(s) {
5795 DOM.get(this.id).disabled = s;
5798 isDisabled : function() {
5799 return DOM.get(this.id).disabled;
5802 select : function(va) {
5803 var t = this, fv, f;
5805 if (va == undefined)
5806 return t.selectByIndex(-1);
5808 // Is string or number make function selector
5817 // Do we need to do something?
5818 if (va != t.selectedValue) {
5820 each(t.items, function(o, i) {
5829 t.selectByIndex(-1);
5833 selectByIndex : function(idx) {
5834 DOM.get(this.id).selectedIndex = idx + 1;
5835 this.selectedValue = this.items[idx] ? this.items[idx].value : null;
5838 add : function(n, v, a) {
5845 DOM.add(DOM.get(this.id), 'option', a, n);
5854 t.onAdd.dispatch(t, o);
5857 getLength : function() {
5858 return DOM.get(this.id).options.length - 1;
5861 renderHTML : function() {
5864 h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
5866 each(t.items, function(it) {
5867 h += DOM.createHTML('option', {value : it.value}, it.title);
5870 h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox'}, h);
5875 postRender : function() {
5880 function onChange(e) {
5881 var v = t.items[e.target.selectedIndex - 1];
5883 if (v && (v = v.value)) {
5884 t.onChange.dispatch(t, v);
5886 if (t.settings.onselect)
5887 t.settings.onselect(v);
5891 Event.add(t.id, 'change', onChange);
5893 // Accessibility keyhandler
5894 Event.add(t.id, 'keydown', function(e) {
5897 Event.remove(t.id, 'change', ch);
5899 bf = Event.add(t.id, 'blur', function() {
5900 Event.add(t.id, 'change', onChange);
5901 Event.remove(t.id, 'blur', bf);
5904 if (e.keyCode == 13 || e.keyCode == 32) {
5906 return Event.cancel(e);
5910 t.onPostRender.dispatch(t, DOM.get(t.id));
5915 /* file:jscripts/tiny_mce/classes/ui/MenuButton.js */
5918 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
5920 tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
5921 MenuButton : function(id, s) {
5923 this.onRenderMenu = new tinymce.util.Dispatcher(this);
5924 s.menu_container = s.menu_container || DOM.doc.body;
5927 showMenu : function() {
5928 var t = this, p1, p2, e = DOM.get(t.id), m;
5933 if (!t.isMenuRendered) {
5935 t.isMenuRendered = true;
5938 if (t.isMenuVisible)
5939 return t.hideMenu();
5941 p1 = DOM.getPos(t.settings.menu_container);
5945 m.settings.offset_x = p2.x;
5946 m.settings.offset_y = p2.y;
5947 m.settings.vp_offset_x = p2.x;
5948 m.settings.vp_offset_y = p2.y;
5949 m.settings.keyboard_focus = t._focused;
5950 m.showMenu(0, e.clientHeight);
5952 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
5953 t.setState('Selected', 1);
5955 t.isMenuVisible = 1;
5958 renderMenu : function() {
5961 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
5963 'class' : this.classPrefix + 'Menu',
5964 icons : t.settings.icons
5967 m.onHideMenu.add(t.hideMenu, t);
5969 t.onRenderMenu.dispatch(t, m);
5973 hideMenu : function(e) {
5976 // Prevent double toogles by canceling the mouse click event to the button
5977 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
5980 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
5981 t.setState('Selected', 0);
5982 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
5987 t.isMenuVisible = 0;
5990 postRender : function() {
5991 var t = this, s = t.settings;
5993 Event.add(t.id, 'click', function() {
5994 if (!t.isDisabled()) {
6006 /* file:jscripts/tiny_mce/classes/ui/SplitButton.js */
6009 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
6011 tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
6012 SplitButton : function(id, s) {
6014 this.classPrefix = 'mceSplitButton';
6017 renderHTML : function() {
6018 var h, t = this, s = t.settings, h1;
6023 h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']});
6025 h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, '');
6027 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>';
6029 h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']});
6030 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>';
6032 h += '</tr></tbody>';
6034 return DOM.createHTML('table', {id : t.id, 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', onmousedown : 'return false;', title : s.title}, h);
6037 postRender : function() {
6038 var t = this, s = t.settings;
6041 Event.add(t.id + '_action', 'click', function() {
6042 if (!t.isDisabled())
6047 Event.add(t.id + '_open', 'click', t.showMenu, t);
6048 Event.add(t.id + '_open', 'focus', function() {t._focused = 1;});
6049 Event.add(t.id + '_open', 'blur', function() {t._focused = 0;});
6051 // Old IE doesn't have hover on all elements
6052 if (tinymce.isIE6 || !DOM.boxModel) {
6053 Event.add(t.id, 'mouseover', function() {
6054 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
6055 DOM.addClass(t.id, 'mceSplitButtonHover');
6058 Event.add(t.id, 'mouseout', function() {
6059 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
6060 DOM.removeClass(t.id, 'mceSplitButtonHover');
6065 destroy : function() {
6068 Event.clear(this.id + '_action');
6069 Event.clear(this.id + '_open');
6075 /* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */
6078 var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
6080 tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
6081 ColorSplitButton : function(id, s) {
6086 t.settings = s = tinymce.extend({
6087 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',
6089 default_color : '#888888'
6092 t.onShowMenu = new tinymce.util.Dispatcher(t);
6093 t.onHideMenu = new tinymce.util.Dispatcher(t);
6095 t.value = s.default_color;
6098 showMenu : function() {
6099 var t = this, r, p, e, p2;
6104 if (!t.isMenuRendered) {
6106 t.isMenuRendered = true;
6109 if (t.isMenuVisible)
6110 return t.hideMenu();
6113 DOM.show(t.id + '_menu');
6114 DOM.addClass(e, 'mceSplitButtonSelected');
6116 DOM.setStyles(t.id + '_menu', {
6118 top : p2.y + e.clientHeight,
6123 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
6126 t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
6127 if (e.keyCode == 27)
6131 DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
6134 t.onShowMenu.dispatch(t);
6136 t.isMenuVisible = 1;
6139 hideMenu : function(e) {
6142 // Prevent double toogles by canceling the mouse click event to the button
6143 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
6146 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
6147 DOM.removeClass(t.id, 'mceSplitButtonSelected');
6148 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
6149 Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
6150 DOM.hide(t.id + '_menu');
6153 t.onHideMenu.dispatch(t);
6155 t.isMenuVisible = 0;
6158 renderMenu : function() {
6159 var t = this, m, i = 0, s = t.settings, n, tb, tr, w;
6161 w = DOM.add(s.menu_container, 'div', {id : t.id + '_menu', 'class' : s['menu_class'] + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
6162 m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
6163 DOM.add(m, 'span', {'class' : 'mceMenuLine'});
6165 n = DOM.add(m, 'table', {'class' : 'mceColorSplitMenu'});
6166 tb = DOM.add(n, 'tbody');
6168 // Generate color grid
6170 each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
6171 c = c.replace(/^#/, '');
6174 tr = DOM.add(tb, 'tr');
6175 i = s.grid_width - 1;
6178 n = DOM.add(tr, 'td');
6180 n = DOM.add(n, 'a', {
6181 href : 'javascript:;',
6183 backgroundColor : '#' + c
6189 if (s.more_colors_func) {
6190 n = DOM.add(tb, 'tr');
6191 n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
6192 n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
6194 Event.add(n, 'click', function(e) {
6195 s.more_colors_func.call(s.more_colors_scope || this);
6196 return Event.cancel(e); // Cancel to fix onbeforeunload problem
6200 DOM.addClass(m, 'mceColorSplitMenu');
6202 Event.add(t.id + '_menu', 'click', function(e) {
6207 if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
6210 return Event.cancel(e); // Prevent IE auto save warning
6216 setColor : function(c) {
6219 DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
6223 t.settings.onselect(c);
6226 postRender : function() {
6227 var t = this, id = t.id;
6230 DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
6231 DOM.setStyle(t.id + '_preview', 'backgroundColor', t.value);
6234 destroy : function() {
6237 Event.clear(this.id + '_menu');
6238 Event.clear(this.id + '_more');
6239 DOM.remove(this.id + '_menu');
6245 /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */
6247 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
6248 renderHTML : function() {
6249 var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl;
6252 for (i=0; i<cl.length; i++) {
6253 // Get current control, prev control, next control and if the control is a list box or not
6258 // Add toolbar start
6260 c = 'mceToolbarStart';
6263 c += ' mceToolbarStartButton';
6264 else if (co.SplitButton)
6265 c += ' mceToolbarStartSplitButton';
6266 else if (co.ListBox)
6267 c += ' mceToolbarStartListBox';
6269 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
6272 // Add toolbar end before list box and after the previous button
6273 // This is to fix the o2k7 editor skins
6274 if (pr && co.ListBox) {
6275 if (pr.Button || pr.SplitButton)
6276 h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
6279 // Render control HTML
6281 // IE 8 quick fix, needed to propertly generate a hit area for anchors
6283 h += '<td style="position: relative">' + co.renderHTML() + '</td>';
6285 h += '<td>' + co.renderHTML() + '</td>';
6287 // Add toolbar start after list box and before the next button
6288 // This is to fix the o2k7 editor skins
6289 if (nx && co.ListBox) {
6290 if (nx.Button || nx.SplitButton)
6291 h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
6295 c = 'mceToolbarEnd';
6298 c += ' mceToolbarEndButton';
6299 else if (co.SplitButton)
6300 c += ' mceToolbarEndSplitButton';
6301 else if (co.ListBox)
6302 c += ' mceToolbarEndListBox';
6304 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
6306 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>');
6311 /* file:jscripts/tiny_mce/classes/AddOnManager.js */
6314 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
6316 tinymce.create('tinymce.AddOnManager', {
6320 onAdd : new Dispatcher(this),
6323 return this.lookup[n];
6326 requireLangPack : function(n) {
6327 var u, s = tinymce.EditorManager.settings;
6329 if (s && s.language) {
6330 u = this.urls[n] + '/langs/' + s.language + '.js';
6332 if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
6333 tinymce.ScriptLoader.load(u);
6335 tinymce.ScriptLoader.add(u);
6339 add : function(id, o) {
6341 this.lookup[id] = o;
6342 this.onAdd.dispatch(this, id, o);
6347 load : function(n, u, cb, s) {
6353 if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
6354 u = tinymce.baseURL + '/' + u;
6356 t.urls[n] = u.substring(0, u.lastIndexOf('/'));
6357 tinymce.ScriptLoader.add(u, cb, s);
6362 // Create plugin and theme managers
6363 tinymce.PluginManager = new tinymce.AddOnManager();
6364 tinymce.ThemeManager = new tinymce.AddOnManager();
6366 /* file:jscripts/tiny_mce/classes/EditorManager.js */
6370 var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode;
6372 tinymce.create('static tinymce.EditorManager', {
6375 activeEditor : null,
6377 preInit : function() {
6378 var t = this, lo = window.location;
6380 // Setup some URLs where the editor API is located and where the document is
6381 tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
6382 if (!/[\/\\]$/.test(tinymce.documentBaseURL))
6383 tinymce.documentBaseURL += '/';
6385 tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
6386 tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
6388 // User already specified a document.domain value
6389 if (document.domain && lo.hostname != document.domain)
6390 tinymce.relaxedDomain = document.domain;
6392 // Setup document domain if tinymce is loaded from other domain
6393 if (!tinymce.relaxedDomain && tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)
6394 document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1');
6396 // Add before unload listener
6397 // This was required since IE was leaking memory if you added and removed beforeunload listeners
6398 // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event
6399 t.onBeforeUnload = new tinymce.util.Dispatcher(t);
6401 // Must be on window or IE will leak if the editor is placed in frame or iframe
6402 Event.add(window, 'beforeunload', function(e) {
6403 t.onBeforeUnload.dispatch(t, e);
6407 init : function(s) {
6408 var t = this, pl, sl = tinymce.ScriptLoader, c, e, el = [], ed;
6410 function execCallback(se, n, s) {
6416 if (tinymce.is(f, 'string')) {
6417 s = f.replace(/\.\w+$/, '');
6418 s = s ? tinymce.resolve(s) : 0;
6419 f = tinymce.resolve(f);
6422 return f.apply(s || this, Array.prototype.slice.call(arguments, 2));
6428 strict_loading_mode : document.contentType == 'application/xhtml+xml'
6433 // If page not loaded and strict mode isn't enabled then load them
6434 if (!Event.domLoaded && !s.strict_loading_mode) {
6437 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
6440 if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
6441 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
6445 pl = explode(s.plugins);
6447 // Load compat2x first
6448 if (tinymce.inArray(pl, 'compat2x') != -1)
6449 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
6451 // Load rest if plugins
6452 each(pl, function(v) {
6453 if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) {
6454 // Skip safari plugin for other browsers
6455 if (!tinymce.isWebKit && v == 'safari')
6458 PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js');
6467 Event.add(document, 'init', function() {
6470 execCallback(s, 'onpageload');
6472 // Verify that it's a valid browser
6476 each(explode(s.browsers), function(v) {
6485 if (tinymce.isGecko)
6491 if (tinymce.isWebKit)
6496 if (tinymce.isOpera)
6510 l = s.elements || '';
6513 each(explode(l), function(v) {
6515 ed = new tinymce.Editor(v, s);
6521 each(document.forms, function(f) {
6522 each(f.elements, function(e) {
6524 v = 'mce_editor_' + c;
6525 DOM.setAttrib(e, 'id', v);
6527 ed = new tinymce.Editor(v, s);
6539 case "specific_textareas":
6540 function hasClass(n, c) {
6541 return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c);
6544 each(DOM.select('textarea'), function(v) {
6545 if (s.editor_deselector && hasClass(v, s.editor_deselector))
6548 if (!s.editor_selector || hasClass(v, s.editor_selector)) {
6549 // Can we use the name
6550 e = DOM.get(v.name);
6554 // Generate unique name if missing or already exists
6555 if (!v.id || t.get(v.id))
6556 v.id = DOM.uniqueId();
6558 ed = new tinymce.Editor(v.id, s);
6566 // Call onInit when all editors are initialized
6570 each (el, function(ed) {
6573 if (!ed.initialized) {
6575 ed.onInit.add(function() {
6580 execCallback(s, 'oninit');
6587 execCallback(s, 'oninit');
6593 get : function(id) {
6594 return this.editors[id];
6597 getInstanceById : function(id) {
6598 return this.get(id);
6602 this.editors[e.id] = e;
6608 remove : function(e) {
6611 // Not in the collection
6612 if (!t.editors[e.id])
6615 delete t.editors[e.id];
6617 // Select another editor since the active one was removed
6618 if (t.activeEditor == e) {
6619 each(t.editors, function(e) {
6621 return false; // Break
6630 execCommand : function(c, u, v) {
6631 var t = this, ed = t.get(v), w;
6639 case "mceAddEditor":
6640 case "mceAddControl":
6642 new tinymce.Editor(v, t.settings).render();
6646 case "mceAddFrameControl":
6649 // Add tinyMCE global instance and tinymce namespace to specified window
6650 w.tinyMCE = tinyMCE;
6651 w.tinymce = tinymce;
6653 tinymce.DOM.doc = w.document;
6654 tinymce.DOM.win = w;
6656 ed = new tinymce.Editor(v.element_id, v);
6659 // Fix IE memory leaks
6663 w.detachEvent('onunload', clr);
6664 w = w.tinyMCE = w.tinymce = null; // IE leak
6667 w.attachEvent('onunload', clr);
6670 v.page_window = null;
6674 case "mceRemoveEditor":
6675 case "mceRemoveControl":
6681 case 'mceToggleEditor':
6683 t.execCommand('mceAddControl', 0, v);
6695 // Run command on active editor
6697 return t.activeEditor.execCommand(c, u, v);
6702 execInstanceCommand : function(id, c, u, v) {
6703 var ed = this.get(id);
6706 return ed.execCommand(c, u, v);
6711 triggerSave : function() {
6712 each(this.editors, function(e) {
6717 addI18n : function(p, o) {
6718 var lo, i18n = this.i18n;
6720 if (!tinymce.is(p, 'string')) {
6721 each(p, function(o, lc) {
6722 each(o, function(o, g) {
6723 each(o, function(o, k) {
6725 i18n[lc + '.' + k] = o;
6727 i18n[lc + '.' + g + '.' + k] = o;
6732 each(o, function(o, k) {
6733 i18n[p + '.' + k] = o;
6740 _setActive : function(e) {
6741 this.selectedInstance = this.activeEditor = e;
6746 tinymce.EditorManager.preInit();
6749 // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call
6750 var tinyMCE = window.tinyMCE = tinymce.EditorManager;
6752 /* file:jscripts/tiny_mce/classes/Editor.js */
6755 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher;
6756 var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit;
6757 var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager;
6758 var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode;
6760 tinymce.create('tinymce.Editor', {
6761 Editor : function(id, s) {
6764 t.id = t.editorId = id;
6765 t.execCommands = {};
6766 t.queryStateCommands = {};
6767 t.queryValueCommands = {};
6770 // Add events to the editor
6793 'onBeforeSetContent',
6794 'onBeforeGetContent',
6801 'onBeforeExecCommand',
6806 'onSetProgressState'
6808 t[e] = new Dispatcher(t);
6811 // Default editor config
6812 t.settings = s = extend({
6815 docs_language : 'en',
6822 document_base_url : tinymce.documentBaseURL,
6823 add_form_submit_trigger : 1,
6825 add_unload_trigger : 1,
6828 remove_script_host : 1,
6829 table_inline_editing : 0,
6830 object_resizing : 1,
6832 accessibility_focus : 1,
6833 custom_shortcuts : 1,
6834 custom_undo_redo_keyboard_shortcuts : 1,
6835 custom_undo_redo_restore_selection : 1,
6836 custom_undo_redo : 1,
6837 doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
6838 visual_table_class : 'mceItemTable',
6840 inline_styles : true,
6841 convert_fonts_to_spans : true,
6842 font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large',
6843 apply_source_formatting : 1,
6844 directionality : 'ltr',
6845 forced_root_block : 'p',
6846 valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
6848 padd_empty_editor : 1,
6851 force_p_newlines : 1,
6852 indentation : '30px',
6857 t.documentBaseURI = new tinymce.util.URI(s.document_base_url || tinymce.documentBaseURL, {
6858 base_uri : tinyMCE.baseURI
6860 t.baseURI = EditorManager.baseURI;
6863 t.execCallback('setup', t);
6866 render : function(nst) {
6867 var t = this, s = t.settings, id = t.id, sl = tinymce.ScriptLoader;
6869 // Page is not loaded yet, wait for it
6870 if (!Event.domLoaded) {
6871 Event.add(document, 'init', function() {
6877 // Force strict loading mode if render us called by user and not internally
6879 s.strict_loading_mode = 1;
6880 tinyMCE.settings = s;
6883 // Element not found, then skip initialization
6884 if (!t.getElement())
6887 if (s.strict_loading_mode) {
6888 sl.settings.strict_mode = s.strict_loading_mode;
6889 tinymce.DOM.settings.strict = 1;
6892 // Add hidden input for non input elements inside form elements
6893 if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form'))
6894 DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
6896 t.windowManager = new tinymce.WindowManager(t);
6898 if (s.encoding == 'xml') {
6899 t.onGetContent.add(function(ed, o) {
6901 o.content = DOM.encode(o.content);
6905 if (s.add_form_submit_trigger) {
6906 t.onSubmit.addToTop(function() {
6907 if (t.initialized) {
6914 if (s.add_unload_trigger && !s.ask) {
6915 t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
6916 if (t.initialized && !t.destroyed && !t.isHidden())
6917 t.save({format : 'raw', no_events : true});
6921 tinymce.addUnload(t.destroy, t);
6923 if (s.submit_patch) {
6924 t.onBeforeRenderUI.add(function() {
6925 var n = t.getElement().form;
6931 if (n._mceOldSubmit)
6934 // Check page uses id="submit" or name="submit" for it's submit button
6935 if (!n.submit.nodeType && !n.submit.length) {
6937 n._mceOldSubmit = n.submit;
6938 n.submit = function() {
6939 // Save all instances
6940 EditorManager.triggerSave();
6943 return this._mceOldSubmit(this);
6952 function loadScripts() {
6954 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
6956 if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
6957 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
6959 each(explode(s.plugins), function(p) {
6960 if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
6961 // Skip safari plugin for other browsers
6962 if (!isWebKit && p == 'safari')
6965 PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js');
6969 // Init when que is loaded
6970 sl.loadQueue(function() {
6973 // Yield for awhile to avoid focus bug on FF 3 when cancel is pressed
6974 window.setTimeout(function() {
6975 Event.remove(t.id, 'focus', ask);
6977 t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
6984 Event.add(t.id, 'focus', ask);
6993 // Load compat2x first
6994 if (s.plugins.indexOf('compat2x') != -1) {
6995 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
6996 sl.loadQueue(loadScripts);
7002 var n, t = this, s = t.settings, w, h, e = t.getElement(), o, ti, u, bi, bc, re;
7004 EditorManager.add(t);
7007 s.theme = s.theme.replace(/-/, '');
7008 o = ThemeManager.get(s.theme);
7011 if (t.theme.init && s.init_theme)
7012 t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
7014 // Create all plugins
7015 each(explode(s.plugins.replace(/\-/g, '')), function(p) {
7016 var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po;
7028 // Setup popup CSS path(s)
7029 if (s.popup_css !== false) {
7031 s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
7033 s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
7036 if (s.popup_css_add)
7037 s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add);
7039 // Setup control factory
7040 t.controlManager = new tinymce.ControlManager(t);
7041 t.undoManager = new tinymce.UndoManager(t);
7044 t.undoManager.onAdd.add(function(um, l) {
7046 return t.onChange.dispatch(t, l, um);
7049 t.undoManager.onUndo.add(function(um, l) {
7050 return t.onUndo.dispatch(t, l, um);
7053 t.undoManager.onRedo.add(function(um, l) {
7054 return t.onRedo.dispatch(t, l, um);
7057 if (s.custom_undo_redo) {
7058 t.onExecCommand.add(function(ed, cmd, ui, val, a) {
7059 if (cmd != 'Undo' && cmd != 'Redo' && cmd != 'mceRepaint' && (!a || !a.skip_undo))
7060 t.undoManager.add();
7064 t.onExecCommand.add(function(ed, c) {
7065 // Don't refresh the select lists until caret move
7066 if (!/^(FontName|FontSize)$/.test(c))
7070 // Remove ghost selections on images and tables in Gecko
7072 function repaint(a, o) {
7073 if (!o || !o.initial)
7074 t.execCommand('mceRepaint');
7077 t.onUndo.add(repaint);
7078 t.onRedo.add(repaint);
7079 t.onSetContent.add(repaint);
7082 // Enables users to override the control factory
7083 t.onBeforeRenderUI.dispatch(t, t.controlManager);
7087 w = s.width || e.style.width || e.offsetWidth;
7088 h = s.height || e.style.height || e.offsetHeight;
7089 t.orgDisplay = e.style.display;
7090 re = /^[0-9\.]+(|px)$/i;
7092 if (re.test('' + w))
7093 w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100);
7095 if (re.test('' + h))
7096 h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100);
7099 o = t.theme.renderUI({
7103 deltaWidth : s.delta_width,
7104 deltaHeight : s.delta_height
7107 t.editorContainer = o.editorContainer;
7112 DOM.setStyles(o.sizeContainer || o.editorContainer, {
7117 h = (o.iframeHeight || h) + (typeof(h) == 'number' ? (o.deltaHeight || 0) : '');
7121 t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />';
7122 t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
7124 if (tinymce.relaxedDomain)
7125 t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>';
7127 bi = s.body_id || 'tinymce';
7128 if (bi.indexOf('=') != -1) {
7129 bi = t.getParam('body_id', '', 'hash');
7130 bi = bi[t.id] || bi;
7133 bc = s.body_class || '';
7134 if (bc.indexOf('=') != -1) {
7135 bc = t.getParam('body_class', '', 'hash');
7136 bc = bc[t.id] || '';
7139 t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>';
7141 // Domain relaxing enabled, then set document domain
7142 if (tinymce.relaxedDomain) {
7143 // We need to write the contents here in IE since multiple writes messes up refresh button and back button
7144 if (isIE || (tinymce.isOpera && parseFloat(opera.version()) >= 9.5))
7145 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();})()';
7146 else if (tinymce.isOpera)
7147 u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
7151 n = DOM.add(o.iframeContainer, 'iframe', {
7153 src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7
7161 t.contentAreaContainer = o.iframeContainer;
7162 DOM.get(o.editorContainer).style.display = t.orgDisplay;
7163 DOM.get(t.id).style.display = 'none';
7165 // Safari 2.x requires us to wait for the load event and load a real HTML doc
7166 if (tinymce.isOldWebKit) {
7167 Event.add(n, 'load', t.setupIframe, t);
7168 n.src = tinymce.baseURL + '/plugins/safari/blank.htm';
7170 if (!isIE || !tinymce.relaxedDomain)
7173 e = n = o = null; // Cleanup
7177 setupIframe : function() {
7178 var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b;
7180 // Setup iframe body
7181 if (!isIE || !tinymce.relaxedDomain) {
7183 d.write(t.iframeHTML);
7187 // Design mode needs to be added here Ctrl+A will fail otherwise
7191 d.designMode = 'On';
7193 // Will fail on Gecko if the editor is placed in an hidden container element
7194 // The design mode will be set ones the editor is focused
7198 // IE needs to use contentEditable or it will display non secure items for HTTPS
7200 // It will not steal focus if we hide it while setting contentEditable
7205 b.contentEditable = true;
7211 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), {
7213 url_converter : t.convertURL,
7214 url_converter_scope : t,
7215 hex_colors : s.force_hex_style_colors,
7216 class_filter : s.class_filter,
7218 fix_ie_paragraphs : 1
7221 t.serializer = new tinymce.dom.Serializer({
7222 entity_encoding : s.entity_encoding,
7223 entities : s.entities,
7224 valid_elements : s.verify_html === false ? '*[*]' : s.valid_elements,
7225 extended_valid_elements : s.extended_valid_elements,
7226 valid_child_elements : s.valid_child_elements,
7227 invalid_elements : s.invalid_elements,
7228 fix_table_elements : s.fix_table_elements,
7229 fix_list_elements : s.fix_list_elements,
7230 fix_content_duplication : s.fix_content_duplication,
7231 convert_fonts_to_spans : s.convert_fonts_to_spans,
7232 font_size_classes : s.font_size_classes,
7233 font_size_style_values : s.font_size_style_values,
7234 apply_source_formatting : s.apply_source_formatting,
7235 remove_linebreaks : s.remove_linebreaks,
7236 element_format : s.element_format,
7240 t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer);
7241 t.forceBlocks = new tinymce.ForceBlocks(t, {
7242 forced_root_block : s.forced_root_block
7244 t.editorCommands = new tinymce.EditorCommands(t);
7247 t.serializer.onPreProcess.add(function(se, o) {
7248 return t.onPreProcess.dispatch(t, o, se);
7251 t.serializer.onPostProcess.add(function(se, o) {
7252 return t.onPostProcess.dispatch(t, o, se);
7255 t.onPreInit.dispatch(t);
7257 if (!s.gecko_spellcheck)
7258 t.getBody().spellcheck = 0;
7263 t.controlManager.onPostRender.dispatch(t, t.controlManager);
7264 t.onPostRender.dispatch(t);
7266 if (s.directionality)
7267 t.getBody().dir = s.directionality;
7270 t.getBody().style.whiteSpace = "nowrap";
7273 t.onNodeChange.add(t.resizeToContent, t);
7275 if (s.custom_elements) {
7276 function handleCustom(ed, o) {
7277 each(explode(s.custom_elements), function(v) {
7280 if (v.indexOf('~') === 0) {
7286 o.content = o.content.replace(new RegExp('<(' + v + ')([^>]*)>', 'g'), '<' + n + ' mce_name="$1"$2>');
7287 o.content = o.content.replace(new RegExp('</(' + v + ')>', 'g'), '</' + n + '>');
7291 t.onBeforeSetContent.add(handleCustom);
7292 t.onPostProcess.add(function(ed, o) {
7298 if (s.handle_node_change_callback) {
7299 t.onNodeChange.add(function(ed, cm, n) {
7300 t.execCallback('handle_node_change_callback', t.id, n, -1, -1, true, t.selection.isCollapsed());
7304 if (s.save_callback) {
7305 t.onSaveContent.add(function(ed, o) {
7306 var h = t.execCallback('save_callback', t.id, o.content, t.getBody());
7313 if (s.onchange_callback) {
7314 t.onChange.add(function(ed, l) {
7315 t.execCallback('onchange_callback', t, l);
7319 if (s.convert_newlines_to_brs) {
7320 t.onBeforeSetContent.add(function(ed, o) {
7322 o.content = o.content.replace(/\r?\n/g, '<br />');
7326 if (s.fix_nesting && isIE) {
7327 t.onBeforeSetContent.add(function(ed, o) {
7328 o.content = t._fixNesting(o.content);
7332 if (s.preformatted) {
7333 t.onPostProcess.add(function(ed, o) {
7334 o.content = o.content.replace(/^\s*<pre.*?>/, '');
7335 o.content = o.content.replace(/<\/pre>\s*$/, '');
7338 o.content = '<pre class="mceItemHidden">' + o.content + '</pre>';
7342 if (s.verify_css_classes) {
7343 t.serializer.attribValueFilter = function(n, v) {
7347 // Build regexp for classes
7349 cl = t.dom.getClasses();
7351 if (cl.length > 0) {
7354 each (cl, function(o) {
7355 s += (s ? '|' : '') + o['class'];
7358 t.classesRE = new RegExp('(' + s + ')', 'gi');
7362 return !t.classesRE || /(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v) || t.classesRE.test(v) ? v : '';
7369 if (s.convert_fonts_to_spans)
7372 if (s.inline_styles)
7373 t._convertInlineElements();
7375 if (s.cleanup_callback) {
7376 t.onBeforeSetContent.add(function(ed, o) {
7377 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
7380 t.onPreProcess.add(function(ed, o) {
7382 t.execCallback('cleanup_callback', 'insert_to_editor_dom', o.node, o);
7385 t.execCallback('cleanup_callback', 'get_from_editor_dom', o.node, o);
7388 t.onPostProcess.add(function(ed, o) {
7390 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
7393 o.content = t.execCallback('cleanup_callback', 'get_from_editor', o.content, o);
7397 if (s.save_callback) {
7398 t.onGetContent.add(function(ed, o) {
7400 o.content = t.execCallback('save_callback', t.id, o.content, t.getBody());
7404 if (s.handle_event_callback) {
7405 t.onEvent.add(function(ed, e, o) {
7406 if (t.execCallback('handle_event_callback', e, ed, o) === false)
7411 t.onSetContent.add(function() {
7412 // Safari needs some time, it will crash the browser when a link is created otherwise
7413 // I think this crash issue is resolved in the latest 3.0.4
7414 //window.setTimeout(function() {
7415 t.addVisual(t.getBody());
7419 // Remove empty contents
7420 if (s.padd_empty_editor) {
7421 t.onPostProcess.add(function(ed, o) {
7422 o.content = o.content.replace(/^(<p[^>]*>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, '');
7426 if (isGecko && !s.readonly) {
7428 // Design mode must be set here once again to fix a bug where
7429 // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
7430 d.designMode = 'Off';
7431 d.designMode = 'On';
7433 // Will fail on Gecko if the editor is placed in an hidden container element
7434 // The design mode will be set ones the editor is focused
7438 // A small timeout was needed since firefox will remove. Bug: #1838304
7439 setTimeout(function () {
7443 t.load({initial : true, format : (s.cleanup_on_startup ? 'html' : 'raw')});
7444 t.startContent = t.getContent({format : 'raw'});
7445 t.undoManager.add({initial : true});
7446 t.initialized = true;
7448 t.onInit.dispatch(t);
7449 t.execCallback('setupcontent_callback', t.id, t.getBody(), t.getDoc());
7450 t.execCallback('init_instance_callback', t);
7452 t.nodeChanged({initial : 1});
7454 // Load specified content CSS last
7455 if (s.content_css) {
7456 tinymce.each(explode(s.content_css), function(u) {
7457 t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));
7461 // Handle auto focus
7463 setTimeout(function () {
7464 var ed = EditorManager.get(s.auto_focus);
7466 ed.selection.select(ed.getBody(), 1);
7467 ed.selection.collapse(1);
7468 ed.getWin().focus();
7477 focus : function(sf) {
7478 var oed, t = this, ce = t.settings.content_editable;
7481 // Is not content editable or the selection is outside the area in IE
7482 // the IE statement is needed to avoid bluring if element selections inside layers since
7483 // the layer is like it's own document in IE
7484 if (!ce && (!isIE || t.selection.getNode().ownerDocument != t.getDoc()))
7489 if (EditorManager.activeEditor != t) {
7490 if ((oed = EditorManager.activeEditor) != null)
7491 oed.onDeactivate.dispatch(oed, t);
7493 t.onActivate.dispatch(t, oed);
7496 EditorManager._setActive(t);
7499 execCallback : function(n) {
7500 var t = this, f = t.settings[n], s;
7505 // Look through lookup
7506 if (t.callbackLookup && (s = t.callbackLookup[n])) {
7511 if (is(f, 'string')) {
7512 s = f.replace(/\.\w+$/, '');
7513 s = s ? tinymce.resolve(s) : 0;
7514 f = tinymce.resolve(f);
7515 t.callbackLookup = t.callbackLookup || {};
7516 t.callbackLookup[n] = {func : f, scope : s};
7519 return f.apply(s || t, Array.prototype.slice.call(arguments, 1));
7522 translate : function(s) {
7523 var c = this.settings.language || 'en', i18n = EditorManager.i18n;
7528 return i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
7529 return i18n[c + '.' + b] || '{#' + b + '}';
7533 getLang : function(n, dv) {
7534 return EditorManager.i18n[(this.settings.language || 'en') + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
7537 getParam : function(n, dv, ty) {
7538 var tr = tinymce.trim, v = is(this.settings[n]) ? this.settings[n] : dv, o;
7540 if (ty === 'hash') {
7543 if (is(v, 'string')) {
7544 each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) {
7548 o[tr(v[0])] = tr(v[1]);
7550 o[tr(v[0])] = tr(v);
7561 nodeChanged : function(o) {
7562 var t = this, s = t.selection, n = s.getNode() || t.getBody();
7564 // Fix for bug #1896577 it seems that this can not be fired while the editor is loading
7565 if (t.initialized) {
7566 t.onNodeChange.dispatch(
7568 o ? o.controlManager || t.controlManager : t.controlManager,
7569 isIE && n.ownerDocument != t.getDoc() ? t.getBody() : n, // Fix for IE initial state
7576 addButton : function(n, s) {
7579 t.buttons = t.buttons || {};
7583 addCommand : function(n, f, s) {
7584 this.execCommands[n] = {func : f, scope : s || this};
7587 addQueryStateHandler : function(n, f, s) {
7588 this.queryStateCommands[n] = {func : f, scope : s || this};
7591 addQueryValueHandler : function(n, f, s) {
7592 this.queryValueCommands[n] = {func : f, scope : s || this};
7595 addShortcut : function(pa, desc, cmd_func, sc) {
7598 if (!t.settings.custom_shortcuts)
7601 t.shortcuts = t.shortcuts || {};
7603 if (is(cmd_func, 'string')) {
7606 cmd_func = function() {
7607 t.execCommand(c, false, null);
7611 if (is(cmd_func, 'object')) {
7614 cmd_func = function() {
7615 t.execCommand(c[0], c[1], c[2]);
7619 each(explode(pa), function(pa) {
7629 each(explode(pa, '+'), function(v) {
7638 o.charCode = v.charCodeAt(0);
7639 o.keyCode = v.toUpperCase().charCodeAt(0);
7643 t.shortcuts[(o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode] = o;
7649 execCommand : function(cmd, ui, val, a) {
7650 var t = this, s = 0, o, st;
7652 if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus))
7656 t.onBeforeExecCommand.dispatch(t, cmd, ui, val, o);
7661 if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
7662 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7666 // Registred commands
7667 if (o = t.execCommands[cmd]) {
7668 st = o.func.call(o.scope, ui, val);
7670 // Fall through on true
7672 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7678 each(t.plugins, function(p) {
7679 if (p.execCommand && p.execCommand(cmd, ui, val)) {
7680 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7690 if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
7691 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7696 if (t.editorCommands.execCommand(cmd, ui, val)) {
7697 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7702 t.getDoc().execCommand(cmd, ui, val);
7703 t.onExecCommand.dispatch(t, cmd, ui, val, a);
7706 queryCommandState : function(c) {
7709 // Is hidden then return undefined
7713 // Registred commands
7714 if (o = t.queryStateCommands[c]) {
7715 s = o.func.call(o.scope);
7717 // Fall though on true
7722 // Registred commands
7723 o = t.editorCommands.queryCommandState(c);
7729 return this.getDoc().queryCommandState(c);
7731 // Fails sometimes see bug: 1896577
7735 queryCommandValue : function(c) {
7738 // Is hidden then return undefined
7742 // Registred commands
7743 if (o = t.queryValueCommands[c]) {
7744 s = o.func.call(o.scope);
7746 // Fall though on true
7751 // Registred commands
7752 o = t.editorCommands.queryCommandValue(c);
7758 return this.getDoc().queryCommandValue(c);
7760 // Fails sometimes see bug: 1896577
7767 DOM.show(t.getContainer());
7773 var t = this, d = t.getDoc();
7775 // Fixed bug where IE has a blinking cursor left from the editor
7777 d.execCommand('SelectAll');
7779 // We must save before we hide so Safari doesn't crash
7781 DOM.hide(t.getContainer());
7782 DOM.setStyle(t.id, 'display', t.orgDisplay);
7785 isHidden : function() {
7786 return !DOM.isHidden(this.id);
7789 setProgressState : function(b, ti, o) {
7790 this.onSetProgressState.dispatch(this, b, ti, o);
7795 resizeToContent : function() {
7798 DOM.setStyle(t.id + "_ifr", 'height', t.getBody().scrollHeight);
7801 load : function(o) {
7802 var t = this, e = t.getElement(), h;
7808 h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
7812 t.onLoadContent.dispatch(t, o);
7814 o.element = e = null;
7820 save : function(o) {
7821 var t = this, e = t.getElement(), h, f;
7823 if (!e || !t.initialized)
7829 // Add undo level will trigger onchange event
7831 t.undoManager.typing = 0;
7832 t.undoManager.add();
7836 h = o.content = t.getContent(o);
7839 t.onSaveContent.dispatch(t, o);
7843 if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
7846 // Update hidden form element
7847 if (f = DOM.getParent(t.id, 'form')) {
7848 each(f.elements, function(e) {
7849 if (e.name == t.id) {
7858 o.element = e = null;
7863 setContent : function(h, o) {
7867 o.format = o.format || 'html';
7872 t.onBeforeSetContent.dispatch(t, o);
7874 // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
7875 // It will also be impossible to place the caret in the editor unless there is a BR element present
7876 if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
7877 o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />');
7881 o.content = t.dom.setHTML(t.getBody(), tinymce.trim(o.content));
7883 if (o.format != 'raw' && t.settings.cleanup) {
7885 o.content = t.dom.setHTML(t.getBody(), t.serializer.serialize(t.getBody(), o));
7889 t.onSetContent.dispatch(t, o);
7894 getContent : function(o) {
7898 o.format = o.format || 'html';
7902 t.onBeforeGetContent.dispatch(t, o);
7904 if (o.format != 'raw' && t.settings.cleanup) {
7906 h = t.serializer.serialize(t.getBody(), o);
7908 h = t.getBody().innerHTML;
7910 h = h.replace(/^\s*|\s*$/g, '');
7914 t.onGetContent.dispatch(t, o);
7919 isDirty : function() {
7922 return tinymce.trim(t.startContent) != tinymce.trim(t.getContent({format : 'raw', no_events : 1})) && !t.isNotDirty;
7925 getContainer : function() {
7929 t.container = DOM.get(t.editorContainer || t.id + '_parent');
7934 getContentAreaContainer : function() {
7935 return this.contentAreaContainer;
7938 getElement : function() {
7939 return DOM.get(this.settings.content_element || this.id);
7942 getWin : function() {
7945 if (!t.contentWindow) {
7946 e = DOM.get(t.id + "_ifr");
7949 t.contentWindow = e.contentWindow;
7952 return t.contentWindow;
7955 getDoc : function() {
7958 if (!t.contentDocument) {
7962 t.contentDocument = w.document;
7965 return t.contentDocument;
7968 getBody : function() {
7969 return this.bodyElement || this.getDoc().body;
7972 convertURL : function(u, n, e) {
7973 var t = this, s = t.settings;
7975 // Use callback instead
7976 if (s.urlconverter_callback)
7977 return t.execCallback('urlconverter_callback', u, e, true, n);
7979 // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
7980 if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
7983 // Convert to relative
7984 if (s.relative_urls)
7985 return t.documentBaseURI.toRelative(u);
7987 // Convert to absolute
7988 u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);
7993 addVisual : function(e) {
7994 var t = this, s = t.settings;
7996 e = e || t.getBody();
7998 if (!is(t.hasVisual))
7999 t.hasVisual = s.visual;
8001 each(t.dom.select('table,a', e), function(e) {
8004 switch (e.nodeName) {
8006 v = t.dom.getAttrib(e, 'border');
8008 if (!v || v == '0') {
8010 t.dom.addClass(e, s.visual_table_class);
8012 t.dom.removeClass(e, s.visual_table_class);
8018 v = t.dom.getAttrib(e, 'name');
8022 t.dom.addClass(e, 'mceItemAnchor');
8024 t.dom.removeClass(e, 'mceItemAnchor');
8031 t.onVisualAid.dispatch(t, e, t.hasVisual);
8034 remove : function() {
8035 var t = this, e = t.getContainer();
8037 t.removed = 1; // Cancels post remove event execution
8040 t.execCallback('remove_instance_callback', t);
8041 t.onRemove.dispatch(t);
8043 // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command
8044 t.onExecCommand.listeners = [];
8046 EditorManager.remove(t);
8050 destroy : function(s) {
8053 // One time is enough
8058 tinymce.removeUnload(t.destroy);
8059 tinyMCE.onBeforeUnload.remove(t._beforeUnload);
8062 if (t.theme.destroy)
8065 // Destroy controls, selection and dom
8066 t.controlManager.destroy();
8067 t.selection.destroy();
8070 // Remove all events
8072 // Don't clear the window or document if content editable
8073 // is enabled since other instances might still be present
8074 if (!t.settings.content_editable) {
8075 Event.clear(t.getWin());
8076 Event.clear(t.getDoc());
8079 Event.clear(t.getBody());
8080 Event.clear(t.formElement);
8083 if (t.formElement) {
8084 t.formElement.submit = t.formElement._mceOldSubmit;
8085 t.formElement._mceOldSubmit = null;
8088 t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null;
8091 t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null;
8096 // Internal functions
8098 _addEvents : function() {
8099 // 'focus', 'blur', 'dblclick', 'beforedeactivate', submit, reset
8100 var t = this, i, s = t.settings, lo = {
8101 mouseup : 'onMouseUp',
8102 mousedown : 'onMouseDown',
8105 keydown : 'onKeyDown',
8106 keypress : 'onKeyPress',
8107 submit : 'onSubmit',
8109 contextmenu : 'onContextMenu',
8110 dblclick : 'onDblClick',
8111 paste : 'onPaste' // Doesn't work in all browsers yet
8114 function eventHandler(e, o) {
8117 // Don't fire events when it's removed
8121 // Generic event handler
8122 if (t.onEvent.dispatch(t, e, o) !== false) {
8123 // Specific event handler
8124 t[lo[e.fakeType || e.type]].dispatch(t, e, o);
8129 each(lo, function(v, k) {
8132 if (tinymce.isOpera) {
8133 // Fake contextmenu on Opera
8134 Event.add(t.getBody(), 'mousedown', function(e) {
8136 e.fakeType = 'contextmenu';
8141 Event.add(t.getBody(), k, eventHandler);
8145 Event.add(t.getBody(), k, function(e) {
8148 // Get plain text data
8149 if (e.clipboardData)
8150 tx = e.clipboardData.getData('text/plain');
8151 else if (tinymce.isIE)
8152 tx = t.getWin().clipboardData.getData('Text');
8155 /*if (tinymce.isIE) {
8156 el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
8157 r = DOM.doc.body.createTextRange();
8158 r.moveToElementText(el);
8159 r.execCommand('Paste');
8164 eventHandler(e, {text : tx, html : h});
8170 Event.add(t.getElement().form || DOM.getParent(t.id, 'form'), k, eventHandler);
8174 Event.add(s.content_editable ? t.getBody() : t.getDoc(), k, eventHandler);
8178 Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) {
8183 // Fixes bug where a specified document_base_uri could result in broken images
8184 // This will also fix drag drop of images in Gecko
8185 if (tinymce.isGecko) {
8186 // Convert all images to absolute URLs
8187 /* t.onSetContent.add(function(ed, o) {
8188 each(ed.dom.select('img'), function(e) {
8191 if (v = e.getAttribute('mce_src'))
8192 e.src = t.documentBaseURI.toAbsolute(v);
8196 Event.add(t.getDoc(), 'DOMNodeInserted', function(e) {
8201 if (e.nodeType === 1 && e.nodeName === 'IMG' && (v = e.getAttribute('mce_src')))
8202 e.src = t.documentBaseURI.toAbsolute(v);
8206 // Set various midas options in Gecko
8208 function setOpts() {
8209 var t = this, d = t.getDoc(), s = t.settings;
8211 if (isGecko && !s.readonly) {
8212 if (t._isHidden()) {
8214 if (!s.content_editable)
8215 d.designMode = 'On';
8217 // Fails if it's hidden
8222 // Try new Gecko method
8223 d.execCommand("styleWithCSS", 0, false);
8227 try {d.execCommand("useCSS", 0, true);} catch (ex) {}
8230 if (!s.table_inline_editing)
8231 try {d.execCommand('enableInlineTableEditing', false, false);} catch (ex) {}
8233 if (!s.object_resizing)
8234 try {d.execCommand('enableObjectResizing', false, false);} catch (ex) {}
8238 t.onBeforeExecCommand.add(setOpts);
8239 t.onMouseDown.add(setOpts);
8242 // Add node change handlers
8243 t.onMouseUp.add(t.nodeChanged);
8244 t.onClick.add(t.nodeChanged);
8245 t.onKeyUp.add(function(ed, e) {
8248 if ((c >= 33 && c <= 36) || (c >= 37 && c <= 40) || c == 13 || c == 45 || c == 46 || c == 8 || (tinymce.isMac && (c == 91 || c == 93)) || e.ctrlKey)
8252 // Add reset handler
8253 t.onReset.add(function() {
8254 t.setContent(t.startContent, {format : 'raw'});
8257 if (t.getParam('tab_focus')) {
8258 function tabCancel(ed, e) {
8259 if (e.keyCode === 9)
8260 return Event.cancel(e);
8263 function tabHandler(ed, e) {
8267 f = DOM.getParent(ed.id, 'form');
8271 each(el, function(e, i) {
8272 if (e.id == ed.id) {
8279 for (i = x + 1; i < el.length; i++) {
8280 if (el[i].type != 'hidden')
8284 for (i = x - 1; i >= 0; i--) {
8285 if (el[i].type != 'hidden')
8294 if (e.keyCode === 9) {
8295 v = explode(ed.getParam('tab_focus'));
8297 if (v.length == 1) {
8302 // Find element to focus
8304 if (v[0] == ':prev')
8309 if (v[1] == ':next')
8316 if (ed = EditorManager.get(el.id || el.name))
8319 window.setTimeout(function() {window.focus();el.focus();}, 10);
8321 return Event.cancel(e);
8326 t.onKeyUp.add(tabCancel);
8329 t.onKeyPress.add(tabHandler);
8330 t.onKeyDown.add(tabCancel);
8332 t.onKeyDown.add(tabHandler);
8336 if (s.custom_shortcuts) {
8337 if (s.custom_undo_redo_keyboard_shortcuts) {
8338 t.addShortcut('ctrl+z', t.getLang('undo_desc'), 'Undo');
8339 t.addShortcut('ctrl+y', t.getLang('redo_desc'), 'Redo');
8342 // Add default shortcuts for gecko
8344 t.addShortcut('ctrl+b', t.getLang('bold_desc'), 'Bold');
8345 t.addShortcut('ctrl+i', t.getLang('italic_desc'), 'Italic');
8346 t.addShortcut('ctrl+u', t.getLang('underline_desc'), 'Underline');
8349 // BlockFormat shortcuts keys
8350 for (i=1; i<=6; i++)
8351 t.addShortcut('ctrl+' + i, '', ['FormatBlock', false, '<h' + i + '>']);
8353 t.addShortcut('ctrl+7', '', ['FormatBlock', false, '<p>']);
8354 t.addShortcut('ctrl+8', '', ['FormatBlock', false, '<div>']);
8355 t.addShortcut('ctrl+9', '', ['FormatBlock', false, '<address>']);
8360 if (!e.altKey && !e.ctrlKey && !e.metaKey)
8363 each(t.shortcuts, function(o) {
8364 if (tinymce.isMac && o.ctrl != e.metaKey)
8366 else if (!tinymce.isMac && o.ctrl != e.ctrlKey)
8369 if (o.alt != e.altKey)
8372 if (o.shift != e.shiftKey)
8375 if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) {
8384 t.onKeyUp.add(function(ed, e) {
8388 return Event.cancel(e);
8391 t.onKeyPress.add(function(ed, e) {
8395 return Event.cancel(e);
8398 t.onKeyDown.add(function(ed, e) {
8402 o.func.call(o.scope);
8403 return Event.cancel(e);
8409 // Fix so resize will only update the width and height attributes not the styles of an image
8410 // It will also block mceItemNoResize items
8411 Event.add(t.getDoc(), 'controlselect', function(e) {
8412 var re = t.resizeInfo, cb;
8416 // Don't do this action for non image elements
8417 if (e.nodeName !== 'IMG')
8421 Event.remove(re.node, re.ev, re.cb);
8423 if (!t.dom.hasClass(e, 'mceItemNoResize')) {
8425 cb = Event.add(e, ev, function(e) {
8430 if (v = t.dom.getStyle(e, 'width')) {
8431 t.dom.setAttrib(e, 'width', v.replace(/[^0-9%]+/g, ''));
8432 t.dom.setStyle(e, 'width', '');
8435 if (v = t.dom.getStyle(e, 'height')) {
8436 t.dom.setAttrib(e, 'height', v.replace(/[^0-9%]+/g, ''));
8437 t.dom.setStyle(e, 'height', '');
8442 cb = Event.add(e, 'resizestart', Event.cancel, Event);
8445 re = t.resizeInfo = {
8452 t.onKeyDown.add(function(ed, e) {
8453 switch (e.keyCode) {
8455 // Fix IE control + backspace browser bug
8456 if (t.selection.getRng().item) {
8457 t.selection.getRng().item(0).removeNode();
8458 return Event.cancel(e);
8464 if (tinymce.isOpera) {
8465 t.onClick.add(function(ed, e) {
8470 // Add custom undo/redo handlers
8471 if (s.custom_undo_redo) {
8472 function addUndo() {
8473 t.undoManager.typing = 0;
8474 t.undoManager.add();
8477 // Add undo level on editor blur
8479 Event.add(t.getWin(), 'blur', function(e) {
8482 // Check added for fullscreen bug
8484 n = t.selection.getNode();
8486 // Add undo level is selection was lost to another document
8487 if (!t.removed && n.ownerDocument && n.ownerDocument != t.getDoc())
8492 Event.add(t.getDoc(), 'blur', function() {
8493 if (t.selection && !t.removed)
8498 t.onMouseDown.add(addUndo);
8500 t.onKeyUp.add(function(ed, e) {
8501 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.ctrlKey) {
8502 t.undoManager.typing = 0;
8503 t.undoManager.add();
8507 t.onKeyDown.add(function(ed, e) {
8508 // Is caracter positon keys
8509 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45) {
8510 if (t.undoManager.typing) {
8511 t.undoManager.add();
8512 t.undoManager.typing = 0;
8518 if (!t.undoManager.typing) {
8519 t.undoManager.add();
8520 t.undoManager.typing = 1;
8526 _convertInlineElements : function() {
8527 var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp;
8529 function convert(ed, o) {
8530 if (!s.inline_styles)
8534 each(t.dom.select('table,u,strike', o.node), function(n) {
8535 switch (n.nodeName) {
8537 if (v = dom.getAttrib(n, 'height')) {
8538 dom.setStyle(n, 'height', v);
8539 dom.setAttrib(n, 'height', '');
8545 //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
8546 n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
8547 dom.setAttrib(n, 'mce_style', '');
8548 dom.setAttrib(n, 'mce_name', 'span');
8553 each(t.dom.select('table,span', o.node).reverse(), function(n) {
8554 if (n.nodeName == 'TABLE') {
8555 if (v = dom.getStyle(n, 'height'))
8556 dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, ''));
8558 // Convert spans to elements
8559 if (n.style.textDecoration == 'underline')
8561 else if (n.style.textDecoration == 'line-through')
8567 n.style.textDecoration = '';
8568 dom.setAttrib(n, 'mce_style', '');
8570 e = dom.create(na, {
8571 style : dom.getAttrib(n, 'style')
8574 dom.replace(e, n, 1);
8581 t.onPreProcess.add(convert);
8583 if (!s.cleanup_on_startup) {
8584 t.onSetContent.add(function(ed, o) {
8586 convert(t, {node : t.getBody(), set : 1});
8591 _convertFonts : function() {
8592 var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl;
8595 if (!s.inline_styles)
8598 // Font pt values and font size names
8599 fz = [8, 10, 12, 14, 18, 24, 36];
8600 fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large'];
8602 if (sl = s.font_size_style_values)
8605 if (cl = s.font_size_classes)
8608 function process(no) {
8611 // Keep unit tests happy
8612 if (!s.inline_styles)
8615 nl = t.dom.select('font', no);
8616 for (x = nl.length - 1; x >= 0; x--) {
8619 sp = dom.create('span', {
8620 style : dom.getAttrib(n, 'style'),
8621 'class' : dom.getAttrib(n, 'class')
8625 fontFamily : dom.getAttrib(n, 'face'),
8626 color : dom.getAttrib(n, 'color'),
8627 backgroundColor : n.style.backgroundColor
8632 dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
8634 dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
8637 dom.setAttrib(sp, 'mce_style', '');
8638 dom.replace(sp, n, 1);
8643 t.onPreProcess.add(function(ed, o) {
8648 t.onSetContent.add(function(ed, o) {
8654 _isHidden : function() {
8660 // Weird, wheres that cursor selection?
8661 s = this.selection.getSel();
8662 return (!s || !s.rangeCount || s.rangeCount == 0);
8665 // Fix for bug #1867292
8666 _fixNesting : function(s) {
8669 s = s.replace(/<(\/)?([^\s>]+)[^>]*?>/g, function(a, b, c) {
8672 // Handle end element
8677 if (c !== d[d.length - 1].tag) {
8678 for (i=d.length - 1; i>=0; i--) {
8679 if (d[i].tag === c) {
8689 if (d.length && d[d.length - 1].close) {
8690 a = a + '</' + d[d.length - 1].tag + '>';
8696 if (/^(br|hr|input|meta|img|link|param)$/i.test(c))
8699 // Ignore closed ones
8703 d.push({tag : c}); // Push start element
8709 // End all open tags
8710 for (i=d.length - 1; i>=0; i--)
8711 s += '</' + d[i].tag + '>';
8719 /* file:jscripts/tiny_mce/classes/EditorCommands.js */
8722 var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit;
8724 function isBlock(n) {
8725 return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n.nodeName);
8728 tinymce.create('tinymce.EditorCommands', {
8729 EditorCommands : function(ed) {
8733 execCommand : function(cmd, ui, val) {
8734 var t = this, ed = t.editor, f;
8741 ed.getDoc().execCommand(cmd, ui, val);
8744 ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
8746 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
8749 ed.windowManager.alert(ed.getLang('clipboard_no_support'));
8755 case 'mceResetDesignMode':
8756 case 'mceBeginUndoLevel':
8764 // Bundle these together
8766 case 'JustifyCenter':
8767 case 'JustifyRight':
8769 t.mceJustify(cmd, cmd.substring(7).toLowerCase());
8772 case 'mceEndUndoLevel':
8773 case 'mceAddUndoLevel':
8774 ed.undoManager.add();
8781 f.call(this, ui, val);
8789 Indent : function() {
8790 var ed = this.editor, d = ed.dom, s = ed.selection, e, iv, iu;
8792 // Setup indent level
8793 iv = ed.settings.indentation;
8794 iu = /[a-z%]+$/i.exec(iv);
8797 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
8798 each(this._getSelectedBlocks(), function(e) {
8799 d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu);
8805 ed.getDoc().execCommand('Indent', false, null);
8808 d.getParent(s.getNode(), function(n) {
8809 if (n.nodeName == 'BLOCKQUOTE') {
8810 n.dir = n.style.cssText = '';
8816 Outdent : function() {
8817 var ed = this.editor, d = ed.dom, s = ed.selection, e, v, iv, iu;
8819 // Setup indent level
8820 iv = ed.settings.indentation;
8821 iu = /[a-z%]+$/i.exec(iv);
8824 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
8825 each(this._getSelectedBlocks(), function(e) {
8826 v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv);
8827 d.setStyle(e, 'paddingLeft', v ? v + iu : '');
8833 ed.getDoc().execCommand('Outdent', false, null);
8836 mceSetAttribute : function(u, v) {
8837 var ed = this.editor, d = ed.dom, e;
8839 if (e = d.getParent(ed.selection.getNode(), d.isBlock))
8840 d.setAttrib(e, v.name, v.value);
8843 mceSetContent : function(u, v) {
8844 this.editor.setContent(v);
8847 mceToggleVisualAid : function() {
8848 var ed = this.editor;
8850 ed.hasVisual = !ed.hasVisual;
8854 mceReplaceContent : function(u, v) {
8855 var s = this.editor.selection;
8857 s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'})));
8860 mceInsertLink : function(u, v) {
8861 var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A');
8863 if (tinymce.is(v, 'string'))
8867 each(v, function(v, k) {
8868 ed.dom.setAttrib(e, k, v);
8873 ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
8874 each(ed.dom.select('a'), function(e) {
8875 if (e.href == 'javascript:mctmp(0);')
8882 ed.dom.remove(e, 1);
8886 UnLink : function() {
8887 var ed = this.editor, s = ed.selection;
8889 if (s.isCollapsed())
8890 s.select(s.getNode());
8892 ed.getDoc().execCommand('unlink', false, null);
8896 FontName : function(u, v) {
8897 var t = this, ed = t.editor, s = ed.selection, e;
8900 if (s.isCollapsed())
8901 s.select(s.getNode());
8905 if (ed.settings.convert_fonts_to_spans)
8906 t._applyInlineStyle('span', {style : {fontFamily : v}});
8908 ed.getDoc().execCommand('FontName', false, v);
8912 FontSize : function(u, v) {
8913 var ed = this.editor, s = ed.settings, fc, fs;
8915 // Use style options instead
8916 if (s.convert_fonts_to_spans && v >= 1 && v <= 7) {
8917 fs = tinymce.explode(s.font_size_style_values);
8918 fc = tinymce.explode(s.font_size_classes);
8926 if (v >= 1 && v <= 7)
8927 ed.getDoc().execCommand('FontSize', false, v);
8929 this._applyInlineStyle('span', {style : {fontSize : v}});
8932 queryCommandValue : function(c) {
8933 var f = this['queryValue' + c];
8936 return f.call(this, c);
8941 queryCommandState : function(cmd) {
8945 // Bundle these together
8947 case 'JustifyCenter':
8948 case 'JustifyRight':
8950 return this.queryStateJustify(cmd, cmd.substring(7).toLowerCase());
8953 if (f = this['queryState' + cmd])
8954 return f.call(this, cmd);
8960 _queryState : function(c) {
8962 return this.editor.getDoc().queryCommandState(c);
8968 _queryVal : function(c) {
8970 return this.editor.getDoc().queryCommandValue(c);
8976 queryValueFontSize : function() {
8977 var ed = this.editor, v = 0, p;
8979 if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
8980 v = p.style.fontSize;
8982 if (!v && (isOpera || isWebKit)) {
8983 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
8989 return v || this._queryVal('FontSize');
8992 queryValueFontName : function() {
8993 var ed = this.editor, v = 0, p;
8995 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
8998 if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
8999 v = p.style.fontFamily.replace(/, /g, ',').replace(/[\'\"]/g, '').toLowerCase();
9002 v = this._queryVal('FontName');
9007 mceJustify : function(c, v) {
9008 var ed = this.editor, se = ed.selection, n = se.getNode(), nn = n.nodeName, bl, nb, dom = ed.dom, rm;
9010 if (ed.settings.inline_styles && this.queryStateJustify(c, v))
9013 bl = dom.getParent(n, ed.dom.isBlock);
9021 dom.setStyle(bl || n.parentNode, 'textAlign', '');
9023 dom.setStyle(n, 'float', '');
9028 if (v == 'center') {
9029 // Do not change table elements
9030 if (bl && /^(TD|TH)$/.test(bl.nodeName))
9033 if (!bl || bl.childNodes.length > 1) {
9034 nb = dom.create('p');
9035 nb.appendChild(n.cloneNode(false));
9038 dom.insertAfter(nb, bl);
9040 dom.insertAfter(nb, n);
9047 dom.setStyle(bl, 'textAlign', v);
9048 dom.setStyle(n, 'float', '');
9050 dom.setStyle(n, 'float', v);
9051 dom.setStyle(bl || n.parentNode, 'textAlign', '');
9058 // Handle the alignment outselfs, less quirks in all browsers
9059 if (ed.settings.inline_styles && ed.settings.forced_root_block) {
9063 each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
9064 dom.setAttrib(e, 'align', '');
9065 dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v);
9070 ed.getDoc().execCommand(c, false, null);
9072 if (ed.settings.inline_styles) {
9074 dom.getParent(ed.selection.getNode(), function(n) {
9075 if (n.style && n.style.textAlign)
9076 dom.setStyle(n, 'textAlign', '');
9082 each(dom.select('*'), function(n) {
9089 dom.setStyle(n, 'textAlign', v);
9090 dom.setAttrib(n, 'align', '');
9096 mceSetCSSClass : function(u, v) {
9097 this.mceSetStyleInfo(0, {command : 'setattrib', name : 'class', value : v});
9100 getSelectedElement : function() {
9101 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;
9103 if (se.isCollapsed() || r.item)
9104 return se.getNode();
9107 re = ed.settings.merge_styles_invalid_parents;
9108 if (tinymce.is(re, 'string'))
9109 re = new RegExp(re, 'i');
9114 sc = r1.parentElement();
9118 ec = r2.parentElement();
9121 r1.move('character', 1);
9122 sc = r1.parentElement();
9127 r1.moveToElementText(sc);
9129 if (r1.compareEndPoints('StartToStart', r) == 0 && r1.compareEndPoints('EndToEnd', r) == 0)
9130 return re && re.test(sc.nodeName) ? null : sc;
9133 function getParent(n) {
9134 return dom.getParent(n, function(n) {return n.nodeType == 1;});
9137 sc = r.startContainer;
9138 ec = r.endContainer;
9145 if (sc.hasChildNodes()) {
9146 sp = sc.childNodes[so];
9147 return re && re.test(sp.nodeName) ? null : sp;
9153 if (sc.nodeType != 3 || ec.nodeType != 3)
9159 if (sp && sp.firstChild != sc)
9163 if (so == sc.nodeValue.length) {
9166 if (e && e.nodeType == 1)
9167 sp = sc.nextSibling;
9171 e = ec.previousSibling;
9173 if (e && e.nodeType == 1)
9177 if (eo == ec.nodeValue.length) {
9180 if (ep && ep.lastChild != ec)
9186 return re && sp && re.test(sp.nodeName) ? null : sp;
9192 InsertHorizontalRule : function() {
9193 // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
9194 if (isGecko || isIE)
9195 this.editor.selection.setContent('<hr />');
9197 this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
9200 RemoveFormat : function() {
9201 var t = this, ed = t.editor, s = ed.selection, b;
9203 // Safari breaks tables
9205 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'});
9207 ed.getDoc().execCommand('RemoveFormat', false, null);
9209 t.mceSetStyleInfo(0, {command : 'removeformat'});
9213 mceSetStyleInfo : function(u, v) {
9214 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;
9216 function set(n, e) {
9217 if (n.nodeType == 1) {
9218 switch (v.command) {
9220 return dom.setAttrib(n, v.name, v.value);
9223 return dom.setStyle(n, v.name, v.value);
9225 case 'removeformat':
9226 return dom.setAttrib(n, 'class', '');
9232 re = ed.settings.merge_styles_invalid_parents;
9233 if (tinymce.is(re, 'string'))
9234 re = new RegExp(re, 'i');
9236 // Set style info on selected element
9237 if ((e = t.getSelectedElement()) && !ed.settings.force_span_wrappers)
9240 // Generate wrappers and set styles on them
9241 d.execCommand('FontName', false, '__');
9242 each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
9245 if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
9246 sp = dom.create(nn, {mce_new : '1'});
9250 each (n.childNodes, function(n) {
9251 sp.appendChild(n.cloneNode(true));
9259 // Remove wrappers inside new ones
9260 each(dom.select(nn).reverse(), function(n) {
9261 var p = n.parentNode;
9263 // Check if it's an old span in a new wrapper
9264 if (!dom.getAttrib(n, 'mce_new')) {
9266 p = dom.getParent(n, function(n) {
9267 return n.nodeType == 1 && dom.getAttrib(n, 'mce_new');
9275 // Merge wrappers with parent wrappers
9276 each(dom.select(nn).reverse(), function(n) {
9277 var p = n.parentNode;
9279 if (!p || !dom.getAttrib(n, 'mce_new'))
9282 if (ed.settings.force_span_wrappers && p.nodeName != 'SPAN')
9285 // Has parent of the same type and only child
9286 if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1)
9287 return dom.remove(p, 1);
9289 // Has parent that is more suitable to have the class and only child
9290 if (n.nodeType == 1 && (!re || !re.test(p.nodeName)) && p.childNodes.length == 1) {
9291 set(p); // Set style info on parent instead
9292 dom.setAttrib(n, 'class', '');
9296 // Remove empty wrappers
9297 each(dom.select(nn).reverse(), function(n) {
9298 if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) {
9299 if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style'))
9300 return dom.remove(n, 1);
9302 dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker
9306 s.moveToBookmark(b);
9309 queryStateJustify : function(c, v) {
9310 var ed = this.editor, n = ed.selection.getNode(), dom = ed.dom;
9312 if (n && n.nodeName == 'IMG') {
9313 if (dom.getStyle(n, 'float') == v)
9316 return n.parentNode.style.textAlign == v;
9319 n = dom.getParent(ed.selection.getStart(), function(n) {
9320 return n.nodeType == 1 && n.style.textAlign;
9326 if (ed.settings.inline_styles)
9327 return (n && n.style.textAlign == v);
9329 return this._queryState(c);
9332 ForeColor : function(ui, v) {
9333 var ed = this.editor;
9335 if (ed.settings.convert_fonts_to_spans) {
9336 this._applyInlineStyle('span', {style : {color : v}});
9339 ed.getDoc().execCommand('ForeColor', false, v);
9342 HiliteColor : function(ui, val) {
9343 var t = this, ed = t.editor, d = ed.getDoc();
9345 if (ed.settings.convert_fonts_to_spans) {
9346 this._applyInlineStyle('span', {style : {backgroundColor : val}});
9355 // Try new Gecko method
9356 d.execCommand("styleWithCSS", 0, s);
9359 d.execCommand("useCSS", 0, !s);
9363 if (isGecko || isOpera) {
9365 d.execCommand('hilitecolor', false, val);
9368 d.execCommand('BackColor', false, val);
9372 var ed = this.editor;
9374 if (ed.settings.custom_undo_redo) {
9375 ed.undoManager.undo();
9378 ed.getDoc().execCommand('Undo', false, null);
9382 var ed = this.editor;
9384 if (ed.settings.custom_undo_redo) {
9385 ed.undoManager.redo();
9388 ed.getDoc().execCommand('Redo', false, null);
9391 FormatBlock : function(ui, val) {
9392 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b;
9394 function isBlock(n) {
9395 return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);
9398 bl = dom.getParent(s.getNode(), function(n) {
9402 // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div>
9403 // FF and Opera doesn't change parent DIV elements if you switch format
9405 if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
9406 // Rename block element
9407 nb = ed.dom.create(val);
9409 each(dom.getAttribs(bl), function(v) {
9410 dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName));
9413 b = s.getBookmark();
9414 dom.replace(nb, bl, 1);
9415 s.moveToBookmark(b);
9421 val = ed.settings.forced_root_block ? (val || '<p>') : val;
9423 if (val.indexOf('<') == -1)
9424 val = '<' + val + '>';
9426 if (tinymce.isGecko)
9427 val = val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi, '$1');
9429 ed.getDoc().execCommand('FormatBlock', false, val);
9432 mceCleanup : function() {
9433 var ed = this.editor, s = ed.selection, b = s.getBookmark();
9434 ed.setContent(ed.getContent());
9435 s.moveToBookmark(b);
9438 mceRemoveNode : function(ui, val) {
9439 var ed = this.editor, s = ed.selection, b, n = val || s.getNode();
9441 // Make sure that the body node isn't removed
9442 if (n == ed.getBody())
9445 b = s.getBookmark();
9446 ed.dom.remove(n, 1);
9447 s.moveToBookmark(b);
9451 mceSelectNodeDepth : function(ui, val) {
9452 var ed = this.editor, s = ed.selection, c = 0;
9454 ed.dom.getParent(s.getNode(), function(n) {
9455 if (n.nodeType == 1 && c++ == val) {
9463 mceSelectNode : function(u, v) {
9464 this.editor.selection.select(v);
9467 mceInsertContent : function(ui, val) {
9468 this.editor.selection.setContent(val);
9471 mceInsertRawHTML : function(ui, val) {
9472 var ed = this.editor;
9474 ed.selection.setContent('tiny_mce_marker');
9475 ed.setContent(ed.getContent().replace(/tiny_mce_marker/g, val));
9478 mceRepaint : function() {
9479 var s, b, e = this.editor;
9481 if (tinymce.isGecko) {
9484 b = s.getBookmark(true);
9487 s.getSel().selectAllChildren(e.getBody());
9490 s.moveToBookmark(b);
9497 queryStateUnderline : function() {
9498 var ed = this.editor, n = ed.selection.getNode();
9500 if (n && n.nodeName == 'A')
9503 return this._queryState('Underline');
9506 queryStateOutdent : function() {
9507 var ed = this.editor, n;
9509 if (ed.settings.inline_styles) {
9510 if ((n = ed.dom.getParent(ed.selection.getStart(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
9513 if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
9517 return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList() || (!ed.settings.inline_styles && !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE'));
9520 queryStateInsertUnorderedList : function() {
9521 return this.editor.dom.getParent(this.editor.selection.getNode(), 'UL');
9524 queryStateInsertOrderedList : function() {
9525 return this.editor.dom.getParent(this.editor.selection.getNode(), 'OL');
9528 queryStatemceBlockQuote : function() {
9529 return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
9532 mceBlockQuote : function() {
9533 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
9536 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
9539 // Get start/end block
9540 sb = dom.getParent(s.getStart(), isBlock);
9541 eb = dom.getParent(s.getEnd(), isBlock);
9543 // Remove blockquote(s)
9544 if (bq = getBQ(sb)) {
9545 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
9546 bm = s.getBookmark();
9548 // Move all elements after the end block into new bq
9550 bq2 = bq.cloneNode(false);
9552 while (n = eb.nextSibling)
9553 bq2.appendChild(n.parentNode.removeChild(n));
9558 dom.insertAfter(bq2, bq);
9560 // Move all selected blocks after the current bq
9561 nl = t._getSelectedBlocks(sb, eb);
9562 for (i = nl.length - 1; i >= 0; i--) {
9563 dom.insertAfter(nl[i], bq);
9566 // Empty bq, then remove it
9567 if (/^\s*$/.test(bq.innerHTML))
9568 dom.remove(bq, 1); // Keep children so boomark restoration works correctly
9570 // Empty bq, then remote it
9571 if (bq2 && /^\s*$/.test(bq2.innerHTML))
9572 dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
9575 // Move caret inside empty block element
9577 r = ed.getDoc().createRange();
9585 // IE misses the empty block some times element so we must move back the caret
9586 if (dom.getParent(s.getStart(), isBlock) != sb) {
9588 r.move('character', -1);
9593 t.editor.selection.moveToBookmark(bm);
9598 // Since IE can start with a totally empty document we need to add the first bq and paragraph
9599 if (isIE && !sb && !eb) {
9600 t.editor.getDoc().execCommand('Indent');
9601 n = getBQ(s.getNode());
9602 n.style.margin = n.dir = ''; // IE adds margin and dir to bq
9609 // If empty paragraph node then do not use bookmark
9610 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
9611 bm = s.getBookmark();
9613 // Move selected block elements into a bq
9614 each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
9615 // Found existing BQ add to this one
9616 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
9621 // No BQ found, create one
9623 bq = dom.create('blockquote');
9624 e.parentNode.insertBefore(bq, e);
9627 // Add children from existing BQ
9628 if (e.nodeName == 'BLOCKQUOTE' && bq) {
9632 bq.appendChild(n.cloneNode(true));
9640 // Add non BQ element to BQ
9641 bq.appendChild(dom.remove(e));
9645 // Move caret inside empty block element
9647 r = ed.getDoc().createRange();
9656 s.moveToBookmark(bm);
9659 _applyInlineStyle : function(na, at, op) {
9660 var t = this, ed = t.editor, dom = ed.dom, bm, lo = {}, kh;
9662 na = na.toUpperCase();
9664 if (op && op.check_classes && at['class'])
9665 op.check_classes.push(at['class']);
9667 function replaceFonts() {
9670 each(dom.select(tinymce.isWebKit && !tinymce.isAir ? 'span' : 'font'), function(n) {
9671 if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline') {
9673 bm = ed.selection.getBookmark();
9676 dom.replace(dom.create(na, at), n, 1);
9680 // Remove redundant elements
9681 each(dom.select(na), function(n) {
9682 if (n.getAttribute('_mce_new')) {
9683 function removeStyle(n) {
9684 if (n.nodeType == 1) {
9685 each(at.style, function(v, k) {
9686 dom.setStyle(n, k, '');
9689 // Remove spans with the same class or marked classes
9690 if (at['class'] && n.className && op) {
9691 each(op.check_classes, function(c) {
9692 if (dom.hasClass(n, c))
9693 dom.removeClass(n, c);
9699 // Remove specified style information from child elements
9700 each(dom.select(na, n), removeStyle);
9702 // Remove the specified style information on parent if current node is only child (IE)
9703 if (n.parentNode && n.parentNode.nodeType == 1 && n.parentNode.childNodes.length == 1)
9704 removeStyle(n.parentNode);
9706 // Remove the child elements style info if a parent already has it
9707 dom.getParent(n.parentNode, function(pn) {
9708 if (pn.nodeType == 1) {
9710 each(at.style, function(v, k) {
9713 if (!lo[k] && (sv = dom.getStyle(pn, k))) {
9715 dom.setStyle(n, k, '');
9722 // Remove spans with the same class or marked classes
9723 if (at['class'] && pn.className && op) {
9724 each(op.check_classes, function(c) {
9725 if (dom.hasClass(pn, c))
9726 dom.removeClass(n, c);
9734 n.removeAttribute('_mce_new');
9738 // Remove empty span elements
9739 each(dom.select(na).reverse(), function(n) {
9742 // Check if there is any attributes
9743 each(dom.getAttribs(n), function(an) {
9744 if (an.nodeName.substring(0, 1) != '_' && dom.getAttrib(n, an.nodeName) != '') {
9745 //console.log(dom.getOuterHTML(n), dom.getAttrib(n, an.nodeName));
9750 // No attributes then remove the element and keep the children
9755 ed.selection.moveToBookmark(bm);
9760 // Create inline elements
9762 ed.getDoc().execCommand('FontName', false, 'mceinline');
9765 if (kh = t._applyInlineStyle.keyhandler) {
9766 ed.onKeyUp.remove(kh);
9767 ed.onKeyPress.remove(kh);
9768 ed.onKeyDown.remove(kh);
9769 ed.onSetContent.remove(t._applyInlineStyle.chandler);
9772 if (ed.selection.isCollapsed()) {
9773 // Start collecting styles
9774 t._pendingStyles = tinymce.extend(t._pendingStyles || {}, at.style);
9776 t._applyInlineStyle.chandler = ed.onSetContent.add(function() {
9777 delete t._pendingStyles;
9780 t._applyInlineStyle.keyhandler = kh = function(e) {
9781 // Use pending styles
9782 if (t._pendingStyles) {
9783 at.style = t._pendingStyles;
9784 delete t._pendingStyles;
9787 if (replaceFonts()) {
9788 ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);
9789 ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);
9792 if (e.type == 'keyup')
9793 ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);
9796 ed.onKeyDown.add(kh);
9797 ed.onKeyPress.add(kh);
9800 t._pendingStyles = 0;
9804 _mceBlockQuote : function() {
9805 var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom;
9807 function findBQ(e) {
9808 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
9811 // Remove blockquote(s)
9812 if (findBQ(s.getStart())) {
9813 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
9814 // Found BQ lets remove it
9815 if (e.nodeName == 'BLOCKQUOTE')
9819 t.editor.selection.moveToBookmark(b);
9823 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
9826 // Found existing BQ add to this one
9827 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
9832 // No BQ found, create one
9834 bq = dom.create('blockquote');
9835 e.parentNode.insertBefore(bq, e);
9838 // Add children from existing BQ
9839 if (e.nodeName == 'BLOCKQUOTE' && bq) {
9843 bq.appendChild(n.cloneNode(true));
9852 // Add non BQ element to BQ
9853 bq.appendChild(dom.remove(e));
9856 t.editor.selection.moveToBookmark(b);
9859 _getSelectedBlocks : function(st, en) {
9860 var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = [];
9862 sb = dom.getParent(st || s.getStart(), isBlock);
9863 eb = dom.getParent(en || s.getEnd(), isBlock);
9868 if (sb && eb && sb != eb) {
9871 while ((n = n.nextSibling) && n != eb) {
9886 /* file:jscripts/tiny_mce/classes/UndoManager.js */
9888 tinymce.create('tinymce.UndoManager', {
9893 UndoManager : function(ed) {
9894 var t = this, Dispatcher = tinymce.util.Dispatcher;
9898 t.onAdd = new Dispatcher(this);
9899 t.onUndo = new Dispatcher(this);
9900 t.onRedo = new Dispatcher(this);
9904 var t = this, i, ed = t.editor, b, s = ed.settings, la;
9907 l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
9909 // Add undo level if needed
9910 l.content = l.content.replace(/^\s*|\s*$/g, '');
9911 la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index];
9912 if (!l.initial && la && l.content == la.content)
9916 if (s.custom_undo_redo_levels) {
9917 if (t.data.length > s.custom_undo_redo_levels) {
9918 for (i = 0; i < t.data.length - 1; i++)
9919 t.data[i] = t.data[i + 1];
9922 t.index = t.data.length;
9926 if (s.custom_undo_redo_restore_selection && !l.initial)
9927 l.bookmark = b = l.bookmark || ed.selection.getBookmark();
9929 if (t.index < t.data.length)
9932 // Only initial marked undo levels should be allowed as first item
9933 // This to workaround a bug with Firefox and the blur event
9934 if (t.data.length === 0 && !l.initial)
9938 t.data.length = t.index + 1;
9939 t.data[t.index++] = l;
9944 // Set initial bookmark use first real undo level
9945 if (t.data.length == 2 && t.data[0].initial)
9946 t.data[0].bookmark = b;
9948 t.onAdd.dispatch(t, l);
9951 //console.dir(t.data);
9957 var t = this, ed = t.editor, l = l, i;
9965 // If undo on last index then take snapshot
9966 if (t.index == t.data.length && t.index > 1) {
9976 l = t.data[--t.index];
9977 ed.setContent(l.content, {format : 'raw'});
9978 ed.selection.moveToBookmark(l.bookmark);
9980 t.onUndo.dispatch(t, l);
9987 var t = this, ed = t.editor, l = null;
9989 if (t.index < t.data.length - 1) {
9990 l = t.data[++t.index];
9991 ed.setContent(l.content, {format : 'raw'});
9992 ed.selection.moveToBookmark(l.bookmark);
9994 t.onRedo.dispatch(t, l);
10000 clear : function() {
10006 t.add({initial : true});
10009 hasUndo : function() {
10010 return this.index != 0 || this.typing;
10013 hasRedo : function() {
10014 return this.index < this.data.length - 1;
10018 /* file:jscripts/tiny_mce/classes/ForceBlocks.js */
10022 var Event, isIE, isGecko, isOpera, each, extend;
10024 Event = tinymce.dom.Event;
10025 isIE = tinymce.isIE;
10026 isGecko = tinymce.isGecko;
10027 isOpera = tinymce.isOpera;
10028 each = tinymce.each;
10029 extend = tinymce.extend;
10031 tinymce.create('tinymce.ForceBlocks', {
10032 ForceBlocks : function(ed) {
10033 var t = this, s = ed.settings, elm;
10037 elm = (s.forced_root_block || 'p').toLowerCase();
10038 s.element = elm.toUpperCase();
10040 ed.onPreInit.add(t.setup, t);
10042 t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi');
10043 t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
10044 t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
10045 t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi');
10046 t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
10047 t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
10049 function padd(ed, o) {
10051 o.content = o.content.replace(t.reOpera, '</' + elm + '>');
10053 o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>');
10055 if (!isIE && !isOpera && o.set) {
10056 // Use instead of BR in padded paragraphs
10057 o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>');
10058 o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>');
10060 o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>');
10061 o.content = o.content.replace(t.reTrailBr, '</' + elm + '>');
10065 ed.onBeforeSetContent.add(padd);
10066 ed.onPostProcess.add(padd);
10068 if (s.forced_root_block) {
10069 ed.onInit.add(t.forceRoots, t);
10070 ed.onSetContent.add(t.forceRoots, t);
10071 ed.onBeforeGetContent.add(t.forceRoots, t);
10075 setup : function() {
10076 var t = this, ed = t.editor, s = ed.settings;
10078 // Force root blocks when typing and when getting output
10079 if (s.forced_root_block) {
10080 ed.onKeyUp.add(t.forceRoots, t);
10081 ed.onPreProcess.add(t.forceRoots, t);
10084 if (s.force_br_newlines) {
10085 // Force IE to produce BRs on enter
10087 ed.onKeyPress.add(function(ed, e) {
10088 var n, s = ed.selection;
10090 if (e.keyCode == 13 && s.getNode().nodeName != 'LI') {
10091 s.setContent('<br id="__" /> ', {format : 'raw'});
10092 n = ed.dom.get('__');
10093 n.removeAttribute('id');
10096 return Event.cancel(e);
10104 if (!isIE && s.force_p_newlines) {
10105 /* ed.onPreProcess.add(function(ed, o) {
10106 each(ed.dom.select('br', o.node), function(n) {
10107 var p = n.parentNode;
10109 // Replace <p><br /></p> with <p> </p>
10110 if (p && p.nodeName == 'p' && (p.childNodes.length == 1 || p.lastChild == n)) {
10111 p.replaceChild(ed.getDoc().createTextNode('\u00a0'), n);
10116 ed.onKeyPress.add(function(ed, e) {
10117 if (e.keyCode == 13 && !e.shiftKey) {
10118 if (!t.insertPara(e))
10124 ed.onKeyDown.add(function(ed, e) {
10125 if ((e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey)
10126 t.backspaceDelete(e, e.keyCode == 8);
10131 function ren(rn, na) {
10132 var ne = ed.dom.create(na);
10134 each(rn.attributes, function(a) {
10135 if (a.specified && a.nodeValue)
10136 ne.setAttribute(a.nodeName.toLowerCase(), a.nodeValue);
10139 each(rn.childNodes, function(n) {
10140 ne.appendChild(n.cloneNode(true));
10143 rn.parentNode.replaceChild(ne, rn);
10148 // Replaces IE:s auto generated paragraphs with the specified element name
10149 if (isIE && s.element != 'P') {
10150 ed.onKeyPress.add(function(ed, e) {
10151 t.lastElm = ed.selection.getNode().nodeName;
10154 ed.onKeyUp.add(function(ed, e) {
10155 var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
10157 if (b.childNodes.length === 1 && n.nodeName == 'P') {
10158 n = ren(n, s.element);
10162 } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
10163 bl = ed.dom.getParent(n, 'P');
10166 ren(bl, s.element);
10174 find : function(n, t, s) {
10175 var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, false), c = -1;
10177 while (n = w.nextNode()) {
10181 if (t == 0 && n == s)
10185 if (t == 1 && c == s)
10192 forceRoots : function(ed, e) {
10193 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;
10194 var nx, bl, bp, sp, le, nl = b.childNodes, i, n, eid;
10196 // Fix for bug #1863847
10197 //if (e && e.keyCode == 13)
10200 // Wrap non blocks into blocks
10201 for (i = nl.length - 1; i >= 0; i--) {
10204 // Is text or non block element
10205 if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
10207 // Create new block but ignore whitespace
10208 if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
10210 if (si == -2 && r) {
10212 // If selection is element then mark it
10213 if (r.startContainer.nodeType == 1 && (n = r.startContainer.childNodes[r.startOffset]) && n.nodeType == 1) {
10214 // Save the id of the selected element
10215 eid = n.getAttribute("id");
10216 n.setAttribute("id", "__mce");
10218 // If element is inside body, might not be the case in contentEdiable mode
10219 if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
10220 so = r.startOffset;
10222 si = t.find(b, 0, r.startContainer);
10223 ei = t.find(b, 0, r.endContainer);
10227 tr = d.body.createTextRange();
10228 tr.moveToElementText(b);
10230 bp = tr.move('character', c) * -1;
10232 tr = r.duplicate();
10234 sp = tr.move('character', c) * -1;
10236 tr = r.duplicate();
10238 le = (tr.move('character', c) * -1) - sp;
10245 bl = ed.dom.create(ed.settings.forced_root_block);
10246 bl.appendChild(nx.cloneNode(1));
10247 nx.parentNode.replaceChild(bl, nx);
10250 if (bl.hasChildNodes())
10251 bl.insertBefore(nx, bl.firstChild);
10253 bl.appendChild(nx);
10256 bl = null; // Time to create new block
10259 // Restore selection
10262 bl = b.getElementsByTagName(ed.settings.element)[0];
10263 r = d.createRange();
10265 // Select last location or generated block
10267 r.setStart(t.find(b, 1, si), so);
10271 // Select last location or generated block
10273 r.setEnd(t.find(b, 1, ei), eo);
10278 s.removeAllRanges();
10283 r = s.createRange();
10284 r.moveToElementText(b);
10286 r.moveStart('character', si);
10287 r.moveEnd('character', ei);
10293 } else if (!isIE && (n = ed.dom.get('__mce'))) {
10294 // Restore the id of the selected element
10296 n.setAttribute('id', eid);
10298 n.removeAttribute('id');
10300 // Move caret before selected element
10301 r = d.createRange();
10302 r.setStartBefore(n);
10308 getParentBlock : function(n) {
10311 return d.getParent(n, d.isBlock);
10314 insertPara : function(e) {
10315 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;
10316 var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch, car;
10318 function isEmpty(n) {
10320 n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
10321 n = n.replace(/<[^>]+>/g, ''); // Remove all tags
10323 return n.replace(/[ \t\r\n]+/g, '') == '';
10326 // If root blocks are forced then use Operas default behavior since it's really good
10327 // Removed due to bug: #1853816
10328 // if (se.forced_root_block && isOpera)
10331 // Setup before range
10332 rb = d.createRange();
10334 // If is before the first block element and in body, then move it into first block element
10335 rb.setStart(s.anchorNode, s.anchorOffset);
10338 // Setup after range
10339 ra = d.createRange();
10341 // If is before the first block element and in body, then move it into first block element
10342 ra.setStart(s.focusNode, s.focusOffset);
10345 // Setup start/end points
10346 dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
10347 sn = dir ? s.anchorNode : s.focusNode;
10348 so = dir ? s.anchorOffset : s.focusOffset;
10349 en = dir ? s.focusNode : s.anchorNode;
10350 eo = dir ? s.focusOffset : s.anchorOffset;
10352 // If selection is in empty table cell
10353 if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
10354 dom.remove(sn.firstChild); // Remove BR
10356 // Create two new block elements
10357 ed.dom.add(sn, se.element, null, '<br />');
10358 aft = ed.dom.add(sn, se.element, null, '<br />');
10360 // Move caret into the last one
10361 r = d.createRange();
10362 r.selectNodeContents(aft);
10364 ed.selection.setRng(r);
10369 // If the caret is in an invalid location in FF we need to move it into the first block
10370 if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
10371 sn = en = sn.firstChild;
10373 rb = d.createRange();
10374 rb.setStart(sn, 0);
10375 ra = d.createRange();
10376 ra.setStart(en, 0);
10379 // Never use body as start or end node
10380 sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
10381 sn = sn.nodeName == "BODY" ? sn.firstChild : sn;
10382 en = en.nodeName == "HTML" ? d.body : en; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
10383 en = en.nodeName == "BODY" ? en.firstChild : en;
10385 // Get start and end blocks
10386 sb = t.getParentBlock(sn);
10387 eb = t.getParentBlock(en);
10388 bn = sb ? sb.nodeName : se.element; // Get block name to create
10390 // Return inside list use default browser behavior
10391 if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
10394 // If caption or absolute layers then always generate new blocks within
10395 if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
10400 // If caption or absolute layers then always generate new blocks within
10401 if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
10407 if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
10412 // Setup new before and after blocks
10413 bef = (sb && sb.nodeName == bn) ? sb.cloneNode(0) : ed.dom.create(bn);
10414 aft = (eb && eb.nodeName == bn) ? eb.cloneNode(0) : ed.dom.create(bn);
10416 // Remove id from after clone
10417 aft.removeAttribute('id');
10419 // Is header and cursor is at the end, then force paragraph under
10420 if (/^(H[1-6])$/.test(bn) && sn.nodeValue && so == sn.nodeValue.length)
10421 aft = ed.dom.create(se.element);
10423 // Find start chop node
10426 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
10430 } while ((n = n.previousSibling ? n.previousSibling : n.parentNode));
10432 // Find end chop node
10435 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
10439 } while ((n = n.nextSibling ? n.nextSibling : n.parentNode));
10441 // Place first chop part into before block element
10442 if (sc.nodeName == bn)
10443 rb.setStart(sc, 0);
10445 rb.setStartBefore(sc);
10448 bef.appendChild(rb.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
10450 // Place secnd chop part within new block element
10452 ra.setEndAfter(ec);
10454 //console.debug(s.focusNode, s.focusOffset);
10457 ra.setStart(en, eo);
10458 aft.appendChild(ra.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
10460 // Create range around everything
10461 r = d.createRange();
10462 if (!sc.previousSibling && sc.parentNode.nodeName == bn) {
10463 r.setStartBefore(sc.parentNode);
10465 if (rb.startContainer.nodeName == bn && rb.startOffset == 0)
10466 r.setStartBefore(rb.startContainer);
10468 r.setStart(rb.startContainer, rb.startOffset);
10471 if (!ec.nextSibling && ec.parentNode.nodeName == bn)
10472 r.setEndAfter(ec.parentNode);
10474 r.setEnd(ra.endContainer, ra.endOffset);
10476 // Delete and replace it with new block elements
10477 r.deleteContents();
10480 ed.getWin().scrollTo(0, vp.y);
10482 // Never wrap blocks in blocks
10483 if (bef.firstChild && bef.firstChild.nodeName == bn)
10484 bef.innerHTML = bef.firstChild.innerHTML;
10486 if (aft.firstChild && aft.firstChild.nodeName == bn)
10487 aft.innerHTML = aft.firstChild.innerHTML;
10489 // Padd empty blocks
10491 bef.innerHTML = '<br />';
10493 function appendStyles(e, en) {
10494 var nl = [], nn, n, i;
10498 // Make clones of style elements
10499 if (se.keep_styles) {
10502 // We only want style specific elements
10503 if (/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)) {
10504 nn = n.cloneNode(false);
10505 dom.setAttrib(nn, 'id', ''); // Remove ID since it needs to be unique
10508 } while (n = n.parentNode);
10511 // Append style elements to aft
10512 if (nl.length > 0) {
10513 for (i = nl.length - 1, nn = e; i >= 0; i--)
10514 nn = nn.appendChild(nl[i]);
10516 // Padd most inner style element
10517 nl[0].innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
10518 return nl[0]; // Move caret to most inner element
10520 e.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
10523 // Fill empty afterblook with current style
10525 car = appendStyles(aft, en);
10527 // Opera needs this one backwards for older versions
10528 if (isOpera && parseFloat(opera.version()) < 9.5) {
10540 function first(n) {
10541 return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n;
10544 // Move cursor and scroll into view
10545 r = d.createRange();
10546 r.selectNodeContents(isGecko ? first(car || aft) : car || aft);
10548 s.removeAllRanges();
10551 // 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
10552 y = ed.dom.getPos(aft).y;
10553 ch = aft.clientHeight;
10555 // Is element within viewport
10556 if (y < vp.y || y + ch > vp.y + vp.h) {
10557 ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + 25); // Needs to be hardcoded to roughly one line of text if a huge text block is broken into two blocks
10558 //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));
10564 backspaceDelete : function(e, bs) {
10565 var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn;
10567 // The caret sometimes gets stuck in Gecko if you delete empty paragraphs
10568 // This workaround removes the element by hand and moves the caret to the previous element
10569 if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) {
10570 if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) {
10571 // Find previous block element
10573 while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ;
10576 if (sc != b.firstChild) {
10577 // Find last text node
10578 w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
10579 while (tn = w.nextNode())
10582 // Place caret at the end of last text node
10583 r = ed.getDoc().createRange();
10584 r.setStart(n, n.nodeValue ? n.nodeValue.length : 0);
10585 r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0);
10588 // Remove the target container
10592 return Event.cancel(e);
10597 // Gecko generates BR elements here and there, we don't like those so lets remove them
10598 function handler(e) {
10603 // A new BR was created in a block element, remove it
10604 if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
10605 pr = e.previousSibling;
10607 Event.remove(b, 'DOMNodeInserted', handler);
10609 // Is there whitespace at the end of the node before then we might need the pesky BR
10610 // to place the caret at a correct location see bug: #2013943
10611 if (pr && pr.nodeType == 3 && /\s+$/.test(pr.nodeValue))
10614 // Only remove BR elements that got inserted in the middle of the text
10615 if (e.previousSibling || e.nextSibling)
10620 // Listen for new nodes
10621 Event._add(b, 'DOMNodeInserted', handler);
10624 window.setTimeout(function() {
10625 Event._remove(b, 'DOMNodeInserted', handler);
10631 /* file:jscripts/tiny_mce/classes/ControlManager.js */
10635 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend;
10637 tinymce.create('tinymce.ControlManager', {
10638 ControlManager : function(ed, s) {
10644 t.onAdd = new tinymce.util.Dispatcher(t);
10645 t.onPostRender = new tinymce.util.Dispatcher(t);
10646 t.prefix = s.prefix || ed.id + '_';
10649 t.onPostRender.add(function() {
10650 each(t.controls, function(c) {
10656 get : function(id) {
10657 return this.controls[this.prefix + id] || this.controls[id];
10660 setActive : function(id, s) {
10663 if (c = this.get(id))
10669 setDisabled : function(id, s) {
10672 if (c = this.get(id))
10678 add : function(c) {
10682 t.controls[c.id] = c;
10683 t.onAdd.dispatch(c, t);
10689 createControl : function(n) {
10690 var c, t = this, ed = t.editor;
10692 each(ed.plugins, function(p) {
10693 if (p.createControl) {
10694 c = p.createControl(n, t);
10704 return t.createSeparator();
10707 if (!c && ed.buttons && (c = ed.buttons[n]))
10708 return t.createButton(n, c);
10713 createDropMenu : function(id, s, cc) {
10714 var t = this, ed = t.editor, c, bm, v, cls;
10717 'class' : 'mceDropDown',
10718 constrain : ed.settings.constrain_menus
10721 s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin';
10722 if (v = ed.getParam('skin_variant'))
10723 s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1);
10725 id = t.prefix + id;
10726 cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu;
10727 c = t.controls[id] = new cls(id, s);
10728 c.onAddItem.add(function(c, o) {
10729 var s = o.settings;
10731 s.title = ed.getLang(s.title, s.title);
10734 s.onclick = function(v) {
10735 ed.execCommand(s.cmd, s.ui || false, s.value);
10740 ed.onRemove.add(function() {
10744 // Fix for bug #1897785, #1898007
10745 if (tinymce.isIE) {
10746 c.onShowMenu.add(function() {
10747 bm = ed.selection.getBookmark(1);
10750 c.onHideMenu.add(function() {
10752 ed.selection.moveToBookmark(bm);
10759 createListBox : function(id, s, cc) {
10760 var t = this, ed = t.editor, cmd, c, cls;
10765 s.title = ed.translate(s.title);
10766 s.scope = s.scope || ed;
10769 s.onselect = function(v) {
10770 ed.execCommand(s.cmd, s.ui || false, v || s.value);
10776 'class' : 'mce_' + id,
10778 control_manager : t
10781 id = t.prefix + id;
10783 if (ed.settings.use_native_selects)
10784 c = new tinymce.ui.NativeListBox(id, s);
10786 cls = cc || t._cls.listbox || tinymce.ui.ListBox;
10787 c = new cls(id, s);
10790 t.controls[id] = c;
10792 // Fix focus problem in Safari
10793 if (tinymce.isWebKit) {
10794 c.onPostRender.add(function(c, n) {
10795 // Store bookmark on mousedown
10796 Event.add(n, 'mousedown', function() {
10797 ed.bookmark = ed.selection.getBookmark('simple');
10800 // Restore on focus, since it might be lost
10801 Event.add(n, 'focus', function() {
10802 ed.selection.moveToBookmark(ed.bookmark);
10803 ed.bookmark = null;
10809 ed.onMouseDown.add(c.hideMenu, c);
10814 createButton : function(id, s, cc) {
10815 var t = this, ed = t.editor, o, c, cls;
10820 s.title = ed.translate(s.title);
10821 s.label = ed.translate(s.label);
10822 s.scope = s.scope || ed;
10824 if (!s.onclick && !s.menu_button) {
10825 s.onclick = function() {
10826 ed.execCommand(s.cmd, s.ui || false, s.value);
10832 'class' : 'mce_' + id,
10833 unavailable_prefix : ed.getLang('unavailable', ''),
10835 control_manager : t
10838 id = t.prefix + id;
10840 if (s.menu_button) {
10841 cls = cc || t._cls.menubutton || tinymce.ui.MenuButton;
10842 c = new cls(id, s);
10843 ed.onMouseDown.add(c.hideMenu, c);
10845 cls = t._cls.button || tinymce.ui.Button;
10846 c = new cls(id, s);
10852 createMenuButton : function(id, s, cc) {
10856 return this.createButton(id, s, cc);
10859 createSplitButton : function(id, s, cc) {
10860 var t = this, ed = t.editor, cmd, c, cls;
10865 s.title = ed.translate(s.title);
10866 s.scope = s.scope || ed;
10869 s.onclick = function(v) {
10870 ed.execCommand(s.cmd, s.ui || false, v || s.value);
10875 s.onselect = function(v) {
10876 ed.execCommand(s.cmd, s.ui || false, v || s.value);
10882 'class' : 'mce_' + id,
10884 control_manager : t
10887 id = t.prefix + id;
10888 cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton;
10889 c = t.add(new cls(id, s));
10890 ed.onMouseDown.add(c.hideMenu, c);
10895 createColorSplitButton : function(id, s, cc) {
10896 var t = this, ed = t.editor, cmd, c, cls, bm;
10901 s.title = ed.translate(s.title);
10902 s.scope = s.scope || ed;
10905 s.onclick = function(v) {
10906 ed.execCommand(s.cmd, s.ui || false, v || s.value);
10911 s.onselect = function(v) {
10912 ed.execCommand(s.cmd, s.ui || false, v || s.value);
10918 'class' : 'mce_' + id,
10919 'menu_class' : ed.getParam('skin') + 'Skin',
10921 more_colors_title : ed.getLang('more_colors')
10924 id = t.prefix + id;
10925 cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton;
10926 c = new cls(id, s);
10927 ed.onMouseDown.add(c.hideMenu, c);
10929 // Remove the menu element when the editor is removed
10930 ed.onRemove.add(function() {
10934 // Fix for bug #1897785, #1898007
10935 if (tinymce.isIE) {
10936 c.onShowMenu.add(function() {
10937 bm = ed.selection.getBookmark(1);
10940 c.onHideMenu.add(function() {
10942 ed.selection.moveToBookmark(bm);
10951 createToolbar : function(id, s, cc) {
10952 var c, t = this, cls;
10954 id = t.prefix + id;
10955 cls = cc || t._cls.toolbar || tinymce.ui.Toolbar;
10956 c = new cls(id, s);
10964 createSeparator : function(cc) {
10965 var cls = cc || this._cls.separator || tinymce.ui.Separator;
10970 setControlType : function(n, c) {
10971 return this._cls[n.toLowerCase()] = c;
10974 destroy : function() {
10975 each(this.controls, function(c) {
10979 this.controls = null;
10985 /* file:jscripts/tiny_mce/classes/WindowManager.js */
10988 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera;
10990 tinymce.create('tinymce.WindowManager', {
10991 WindowManager : function(ed) {
10995 t.onOpen = new Dispatcher(t);
10996 t.onClose = new Dispatcher(t);
11001 open : function(s, p) {
11002 var t = this, f = '', x, y, mo = t.editor.settings.dialog_type == 'modal', w, sw, sh, vp = tinymce.DOM.getViewPort(), u;
11004 // Default some options
11007 sw = isOpera ? vp.w : screen.width; // Opera uses windows inside the Opera window
11008 sh = isOpera ? vp.h : screen.height;
11009 s.name = s.name || 'mc_' + new Date().getTime();
11010 s.width = parseInt(s.width || 320);
11011 s.height = parseInt(s.height || 240);
11012 s.resizable = true;
11013 s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0);
11014 s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0);
11016 p.mce_width = s.width;
11017 p.mce_height = s.height;
11018 p.mce_auto_focus = s.auto_focus;
11024 s.dialogWidth = s.width + 'px';
11025 s.dialogHeight = s.height + 'px';
11026 s.scroll = s.scrollbars || false;
11030 // Build features string
11031 each(s, function(v, k) {
11032 if (tinymce.is(v, 'boolean'))
11033 v = v ? 'yes' : 'no';
11035 if (!/^(name|url)$/.test(k)) {
11037 f += (f ? ';' : '') + k + ':' + v;
11039 f += (f ? ',' : '') + k + '=' + v;
11045 t.onOpen.dispatch(t, s, p);
11047 u = s.url || s.file;
11048 if (tinymce.relaxedDomain)
11049 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
11051 u = tinymce._addVer(u);
11056 window.showModalDialog(u, window, f);
11058 w = window.open(u, s.name, f);
11064 alert(t.editor.getLang('popup_blocked'));
11067 close : function(w) {
11069 this.onClose.dispatch(this);
11072 createInstance : function(cl, a, b, c, d, e) {
11073 var f = tinymce.resolve(cl);
11075 return new f(a, b, c, d, e);
11078 confirm : function(t, cb, s, w) {
11081 cb.call(s || this, w.confirm(this._decode(this.editor.getLang(t, t))));
11084 alert : function(tx, cb, s, w) {
11088 w.alert(t._decode(t.editor.getLang(tx, tx)));
11094 // Internal functions
11096 _decode : function(s) {
11097 return tinymce.DOM.decode(s).replace(/\\n/g, '\n');