2 /* file:jscripts/tiny_mce/classes/tinymce.js */
\r
6 minorVersion : '2.1.1',
\r
7 releaseDate : '2008-11-27',
\r
10 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
\r
13 t.isOpera = w.opera && opera.buildNumber;
\r
14 t.isWebKit = /WebKit/.test(ua);
\r
15 t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt;
\r
16 t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
\r
17 t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
\r
18 t.isGecko = !t.isWebKit && /Gecko/.test(ua);
\r
19 t.isMac = ua.indexOf('Mac') != -1;
\r
20 t.isAir = /adobeair/i.test(ua);
\r
22 // TinyMCE .NET webcontrol might be setting the values for TinyMCE
\r
23 if (w.tinyMCEPreInit) {
\r
24 t.suffix = tinyMCEPreInit.suffix;
\r
25 t.baseURL = tinyMCEPreInit.base;
\r
26 t.query = tinyMCEPreInit.query;
\r
30 // Get suffix and base
\r
33 // If base element found, add that infront of baseURL
\r
34 nl = d.getElementsByTagName('base');
\r
35 for (i=0; i<nl.length; i++) {
\r
36 if (v = nl[i].href) {
\r
37 // Host only value like http://site.com or http://site.com:8008
\r
38 if (/^https?:\/\/[^\/]+$/.test(v))
\r
41 base = v ? v.match(/.*\//)[0] : ''; // Get only directory
\r
45 function getBase(n) {
\r
46 if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
\r
47 if (/_(src|dev)\.js/g.test(n.src))
\r
50 if ((p = n.src.indexOf('?')) != -1)
\r
51 t.query = n.src.substring(p + 1);
\r
53 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
\r
55 // If path to script is relative and a base href was found add that one infront
\r
56 if (base && t.baseURL.indexOf('://') == -1)
\r
57 t.baseURL = base + t.baseURL;
\r
66 nl = d.getElementsByTagName('script');
\r
67 for (i=0; i<nl.length; i++) {
\r
73 n = d.getElementsByTagName('head')[0];
\r
75 nl = n.getElementsByTagName('script');
\r
76 for (i=0; i<nl.length; i++) {
\r
85 is : function(o, t) {
\r
89 return n != 'undefined';
\r
91 if (t == 'array' && (o instanceof Array))
\r
99 each : function(o, cb, s) {
\r
107 if (typeof(o.length) != 'undefined') {
\r
108 // Indexed arrays, needed for Safari
\r
109 for (n=0, l = o.length; n<l; n++) {
\r
110 if (cb.call(s, o[n], n, o) === false)
\r
116 if (o.hasOwnProperty(n)) {
\r
117 if (cb.call(s, o[n], n, o) === false)
\r
126 map : function(a, f) {
\r
129 tinymce.each(a, function(v) {
\r
136 grep : function(a, f) {
\r
139 tinymce.each(a, function(v) {
\r
147 inArray : function(a, v) {
\r
151 for (i = 0, l = a.length; i < l; i++) {
\r
160 extend : function(o, e) {
\r
161 var i, a = arguments;
\r
163 for (i=1; i<a.length; i++) {
\r
166 tinymce.each(e, function(v, n) {
\r
167 if (typeof(v) !== 'undefined')
\r
175 trim : function(s) {
\r
176 return (s ? '' + s : '').replace(/^\s*|\s*$/g, '');
\r
181 create : function(s, p) {
\r
182 var t = this, sp, ns, cn, scn, c, de = 0;
\r
184 // Parse : <prefix> <class>:<super class>
\r
185 s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);
\r
186 cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name
\r
188 // Create namespace for new class
\r
189 ns = t.createNS(s[3].replace(/\.\w+$/, ''));
\r
191 // Class already exists
\r
195 // Make pure static class
\r
196 if (s[2] == 'static') {
\r
200 this.onCreate(s[2], s[3], ns[cn]);
\r
205 // Create default constructor
\r
207 p[cn] = function() {};
\r
211 // Add constructor and methods
\r
213 t.extend(ns[cn].prototype, p);
\r
217 sp = t.resolve(s[5]).prototype;
\r
218 scn = s[5].match(/\.(\w+)$/i)[1]; // Class name
\r
220 // Extend constructor
\r
223 // Add passthrough constructor
\r
224 ns[cn] = function() {
\r
225 return sp[scn].apply(this, arguments);
\r
228 // Add inherit constructor
\r
229 ns[cn] = function() {
\r
230 this.parent = sp[scn];
\r
231 return c.apply(this, arguments);
\r
234 ns[cn].prototype[cn] = ns[cn];
\r
236 // Add super methods
\r
237 t.each(sp, function(f, n) {
\r
238 ns[cn].prototype[n] = sp[n];
\r
241 // Add overridden methods
\r
242 t.each(p, function(f, n) {
\r
243 // Extend methods if needed
\r
245 ns[cn].prototype[n] = function() {
\r
246 this.parent = sp[n];
\r
247 return f.apply(this, arguments);
\r
251 ns[cn].prototype[n] = f;
\r
256 // Add static methods
\r
257 t.each(p['static'], function(f, n) {
\r
262 this.onCreate(s[2], s[3], ns[cn].prototype);
\r
265 walk : function(o, f, n, s) {
\r
272 tinymce.each(o, function(o, i) {
\r
273 if (f.call(s, o, i, n) === false)
\r
276 tinymce.walk(o, f, n, s);
\r
281 createNS : function(n, o) {
\r
287 for (i=0; i<n.length; i++) {
\r
299 resolve : function(n, o) {
\r
305 for (i=0, l = n.length; i<l; i++) {
\r
315 addUnload : function(f, s) {
\r
316 var t = this, w = window;
\r
318 f = {func : f, scope : s || this};
\r
321 function unload() {
\r
322 var li = t.unloads, o, n;
\r
325 // Call unload handlers
\r
330 o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
\r
333 // Detach unload function
\r
334 if (w.detachEvent) {
\r
335 w.detachEvent('onbeforeunload', fakeUnload);
\r
336 w.detachEvent('onunload', unload);
\r
337 } else if (w.removeEventListener)
\r
338 w.removeEventListener('unload', unload, false);
\r
340 // Destroy references
\r
341 t.unloads = o = li = w = unload = null;
\r
343 // Run garbarge collector on IE
\r
344 if (window.CollectGarbage)
\r
345 window.CollectGarbage();
\r
349 function fakeUnload() {
\r
352 // Is there things still loading, then do some magic
\r
353 if (d.readyState == 'interactive') {
\r
355 // Prevent memory leak
\r
356 d.detachEvent('onstop', stop);
\r
358 // Call unload handler
\r
364 // Fire unload when the currently loading page is stopped
\r
365 d.attachEvent('onstop', stop);
\r
367 // Remove onstop listener after a while to prevent the unload function
\r
368 // to execute if the user presses cancel in an onbeforeunload
\r
369 // confirm dialog and then presses the browser stop button
\r
370 window.setTimeout(function() {
\r
371 d.detachEvent('onstop', stop);
\r
376 // Attach unload handler
\r
377 if (w.attachEvent) {
\r
378 w.attachEvent('onunload', unload);
\r
379 w.attachEvent('onbeforeunload', fakeUnload);
\r
380 } else if (w.addEventListener)
\r
381 w.addEventListener('unload', unload, false);
\r
383 // Setup initial unload handler array
\r
391 removeUnload : function(f) {
\r
392 var u = this.unloads, r = null;
\r
394 tinymce.each(u, function(o, i) {
\r
395 if (o && o.func == f) {
\r
405 explode : function(s, d) {
\r
406 return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s;
\r
409 _addVer : function(u) {
\r
415 v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
\r
417 if (u.indexOf('#') == -1)
\r
420 return u.replace('#', v + '#');
\r
425 // Required for GZip AJAX loading
\r
426 window.tinymce = tinymce;
\r
428 // Initialize the API
\r
431 /* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */
\r
434 /* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */
\r
437 /* file:jscripts/tiny_mce/classes/util/Dispatcher.js */
\r
439 tinymce.create('tinymce.util.Dispatcher', {
\r
443 Dispatcher : function(s) {
\r
444 this.scope = s || this;
\r
445 this.listeners = [];
\r
448 add : function(cb, s) {
\r
449 this.listeners.push({cb : cb, scope : s || this.scope});
\r
454 addToTop : function(cb, s) {
\r
455 this.listeners.unshift({cb : cb, scope : s || this.scope});
\r
460 remove : function(cb) {
\r
461 var l = this.listeners, o = null;
\r
463 tinymce.each(l, function(c, i) {
\r
474 dispatch : function() {
\r
475 var s, a = arguments, i, li = this.listeners, c;
\r
477 // Needs to be a real loop since the listener count might change while looping
\r
478 // And this is also more efficient
\r
479 for (i = 0; i<li.length; i++) {
\r
481 s = c.cb.apply(c.scope, a);
\r
492 /* file:jscripts/tiny_mce/classes/util/URI.js */
\r
495 var each = tinymce.each;
\r
497 tinymce.create('tinymce.util.URI', {
\r
498 URI : function(u, s) {
\r
499 var t = this, o, a, b;
\r
501 // Default settings
\r
502 s = t.settings = s || {};
\r
504 // Strange app protocol or local anchor
\r
505 if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
\r
510 // Absolute path with no host, fake host and protocol
\r
511 if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
\r
512 u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
\r
515 if (u.indexOf(':/') === -1 && u.indexOf('//') !== 0)
\r
516 u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u);
\r
518 // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
\r
519 u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
\r
520 u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
\r
521 each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
\r
524 // Zope 3 workaround, they use @@something
\r
526 s = s.replace(/\(mce_at\)/g, '@@');
\r
531 if (b = s.base_uri) {
\r
533 t.protocol = b.protocol;
\r
536 t.userInfo = b.userInfo;
\r
538 if (!t.port && t.host == 'mce_host')
\r
541 if (!t.host || t.host == 'mce_host')
\r
547 //t.path = t.path || '/';
\r
550 setPath : function(p) {
\r
553 p = /^(.*?)\/?(\w+)?$/.exec(p);
\r
555 // Update path parts
\r
557 t.directory = p[1];
\r
565 toRelative : function(u) {
\r
571 u = new tinymce.util.URI(u, {base_uri : t});
\r
573 // Not on same domain/port or protocol
\r
574 if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
\r
577 o = t.toRelPath(t.path, u.path);
\r
581 o += '?' + u.query;
\r
585 o += '#' + u.anchor;
\r
590 toAbsolute : function(u, nh) {
\r
591 var u = new tinymce.util.URI(u, {base_uri : this});
\r
593 return u.getURI(this.host == u.host ? nh : 0);
\r
596 toRelPath : function(base, path) {
\r
597 var items, bp = 0, out = '', i, l;
\r
600 base = base.substring(0, base.lastIndexOf('/'));
\r
601 base = base.split('/');
\r
602 items = path.split('/');
\r
604 if (base.length >= items.length) {
\r
605 for (i = 0, l = base.length; i < l; i++) {
\r
606 if (i >= items.length || base[i] != items[i]) {
\r
613 if (base.length < items.length) {
\r
614 for (i = 0, l = items.length; i < l; i++) {
\r
615 if (i >= base.length || base[i] != items[i]) {
\r
625 for (i = 0, l = base.length - (bp - 1); i < l; i++)
\r
628 for (i = bp - 1, l = items.length; i < l; i++) {
\r
630 out += "/" + items[i];
\r
638 toAbsPath : function(base, path) {
\r
639 var i, nb = 0, o = [];
\r
642 base = base.split('/');
\r
643 path = path.split('/');
\r
645 // Remove empty chunks
\r
646 each(base, function(k) {
\r
653 // Merge relURLParts chunks
\r
654 for (i = path.length - 1, o = []; i >= 0; i--) {
\r
655 // Ignore empty or .
\r
656 if (path[i].length == 0 || path[i] == ".")
\r
660 if (path[i] == '..') {
\r
674 i = base.length - nb;
\r
678 return '/' + o.reverse().join('/');
\r
680 return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
\r
683 getURI : function(nh) {
\r
687 if (!t.source || nh) {
\r
692 s += t.protocol + '://';
\r
695 s += t.userInfo + '@';
\r
708 s += '?' + t.query;
\r
711 s += '#' + t.anchor;
\r
722 /* file:jscripts/tiny_mce/classes/util/Cookie.js */
\r
725 var each = tinymce.each;
\r
727 tinymce.create('static tinymce.util.Cookie', {
\r
728 getHash : function(n) {
\r
729 var v = this.get(n), h;
\r
732 each(v.split('&'), function(v) {
\r
735 h[unescape(v[0])] = unescape(v[1]);
\r
742 setHash : function(n, v, e, p, d, s) {
\r
745 each(v, function(v, k) {
\r
746 o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
\r
749 this.set(n, o, e, p, d, s);
\r
752 get : function(n) {
\r
753 var c = document.cookie, e, p = n + "=", b;
\r
759 b = c.indexOf("; " + p);
\r
769 e = c.indexOf(";", b);
\r
774 return unescape(c.substring(b + p.length, e));
\r
777 set : function(n, v, e, p, d, s) {
\r
778 document.cookie = n + "=" + escape(v) +
\r
779 ((e) ? "; expires=" + e.toGMTString() : "") +
\r
780 ((p) ? "; path=" + escape(p) : "") +
\r
781 ((d) ? "; domain=" + d : "") +
\r
782 ((s) ? "; secure" : "");
\r
785 remove : function(n, p) {
\r
786 var d = new Date();
\r
788 d.setTime(d.getTime() - 1000);
\r
790 this.set(n, '', d, p, d);
\r
796 /* file:jscripts/tiny_mce/classes/util/JSON.js */
\r
798 tinymce.create('static tinymce.util.JSON', {
\r
799 serialize : function(o) {
\r
800 var i, v, s = tinymce.util.JSON.serialize, t;
\r
807 if (t == 'string') {
\r
808 v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
\r
810 return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) {
\r
814 return '\\' + v.charAt(i + 1);
\r
816 a = b.charCodeAt().toString(16);
\r
818 return '\\u' + '0000'.substring(a.length) + a;
\r
822 if (t == 'object') {
\r
823 if (o instanceof Array) {
\r
824 for (i=0, v = '['; i<o.length; i++)
\r
825 v += (i > 0 ? ',' : '') + s(o[i]);
\r
833 v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
\r
841 parse : function(s) {
\r
843 return eval('(' + s + ')');
\r
851 /* file:jscripts/tiny_mce/classes/util/XHR.js */
\r
853 tinymce.create('static tinymce.util.XHR', {
\r
854 send : function(o) {
\r
855 var x, t, w = window, c = 0;
\r
857 // Default settings
\r
858 o.scope = o.scope || this;
\r
859 o.success_scope = o.success_scope || o.scope;
\r
860 o.error_scope = o.error_scope || o.scope;
\r
861 o.async = o.async === false ? false : true;
\r
862 o.data = o.data || '';
\r
868 x = new ActiveXObject(s);
\r
875 x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
\r
878 if (x.overrideMimeType)
\r
879 x.overrideMimeType(o.content_type);
\r
881 x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
\r
883 if (o.content_type)
\r
884 x.setRequestHeader('Content-Type', o.content_type);
\r
889 if (!o.async || x.readyState == 4 || c++ > 10000) {
\r
890 if (o.success && c < 10000 && x.status == 200)
\r
891 o.success.call(o.success_scope, '' + x.responseText, x, o);
\r
893 o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
\r
897 w.setTimeout(ready, 10);
\r
900 // Syncronous request
\r
904 // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
\r
905 t = w.setTimeout(ready, 10);
\r
911 /* file:jscripts/tiny_mce/classes/util/JSONRequest.js */
\r
914 var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
\r
916 tinymce.create('tinymce.util.JSONRequest', {
\r
917 JSONRequest : function(s) {
\r
918 this.settings = extend({
\r
923 send : function(o) {
\r
924 var ecb = o.error, scb = o.success;
\r
926 o = extend(this.settings, o);
\r
928 o.success = function(c, x) {
\r
931 if (typeof(c) == 'undefined') {
\r
933 error : 'JSON Parse error.'
\r
938 ecb.call(o.error_scope || o.scope, c.error, x);
\r
940 scb.call(o.success_scope || o.scope, c.result);
\r
943 o.error = function(ty, x) {
\r
944 ecb.call(o.error_scope || o.scope, ty, x);
\r
947 o.data = JSON.serialize({
\r
948 id : o.id || 'c' + (this.count++),
\r
953 // JSON content type for Ruby on rails. Bug: #1883287
\r
954 o.content_type = 'application/json';
\r
960 sendRPC : function(o) {
\r
961 return new tinymce.util.JSONRequest().send(o);
\r
967 /* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */
\r
971 var each = tinymce.each, is = tinymce.is;
\r
972 var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE;
\r
974 tinymce.create('tinymce.dom.DOMUtils', {
\r
979 pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/,
\r
981 idPattern : /^#[\w]+$/,
\r
982 elmPattern : /^[\w_*]+$/,
\r
983 elmClassPattern : /^([\w_]*)\.([\w_]+)$/,
\r
986 "class" : "className",
\r
987 className : "className",
\r
988 checked : "checked",
\r
989 disabled : "disabled",
\r
990 maxlength : "maxLength",
\r
991 readonly : "readOnly",
\r
992 selected : "selected",
\r
999 DOMUtils : function(d, s) {
\r
1005 t.cssFlicker = false;
\r
1007 t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat";
\r
1008 t.stdMode = d.documentMode === 8;
\r
1010 this.settings = s = tinymce.extend({
\r
1011 keep_values : false,
\r
1016 // Fix IE6SP2 flicker and check it failed for pre SP2
\r
1017 if (tinymce.isIE6) {
\r
1019 d.execCommand('BackgroundImageCache', false, true);
\r
1021 t.cssFlicker = true;
\r
1025 tinymce.addUnload(t.destroy, t);
\r
1028 getRoot : function() {
\r
1029 var t = this, s = t.settings;
\r
1031 return (s && t.get(s.root_element)) || t.doc.body;
\r
1034 getViewPort : function(w) {
\r
1037 w = !w ? this.win : w;
\r
1039 b = this.boxModel ? d.documentElement : d.body;
\r
1041 // Returns viewport size excluding scrollbars
\r
1043 x : w.pageXOffset || b.scrollLeft,
\r
1044 y : w.pageYOffset || b.scrollTop,
\r
1045 w : w.innerWidth || b.clientWidth,
\r
1046 h : w.innerHeight || b.clientHeight
\r
1050 getRect : function(e) {
\r
1051 var p, t = this, sr;
\r
1055 sr = t.getSize(e);
\r
1065 getSize : function(e) {
\r
1066 var t = this, w, h;
\r
1069 w = t.getStyle(e, 'width');
\r
1070 h = t.getStyle(e, 'height');
\r
1072 // Non pixel value, then force offset/clientWidth
\r
1073 if (w.indexOf('px') === -1)
\r
1076 // Non pixel value, then force offset/clientWidth
\r
1077 if (h.indexOf('px') === -1)
\r
1081 w : parseInt(w) || e.offsetWidth || e.clientWidth,
\r
1082 h : parseInt(h) || e.offsetHeight || e.clientHeight
\r
1086 getParent : function(n, f, r) {
\r
1087 var na, se = this.settings;
\r
1091 if (se.strict_root)
\r
1092 r = r || this.getRoot();
\r
1094 // Wrap node name as func
\r
1095 if (is(f, 'string')) {
\r
1096 na = f.toUpperCase();
\r
1102 if (n.nodeType == 1 && na === '*') {
\r
1107 each(na.split(','), function(v) {
\r
1108 if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName.toUpperCase() == v)) {
\r
1110 return false; // Break loop
\r
1131 get : function(e) {
\r
1134 if (e && this.doc && typeof(e) == 'string') {
\r
1136 e = this.doc.getElementById(e);
\r
1138 // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick
\r
1139 if (e && e.id !== n)
\r
1140 return this.doc.getElementsByName(n)[1];
\r
1149 select : function(pa, s) {
\r
1150 var t = this, cs, c, pl, o = [], x, i, l, n, xp;
\r
1152 s = t.get(s) || t.doc;
\r
1154 // Look for native support and use that if it's found
\r
1155 if (s.querySelectorAll) {
\r
1156 // Element scope then use temp id
\r
1157 // We need to do this to be compatible with other implementations
\r
1158 // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461
\r
1162 pa = '#_mc_tmp ' + pa;
\r
1165 // Select elements
\r
1166 l = tinymce.grep(s.querySelectorAll(pa));
\r
1174 if (!t.selectorRe)
\r
1175 t.selectorRe = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i;;
\r
1177 // Air doesn't support eval due to security sandboxing and querySelectorAll isn't supported yet
\r
1178 if (tinymce.isAir) {
\r
1179 each(tinymce.explode(pa), function(v) {
\r
1180 if (!(xp = t.cache[v])) {
\r
1183 each(v.split(' '), function(v) {
\r
1184 v = t.selectorRe.exec(v);
\r
1186 xp += v[1] ? '//' + v[1] : '//*';
\r
1190 xp += "[@id='" + v[2] + "']";
\r
1194 each(v[3].split('.'), function(n) {
\r
1195 xp += "[@class = '" + n + "' or contains(concat(' ', @class, ' '), ' " + n + " ')]";
\r
1203 xp = t.doc.evaluate(xp, s, null, 4, null);
\r
1205 while (n = xp.iterateNext())
\r
1212 if (t.settings.strict) {
\r
1213 function get(s, n) {
\r
1214 return s.getElementsByTagName(n.toLowerCase());
\r
1217 function get(s, n) {
\r
1218 return s.getElementsByTagName(n);
\r
1222 // Simple element pattern. For example: "p" or "*"
\r
1223 if (t.elmPattern.test(pa)) {
\r
1226 for (i = 0, l = x.length; i<l; i++)
\r
1232 // Simple class pattern. For example: "p.class" or ".class"
\r
1233 if (t.elmClassPattern.test(pa)) {
\r
1234 pl = t.elmClassPattern.exec(pa);
\r
1235 x = get(s, pl[1] || '*');
\r
1236 c = ' ' + pl[2] + ' ';
\r
1238 for (i = 0, l = x.length; i<l; i++) {
\r
1241 if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
\r
1248 function collect(n) {
\r
1249 if (!n.mce_save) {
\r
1255 function collectIE(n) {
\r
1256 if (!n.getAttribute('mce_save')) {
\r
1257 n.setAttribute('mce_save', '1');
\r
1262 function find(n, f, r) {
\r
1263 var i, l, nl = get(r, n);
\r
1265 for (i = 0, l = nl.length; i < l; i++)
\r
1269 each(pa.split(','), function(v, i) {
\r
1270 v = tinymce.trim(v);
\r
1272 // Simple element pattern, most common in TinyMCE
\r
1273 if (t.elmPattern.test(v)) {
\r
1274 each(get(s, v), function(n) {
\r
1281 // Simple element pattern with class, fairly common in TinyMCE
\r
1282 if (t.elmClassPattern.test(v)) {
\r
1283 x = t.elmClassPattern.exec(v);
\r
1285 each(get(s, x[1]), function(n) {
\r
1286 if (t.hasClass(n, x[2]))
\r
1293 if (!(cs = t.cache[pa])) {
\r
1294 cs = 'x=(function(cf, s) {';
\r
1295 pl = v.split(' ');
\r
1297 each(pl, function(v) {
\r
1298 var p = t.selectorRe.exec(v);
\r
1301 p[1] = p[1] || '*';
\r
1302 cs += 'find("' + p[1] + '", function(n) {';
\r
1306 cs += 'if (n.id !== "' + p[2] + '") return;';
\r
1310 cs += 'var c = " " + n.className + " ";';
\r
1313 each(p[3].split('.'), function(v) {
\r
1315 c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
\r
1317 cs += c + ') return;';
\r
1323 for (i = pl.length - 1; i >= 0; i--)
\r
1324 cs += '}, ' + (i ? 'n' : 's') + ');';
\r
1328 // Compile CSS pattern function
\r
1329 t.cache[pa] = cs = eval(cs);
\r
1332 // Run selector function
\r
1333 cs(isIE ? collectIE : collect, s);
\r
1337 each(o, function(n) {
\r
1339 n.removeAttribute('mce_save');
\r
1341 delete n.mce_save;
\r
1349 add : function(p, n, a, h, c) {
\r
1352 return this.run(p, function(p) {
\r
1355 e = is(n, 'string') ? t.doc.createElement(n) : n;
\r
1356 t.setAttribs(e, a);
\r
1365 return !c ? p.appendChild(e) : e;
\r
1369 create : function(n, a, h) {
\r
1370 return this.add(this.doc.createElement(n), n, a, h, 1);
\r
1373 createHTML : function(n, a, h) {
\r
1374 var o = '', t = this, k;
\r
1379 if (a.hasOwnProperty(k))
\r
1380 o += ' ' + k + '="' + t.encode(a[k]) + '"';
\r
1383 if (tinymce.is(h))
\r
1384 return o + '>' + h + '</' + n + '>';
\r
1389 remove : function(n, k) {
\r
1390 return this.run(n, function(n) {
\r
1399 each (n.childNodes, function(c) {
\r
1400 p.insertBefore(c.cloneNode(true), n);
\r
1404 // Fix IE psuedo leak
\r
1406 p = n.cloneNode(true);
\r
1412 return p.removeChild(n);
\r
1418 setStyle : function(n, na, v) {
\r
1421 return t.run(n, function(e) {
\r
1426 // Camelcase it, if needed
\r
1427 na = na.replace(/-(\D)/g, function(a, b){
\r
1428 return b.toUpperCase();
\r
1431 // Default px suffix on these
\r
1432 if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v)))
\r
1437 // IE specific opacity
\r
1439 s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")";
\r
1441 if (!n.currentStyle || !n.currentStyle.hasLayout)
\r
1442 s.display = 'inline-block';
\r
1445 // Fix for older browsers
\r
1446 s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || '';
\r
1450 isIE ? s.styleFloat = v : s.cssFloat = v;
\r
1457 // Force update of the style data
\r
1458 if (t.settings.update_styles)
\r
1459 t.setAttrib(e, 'mce_style');
\r
1463 getStyle : function(n, na, c) {
\r
1470 if (this.doc.defaultView && c) {
\r
1471 // Remove camelcase
\r
1472 na = na.replace(/[A-Z]/g, function(a){
\r
1477 return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na);
\r
1479 // Old safari might fail
\r
1484 // Camelcase it, if needed
\r
1485 na = na.replace(/-(\D)/g, function(a, b){
\r
1486 return b.toUpperCase();
\r
1489 if (na == 'float')
\r
1490 na = isIE ? 'styleFloat' : 'cssFloat';
\r
1493 if (n.currentStyle && c)
\r
1494 return n.currentStyle[na];
\r
1496 return n.style[na];
\r
1499 setStyles : function(e, o) {
\r
1500 var t = this, s = t.settings, ol;
\r
1502 ol = s.update_styles;
\r
1503 s.update_styles = 0;
\r
1505 each(o, function(v, n) {
\r
1506 t.setStyle(e, n, v);
\r
1509 // Update style info
\r
1510 s.update_styles = ol;
\r
1511 if (s.update_styles)
\r
1512 t.setAttrib(e, s.cssText);
\r
1515 setAttrib : function(e, n, v) {
\r
1518 // Whats the point
\r
1522 // Strict XML mode
\r
1523 if (t.settings.strict)
\r
1524 n = n.toLowerCase();
\r
1526 return this.run(e, function(e) {
\r
1527 var s = t.settings;
\r
1531 if (!is(v, 'string')) {
\r
1532 each(v, function(v, n) {
\r
1533 t.setStyle(e, n, v);
\r
1539 // No mce_style for elements with these since they might get resized by the user
\r
1540 if (s.keep_values) {
\r
1541 if (v && !t._isRes(v))
\r
1542 e.setAttribute('mce_style', v, 2);
\r
1544 e.removeAttribute('mce_style', 2);
\r
1547 e.style.cssText = v;
\r
1551 e.className = v || ''; // Fix IE null bug
\r
1556 if (s.keep_values) {
\r
1557 if (s.url_converter)
\r
1558 v = s.url_converter.call(s.url_converter_scope || t, v, n, e);
\r
1560 t.setAttrib(e, 'mce_' + n, v, 2);
\r
1566 e.setAttribute('mce_style', v);
\r
1570 if (is(v) && v !== null && v.length !== 0)
\r
1571 e.setAttribute(n, '' + v, 2);
\r
1573 e.removeAttribute(n, 2);
\r
1577 setAttribs : function(e, o) {
\r
1580 return this.run(e, function(e) {
\r
1581 each(o, function(v, n) {
\r
1582 t.setAttrib(e, n, v);
\r
1589 getAttrib : function(e, n, dv) {
\r
1594 if (!e || e.nodeType !== 1)
\r
1600 // Try the mce variant for these
\r
1601 if (/^(src|href|style|coords|shape)$/.test(n)) {
\r
1602 v = e.getAttribute("mce_" + n);
\r
1608 if (isIE && t.props[n]) {
\r
1609 v = e[t.props[n]];
\r
1610 v = v && v.nodeValue ? v.nodeValue : v;
\r
1614 v = e.getAttribute(n, 2);
\r
1616 if (n === 'style') {
\r
1617 v = v || e.style.cssText;
\r
1620 v = t.serializeStyle(t.parseStyle(v));
\r
1622 if (t.settings.keep_values && !t._isRes(v))
\r
1623 e.setAttribute('mce_style', v);
\r
1627 // Remove Apple and WebKit stuff
\r
1628 if (isWebKit && n === "class" && v)
\r
1629 v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, '');
\r
1631 // Handle IE issues
\r
1636 // IE returns 1 as default value
\r
1643 // IE returns +0 as default value for size
\r
1644 if (v === '+0' || v === 20)
\r
1661 // IE returns -1 as default value
\r
1669 // IE returns default value
\r
1670 if (v === 32768 || v === 2147483647 || v === '32768')
\r
1684 v = v.toLowerCase();
\r
1688 // IE has odd anonymous function for event attributes
\r
1689 if (n.indexOf('on') === 0 && v)
\r
1690 v = ('' + v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/, '$1');
\r
1694 return (v !== undefined && v !== null && v !== '') ? '' + v : dv;
\r
1697 getPos : function(n) {
\r
1698 var t = this, x = 0, y = 0, e, d = t.doc, r;
\r
1702 // Use getBoundingClientRect on IE, Opera has it but it's not perfect
\r
1704 n = n.getBoundingClientRect();
\r
1705 e = t.boxModel ? d.documentElement : d.body;
\r
1706 x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
\r
1707 x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
\r
1708 n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
\r
1710 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
\r
1715 x += r.offsetLeft || 0;
\r
1716 y += r.offsetTop || 0;
\r
1717 r = r.offsetParent;
\r
1722 // Opera 9.25 bug fix, fixed in 9.50
\r
1723 if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
\r
1724 x -= r.scrollLeft || 0;
\r
1725 y -= r.scrollTop || 0;
\r
1734 return {x : x, y : y};
\r
1737 parseStyle : function(st) {
\r
1738 var t = this, s = t.settings, o = {};
\r
1743 function compress(p, s, ot) {
\r
1746 // Get values and check it it needs compressing
\r
1747 t = o[p + '-top' + s];
\r
1751 r = o[p + '-right' + s];
\r
1755 b = o[p + '-bottom' + s];
\r
1759 l = o[p + '-left' + s];
\r
1765 delete o[p + '-top' + s];
\r
1766 delete o[p + '-right' + s];
\r
1767 delete o[p + '-bottom' + s];
\r
1768 delete o[p + '-left' + s];
\r
1771 function compress2(ta, a, b, c) {
\r
1787 o[ta] = o[a] + ' ' + o[b] + ' ' + o[c];
\r
1793 st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities
\r
1795 each(st.split(';'), function(v) {
\r
1799 v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities
\r
1800 v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
\r
1802 sv = tinymce.trim(v[1]);
\r
1803 sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];});
\r
1805 sv = sv.replace(/rgb\([^\)]+\)/g, function(v) {
\r
1806 return t.toHex(v);
\r
1809 if (s.url_converter) {
\r
1810 sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
\r
1811 return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')';
\r
1815 o[tinymce.trim(v[0]).toLowerCase()] = sv;
\r
1819 compress("border", "", "border");
\r
1820 compress("border", "-width", "border-width");
\r
1821 compress("border", "-color", "border-color");
\r
1822 compress("border", "-style", "border-style");
\r
1823 compress("padding", "", "padding");
\r
1824 compress("margin", "", "margin");
\r
1825 compress2('border', 'border-width', 'border-style', 'border-color');
\r
1828 // Remove pointless border
\r
1829 if (o.border == 'medium none')
\r
1836 serializeStyle : function(o) {
\r
1839 each(o, function(v, k) {
\r
1841 if (tinymce.isGecko && k.indexOf('-moz-') === 0)
\r
1846 case 'background-color':
\r
1847 v = v.toLowerCase();
\r
1851 s += (s ? ' ' : '') + k + ': ' + v + ';';
\r
1858 loadCSS : function(u) {
\r
1859 var t = this, d = t.doc;
\r
1864 each(u.split(','), function(u) {
\r
1868 t.files[u] = true;
\r
1869 t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
\r
1875 addClass : function(e, c) {
\r
1876 return this.run(e, function(e) {
\r
1882 if (this.hasClass(e, c))
\r
1883 return e.className;
\r
1885 o = this.removeClass(e, c);
\r
1887 return e.className = (o != '' ? (o + ' ') : '') + c;
\r
1891 removeClass : function(e, c) {
\r
1894 return t.run(e, function(e) {
\r
1897 if (t.hasClass(e, c)) {
\r
1899 re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
\r
1901 v = e.className.replace(re, ' ');
\r
1903 return e.className = tinymce.trim(v != ' ' ? v : '');
\r
1906 return e.className;
\r
1910 hasClass : function(n, c) {
\r
1916 return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1;
\r
1919 show : function(e) {
\r
1920 return this.setStyle(e, 'display', 'block');
\r
1923 hide : function(e) {
\r
1924 return this.setStyle(e, 'display', 'none');
\r
1927 isHidden : function(e) {
\r
1930 return !e || e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
\r
1935 uniqueId : function(p) {
\r
1936 return (!p ? 'mce_' : p) + (this.counter++);
\r
1939 setHTML : function(e, h) {
\r
1942 return this.run(e, function(e) {
\r
1943 var x, i, nl, n, p, x;
\r
1945 h = t.processHTML(h);
\r
1950 // IE will remove comments from the beginning
\r
1951 // unless you padd the contents with something
\r
1952 e.innerHTML = '<br />' + h;
\r
1953 e.removeChild(e.firstChild);
\r
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
\r
1956 // This seems to fix this problem
\r
1958 // Remove all child nodes
\r
1959 while (e.firstChild)
\r
1960 e.firstChild.removeNode();
\r
1962 // Create new div with HTML contents and a BR infront to keep comments
\r
1963 x = t.create('div');
\r
1964 x.innerHTML = '<br />' + h;
\r
1966 // Add all children from div to target
\r
1967 each (x.childNodes, function(n, i) {
\r
1968 // Skip br element
\r
1975 // IE has a serious bug when it comes to paragraphs it can produce an invalid
\r
1976 // DOM tree if contents like this <p><ul><li>Item 1</li></ul></p> is inserted
\r
1977 // It seems to be that IE doesn't like a root block element placed inside another root block element
\r
1978 if (t.settings.fix_ie_paragraphs)
\r
1979 h = h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi, '<p$1 mce_keep="true"> </p>');
\r
1983 if (t.settings.fix_ie_paragraphs) {
\r
1984 // Check for odd paragraphs this is a sign of a broken DOM
\r
1985 nl = e.getElementsByTagName("p");
\r
1986 for (i = nl.length - 1, x = 0; i >= 0; i--) {
\r
1989 if (!n.hasChildNodes()) {
\r
1990 if (!n.mce_keep) {
\r
1991 x = 1; // Is broken
\r
1995 n.removeAttribute('mce_keep');
\r
2000 // Time to fix the madness IE left us
\r
2002 // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
\r
2003 // after we use innerHTML we can fix the DOM tree
\r
2004 h = h.replace(/<p ([^>]+)>|<p>/g, '<div $1 mce_tmp="1">');
\r
2005 h = h.replace(/<\/p>/g, '</div>');
\r
2007 // Set the new HTML with DIVs
\r
2010 // Replace all DIV elements with he mce_tmp attibute back to paragraphs
\r
2011 // This is needed since IE has a annoying bug see above for details
\r
2012 // This is a slow process but it has to be done. :(
\r
2013 if (t.settings.fix_ie_paragraphs) {
\r
2014 nl = e.getElementsByTagName("DIV");
\r
2015 for (i = nl.length - 1; i >= 0; i--) {
\r
2018 // Is it a temp div
\r
2020 // Create new paragraph
\r
2021 p = t.doc.createElement('p');
\r
2023 // Copy all attributes
\r
2024 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
\r
2027 if (b !== 'mce_tmp') {
\r
2028 v = n.getAttribute(b);
\r
2030 if (!v && b === 'class')
\r
2033 p.setAttribute(b, v);
\r
2037 // Append all children to new paragraph
\r
2038 for (x = 0; x<n.childNodes.length; x++)
\r
2039 p.appendChild(n.childNodes[x].cloneNode(true));
\r
2041 // Replace div with new paragraph
\r
2054 processHTML : function(h) {
\r
2055 var t = this, s = t.settings;
\r
2057 if (!s.process_html)
\r
2060 // Convert strong and em to b and i in FF since it can't handle them
\r
2061 if (tinymce.isGecko) {
\r
2062 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
\r
2063 h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
\r
2064 } else if (isIE) {
\r
2065 h = h.replace(/'/g, '''); // IE can't handle apos
\r
2066 h = h.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi, ''); // IE doesn't handle default values correct
\r
2069 // Fix some issues
\r
2070 h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open
\r
2072 // Store away src and href in mce_src and mce_href since browsers mess them up
\r
2073 if (s.keep_values) {
\r
2074 // Wrap scripts and styles in comments for serialization purposes
\r
2075 if (/<script|style/.test(h)) {
\r
2076 function trim(s) {
\r
2077 // Remove prefix and suffix code for element
\r
2078 s = s.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n');
\r
2079 s = s.replace(/^[\r\n]*|[\r\n]*$/g, '');
\r
2080 s = s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<!\[CDATA\[|<!--|<!\[CDATA\[)[\r\n]*/g, '');
\r
2081 s = s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->|\]\]-->)\s*$/g, '');
\r
2086 // Preserve script elements
\r
2087 h = h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g, function(v, a, b) {
\r
2088 // Remove prefix and suffix code for script element
\r
2091 // Force type attribute
\r
2093 a = ' type="text/javascript"';
\r
2095 // Wrap contents in a comment
\r
2097 b = '<!--\n' + b + '\n// -->';
\r
2099 // Output fake element
\r
2100 return '<mce:script' + a + '>' + b + '</mce:script>';
\r
2103 // Preserve style elements
\r
2104 h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g, function(v, a, b) {
\r
2106 return '<mce:style' + a + '><!--\n' + b + '\n--></mce:style><style' + a + ' mce_bogus="1">' + b + '</style>';
\r
2110 h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->');
\r
2112 // Process all tags with src, href or style
\r
2113 h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
\r
2114 function handle(m, b, c) {
\r
2117 // Tag already got a mce_ version
\r
2118 if (a.indexOf('mce_' + b) != -1)
\r
2121 if (b == 'style') {
\r
2122 // Why did I need this one?
\r
2124 // u = t.serializeStyle(t.parseStyle(u));
\r
2126 // No mce_style for elements with these since they might get resized by the user
\r
2130 if (s.hex_colors) {
\r
2131 u = u.replace(/rgb\([^\)]+\)/g, function(v) {
\r
2132 return t.toHex(v);
\r
2136 if (s.url_converter) {
\r
2137 u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
\r
2138 return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
\r
2141 } else if (b != 'coords' && b != 'shape') {
\r
2142 if (s.url_converter)
\r
2143 u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
\r
2146 return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
\r
2149 a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C
\r
2150 a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C
\r
2152 return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
\r
2159 getOuterHTML : function(e) {
\r
2168 return e.outerHTML;
\r
2170 d = (e.ownerDocument || this.doc).createElement("body");
\r
2171 d.appendChild(e.cloneNode(true));
\r
2173 return d.innerHTML;
\r
2176 setOuterHTML : function(e, h, d) {
\r
2179 return this.run(e, function(e) {
\r
2183 d = d || e.ownerDocument || t.doc;
\r
2185 if (isIE && e.nodeType == 1)
\r
2188 tp = d.createElement("body");
\r
2193 t.insertAfter(n.cloneNode(true), e);
\r
2194 n = n.previousSibling;
\r
2202 decode : function(s) {
\r
2205 // Look for entities to decode
\r
2206 if (/&[^;]+;/.test(s)) {
\r
2207 // Decode the entities using a div element not super efficient but less code
\r
2208 e = this.doc.createElement("div");
\r
2216 } while (n.nextSibling);
\r
2225 encode : function(s) {
\r
2226 return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
\r
2247 insertAfter : function(n, r) {
\r
2252 return this.run(n, function(n) {
\r
2256 ns = r.nextSibling;
\r
2259 p.insertBefore(n, ns);
\r
2269 isBlock : function(n) {
\r
2270 if (n.nodeType && n.nodeType !== 1)
\r
2273 n = n.nodeName || n;
\r
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);
\r
2280 replace : function(n, o, k) {
\r
2281 if (is(o, 'array'))
\r
2282 n = n.cloneNode(true);
\r
2284 return this.run(o, function(o) {
\r
2286 each(o.childNodes, function(c) {
\r
2287 n.appendChild(c.cloneNode(true));
\r
2291 // Fix IE psuedo leak for elements since replacing elements if fairly common
\r
2292 // Will break parentNode for some unknown reason
\r
2293 /* if (isIE && o.nodeType === 1) {
\r
2294 o.parentNode.insertBefore(n, o);
\r
2299 return o.parentNode.replaceChild(n, o);
\r
2305 toHex : function(s) {
\r
2306 var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
\r
2309 s = parseInt(s).toString(16);
\r
2311 return s.length > 1 ? s : '0' + s; // 0 -> 00
\r
2315 s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
\r
2323 getClasses : function() {
\r
2324 var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
\r
2329 function addClasses(s) {
\r
2330 // IE style imports
\r
2331 each(s.imports, function(r) {
\r
2335 each(s.cssRules || s.rules, function(r) {
\r
2336 // Real type or fake it on IE
\r
2337 switch (r.type || 1) {
\r
2340 if (r.selectorText) {
\r
2341 each(r.selectorText.split(','), function(v) {
\r
2342 v = v.replace(/^\s*|\s*$|^\s\./g, "");
\r
2344 // Is internal or it doesn't contain a class
\r
2345 if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v))
\r
2348 // Remove everything but class name
\r
2350 v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1');
\r
2353 if (f && !(v = f(v, ov)))
\r
2357 cl.push({'class' : v});
\r
2366 addClasses(r.styleSheet);
\r
2373 each(t.doc.styleSheets, addClasses);
\r
2378 if (cl.length > 0)
\r
2384 run : function(e, f, s) {
\r
2387 if (t.doc && typeof(e) === 'string')
\r
2394 if (!e.nodeType && (e.length || e.length === 0)) {
\r
2397 each(e, function(e, i) {
\r
2399 if (typeof(e) == 'string')
\r
2400 e = t.doc.getElementById(e);
\r
2402 o.push(f.call(s, e, i));
\r
2409 return f.call(s, e);
\r
2412 getAttribs : function(n) {
\r
2423 // Object will throw exception in IE
\r
2424 if (n.nodeName == 'OBJECT')
\r
2425 return n.attributes;
\r
2427 // It's crazy that this is faster in IE but it's because it returns all attributes all the time
\r
2428 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
\r
2429 o.push({specified : 1, nodeName : b});
\r
2435 return n.attributes;
\r
2438 destroy : function(s) {
\r
2441 t.win = t.doc = t.root = null;
\r
2443 // Manual destroy then remove unload handler
\r
2445 tinymce.removeUnload(t.destroy);
\r
2448 _isRes : function(c) {
\r
2449 // Is live resizble element
\r
2450 return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c);
\r
2454 walk : function(n, f, s) {
\r
2455 var d = this.doc, w;
\r
2457 if (d.createTreeWalker) {
\r
2458 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
2460 while ((n = w.nextNode()) != null)
\r
2461 f.call(s || this, n);
\r
2463 tinymce.walk(n, f, 'childNodes', s);
\r
2468 toRGB : function(s) {
\r
2469 var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
\r
2472 // #FFF -> #FFFFFF
\r
2474 c[3] = c[2] = c[1];
\r
2476 return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
\r
2486 tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
\r
2489 /* file:jscripts/tiny_mce/classes/dom/Event.js */
\r
2493 var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
\r
2495 tinymce.create('static tinymce.dom.Event', {
\r
2501 add : function(o, n, f, s) {
\r
2502 var cb, t = this, el = t.events, r;
\r
2505 if (o && o instanceof Array) {
\r
2508 each(o, function(o) {
\r
2510 r.push(t.add(o, n, f, s));
\r
2521 // Setup event callback
\r
2522 cb = function(e) {
\r
2523 e = e || window.event;
\r
2525 // Patch in target in IE it's W3C valid
\r
2526 if (e && !e.target && isIE)
\r
2527 e.target = e.srcElement;
\r
2532 return f.call(s, e);
\r
2535 if (n == 'unload') {
\r
2536 tinymce.unloads.unshift({func : cb});
\r
2540 if (n == 'init') {
\r
2549 // Store away listener reference
\r
2563 remove : function(o, n, f) {
\r
2564 var t = this, a = t.events, s = false, r;
\r
2567 if (o && o instanceof Array) {
\r
2570 each(o, function(o) {
\r
2572 r.push(t.remove(o, n, f));
\r
2580 each(a, function(e, i) {
\r
2581 if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
\r
2583 t._remove(o, n, e.cfunc);
\r
2592 clear : function(o) {
\r
2593 var t = this, a = t.events, i, e;
\r
2598 for (i = a.length - 1; i >= 0; i--) {
\r
2601 if (e.obj === o) {
\r
2602 t._remove(e.obj, e.name, e.cfunc);
\r
2603 e.obj = e.cfunc = null;
\r
2612 cancel : function(e) {
\r
2617 return this.prevent(e);
\r
2620 stop : function(e) {
\r
2621 if (e.stopPropagation)
\r
2622 e.stopPropagation();
\r
2624 e.cancelBubble = true;
\r
2629 prevent : function(e) {
\r
2630 if (e.preventDefault)
\r
2631 e.preventDefault();
\r
2633 e.returnValue = false;
\r
2638 _unload : function() {
\r
2641 each(t.events, function(e, i) {
\r
2642 t._remove(e.obj, e.name, e.cfunc);
\r
2643 e.obj = e.cfunc = null;
\r
2650 _add : function(o, n, f) {
\r
2651 if (o.attachEvent)
\r
2652 o.attachEvent('on' + n, f);
\r
2653 else if (o.addEventListener)
\r
2654 o.addEventListener(n, f, false);
\r
2659 _remove : function(o, n, f) {
\r
2662 if (o.detachEvent)
\r
2663 o.detachEvent('on' + n, f);
\r
2664 else if (o.removeEventListener)
\r
2665 o.removeEventListener(n, f, false);
\r
2667 o['on' + n] = null;
\r
2669 // Might fail with permission denined on IE so we just ignore that
\r
2674 _pageInit : function() {
\r
2677 // Safari on Mac fires this twice
\r
2681 e._remove(window, 'DOMContentLoaded', e._pageInit);
\r
2682 e.domLoaded = true;
\r
2684 each(e.inits, function(c) {
\r
2691 _wait : function() {
\r
2694 // No need since the document is already loaded
\r
2695 if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
\r
2696 Event.domLoaded = 1;
\r
2700 if (isIE && document.location.protocol != 'https:') {
\r
2701 // Fake DOMContentLoaded on IE
\r
2702 document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
\r
2703 DOM.get("__ie_onload").onreadystatechange = function() {
\r
2704 if (this.readyState == "complete") {
\r
2705 Event._pageInit();
\r
2706 DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
\r
2710 Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
\r
2712 if (isIE || isWebKit) {
\r
2713 t = setInterval(function() {
\r
2714 if (/loaded|complete/.test(document.readyState)) {
\r
2716 Event._pageInit();
\r
2726 Event = tinymce.dom.Event;
\r
2728 // Dispatch DOM content loaded event for IE and Safari
\r
2730 tinymce.addUnload(Event._unload);
\r
2733 /* file:jscripts/tiny_mce/classes/dom/Element.js */
\r
2736 var each = tinymce.each;
\r
2738 tinymce.create('tinymce.dom.Element', {
\r
2739 Element : function(id, s) {
\r
2740 var t = this, dom, el;
\r
2744 t.dom = dom = s.dom || tinymce.DOM;
\r
2747 // Only IE leaks DOM references, this is a lot faster
\r
2748 if (!tinymce.isIE)
\r
2749 el = t.dom.get(t.id);
\r
2774 t[k] = function() {
\r
2775 var a = arguments, o;
\r
2778 if (tinymce.isOpera) {
\r
2781 each(arguments, function(v) {
\r
2785 Array.prototype.unshift.call(a, el || id);
\r
2787 o = dom[k].apply(dom, a);
\r
2795 on : function(n, f, s) {
\r
2796 return tinymce.dom.Event.add(this.id, n, f, s);
\r
2799 getXY : function() {
\r
2801 x : parseInt(this.getStyle('left')),
\r
2802 y : parseInt(this.getStyle('top'))
\r
2806 getSize : function() {
\r
2807 var n = this.dom.get(this.id);
\r
2810 w : parseInt(this.getStyle('width') || n.clientWidth),
\r
2811 h : parseInt(this.getStyle('height') || n.clientHeight)
\r
2815 moveTo : function(x, y) {
\r
2816 this.setStyles({left : x, top : y});
\r
2819 moveBy : function(x, y) {
\r
2820 var p = this.getXY();
\r
2822 this.moveTo(p.x + x, p.y + y);
\r
2825 resizeTo : function(w, h) {
\r
2826 this.setStyles({width : w, height : h});
\r
2829 resizeBy : function(w, h) {
\r
2830 var s = this.getSize();
\r
2832 this.resizeTo(s.w + w, s.h + h);
\r
2835 update : function(k) {
\r
2836 var t = this, b, dom = t.dom;
\r
2838 if (tinymce.isIE6 && t.settings.blocker) {
\r
2842 if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0)
\r
2845 // Remove blocker on remove
\r
2846 if (k == 'remove') {
\r
2847 dom.remove(t.blocker);
\r
2852 t.blocker = dom.uniqueId();
\r
2853 b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'});
\r
2854 dom.setStyle(b, 'opacity', 0);
\r
2856 b = dom.get(t.blocker);
\r
2858 dom.setStyle(b, 'left', t.getStyle('left', 1));
\r
2859 dom.setStyle(b, 'top', t.getStyle('top', 1));
\r
2860 dom.setStyle(b, 'width', t.getStyle('width', 1));
\r
2861 dom.setStyle(b, 'height', t.getStyle('height', 1));
\r
2862 dom.setStyle(b, 'display', t.getStyle('display', 1));
\r
2863 dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1);
\r
2870 /* file:jscripts/tiny_mce/classes/dom/Selection.js */
\r
2873 function trimNl(s) {
\r
2874 return s.replace(/[\n\r]+/g, '');
\r
2878 var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each;
\r
2880 tinymce.create('tinymce.dom.Selection', {
\r
2881 Selection : function(dom, win, serializer) {
\r
2886 t.serializer = serializer;
\r
2890 'onBeforeSetContent',
\r
2891 'onBeforeGetContent',
\r
2895 t[e] = new tinymce.util.Dispatcher(t);
\r
2899 tinymce.addUnload(t.destroy, t);
\r
2902 getContent : function(s) {
\r
2903 var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n;
\r
2908 s.format = s.format || 'html';
\r
2909 t.onBeforeGetContent.dispatch(t, s);
\r
2911 if (s.format == 'text')
\r
2912 return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : ''));
\r
2914 if (r.cloneContents) {
\r
2915 n = r.cloneContents();
\r
2919 } else if (is(r.item) || is(r.htmlText))
\r
2920 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
\r
2922 e.innerHTML = r.toString();
\r
2924 // Keep whitespace before and after
\r
2925 if (/^\s/.test(e.innerHTML))
\r
2928 if (/\s+$/.test(e.innerHTML))
\r
2931 s.getInner = true;
\r
2933 s.content = t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
\r
2934 t.onGetContent.dispatch(t, s);
\r
2939 setContent : function(h, s) {
\r
2940 var t = this, r = t.getRng(), c, d = t.win.document;
\r
2942 s = s || {format : 'html'};
\r
2944 h = s.content = t.dom.processHTML(h);
\r
2946 // Dispatch before set content event
\r
2947 t.onBeforeSetContent.dispatch(t, s);
\r
2950 if (r.insertNode) {
\r
2951 // Make caret marker since insertNode places the caret in the beginning of text after insert
\r
2952 h += '<span id="__caret">_</span>';
\r
2954 // Delete and insert new node
\r
2955 r.deleteContents();
\r
2956 r.insertNode(t.getRng().createContextualFragment(h));
\r
2958 // Move to caret marker
\r
2959 c = t.dom.get('__caret');
\r
2961 // Make sure we wrap it compleatly, Opera fails with a simple select call
\r
2962 r = d.createRange();
\r
2963 r.setStartBefore(c);
\r
2967 // Delete the marker, and hopefully the caret gets placed in the right location
\r
2968 d.execCommand('Delete', false, null);
\r
2970 // In case it's still there
\r
2971 t.dom.remove('__caret');
\r
2974 // Delete content and get caret text selection
\r
2975 d.execCommand('Delete', false, null);
\r
2982 // Dispatch set content event
\r
2983 t.onSetContent.dispatch(t, s);
\r
2986 getStart : function() {
\r
2987 var t = this, r = t.getRng(), e;
\r
2993 r = r.duplicate();
\r
2995 e = r.parentElement();
\r
2997 if (e && e.nodeName == 'BODY')
\r
2998 return e.firstChild;
\r
3002 e = r.startContainer;
\r
3004 if (e.nodeName == 'BODY')
\r
3005 return e.firstChild;
\r
3007 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
\r
3011 getEnd : function() {
\r
3012 var t = this, r = t.getRng(), e;
\r
3018 r = r.duplicate();
\r
3020 e = r.parentElement();
\r
3022 if (e && e.nodeName == 'BODY')
\r
3023 return e.lastChild;
\r
3027 e = r.endContainer;
\r
3029 if (e.nodeName == 'BODY')
\r
3030 return e.lastChild;
\r
3032 return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
\r
3036 getBookmark : function(si) {
\r
3037 var t = this, r = t.getRng(), tr, sx, sy, vp = t.dom.getViewPort(t.win), e, sp, bp, le, c = -0xFFFFFF, s, ro = t.dom.getRoot(), wb = 0, wa = 0, nv;
\r
3041 // Simple bookmark fast but not as persistent
\r
3042 if (si == 'simple')
\r
3043 return {rng : r, scrollX : sx, scrollY : sy};
\r
3047 // Control selection
\r
3051 each(t.dom.select(e.nodeName), function(n, i) {
\r
3067 tr = t.dom.doc.body.createTextRange();
\r
3068 tr.moveToElementText(ro);
\r
3069 tr.collapse(true);
\r
3070 bp = Math.abs(tr.move('character', c));
\r
3072 tr = r.duplicate();
\r
3073 tr.collapse(true);
\r
3074 sp = Math.abs(tr.move('character', c));
\r
3076 tr = r.duplicate();
\r
3077 tr.collapse(false);
\r
3078 le = Math.abs(tr.move('character', c)) - sp;
\r
3095 // Image selection
\r
3096 if (e && e.nodeName == 'IMG') {
\r
3105 function getPos(r, sn, en) {
\r
3106 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
\r
3108 while ((n = w.nextNode()) != null) {
\r
3117 p += trimNl(n.nodeValue || '').length;
\r
3123 // Caret or selection
\r
3124 if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
\r
3125 e = getPos(ro, s.anchorNode, s.focusNode);
\r
3128 return {scrollX : sx, scrollY : sy};
\r
3130 // Count whitespace before
\r
3131 trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
\r
3134 start : Math.max(e.start + s.anchorOffset - wb, 0),
\r
3135 end : Math.max(e.end + s.focusOffset - wb, 0),
\r
3138 beg : s.anchorOffset - wb == 0
\r
3141 e = getPos(ro, r.startContainer, r.endContainer);
\r
3143 // Count whitespace before start and end container
\r
3144 //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
\r
3145 //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
\r
3148 return {scrollX : sx, scrollY : sy};
\r
3151 start : Math.max(e.start + r.startOffset - wb, 0),
\r
3152 end : Math.max(e.end + r.endOffset - wa, 0),
\r
3155 beg : r.startOffset - wb == 0
\r
3160 moveToBookmark : function(b) {
\r
3161 var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv;
\r
3163 function getPos(r, sp, ep) {
\r
3164 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb;
\r
3166 while ((n = w.nextNode()) != null) {
\r
3169 nv = n.nodeValue || '';
\r
3170 //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
\r
3171 //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
\r
3173 nvl = trimNl(nv).length;
\r
3176 if (p >= sp && !d.startNode) {
\r
3177 o = sp - (p - nvl);
\r
3179 // Fix for odd quirk in FF
\r
3180 if (b.beg && o >= nvl)
\r
3184 d.startOffset = o + wb;
\r
3189 d.endOffset = ep - (p - nvl) + wb;
\r
3200 t.win.scrollTo(b.scrollX, b.scrollY);
\r
3202 // Handle explorer
\r
3217 // Handle control bookmark
\r
3219 r = ro.createControlRange();
\r
3221 each(t.dom.select(b.tag), function(n, i) {
\r
3226 // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
\r
3228 // Incorrect bookmark
\r
3232 r = s.createRange();
\r
3233 r.moveToElementText(ro);
\r
3235 r.moveStart('character', b.start);
\r
3236 r.moveEnd('character', b.length);
\r
3245 // Needed for some odd IE bug #1843306
\r
3257 s.removeAllRanges();
\r
3258 s.addRange(b.rng);
\r
3260 if (is(b.start) && is(b.end)) {
\r
3262 sd = getPos(ro, b.start, b.end);
\r
3265 r = t.dom.doc.createRange();
\r
3266 r.setStart(sd.startNode, sd.startOffset);
\r
3267 r.setEnd(sd.endNode, sd.endOffset);
\r
3268 s.removeAllRanges();
\r
3272 if (!tinymce.isOpera)
\r
3281 select : function(n, c) {
\r
3282 var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document;
\r
3284 function first(n) {
\r
3285 return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null;
\r
3288 function last(n) {
\r
3294 w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
3295 while (c = w.nextNode())
\r
3305 if (/^(IMG|TABLE)$/.test(n.nodeName)) {
\r
3306 r = b.createControlRange();
\r
3309 r = b.createTextRange();
\r
3310 r.moveToElementText(n);
\r
3315 // Throws illigal agrument in IE some times
\r
3323 //console.debug(fn, ln);
\r
3324 r = d.createRange();
\r
3325 r.setStart(fn, 0);
\r
3326 r.setEnd(ln, ln.nodeValue.length);
\r
3338 isCollapsed : function() {
\r
3339 var t = this, r = t.getRng(), s = t.getSel();
\r
3344 return !s || r.boundingWidth == 0 || r.collapsed;
\r
3347 collapse : function(b) {
\r
3348 var t = this, r = t.getRng(), n;
\r
3350 // Control range on IE
\r
3353 r = this.win.document.body.createTextRange();
\r
3354 r.moveToElementText(n);
\r
3361 getSel : function() {
\r
3362 var t = this, w = this.win;
\r
3364 return w.getSelection ? w.getSelection() : w.document.selection;
\r
3367 getRng : function() {
\r
3368 var t = this, s = t.getSel(), r;
\r
3372 r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange());
\r
3374 // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
\r
3377 // No range found then create an empty one
\r
3378 // This can occur when the editor is placed in a hidden container element on Gecko
\r
3379 // Or on IE when there was an exception
\r
3381 r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange();
\r
3386 setRng : function(r) {
\r
3390 s = this.getSel();
\r
3393 s.removeAllRanges();
\r
3400 // Needed for some odd IE bug #1843306
\r
3405 setNode : function(n) {
\r
3408 t.setContent(t.dom.getOuterHTML(n));
\r
3413 getNode : function() {
\r
3414 var t = this, r = t.getRng(), s = t.getSel(), e;
\r
3417 // Range maybe lost after the editor is made visible again
\r
3419 return t.dom.getRoot();
\r
3421 e = r.commonAncestorContainer;
\r
3423 // Handle selection a image or other control like element such as anchors
\r
3424 if (!r.collapsed) {
\r
3425 // If the anchor node is a element instead of a text node then return this element
\r
3426 if (tinymce.isWebKit && s.anchorNode && s.anchorNode.nodeType == 1)
\r
3427 return s.anchorNode.childNodes[s.anchorOffset];
\r
3429 if (r.startContainer == r.endContainer) {
\r
3430 if (r.startOffset - r.endOffset < 2) {
\r
3431 if (r.startContainer.hasChildNodes())
\r
3432 e = r.startContainer.childNodes[r.startOffset];
\r
3437 return t.dom.getParent(e, function(n) {
\r
3438 return n.nodeType == 1;
\r
3442 return r.item ? r.item(0) : r.parentElement();
\r
3445 destroy : function(s) {
\r
3450 // Manual destroy then remove unload handler
\r
3452 tinymce.removeUnload(t.destroy);
\r
3458 /* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */
\r
3461 tinymce.create('tinymce.dom.XMLWriter', {
\r
3464 XMLWriter : function(s) {
\r
3465 // Get XML document
\r
3466 function getXML() {
\r
3467 var i = document.implementation;
\r
3469 if (!i || !i.createDocument) {
\r
3471 try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
\r
3472 try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
\r
3474 return i.createDocument('', '', null);
\r
3477 this.doc = getXML();
\r
3479 // Since Opera and WebKit doesn't escape > into > we need to do it our self to normalize the output for all browsers
\r
3480 this.valid = tinymce.isOpera || tinymce.isWebKit;
\r
3485 reset : function() {
\r
3486 var t = this, d = t.doc;
\r
3489 d.removeChild(d.firstChild);
\r
3491 t.node = d.appendChild(d.createElement("html"));
\r
3494 writeStartElement : function(n) {
\r
3497 t.node = t.node.appendChild(t.doc.createElement(n));
\r
3500 writeAttribute : function(n, v) {
\r
3502 v = v.replace(/>/g, '%MCGT%');
\r
3504 this.node.setAttribute(n, v);
\r
3507 writeEndElement : function() {
\r
3508 this.node = this.node.parentNode;
\r
3511 writeFullEndElement : function() {
\r
3512 var t = this, n = t.node;
\r
3514 n.appendChild(t.doc.createTextNode(""));
\r
3515 t.node = n.parentNode;
\r
3518 writeText : function(v) {
\r
3520 v = v.replace(/>/g, '%MCGT%');
\r
3522 this.node.appendChild(this.doc.createTextNode(v));
\r
3525 writeCDATA : function(v) {
\r
3526 this.node.appendChild(this.doc.createCDATA(v));
\r
3529 writeComment : function(v) {
\r
3530 // Fix for bug #2035694
\r
3532 v = v.replace(/^\-|\-$/g, ' ');
\r
3534 this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' ')));
\r
3537 getContent : function() {
\r
3540 h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);
\r
3541 h = h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g, '');
\r
3542 h = h.replace(/ ?\/>/g, ' />');
\r
3545 h = h.replace(/\%MCGT%/g, '>');
\r
3553 /* file:jscripts/tiny_mce/classes/dom/StringWriter.js */
\r
3556 tinymce.create('tinymce.dom.StringWriter', {
\r
3563 StringWriter : function(s) {
\r
3564 this.settings = tinymce.extend({
\r
3565 indent_char : ' ',
\r
3572 reset : function() {
\r
3579 writeStartElement : function(n) {
\r
3580 this._writeAttributesEnd();
\r
3581 this.writeRaw('<' + n);
\r
3582 this.tags.push(n);
\r
3583 this.inAttr = true;
\r
3585 this.elementCount = this.count;
\r
3588 writeAttribute : function(n, v) {
\r
3591 t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"');
\r
3594 writeEndElement : function() {
\r
3597 if (this.tags.length > 0) {
\r
3598 n = this.tags.pop();
\r
3600 if (this._writeAttributesEnd(1))
\r
3601 this.writeRaw('</' + n + '>');
\r
3603 if (this.settings.indentation > 0)
\r
3604 this.writeRaw('\n');
\r
3608 writeFullEndElement : function() {
\r
3609 if (this.tags.length > 0) {
\r
3610 this._writeAttributesEnd();
\r
3611 this.writeRaw('</' + this.tags.pop() + '>');
\r
3613 if (this.settings.indentation > 0)
\r
3614 this.writeRaw('\n');
\r
3618 writeText : function(v) {
\r
3619 this._writeAttributesEnd();
\r
3620 this.writeRaw(this.encode(v));
\r
3624 writeCDATA : function(v) {
\r
3625 this._writeAttributesEnd();
\r
3626 this.writeRaw('<![CDATA[' + v + ']]>');
\r
3630 writeComment : function(v) {
\r
3631 this._writeAttributesEnd();
\r
3632 this.writeRaw('<!-- ' + v + '-->');
\r
3636 writeRaw : function(v) {
\r
3640 encode : function(s) {
\r
3641 return s.replace(/[<>&"]/g, function(v) {
\r
3660 getContent : function() {
\r
3664 _writeAttributesEnd : function(s) {
\r
3668 this.inAttr = false;
\r
3670 if (s && this.elementCount == this.count) {
\r
3671 this.writeRaw(' />');
\r
3675 this.writeRaw('>');
\r
3683 /* file:jscripts/tiny_mce/classes/dom/Serializer.js */
\r
3687 var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko;
\r
3689 // Returns only attribites that have values not all attributes in IE
\r
3690 function getIEAtts(n) {
\r
3693 // Object will throw exception in IE
\r
3694 if (n.nodeName == 'OBJECT')
\r
3695 return n.attributes;
\r
3697 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
\r
3698 o.push({specified : 1, nodeName : b});
\r
3704 function wildcardToRE(s) {
\r
3705 return s.replace(/([?+*])/g, '.$1');
\r
3708 tinymce.create('tinymce.dom.Serializer', {
\r
3709 Serializer : function(s) {
\r
3713 t.onPreProcess = new Dispatcher(t);
\r
3714 t.onPostProcess = new Dispatcher(t);
\r
3716 if (tinymce.relaxedDomain && tinymce.isGecko) {
\r
3717 // Gecko has a bug where we can't create a new XML document if domain relaxing is used
\r
3718 t.writer = new tinymce.dom.StringWriter();
\r
3721 t.writer = new tinymce.dom.XMLWriter();
\r
3723 // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
\r
3724 t.writer = new tinymce.dom.StringWriter();
\r
3728 // Default settings
\r
3729 t.settings = s = extend({
\r
3730 dom : tinymce.DOM,
\r
3734 invalid_attrs : /^(mce_|_moz_)/,
\r
3735 closed : /(br|hr|input|meta|img|link|param)/,
\r
3736 entity_encoding : 'named',
\r
3737 entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',
\r
3738 bool_attrs : /(checked|disabled|readonly|selected|nowrap)/,
\r
3739 valid_elements : '*[*]',
\r
3740 extended_valid_elements : 0,
\r
3741 valid_child_elements : 0,
\r
3742 invalid_elements : 0,
\r
3743 fix_table_elements : 0,
\r
3744 fix_list_elements : true,
\r
3745 fix_content_duplication : true,
\r
3746 convert_fonts_to_spans : false,
\r
3747 font_size_classes : 0,
\r
3748 font_size_style_values : 0,
\r
3749 apply_source_formatting : 0,
\r
3750 indent_mode : 'simple',
\r
3751 indent_char : '\t',
\r
3752 indent_levels : 1,
\r
3753 remove_linebreaks : 1,
\r
3754 remove_redundant_brs : 1,
\r
3755 element_format : 'xhtml'
\r
3760 if (s.remove_redundant_brs) {
\r
3761 t.onPostProcess.add(function(se, o) {
\r
3762 // Remove BR elements at end of list elements since they get rendered in IE
\r
3763 o.content = o.content.replace(/<br \/>(\s*<\/li>)/g, '$1');
\r
3767 // Remove XHTML element endings i.e. produce crap :) XHTML is better
\r
3768 if (s.element_format == 'html') {
\r
3769 t.onPostProcess.add(function(se, o) {
\r
3770 o.content = o.content.replace(/<([^>]+) \/>/g, '<$1>');
\r
3774 if (s.fix_list_elements) {
\r
3775 t.onPreProcess.add(function(se, o) {
\r
3776 var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np;
\r
3778 function prevNode(e, n) {
\r
3779 var a = n.split(','), i;
\r
3781 while ((e = e.previousSibling) != null) {
\r
3782 for (i=0; i<a.length; i++) {
\r
3783 if (e.nodeName == a[i])
\r
3791 for (x=0; x<a.length; x++) {
\r
3792 nl = t.dom.select(a[x], o.node);
\r
3794 for (i=0; i<nl.length; i++) {
\r
3798 if (r.test(p.nodeName)) {
\r
3799 np = prevNode(n, 'LI');
\r
3802 np = t.dom.create('li');
\r
3803 np.innerHTML = ' ';
\r
3804 np.appendChild(n);
\r
3805 p.insertBefore(np, p.firstChild);
\r
3807 np.appendChild(n);
\r
3814 if (s.fix_table_elements) {
\r
3815 t.onPreProcess.add(function(se, o) {
\r
3816 each(t.dom.select('table', o.node), function(e) {
\r
3817 var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns;
\r
3820 pa2 = pa.cloneNode(false);
\r
3823 for (n = e; n = n.parentNode;) {
\r
3831 for (i = pl.length - 1; i >= 0; i--) {
\r
3832 if (i == pl.length - 1) {
\r
3833 while (ns = pl[i - 1].nextSibling)
\r
3834 tm.appendChild(ns.parentNode.removeChild(ns));
\r
3836 n = pl[i].cloneNode(false);
\r
3839 while (ns = pl[i - 1].nextSibling)
\r
3840 n.appendChild(ns.parentNode.removeChild(ns));
\r
3843 tm = tm.appendChild(n);
\r
3847 e = t.dom.insertAfter(e.parentNode.removeChild(e), pa);
\r
3848 t.dom.insertAfter(e, pa);
\r
3849 t.dom.insertAfter(pa2, e);
\r
3856 setEntities : function(s) {
\r
3857 var t = this, a, i, l = {}, re = '', v;
\r
3859 // No need to setup more than once
\r
3860 if (t.entityLookup)
\r
3863 // Build regex and lookup array
\r
3865 for (i = 0; i < a.length; i += 2) {
\r
3868 // Don't add default & " etc.
\r
3869 if (v == 34 || v == 38 || v == 60 || v == 62)
\r
3872 l[String.fromCharCode(a[i])] = a[i + 1];
\r
3874 v = parseInt(a[i]).toString(16);
\r
3875 re += '\\u' + '0000'.substring(v.length) + v;
\r
3879 t.settings.entity_encoding = 'raw';
\r
3883 t.entitiesRE = new RegExp('[' + re + ']', 'g');
\r
3884 t.entityLookup = l;
\r
3887 setValidChildRules : function(s) {
\r
3888 this.childRules = null;
\r
3889 this.addValidChildRules(s);
\r
3892 addValidChildRules : function(s) {
\r
3893 var t = this, inst, intr, bloc;
\r
3898 inst = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
\r
3899 intr = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
\r
3900 bloc = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
\r
3902 each(s.split(','), function(s) {
\r
3903 var p = s.split(/\[|\]/), re;
\r
3906 each(p[1].split('|'), function(v) {
\r
3915 case '%itrans_na':
\r
3916 v = intr.substring(2);
\r
3923 case '%istrict_na':
\r
3924 v = inst.substring(2);
\r
3938 re = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
\r
3940 each(p[0].split('/'), function(s) {
\r
3941 t.childRules = t.childRules || {};
\r
3942 t.childRules[s] = re;
\r
3948 each(t.childRules, function(v, k) {
\r
3955 t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
\r
3957 /*console.debug(t.parentElementsRE.toString());
\r
3958 each(t.childRules, function(v) {
\r
3959 console.debug(v.toString());
\r
3963 setRules : function(s) {
\r
3969 t.validElements = {};
\r
3971 return t.addRules(s);
\r
3974 addRules : function(s) {
\r
3982 each(s.split(','), function(s) {
\r
3983 var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = [];
\r
3985 // Extend with default rules
\r
3987 at = tinymce.extend([], dr.attribs);
\r
3989 // Parse attributes
\r
3990 if (p.length > 1) {
\r
3991 each(p[1].split('|'), function(s) {
\r
3996 // Parse attribute rule
\r
3997 s = s.replace(/::/g, '~');
\r
3998 s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);
\r
3999 s[2] = s[2].replace(/~/g, ':');
\r
4001 // Add required attributes
\r
4002 if (s[1] == '!') {
\r
4007 // Remove inherited attributes
\r
4008 if (s[1] == '-') {
\r
4009 for (i = 0; i <at.length; i++) {
\r
4010 if (at[i].name == s[2]) {
\r
4018 // Add default attrib values
\r
4020 ar.defaultVal = s[4] || '';
\r
4023 // Add forced attrib values
\r
4025 ar.forcedVal = s[4];
\r
4028 // Add validation values
\r
4030 ar.validVals = s[4].split('?');
\r
4034 if (/[*.?]/.test(s[2])) {
\r
4036 ar.nameRE = new RegExp('^' + wildcardToRE(s[2]) + '$');
\r
4047 // Handle element names
\r
4048 each(tn, function(s, i) {
\r
4049 var pr = s.charAt(0), x = 1, ru = {};
\r
4051 // Extend with default rule data
\r
4054 ru.noEmpty = dr.noEmpty;
\r
4057 ru.fullEnd = dr.fullEnd;
\r
4060 ru.padd = dr.padd;
\r
4063 // Handle prefixes
\r
4066 ru.noEmpty = true;
\r
4070 ru.fullEnd = true;
\r
4081 tn[i] = s = s.substring(x);
\r
4082 t.validElements[s] = 1;
\r
4084 // Add element name or element regex
\r
4085 if (/[*.?]/.test(tn[0])) {
\r
4086 ru.nameRE = new RegExp('^' + wildcardToRE(tn[0]) + '$');
\r
4087 t.wildRules = t.wildRules || {};
\r
4088 t.wildRules.push(ru);
\r
4092 // Store away default rule
\r
4102 ru.requiredAttribs = ra;
\r
4105 // Build valid attributes regexp
\r
4107 each(va, function(v) {
\r
4111 s += '(' + wildcardToRE(v) + ')';
\r
4113 ru.validAttribsRE = new RegExp('^' + s.toLowerCase() + '$');
\r
4114 ru.wildAttribs = wat;
\r
4119 // Build valid elements regexp
\r
4121 each(t.validElements, function(v, k) {
\r
4128 t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$');
\r
4130 //console.debug(t.validElementsRE.toString());
\r
4131 //console.dir(t.rules);
\r
4132 //console.dir(t.wildRules);
\r
4135 findRule : function(n) {
\r
4136 var t = this, rl = t.rules, i, r;
\r
4147 for (i = 0; i < rl.length; i++) {
\r
4148 if (rl[i].nameRE.test(n))
\r
4155 findAttribRule : function(ru, n) {
\r
4156 var i, wa = ru.wildAttribs;
\r
4158 for (i = 0; i < wa.length; i++) {
\r
4159 if (wa[i].nameRE.test(n))
\r
4166 serialize : function(n, o) {
\r
4171 o.format = o.format || 'html';
\r
4173 n = n.cloneNode(true);
\r
4174 t.key = '' + (parseInt(t.key) + 1);
\r
4177 if (!o.no_events) {
\r
4179 t.onPreProcess.dispatch(t, o);
\r
4182 // Serialize HTML DOM into a string
\r
4184 t._serializeNode(n, o.getInner);
\r
4187 o.content = t.writer.getContent();
\r
4190 t.onPostProcess.dispatch(t, o);
\r
4192 t._postProcess(o);
\r
4195 return tinymce.trim(o.content);
\r
4198 // Internal functions
\r
4200 _postProcess : function(o) {
\r
4201 var t = this, s = t.settings, h = o.content, sc = [], p;
\r
4203 if (o.format == 'html') {
\r
4204 // Protect some elements
\r
4208 {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
\r
4209 {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
\r
4210 {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1},
\r
4211 {pattern : /(<!--\[CDATA\[)(.*?)(\]\]-->)/g}
\r
4218 if (s.entity_encoding !== 'raw')
\r
4221 // Use BR instead of padded P elements inside editor and use <p> </p> outside editor
\r
4223 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>');
\r
4225 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/
\r
4227 // Since Gecko and Safari keeps whitespace in the DOM we need to
\r
4228 // remove it inorder to match other browsers. But I think Gecko and Safari is right.
\r
4229 // This process is only done when getting contents out from the editor.
\r
4231 // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char
\r
4232 h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1> </p>' : '<p$1> </p>');
\r
4234 if (s.remove_linebreaks) {
\r
4235 h = h.replace(/\r?\n|\r/g, ' ');
\r
4236 h = h.replace(/(<[^>]+>)\s+/g, '$1 ');
\r
4237 h = h.replace(/\s+(<\/[^>]+>)/g, ' $1');
\r
4238 h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g, '<$1 $2>'); // Trim block start
\r
4239 h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g, '<$1>'); // Trim block start
\r
4240 h = h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g, '</$1>'); // Trim block end
\r
4243 // Simple indentation
\r
4244 if (s.apply_source_formatting && s.indent_mode == 'simple') {
\r
4245 // Add line breaks before and after block elements
\r
4246 h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n');
\r
4247 h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>');
\r
4248 h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '</$1>\n');
\r
4249 h = h.replace(/\n\n/g, '\n');
\r
4253 h = t._unprotect(h, p);
\r
4255 // Restore CDATA sections
\r
4256 h = h.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g, '<![CDATA[$1]]>');
\r
4258 // Restore the \u00a0 character if raw mode is enabled
\r
4259 if (s.entity_encoding == 'raw')
\r
4260 h = h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g, '<p$1>\u00a0</p>');
\r
4266 _serializeNode : function(n, inn) {
\r
4267 var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv;
\r
4269 if (!s.node_filter || s.node_filter(n)) {
\r
4270 switch (n.nodeType) {
\r
4271 case 1: // Element
\r
4272 if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus'))
\r
4276 hc = n.hasChildNodes();
\r
4277 nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase();
\r
4279 // Add correct prefix on IE
\r
4281 if (n.scopeName !== 'HTML' && n.scopeName !== 'html')
\r
4282 nn = n.scopeName + ':' + nn;
\r
4285 // Remove mce prefix on IE needed for the abbr element
\r
4286 if (nn.indexOf('mce:') === 0)
\r
4287 nn = nn.substring(4);
\r
4290 if (!t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) {
\r
4296 // Fix IE content duplication (DOM can have multiple copies of the same node)
\r
4297 if (s.fix_content_duplication) {
\r
4298 if (n.mce_serialized == t.key)
\r
4301 n.mce_serialized = t.key;
\r
4304 // IE sometimes adds a / infront of the node name
\r
4305 if (nn.charAt(0) == '/')
\r
4306 nn = nn.substring(1);
\r
4307 } else if (isGecko) {
\r
4308 // Ignore br elements
\r
4309 if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz')
\r
4313 // Check if valid child
\r
4314 if (t.childRules) {
\r
4315 if (t.parentElementsRE.test(t.elementName)) {
\r
4316 if (!t.childRules[t.elementName].test(nn)) {
\r
4322 t.elementName = nn;
\r
4325 ru = t.findRule(nn);
\r
4326 nn = ru.name || nn;
\r
4328 // Skip empty nodes or empty node name in IE
\r
4329 if ((!hc && ru.noEmpty) || (isIE && !nn)) {
\r
4335 if (ru.requiredAttribs) {
\r
4336 a = ru.requiredAttribs;
\r
4338 for (i = a.length - 1; i >= 0; i--) {
\r
4339 if (this.dom.getAttrib(n, a[i]) !== '')
\r
4343 // None of the required was there
\r
4350 w.writeStartElement(nn);
\r
4352 // Add ordered attributes
\r
4354 for (i=0, at = ru.attribs, l = at.length; i<l; i++) {
\r
4356 v = t._getAttrib(n, a);
\r
4359 w.writeAttribute(a.name, v);
\r
4363 // Add wild attributes
\r
4364 if (ru.validAttribsRE) {
\r
4365 at = isIE ? getIEAtts(n) : n.attributes;
\r
4366 for (i=at.length-1; i>-1; i--) {
\r
4369 if (no.specified) {
\r
4370 a = no.nodeName.toLowerCase();
\r
4372 if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a))
\r
4375 ar = t.findAttribRule(ru, a);
\r
4376 v = t._getAttrib(n, ar, a);
\r
4379 w.writeAttribute(a, v);
\r
4384 // Padd empty nodes with a
\r
4386 // If it has only one bogus child, padd it anyway workaround for <td><br /></td> bug
\r
4387 if (hc && (cn = n.firstChild) && cn.nodeType === 1 && n.childNodes.length === 1) {
\r
4388 if (cn.hasAttribute ? cn.hasAttribute('mce_bogus') : cn.getAttribute('mce_bogus'))
\r
4389 w.writeText('\u00a0');
\r
4391 w.writeText('\u00a0'); // No children then padd it
\r
4397 // Check if valid child
\r
4398 if (t.childRules && t.parentElementsRE.test(t.elementName)) {
\r
4399 if (!t.childRules[t.elementName].test(n.nodeName))
\r
4403 return w.writeText(n.nodeValue);
\r
4406 return w.writeCDATA(n.nodeValue);
\r
4408 case 8: // Comment
\r
4409 return w.writeComment(n.nodeValue);
\r
4411 } else if (n.nodeType == 1)
\r
4412 hc = n.hasChildNodes();
\r
4415 cn = n.firstChild;
\r
4418 t._serializeNode(cn);
\r
4419 t.elementName = nn;
\r
4420 cn = cn.nextSibling;
\r
4424 // Write element end
\r
4426 if (hc || !s.closed.test(nn))
\r
4427 w.writeFullEndElement();
\r
4429 w.writeEndElement();
\r
4433 _protect : function(o) {
\r
4436 o.items = o.items || [];
\r
4439 return s.replace(/[\r\n\\]/g, function(c) {
\r
4442 else if (c === '\\')
\r
4450 return s.replace(/\\[\\rn]/g, function(c) {
\r
4453 else if (c === '\\\\')
\r
4460 each(o.patterns, function(p) {
\r
4461 o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
\r
4468 return a + '<!--mce:' + (o.items.length - 1) + '-->' + c;
\r
4475 _unprotect : function(h, o) {
\r
4476 h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) {
\r
4477 return o.items[parseInt(b)];
\r
4485 _encode : function(h) {
\r
4486 var t = this, s = t.settings, l;
\r
4489 if (s.entity_encoding !== 'raw') {
\r
4490 if (s.entity_encoding.indexOf('named') != -1) {
\r
4491 t.setEntities(s.entities);
\r
4492 l = t.entityLookup;
\r
4494 h = h.replace(t.entitiesRE, function(a) {
\r
4498 a = '&' + v + ';';
\r
4504 if (s.entity_encoding.indexOf('numeric') != -1) {
\r
4505 h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
\r
4506 return '&#' + a.charCodeAt(0) + ';';
\r
4514 _setup : function() {
\r
4515 var t = this, s = this.settings;
\r
4522 t.setRules(s.valid_elements);
\r
4523 t.addRules(s.extended_valid_elements);
\r
4524 t.addValidChildRules(s.valid_child_elements);
\r
4526 if (s.invalid_elements)
\r
4527 t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
\r
4529 if (s.attrib_value_filter)
\r
4530 t.attribValueFilter = s.attribValueFilter;
\r
4533 _getAttrib : function(n, a, na) {
\r
4536 na = na || a.name;
\r
4538 if (a.forcedVal && (v = a.forcedVal)) {
\r
4539 if (v === '{$uid}')
\r
4540 return this.dom.uniqueId();
\r
4545 v = this.dom.getAttrib(n, na);
\r
4548 if (this.settings.bool_attrs.test(na) && v) {
\r
4549 v = ('' + v).toLowerCase();
\r
4551 if (v === 'false' || v === '0')
\r
4560 // Whats the point? Remove usless attribute value
\r
4567 if (this.attribValueFilter)
\r
4568 v = this.attribValueFilter(na, v, n);
\r
4570 if (a.validVals) {
\r
4571 for (i = a.validVals.length - 1; i >= 0; i--) {
\r
4572 if (v == a.validVals[i])
\r
4580 if (v === '' && typeof(a.defaultVal) != 'undefined') {
\r
4583 if (v === '{$uid}')
\r
4584 return this.dom.uniqueId();
\r
4588 // Remove internal mceItemXX classes when content is extracted from editor
\r
4589 if (na == 'class' && this.processObj.get)
\r
4590 v = v.replace(/\s?mceItem\w+\s?/g, '');
\r
4603 /* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */
\r
4606 var each = tinymce.each, Event = tinymce.dom.Event;
\r
4608 tinymce.create('tinymce.dom.ScriptLoader', {
\r
4609 ScriptLoader : function(s) {
\r
4610 this.settings = s || {};
\r
4615 isDone : function(u) {
\r
4616 return this.lookup[u] ? this.lookup[u].state == 2 : 0;
\r
4619 markDone : function(u) {
\r
4620 this.lookup[u] = {state : 2, url : u};
\r
4623 add : function(u, cb, s, pr) {
\r
4624 var t = this, lo = t.lookup, o;
\r
4627 // Is loaded fire callback
\r
4628 if (cb && o.state == 2)
\r
4629 cb.call(s || this);
\r
4634 o = {state : 0, url : u, func : cb, scope : s || this};
\r
4637 t.queue.unshift(o);
\r
4646 load : function(u, cb, s) {
\r
4649 if (o = t.lookup[u]) {
\r
4650 // Is loaded fire callback
\r
4651 if (cb && o.state == 2)
\r
4657 function loadScript(u) {
\r
4658 if (Event.domLoaded || t.settings.strict_mode) {
\r
4659 tinymce.util.XHR.send({
\r
4660 url : tinymce._addVer(u),
\r
4661 error : t.settings.error,
\r
4663 success : function(co) {
\r
4668 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
\r
4671 if (!tinymce.is(u, 'string')) {
\r
4672 each(u, function(u) {
\r
4686 loadQueue : function(cb, s) {
\r
4689 if (!t.queueLoading) {
\r
4690 t.queueLoading = 1;
\r
4691 t.queueCallbacks = [];
\r
4693 t.loadScripts(t.queue, function() {
\r
4694 t.queueLoading = 0;
\r
4699 each(t.queueCallbacks, function(o) {
\r
4700 o.func.call(o.scope);
\r
4704 t.queueCallbacks.push({func : cb, scope : s || t});
\r
4707 eval : function(co) {
\r
4710 // Evaluate script
\r
4711 if (!w.execScript) {
\r
4715 eval(co, w); // Firefox 3.0a8
\r
4718 w.execScript(co); // IE
\r
4721 loadScripts : function(sc, cb, s) {
\r
4722 var t = this, lo = t.lookup;
\r
4724 function done(o) {
\r
4725 o.state = 2; // Has been loaded
\r
4729 o.func.call(o.scope || t);
\r
4732 function allDone() {
\r
4735 // Check if all files are loaded
\r
4737 each(sc, function(o) {
\r
4740 if (o.state === 2) {// It has finished loading
\r
4747 // They are all loaded
\r
4748 if (l === 0 && cb) {
\r
4754 function load(o) {
\r
4758 o.state = 1; // Is loading
\r
4760 tinymce.dom.ScriptLoader.loadScript(o.url, function() {
\r
4766 tinymce.util.XHR.send({
\r
4768 error : t.settings.error,
\r
4769 success : function(co) {
\r
4778 each(sc, function(o) {
\r
4781 // Add to queue if needed
\r
4788 // Is already loading or has been loaded
\r
4792 if (!Event.domLoaded && !t.settings.strict_mode) {
\r
4795 // Add onload events
\r
4796 if (cb || o.func) {
\r
4797 o.state = 1; // Is loading
\r
4799 ix = tinymce.dom.ScriptLoader._addOnLoad(function() {
\r
4805 ol = ' onreadystatechange="';
\r
4809 ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"';
\r
4812 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
\r
4825 _addOnLoad : function(f) {
\r
4828 t._funcs = t._funcs || [];
\r
4831 return t._funcs.length - 1;
\r
4834 _onLoad : function(e, u, ix) {
\r
4835 if (!tinymce.isIE || e.readyState == 'complete')
\r
4836 this._funcs[ix].call(this);
\r
4839 loadScript : function(u, cb) {
\r
4840 var id = tinymce.DOM.uniqueId(), e;
\r
4844 tinymce.DOM.remove(id);
\r
4847 cb.call(document, u);
\r
4852 if (tinymce.isIE) {
\r
4853 /* Event.add(e, 'readystatechange', function(e) {
\r
4854 if (e.target && e.target.readyState == 'complete')
\r
4858 tinymce.util.XHR.send({
\r
4859 url : tinymce._addVer(u),
\r
4861 success : function(co) {
\r
4862 window.execScript(co);
\r
4867 e = tinymce.DOM.create('script', {id : id, type : 'text/javascript', src : tinymce._addVer(u)});
\r
4868 Event.add(e, 'load', done);
\r
4870 // Check for head or body
\r
4871 (document.getElementsByTagName('head')[0] || document.body).appendChild(e);
\r
4878 // Global script loader
\r
4879 tinymce.ScriptLoader = new tinymce.dom.ScriptLoader();
\r
4882 /* file:jscripts/tiny_mce/classes/ui/Control.js */
\r
4885 // Shorten class names
\r
4886 var DOM = tinymce.DOM, is = tinymce.is;
\r
4888 tinymce.create('tinymce.ui.Control', {
\r
4889 Control : function(id, s) {
\r
4891 this.settings = s = s || {};
\r
4892 this.rendered = false;
\r
4893 this.onRender = new tinymce.util.Dispatcher(this);
\r
4894 this.classPrefix = '';
\r
4895 this.scope = s.scope || this;
\r
4896 this.disabled = 0;
\r
4900 setDisabled : function(s) {
\r
4903 if (s != this.disabled) {
\r
4904 e = DOM.get(this.id);
\r
4906 // Add accessibility title for unavailable actions
\r
4907 if (e && this.settings.unavailable_prefix) {
\r
4909 this.prevTitle = e.title;
\r
4910 e.title = this.settings.unavailable_prefix + ": " + e.title;
\r
4912 e.title = this.prevTitle;
\r
4915 this.setState('Disabled', s);
\r
4916 this.setState('Enabled', !s);
\r
4917 this.disabled = s;
\r
4921 isDisabled : function() {
\r
4922 return this.disabled;
\r
4925 setActive : function(s) {
\r
4926 if (s != this.active) {
\r
4927 this.setState('Active', s);
\r
4932 isActive : function() {
\r
4933 return this.active;
\r
4936 setState : function(c, s) {
\r
4937 var n = DOM.get(this.id);
\r
4939 c = this.classPrefix + c;
\r
4942 DOM.addClass(n, c);
\r
4944 DOM.removeClass(n, c);
\r
4947 isRendered : function() {
\r
4948 return this.rendered;
\r
4951 renderHTML : function() {
\r
4954 renderTo : function(n) {
\r
4955 DOM.setHTML(n, this.renderHTML());
\r
4958 postRender : function() {
\r
4961 // Set pending states
\r
4962 if (is(t.disabled)) {
\r
4968 if (is(t.active)) {
\r
4975 remove : function() {
\r
4976 DOM.remove(this.id);
\r
4980 destroy : function() {
\r
4981 tinymce.dom.Event.clear(this.id);
\r
4986 /* file:jscripts/tiny_mce/classes/ui/Container.js */
\r
4988 tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
\r
4989 Container : function(id, s) {
\r
4990 this.parent(id, s);
\r
4991 this.controls = [];
\r
4995 add : function(c) {
\r
4996 this.lookup[c.id] = c;
\r
4997 this.controls.push(c);
\r
5002 get : function(n) {
\r
5003 return this.lookup[n];
\r
5009 /* file:jscripts/tiny_mce/classes/ui/Separator.js */
\r
5011 tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
\r
5012 Separator : function(id, s) {
\r
5013 this.parent(id, s);
\r
5014 this.classPrefix = 'mceSeparator';
\r
5017 renderHTML : function() {
\r
5018 return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
\r
5023 /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */
\r
5026 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
\r
5028 tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
\r
5029 MenuItem : function(id, s) {
\r
5030 this.parent(id, s);
\r
5031 this.classPrefix = 'mceMenuItem';
\r
5034 setSelected : function(s) {
\r
5035 this.setState('Selected', s);
\r
5036 this.selected = s;
\r
5039 isSelected : function() {
\r
5040 return this.selected;
\r
5043 postRender : function() {
\r
5048 // Set pending state
\r
5049 if (is(t.selected))
\r
5050 t.setSelected(t.selected);
\r
5056 /* file:jscripts/tiny_mce/classes/ui/Menu.js */
\r
5059 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
\r
5061 tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
\r
5062 Menu : function(id, s) {
\r
5067 t.collapsed = false;
\r
5069 t.onAddItem = new tinymce.util.Dispatcher(this);
\r
5072 expand : function(d) {
\r
5076 walk(t, function(o) {
\r
5082 t.collapsed = false;
\r
5085 collapse : function(d) {
\r
5089 walk(t, function(o) {
\r
5095 t.collapsed = true;
\r
5098 isCollapsed : function() {
\r
5099 return this.collapsed;
\r
5102 add : function(o) {
\r
5104 o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
\r
5106 this.onAddItem.dispatch(this, o);
\r
5108 return this.items[o.id] = o;
\r
5111 addSeparator : function() {
\r
5112 return this.add({separator : true});
\r
5115 addMenu : function(o) {
\r
5117 o = this.createMenu(o);
\r
5121 return this.add(o);
\r
5124 hasMenus : function() {
\r
5125 return this.menuCount !== 0;
\r
5128 remove : function(o) {
\r
5129 delete this.items[o.id];
\r
5132 removeAll : function() {
\r
5135 walk(t, function(o) {
\r
5147 createMenu : function(o) {
\r
5148 var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
\r
5150 m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
\r
5157 /* file:jscripts/tiny_mce/classes/ui/DropMenu.js */
\r
5160 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
\r
5162 tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
\r
5163 DropMenu : function(id, s) {
\r
5165 s.container = s.container || DOM.doc.body;
\r
5166 s.offset_x = s.offset_x || 0;
\r
5167 s.offset_y = s.offset_y || 0;
\r
5168 s.vp_offset_x = s.vp_offset_x || 0;
\r
5169 s.vp_offset_y = s.vp_offset_y || 0;
\r
5171 if (is(s.icons) && !s.icons)
\r
5172 s['class'] += ' mceNoIcons';
\r
5174 this.parent(id, s);
\r
5175 this.onShowMenu = new tinymce.util.Dispatcher(this);
\r
5176 this.onHideMenu = new tinymce.util.Dispatcher(this);
\r
5177 this.classPrefix = 'mceMenu';
\r
5180 createMenu : function(s) {
\r
5181 var t = this, cs = t.settings, m;
\r
5183 s.container = s.container || cs.container;
\r
5185 s.constrain = s.constrain || cs.constrain;
\r
5186 s['class'] = s['class'] || cs['class'];
\r
5187 s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
\r
5188 s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
\r
5189 m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
\r
5191 m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
\r
5196 update : function() {
\r
5197 var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
\r
5199 tw = s.max_width ? Math.min(tb.clientWidth, s.max_width) : tb.clientWidth;
\r
5200 th = s.max_height ? Math.min(tb.clientHeight, s.max_height) : tb.clientHeight;
\r
5202 if (!DOM.boxModel)
\r
5203 t.element.setStyles({width : tw + 2, height : th + 2});
\r
5205 t.element.setStyles({width : tw, height : th});
\r
5208 DOM.setStyle(co, 'width', tw);
\r
5210 if (s.max_height) {
\r
5211 DOM.setStyle(co, 'height', th);
\r
5213 if (tb.clientHeight < s.max_height)
\r
5214 DOM.setStyle(co, 'overflow', 'hidden');
\r
5218 showMenu : function(x, y, px) {
\r
5219 var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
\r
5223 if (t.isMenuVisible)
\r
5226 if (!t.rendered) {
\r
5227 co = DOM.add(t.settings.container, t.renderNode());
\r
5229 each(t.items, function(o) {
\r
5233 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
\r
5235 co = DOM.get('menu_' + t.id);
\r
5237 // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
\r
5238 if (!tinymce.isOpera)
\r
5239 DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
\r
5244 x += s.offset_x || 0;
\r
5245 y += s.offset_y || 0;
\r
5249 // Move inside viewport if not submenu
\r
5250 if (s.constrain) {
\r
5251 w = co.clientWidth - ot;
\r
5252 h = co.clientHeight - ot;
\r
5256 if ((x + s.vp_offset_x + w) > mx)
\r
5257 x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
\r
5259 if ((y + s.vp_offset_y + h) > my)
\r
5260 y = Math.max(0, (my - s.vp_offset_y) - h);
\r
5263 DOM.setStyles(co, {left : x , top : y});
\r
5264 t.element.update();
\r
5266 t.isMenuVisible = 1;
\r
5267 t.mouseClickFunc = Event.add(co, 'click', function(e) {
\r
5272 if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
\r
5273 m = t.items[e.id];
\r
5275 if (m.isDisabled())
\r
5284 dm = dm.settings.parent;
\r
5287 if (m.settings.onclick)
\r
5288 m.settings.onclick(e);
\r
5290 return Event.cancel(e); // Cancel to fix onbeforeunload problem
\r
5294 if (t.hasMenus()) {
\r
5295 t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
\r
5299 if (e && (e = DOM.getParent(e, 'TR'))) {
\r
5300 m = t.items[e.id];
\r
5303 t.lastMenu.collapse(1);
\r
5305 if (m.isDisabled())
\r
5308 if (e && DOM.hasClass(e, cp + 'ItemSub')) {
\r
5309 //p = DOM.getPos(s.container);
\r
5310 r = DOM.getRect(e);
\r
5311 m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
\r
5313 DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
\r
5319 t.onShowMenu.dispatch(t);
\r
5321 if (s.keyboard_focus) {
\r
5322 Event.add(co, 'keydown', t._keyHandler, t);
\r
5323 DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
\r
5328 hideMenu : function(c) {
\r
5329 var t = this, co = DOM.get('menu_' + t.id), e;
\r
5331 if (!t.isMenuVisible)
\r
5334 Event.remove(co, 'mouseover', t.mouseOverFunc);
\r
5335 Event.remove(co, 'click', t.mouseClickFunc);
\r
5336 Event.remove(co, 'keydown', t._keyHandler);
\r
5338 t.isMenuVisible = 0;
\r
5346 if (e = DOM.get(t.id))
\r
5347 DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
\r
5349 t.onHideMenu.dispatch(t);
\r
5352 add : function(o) {
\r
5357 if (t.isRendered && (co = DOM.get('menu_' + t.id)))
\r
5358 t._add(DOM.select('tbody', co)[0], o);
\r
5363 collapse : function(d) {
\r
5368 remove : function(o) {
\r
5372 return this.parent(o);
\r
5375 destroy : function() {
\r
5376 var t = this, co = DOM.get('menu_' + t.id);
\r
5378 Event.remove(co, 'mouseover', t.mouseOverFunc);
\r
5379 Event.remove(co, 'click', t.mouseClickFunc);
\r
5382 t.element.remove();
\r
5387 renderNode : function() {
\r
5388 var t = this, s = t.settings, n, tb, co, w;
\r
5390 w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'});
\r
5391 co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
\r
5392 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
\r
5395 DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
\r
5397 // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
\r
5398 n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
\r
5399 tb = DOM.add(n, 'tbody');
\r
5401 each(t.items, function(o) {
\r
5405 t.rendered = true;
\r
5410 // Internal functions
\r
5412 _keyHandler : function(e) {
\r
5413 var t = this, kc = e.keyCode;
\r
5415 function focus(d) {
\r
5416 var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
\r
5426 focus(-1); // Select first link
\r
5437 return this.hideMenu();
\r
5441 _add : function(tb, o) {
\r
5442 var n, s = o.settings, a, ro, it, cp = this.classPrefix, ic;
\r
5444 if (s.separator) {
\r
5445 ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
\r
5446 DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
\r
5448 if (n = ro.previousSibling)
\r
5449 DOM.addClass(n, 'mceLast');
\r
5454 n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
\r
5455 n = it = DOM.add(n, 'td');
\r
5456 n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
\r
5458 DOM.addClass(it, s['class']);
\r
5459 // n = DOM.add(n, 'span', {'class' : 'item'});
\r
5461 ic = DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
\r
5464 DOM.add(ic, 'img', {src : s.icon_src});
\r
5466 n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
\r
5468 if (o.settings.style)
\r
5469 DOM.setAttrib(n, 'style', o.settings.style);
\r
5471 if (tb.childNodes.length == 1)
\r
5472 DOM.addClass(ro, 'mceFirst');
\r
5474 if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
\r
5475 DOM.addClass(ro, 'mceFirst');
\r
5478 DOM.addClass(ro, cp + 'ItemSub');
\r
5480 if (n = ro.previousSibling)
\r
5481 DOM.removeClass(n, 'mceLast');
\r
5483 DOM.addClass(ro, 'mceLast');
\r
5488 /* file:jscripts/tiny_mce/classes/ui/Button.js */
\r
5491 var DOM = tinymce.DOM;
\r
5493 tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
\r
5494 Button : function(id, s) {
\r
5495 this.parent(id, s);
\r
5496 this.classPrefix = 'mceButton';
\r
5499 renderHTML : function() {
\r
5500 var cp = this.classPrefix, s = this.settings, h, l;
\r
5502 l = DOM.encode(s.label || '');
\r
5503 h = '<a id="' + this.id + '" href="javascript:;" class="' + cp + ' ' + cp + 'Enabled ' + s['class'] + (l ? ' ' + cp + 'Labeled' : '') +'" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">';
\r
5506 h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>';
\r
5508 h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>';
\r
5513 postRender : function() {
\r
5514 var t = this, s = t.settings;
\r
5516 tinymce.dom.Event.add(t.id, 'click', function(e) {
\r
5517 if (!t.isDisabled())
\r
5518 return s.onclick.call(s.scope, e);
\r
5525 /* file:jscripts/tiny_mce/classes/ui/ListBox.js */
\r
5528 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
\r
5530 tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
\r
5531 ListBox : function(id, s) {
\r
5536 t.onChange = new Dispatcher(t);
\r
5537 t.onPostRender = new Dispatcher(t);
\r
5538 t.onAdd = new Dispatcher(t);
\r
5539 t.onRenderMenu = new tinymce.util.Dispatcher(this);
\r
5540 t.classPrefix = 'mceListBox';
\r
5543 select : function(va) {
\r
5544 var t = this, fv, f;
\r
5546 if (va == undefined)
\r
5547 return t.selectByIndex(-1);
\r
5549 // Is string or number make function selector
\r
5550 if (va && va.call)
\r
5558 // Do we need to do something?
\r
5559 if (va != t.selectedValue) {
\r
5561 each(t.items, function(o, i) {
\r
5564 t.selectByIndex(i);
\r
5570 t.selectByIndex(-1);
\r
5574 selectByIndex : function(idx) {
\r
5575 var t = this, e, o;
\r
5577 if (idx != t.selectedIndex) {
\r
5578 e = DOM.get(t.id + '_text');
\r
5582 t.selectedValue = o.value;
\r
5583 t.selectedIndex = idx;
\r
5584 DOM.setHTML(e, DOM.encode(o.title));
\r
5585 DOM.removeClass(e, 'mceTitle');
\r
5587 DOM.setHTML(e, DOM.encode(t.settings.title));
\r
5588 DOM.addClass(e, 'mceTitle');
\r
5589 t.selectedValue = t.selectedIndex = null;
\r
5594 t.selectedValue = t.selectedIndex = null;
\r
5597 add : function(n, v, o) {
\r
5601 o = tinymce.extend(o, {
\r
5607 t.onAdd.dispatch(t, o);
\r
5610 getLength : function() {
\r
5611 return this.items.length;
\r
5614 renderHTML : function() {
\r
5615 var h = '', t = this, s = t.settings, cp = t.classPrefix;
\r
5617 h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>';
\r
5618 h += '<td>' + DOM.createHTML('a', {id : t.id + '_text', href : 'javascript:;', 'class' : 'mceText', onclick : "return false;", onmousedown : 'return false;'}, DOM.encode(t.settings.title)) + '</td>';
\r
5619 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>';
\r
5620 h += '</tr></tbody></table>';
\r
5625 showMenu : function() {
\r
5626 var t = this, p1, p2, e = DOM.get(this.id), m;
\r
5628 if (t.isDisabled() || t.items.length == 0)
\r
5631 if (t.menu && t.menu.isMenuVisible)
\r
5632 return t.hideMenu();
\r
5634 if (!t.isMenuRendered) {
\r
5636 t.isMenuRendered = true;
\r
5639 p1 = DOM.getPos(this.settings.menu_container);
\r
5640 p2 = DOM.getPos(e);
\r
5643 m.settings.offset_x = p2.x;
\r
5644 m.settings.offset_y = p2.y;
\r
5645 m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
\r
5649 m.items[t.oldID].setSelected(0);
\r
5651 each(t.items, function(o) {
\r
5652 if (o.value === t.selectedValue) {
\r
5653 m.items[o.id].setSelected(1);
\r
5658 m.showMenu(0, e.clientHeight);
\r
5660 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5661 DOM.addClass(t.id, t.classPrefix + 'Selected');
\r
5663 //DOM.get(t.id + '_text').focus();
\r
5666 hideMenu : function(e) {
\r
5669 // Prevent double toogles by canceling the mouse click event to the button
\r
5670 if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
\r
5673 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
\r
5674 DOM.removeClass(t.id, t.classPrefix + 'Selected');
\r
5675 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5678 t.menu.hideMenu();
\r
5682 renderMenu : function() {
\r
5685 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
\r
5687 'class' : t.classPrefix + 'Menu mceNoIcons',
\r
5692 m.onHideMenu.add(t.hideMenu, t);
\r
5695 title : t.settings.title,
\r
5696 'class' : 'mceMenuItemTitle',
\r
5697 onclick : function() {
\r
5698 if (t.settings.onselect('') !== false)
\r
5699 t.select(''); // Must be runned after
\r
5703 each(t.items, function(o) {
\r
5704 o.id = DOM.uniqueId();
\r
5705 o.onclick = function() {
\r
5706 if (t.settings.onselect(o.value) !== false)
\r
5707 t.select(o.value); // Must be runned after
\r
5713 t.onRenderMenu.dispatch(t, m);
\r
5717 postRender : function() {
\r
5718 var t = this, cp = t.classPrefix;
\r
5720 Event.add(t.id, 'click', t.showMenu, t);
\r
5721 Event.add(t.id + '_text', 'focus', function(e) {
\r
5722 if (!t._focused) {
\r
5723 t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
\r
5724 var idx = -1, v, kc = e.keyCode;
\r
5726 // Find current index
\r
5727 each(t.items, function(v, i) {
\r
5728 if (t.selectedValue == v.value)
\r
5734 v = t.items[idx - 1];
\r
5735 else if (kc == 40)
\r
5736 v = t.items[idx + 1];
\r
5737 else if (kc == 13) {
\r
5738 // Fake select on enter
\r
5739 v = t.selectedValue;
\r
5740 t.selectedValue = null; // Needs to be null to fake change
\r
5741 t.settings.onselect(v);
\r
5742 return Event.cancel(e);
\r
5747 t.select(v.value);
\r
5754 Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
\r
5756 // Old IE doesn't have hover on all elements
\r
5757 if (tinymce.isIE6 || !DOM.boxModel) {
\r
5758 Event.add(t.id, 'mouseover', function() {
\r
5759 if (!DOM.hasClass(t.id, cp + 'Disabled'))
\r
5760 DOM.addClass(t.id, cp + 'Hover');
\r
5763 Event.add(t.id, 'mouseout', function() {
\r
5764 if (!DOM.hasClass(t.id, cp + 'Disabled'))
\r
5765 DOM.removeClass(t.id, cp + 'Hover');
\r
5769 t.onPostRender.dispatch(t, DOM.get(t.id));
\r
5772 destroy : function() {
\r
5775 Event.clear(this.id + '_text');
\r
5780 /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */
\r
5783 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
\r
5785 tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
\r
5786 NativeListBox : function(id, s) {
\r
5787 this.parent(id, s);
\r
5788 this.classPrefix = 'mceNativeListBox';
\r
5791 setDisabled : function(s) {
\r
5792 DOM.get(this.id).disabled = s;
\r
5795 isDisabled : function() {
\r
5796 return DOM.get(this.id).disabled;
\r
5799 select : function(va) {
\r
5800 var t = this, fv, f;
\r
5802 if (va == undefined)
\r
5803 return t.selectByIndex(-1);
\r
5805 // Is string or number make function selector
\r
5806 if (va && va.call)
\r
5814 // Do we need to do something?
\r
5815 if (va != t.selectedValue) {
\r
5817 each(t.items, function(o, i) {
\r
5820 t.selectByIndex(i);
\r
5826 t.selectByIndex(-1);
\r
5830 selectByIndex : function(idx) {
\r
5831 DOM.get(this.id).selectedIndex = idx + 1;
\r
5832 this.selectedValue = this.items[idx] ? this.items[idx].value : null;
\r
5835 add : function(n, v, a) {
\r
5841 if (t.isRendered())
\r
5842 DOM.add(DOM.get(this.id), 'option', a, n);
\r
5851 t.onAdd.dispatch(t, o);
\r
5854 getLength : function() {
\r
5855 return DOM.get(this.id).options.length - 1;
\r
5858 renderHTML : function() {
\r
5861 h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
\r
5863 each(t.items, function(it) {
\r
5864 h += DOM.createHTML('option', {value : it.value}, it.title);
\r
5867 h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox'}, h);
\r
5872 postRender : function() {
\r
5875 t.rendered = true;
\r
5877 function onChange(e) {
\r
5878 var v = t.items[e.target.selectedIndex - 1];
\r
5880 if (v && (v = v.value)) {
\r
5881 t.onChange.dispatch(t, v);
\r
5883 if (t.settings.onselect)
\r
5884 t.settings.onselect(v);
\r
5888 Event.add(t.id, 'change', onChange);
\r
5890 // Accessibility keyhandler
\r
5891 Event.add(t.id, 'keydown', function(e) {
\r
5894 Event.remove(t.id, 'change', ch);
\r
5896 bf = Event.add(t.id, 'blur', function() {
\r
5897 Event.add(t.id, 'change', onChange);
\r
5898 Event.remove(t.id, 'blur', bf);
\r
5901 if (e.keyCode == 13 || e.keyCode == 32) {
\r
5903 return Event.cancel(e);
\r
5907 t.onPostRender.dispatch(t, DOM.get(t.id));
\r
5912 /* file:jscripts/tiny_mce/classes/ui/MenuButton.js */
\r
5915 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
\r
5917 tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
\r
5918 MenuButton : function(id, s) {
\r
5919 this.parent(id, s);
\r
5920 this.onRenderMenu = new tinymce.util.Dispatcher(this);
\r
5921 s.menu_container = s.menu_container || DOM.doc.body;
\r
5924 showMenu : function() {
\r
5925 var t = this, p1, p2, e = DOM.get(t.id), m;
\r
5927 if (t.isDisabled())
\r
5930 if (!t.isMenuRendered) {
\r
5932 t.isMenuRendered = true;
\r
5935 if (t.isMenuVisible)
\r
5936 return t.hideMenu();
\r
5938 p1 = DOM.getPos(t.settings.menu_container);
\r
5939 p2 = DOM.getPos(e);
\r
5942 m.settings.offset_x = p2.x;
\r
5943 m.settings.offset_y = p2.y;
\r
5944 m.settings.vp_offset_x = p2.x;
\r
5945 m.settings.vp_offset_y = p2.y;
\r
5946 m.settings.keyboard_focus = t._focused;
\r
5947 m.showMenu(0, e.clientHeight);
\r
5949 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5950 t.setState('Selected', 1);
\r
5952 t.isMenuVisible = 1;
\r
5955 renderMenu : function() {
\r
5958 m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
\r
5960 'class' : this.classPrefix + 'Menu',
\r
5961 icons : t.settings.icons
\r
5964 m.onHideMenu.add(t.hideMenu, t);
\r
5966 t.onRenderMenu.dispatch(t, m);
\r
5970 hideMenu : function(e) {
\r
5973 // Prevent double toogles by canceling the mouse click event to the button
\r
5974 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
\r
5977 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
\r
5978 t.setState('Selected', 0);
\r
5979 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
5981 t.menu.hideMenu();
\r
5984 t.isMenuVisible = 0;
\r
5987 postRender : function() {
\r
5988 var t = this, s = t.settings;
\r
5990 Event.add(t.id, 'click', function() {
\r
5991 if (!t.isDisabled()) {
\r
5993 s.onclick(t.value);
\r
6003 /* file:jscripts/tiny_mce/classes/ui/SplitButton.js */
\r
6006 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
\r
6008 tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
\r
6009 SplitButton : function(id, s) {
\r
6010 this.parent(id, s);
\r
6011 this.classPrefix = 'mceSplitButton';
\r
6014 renderHTML : function() {
\r
6015 var h, t = this, s = t.settings, h1;
\r
6017 h = '<tbody><tr>';
\r
6020 h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']});
\r
6022 h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, '');
\r
6024 h += '<td>' + DOM.createHTML('a', {id : t.id + '_action', href : 'javascript:;', 'class' : 'mceAction ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
\r
6026 h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']});
\r
6027 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', href : 'javascript:;', 'class' : 'mceOpen ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
\r
6029 h += '</tr></tbody>';
\r
6031 return DOM.createHTML('table', {id : t.id, 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', onmousedown : 'return false;', title : s.title}, h);
\r
6034 postRender : function() {
\r
6035 var t = this, s = t.settings;
\r
6038 Event.add(t.id + '_action', 'click', function() {
\r
6039 if (!t.isDisabled())
\r
6040 s.onclick(t.value);
\r
6044 Event.add(t.id + '_open', 'click', t.showMenu, t);
\r
6045 Event.add(t.id + '_open', 'focus', function() {t._focused = 1;});
\r
6046 Event.add(t.id + '_open', 'blur', function() {t._focused = 0;});
\r
6048 // Old IE doesn't have hover on all elements
\r
6049 if (tinymce.isIE6 || !DOM.boxModel) {
\r
6050 Event.add(t.id, 'mouseover', function() {
\r
6051 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
\r
6052 DOM.addClass(t.id, 'mceSplitButtonHover');
\r
6055 Event.add(t.id, 'mouseout', function() {
\r
6056 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
\r
6057 DOM.removeClass(t.id, 'mceSplitButtonHover');
\r
6062 destroy : function() {
\r
6065 Event.clear(this.id + '_action');
\r
6066 Event.clear(this.id + '_open');
\r
6072 /* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */
\r
6075 var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
\r
6077 tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
\r
6078 ColorSplitButton : function(id, s) {
\r
6083 t.settings = s = tinymce.extend({
\r
6084 colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',
\r
6086 default_color : '#888888'
\r
6089 t.onShowMenu = new tinymce.util.Dispatcher(t);
\r
6090 t.onHideMenu = new tinymce.util.Dispatcher(t);
\r
6092 t.value = s.default_color;
\r
6095 showMenu : function() {
\r
6096 var t = this, r, p, e, p2;
\r
6098 if (t.isDisabled())
\r
6101 if (!t.isMenuRendered) {
\r
6103 t.isMenuRendered = true;
\r
6106 if (t.isMenuVisible)
\r
6107 return t.hideMenu();
\r
6109 e = DOM.get(t.id);
\r
6110 DOM.show(t.id + '_menu');
\r
6111 DOM.addClass(e, 'mceSplitButtonSelected');
\r
6112 p2 = DOM.getPos(e);
\r
6113 DOM.setStyles(t.id + '_menu', {
\r
6115 top : p2.y + e.clientHeight,
\r
6120 Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
\r
6123 t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
\r
6124 if (e.keyCode == 27)
\r
6128 DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
\r
6131 t.onShowMenu.dispatch(t);
\r
6133 t.isMenuVisible = 1;
\r
6136 hideMenu : function(e) {
\r
6139 // Prevent double toogles by canceling the mouse click event to the button
\r
6140 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
\r
6143 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
\r
6144 DOM.removeClass(t.id, 'mceSplitButtonSelected');
\r
6145 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
\r
6146 Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
\r
6147 DOM.hide(t.id + '_menu');
\r
6150 t.onHideMenu.dispatch(t);
\r
6152 t.isMenuVisible = 0;
\r
6155 renderMenu : function() {
\r
6156 var t = this, m, i = 0, s = t.settings, n, tb, tr, w;
\r
6158 w = DOM.add(s.menu_container, 'div', {id : t.id + '_menu', 'class' : s['menu_class'] + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
\r
6159 m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
\r
6160 DOM.add(m, 'span', {'class' : 'mceMenuLine'});
\r
6162 n = DOM.add(m, 'table', {'class' : 'mceColorSplitMenu'});
\r
6163 tb = DOM.add(n, 'tbody');
\r
6165 // Generate color grid
\r
6167 each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
\r
6168 c = c.replace(/^#/, '');
\r
6171 tr = DOM.add(tb, 'tr');
\r
6172 i = s.grid_width - 1;
\r
6175 n = DOM.add(tr, 'td');
\r
6177 n = DOM.add(n, 'a', {
\r
6178 href : 'javascript:;',
\r
6180 backgroundColor : '#' + c
\r
6182 mce_color : '#' + c
\r
6186 if (s.more_colors_func) {
\r
6187 n = DOM.add(tb, 'tr');
\r
6188 n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
\r
6189 n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
\r
6191 Event.add(n, 'click', function(e) {
\r
6192 s.more_colors_func.call(s.more_colors_scope || this);
\r
6193 return Event.cancel(e); // Cancel to fix onbeforeunload problem
\r
6197 DOM.addClass(m, 'mceColorSplitMenu');
\r
6199 Event.add(t.id + '_menu', 'click', function(e) {
\r
6204 if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
\r
6207 return Event.cancel(e); // Prevent IE auto save warning
\r
6213 setColor : function(c) {
\r
6216 DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
\r
6220 t.settings.onselect(c);
\r
6223 postRender : function() {
\r
6224 var t = this, id = t.id;
\r
6227 DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
\r
6228 DOM.setStyle(t.id + '_preview', 'backgroundColor', t.value);
\r
6231 destroy : function() {
\r
6234 Event.clear(this.id + '_menu');
\r
6235 Event.clear(this.id + '_more');
\r
6236 DOM.remove(this.id + '_menu');
\r
6242 /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */
\r
6244 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
\r
6245 renderHTML : function() {
\r
6246 var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl;
\r
6249 for (i=0; i<cl.length; i++) {
\r
6250 // Get current control, prev control, next control and if the control is a list box or not
\r
6255 // Add toolbar start
\r
6257 c = 'mceToolbarStart';
\r
6260 c += ' mceToolbarStartButton';
\r
6261 else if (co.SplitButton)
\r
6262 c += ' mceToolbarStartSplitButton';
\r
6263 else if (co.ListBox)
\r
6264 c += ' mceToolbarStartListBox';
\r
6266 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6269 // Add toolbar end before list box and after the previous button
\r
6270 // This is to fix the o2k7 editor skins
\r
6271 if (pr && co.ListBox) {
\r
6272 if (pr.Button || pr.SplitButton)
\r
6273 h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6276 // Render control HTML
\r
6278 // IE 8 quick fix, needed to propertly generate a hit area for anchors
\r
6280 h += '<td style="position: relative">' + co.renderHTML() + '</td>';
\r
6282 h += '<td>' + co.renderHTML() + '</td>';
\r
6284 // Add toolbar start after list box and before the next button
\r
6285 // This is to fix the o2k7 editor skins
\r
6286 if (nx && co.ListBox) {
\r
6287 if (nx.Button || nx.SplitButton)
\r
6288 h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6292 c = 'mceToolbarEnd';
\r
6295 c += ' mceToolbarEndButton';
\r
6296 else if (co.SplitButton)
\r
6297 c += ' mceToolbarEndSplitButton';
\r
6298 else if (co.ListBox)
\r
6299 c += ' mceToolbarEndListBox';
\r
6301 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
\r
6303 return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || ''}, '<tbody><tr>' + h + '</tr></tbody>');
\r
6308 /* file:jscripts/tiny_mce/classes/AddOnManager.js */
\r
6311 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
\r
6313 tinymce.create('tinymce.AddOnManager', {
\r
6317 onAdd : new Dispatcher(this),
\r
6319 get : function(n) {
\r
6320 return this.lookup[n];
\r
6323 requireLangPack : function(n) {
\r
6324 var u, s = tinymce.EditorManager.settings;
\r
6326 if (s && s.language) {
\r
6327 u = this.urls[n] + '/langs/' + s.language + '.js';
\r
6329 if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
\r
6330 tinymce.ScriptLoader.load(u);
\r
6332 tinymce.ScriptLoader.add(u);
\r
6336 add : function(id, o) {
\r
6337 this.items.push(o);
\r
6338 this.lookup[id] = o;
\r
6339 this.onAdd.dispatch(this, id, o);
\r
6344 load : function(n, u, cb, s) {
\r
6350 if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
\r
6351 u = tinymce.baseURL + '/' + u;
\r
6353 t.urls[n] = u.substring(0, u.lastIndexOf('/'));
\r
6354 tinymce.ScriptLoader.add(u, cb, s);
\r
6359 // Create plugin and theme managers
\r
6360 tinymce.PluginManager = new tinymce.AddOnManager();
\r
6361 tinymce.ThemeManager = new tinymce.AddOnManager();
\r
6363 /* file:jscripts/tiny_mce/classes/EditorManager.js */
\r
6367 var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode;
\r
6369 tinymce.create('static tinymce.EditorManager', {
\r
6372 activeEditor : null,
\r
6374 preInit : function() {
\r
6375 var t = this, lo = window.location;
\r
6377 // Setup some URLs where the editor API is located and where the document is
\r
6378 tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
\r
6379 if (!/[\/\\]$/.test(tinymce.documentBaseURL))
\r
6380 tinymce.documentBaseURL += '/';
\r
6382 tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
\r
6383 tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
\r
6385 // User already specified a document.domain value
\r
6386 if (document.domain && lo.hostname != document.domain)
\r
6387 tinymce.relaxedDomain = document.domain;
\r
6389 // Setup document domain if tinymce is loaded from other domain
\r
6390 if (!tinymce.relaxedDomain && tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)
\r
6391 document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1');
\r
6393 // Add before unload listener
\r
6394 // This was required since IE was leaking memory if you added and removed beforeunload listeners
\r
6395 // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event
\r
6396 t.onBeforeUnload = new tinymce.util.Dispatcher(t);
\r
6398 // Must be on window or IE will leak if the editor is placed in frame or iframe
\r
6399 Event.add(window, 'beforeunload', function(e) {
\r
6400 t.onBeforeUnload.dispatch(t, e);
\r
6404 init : function(s) {
\r
6405 var t = this, pl, sl = tinymce.ScriptLoader, c, e, el = [], ed;
\r
6407 function execCallback(se, n, s) {
\r
6413 if (tinymce.is(f, 'string')) {
\r
6414 s = f.replace(/\.\w+$/, '');
\r
6415 s = s ? tinymce.resolve(s) : 0;
\r
6416 f = tinymce.resolve(f);
\r
6419 return f.apply(s || this, Array.prototype.slice.call(arguments, 2));
\r
6425 strict_loading_mode : document.contentType == 'application/xhtml+xml'
\r
6430 // If page not loaded and strict mode isn't enabled then load them
\r
6431 if (!Event.domLoaded && !s.strict_loading_mode) {
\r
6434 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
\r
6437 if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
\r
6438 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
\r
6442 pl = explode(s.plugins);
\r
6444 // Load compat2x first
\r
6445 if (tinymce.inArray(pl, 'compat2x') != -1)
\r
6446 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
\r
6448 // Load rest if plugins
\r
6449 each(pl, function(v) {
\r
6450 if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) {
\r
6451 // Skip safari plugin for other browsers
\r
6452 if (!tinymce.isWebKit && v == 'safari')
\r
6455 PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js');
\r
6464 Event.add(document, 'init', function() {
\r
6467 execCallback(s, 'onpageload');
\r
6469 // Verify that it's a valid browser
\r
6473 each(explode(s.browsers), function(v) {
\r
6482 if (tinymce.isGecko)
\r
6488 if (tinymce.isWebKit)
\r
6493 if (tinymce.isOpera)
\r
6500 // Not a valid one
\r
6507 l = s.elements || '';
\r
6509 if(l.length > 0) {
\r
6510 each(explode(l), function(v) {
\r
6512 ed = new tinymce.Editor(v, s);
\r
6518 each(document.forms, function(f) {
\r
6519 each(f.elements, function(e) {
\r
6520 if (e.name === v) {
\r
6521 v = 'mce_editor_' + c;
\r
6522 DOM.setAttrib(e, 'id', v);
\r
6524 ed = new tinymce.Editor(v, s);
\r
6536 case "specific_textareas":
\r
6537 function hasClass(n, c) {
\r
6538 return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c);
\r
6541 each(DOM.select('textarea'), function(v) {
\r
6542 if (s.editor_deselector && hasClass(v, s.editor_deselector))
\r
6545 if (!s.editor_selector || hasClass(v, s.editor_selector)) {
\r
6546 // Can we use the name
\r
6547 e = DOM.get(v.name);
\r
6551 // Generate unique name if missing or already exists
\r
6552 if (!v.id || t.get(v.id))
\r
6553 v.id = DOM.uniqueId();
\r
6555 ed = new tinymce.Editor(v.id, s);
\r
6563 // Call onInit when all editors are initialized
\r
6567 each (el, function(ed) {
\r
6570 if (!ed.initialized) {
\r
6572 ed.onInit.add(function() {
\r
6577 execCallback(s, 'oninit');
\r
6584 execCallback(s, 'oninit');
\r
6590 get : function(id) {
\r
6591 return this.editors[id];
\r
6594 getInstanceById : function(id) {
\r
6595 return this.get(id);
\r
6598 add : function(e) {
\r
6599 this.editors[e.id] = e;
\r
6600 this._setActive(e);
\r
6605 remove : function(e) {
\r
6608 // Not in the collection
\r
6609 if (!t.editors[e.id])
\r
6612 delete t.editors[e.id];
\r
6614 // Select another editor since the active one was removed
\r
6615 if (t.activeEditor == e) {
\r
6616 each(t.editors, function(e) {
\r
6618 return false; // Break
\r
6627 execCommand : function(c, u, v) {
\r
6628 var t = this, ed = t.get(v), w;
\r
6630 // Manager commands
\r
6636 case "mceAddEditor":
\r
6637 case "mceAddControl":
\r
6639 new tinymce.Editor(v, t.settings).render();
\r
6643 case "mceAddFrameControl":
\r
6646 // Add tinyMCE global instance and tinymce namespace to specified window
\r
6647 w.tinyMCE = tinyMCE;
\r
6648 w.tinymce = tinymce;
\r
6650 tinymce.DOM.doc = w.document;
\r
6651 tinymce.DOM.win = w;
\r
6653 ed = new tinymce.Editor(v.element_id, v);
\r
6656 // Fix IE memory leaks
\r
6657 if (tinymce.isIE) {
\r
6660 w.detachEvent('onunload', clr);
\r
6661 w = w.tinyMCE = w.tinymce = null; // IE leak
\r
6664 w.attachEvent('onunload', clr);
\r
6667 v.page_window = null;
\r
6671 case "mceRemoveEditor":
\r
6672 case "mceRemoveControl":
\r
6678 case 'mceToggleEditor':
\r
6680 t.execCommand('mceAddControl', 0, v);
\r
6684 if (ed.isHidden())
\r
6692 // Run command on active editor
\r
6693 if (t.activeEditor)
\r
6694 return t.activeEditor.execCommand(c, u, v);
\r
6699 execInstanceCommand : function(id, c, u, v) {
\r
6700 var ed = this.get(id);
\r
6703 return ed.execCommand(c, u, v);
\r
6708 triggerSave : function() {
\r
6709 each(this.editors, function(e) {
\r
6714 addI18n : function(p, o) {
\r
6715 var lo, i18n = this.i18n;
\r
6717 if (!tinymce.is(p, 'string')) {
\r
6718 each(p, function(o, lc) {
\r
6719 each(o, function(o, g) {
\r
6720 each(o, function(o, k) {
\r
6721 if (g === 'common')
\r
6722 i18n[lc + '.' + k] = o;
\r
6724 i18n[lc + '.' + g + '.' + k] = o;
\r
6729 each(o, function(o, k) {
\r
6730 i18n[p + '.' + k] = o;
\r
6735 // Private methods
\r
6737 _setActive : function(e) {
\r
6738 this.selectedInstance = this.activeEditor = e;
\r
6743 tinymce.EditorManager.preInit();
\r
6746 // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call
\r
6747 var tinyMCE = window.tinyMCE = tinymce.EditorManager;
\r
6749 /* file:jscripts/tiny_mce/classes/Editor.js */
\r
6752 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher;
\r
6753 var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit;
\r
6754 var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager;
\r
6755 var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode;
\r
6757 tinymce.create('tinymce.Editor', {
\r
6758 Editor : function(id, s) {
\r
6761 t.id = t.editorId = id;
\r
6762 t.execCommands = {};
\r
6763 t.queryStateCommands = {};
\r
6764 t.queryValueCommands = {};
\r
6767 // Add events to the editor
\r
6770 'onBeforeRenderUI',
\r
6790 'onBeforeSetContent',
\r
6791 'onBeforeGetContent',
\r
6798 'onBeforeExecCommand',
\r
6803 'onSetProgressState'
\r
6805 t[e] = new Dispatcher(t);
\r
6808 // Default editor config
\r
6809 t.settings = s = extend({
\r
6812 docs_language : 'en',
\r
6819 document_base_url : tinymce.documentBaseURL,
\r
6820 add_form_submit_trigger : 1,
\r
6822 add_unload_trigger : 1,
\r
6824 relative_urls : 1,
\r
6825 remove_script_host : 1,
\r
6826 table_inline_editing : 0,
\r
6827 object_resizing : 1,
\r
6829 accessibility_focus : 1,
\r
6830 custom_shortcuts : 1,
\r
6831 custom_undo_redo_keyboard_shortcuts : 1,
\r
6832 custom_undo_redo_restore_selection : 1,
\r
6833 custom_undo_redo : 1,
\r
6834 doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
\r
6835 visual_table_class : 'mceItemTable',
\r
6837 inline_styles : true,
\r
6838 convert_fonts_to_spans : true,
\r
6839 font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large',
\r
6840 apply_source_formatting : 1,
\r
6841 directionality : 'ltr',
\r
6842 forced_root_block : 'p',
\r
6843 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',
\r
6845 padd_empty_editor : 1,
\r
6848 force_p_newlines : 1,
\r
6849 indentation : '30px',
\r
6854 t.documentBaseURI = new tinymce.util.URI(s.document_base_url || tinymce.documentBaseURL, {
\r
6855 base_uri : tinyMCE.baseURI
\r
6857 t.baseURI = EditorManager.baseURI;
\r
6860 t.execCallback('setup', t);
\r
6863 render : function(nst) {
\r
6864 var t = this, s = t.settings, id = t.id, sl = tinymce.ScriptLoader;
\r
6866 // Page is not loaded yet, wait for it
\r
6867 if (!Event.domLoaded) {
\r
6868 Event.add(document, 'init', function() {
\r
6874 // Force strict loading mode if render us called by user and not internally
\r
6876 s.strict_loading_mode = 1;
\r
6877 tinyMCE.settings = s;
\r
6880 // Element not found, then skip initialization
\r
6881 if (!t.getElement())
\r
6884 if (s.strict_loading_mode) {
\r
6885 sl.settings.strict_mode = s.strict_loading_mode;
\r
6886 tinymce.DOM.settings.strict = 1;
\r
6889 // Add hidden input for non input elements inside form elements
\r
6890 if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form'))
\r
6891 DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
\r
6893 t.windowManager = new tinymce.WindowManager(t);
\r
6895 if (s.encoding == 'xml') {
\r
6896 t.onGetContent.add(function(ed, o) {
\r
6898 o.content = DOM.encode(o.content);
\r
6902 if (s.add_form_submit_trigger) {
\r
6903 t.onSubmit.addToTop(function() {
\r
6904 if (t.initialized) {
\r
6911 if (s.add_unload_trigger && !s.ask) {
\r
6912 t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
\r
6913 if (t.initialized && !t.destroyed && !t.isHidden())
\r
6914 t.save({format : 'raw', no_events : true});
\r
6918 tinymce.addUnload(t.destroy, t);
\r
6920 if (s.submit_patch) {
\r
6921 t.onBeforeRenderUI.add(function() {
\r
6922 var n = t.getElement().form;
\r
6927 // Already patched
\r
6928 if (n._mceOldSubmit)
\r
6931 // Check page uses id="submit" or name="submit" for it's submit button
\r
6932 if (!n.submit.nodeType && !n.submit.length) {
\r
6933 t.formElement = n;
\r
6934 n._mceOldSubmit = n.submit;
\r
6935 n.submit = function() {
\r
6936 // Save all instances
\r
6937 EditorManager.triggerSave();
\r
6940 return this._mceOldSubmit(this);
\r
6949 function loadScripts() {
\r
6951 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
\r
6953 if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
\r
6954 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
\r
6956 each(explode(s.plugins), function(p) {
\r
6957 if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
\r
6958 // Skip safari plugin for other browsers
\r
6959 if (!isWebKit && p == 'safari')
\r
6962 PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js');
\r
6966 // Init when que is loaded
\r
6967 sl.loadQueue(function() {
\r
6970 // Yield for awhile to avoid focus bug on FF 3 when cancel is pressed
\r
6971 window.setTimeout(function() {
\r
6972 Event.remove(t.id, 'focus', ask);
\r
6974 t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
\r
6981 Event.add(t.id, 'focus', ask);
\r
6990 // Load compat2x first
\r
6991 if (s.plugins.indexOf('compat2x') != -1) {
\r
6992 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
\r
6993 sl.loadQueue(loadScripts);
\r
6998 init : function() {
\r
6999 var n, t = this, s = t.settings, w, h, e = t.getElement(), o, ti, u, bi, bc, re;
\r
7001 EditorManager.add(t);
\r
7004 s.theme = s.theme.replace(/-/, '');
\r
7005 o = ThemeManager.get(s.theme);
\r
7006 t.theme = new o();
\r
7008 if (t.theme.init && s.init_theme)
\r
7009 t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
\r
7011 // Create all plugins
\r
7012 each(explode(s.plugins.replace(/\-/g, '')), function(p) {
\r
7013 var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po;
\r
7018 t.plugins[p] = po;
\r
7025 // Setup popup CSS path(s)
\r
7026 if (s.popup_css !== false) {
\r
7028 s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
\r
7030 s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
\r
7033 if (s.popup_css_add)
\r
7034 s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add);
\r
7036 // Setup control factory
\r
7037 t.controlManager = new tinymce.ControlManager(t);
\r
7038 t.undoManager = new tinymce.UndoManager(t);
\r
7041 t.undoManager.onAdd.add(function(um, l) {
\r
7043 return t.onChange.dispatch(t, l, um);
\r
7046 t.undoManager.onUndo.add(function(um, l) {
\r
7047 return t.onUndo.dispatch(t, l, um);
\r
7050 t.undoManager.onRedo.add(function(um, l) {
\r
7051 return t.onRedo.dispatch(t, l, um);
\r
7054 if (s.custom_undo_redo) {
\r
7055 t.onExecCommand.add(function(ed, cmd, ui, val, a) {
\r
7056 if (cmd != 'Undo' && cmd != 'Redo' && cmd != 'mceRepaint' && (!a || !a.skip_undo))
\r
7057 t.undoManager.add();
\r
7061 t.onExecCommand.add(function(ed, c) {
\r
7062 // Don't refresh the select lists until caret move
\r
7063 if (!/^(FontName|FontSize)$/.test(c))
\r
7067 // Remove ghost selections on images and tables in Gecko
\r
7069 function repaint(a, o) {
\r
7070 if (!o || !o.initial)
\r
7071 t.execCommand('mceRepaint');
\r
7074 t.onUndo.add(repaint);
\r
7075 t.onRedo.add(repaint);
\r
7076 t.onSetContent.add(repaint);
\r
7079 // Enables users to override the control factory
\r
7080 t.onBeforeRenderUI.dispatch(t, t.controlManager);
\r
7083 if (s.render_ui) {
\r
7084 w = s.width || e.style.width || e.offsetWidth;
\r
7085 h = s.height || e.style.height || e.offsetHeight;
\r
7086 t.orgDisplay = e.style.display;
\r
7087 re = /^[0-9\.]+(|px)$/i;
\r
7089 if (re.test('' + w))
\r
7090 w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100);
\r
7092 if (re.test('' + h))
\r
7093 h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100);
\r
7096 o = t.theme.renderUI({
\r
7100 deltaWidth : s.delta_width,
\r
7101 deltaHeight : s.delta_height
\r
7104 t.editorContainer = o.editorContainer;
\r
7109 DOM.setStyles(o.sizeContainer || o.editorContainer, {
\r
7114 h = (o.iframeHeight || h) + (typeof(h) == 'number' ? (o.deltaHeight || 0) : '');
\r
7118 t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />';
\r
7119 t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
\r
7121 if (tinymce.relaxedDomain)
\r
7122 t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>';
\r
7124 bi = s.body_id || 'tinymce';
\r
7125 if (bi.indexOf('=') != -1) {
\r
7126 bi = t.getParam('body_id', '', 'hash');
\r
7127 bi = bi[t.id] || bi;
\r
7130 bc = s.body_class || '';
\r
7131 if (bc.indexOf('=') != -1) {
\r
7132 bc = t.getParam('body_class', '', 'hash');
\r
7133 bc = bc[t.id] || '';
\r
7136 t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>';
\r
7138 // Domain relaxing enabled, then set document domain
\r
7139 if (tinymce.relaxedDomain) {
\r
7140 // We need to write the contents here in IE since multiple writes messes up refresh button and back button
\r
7141 if (isIE || (tinymce.isOpera && parseFloat(opera.version()) >= 9.5))
\r
7142 u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
\r
7143 else if (tinymce.isOpera)
\r
7144 u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
\r
7148 n = DOM.add(o.iframeContainer, 'iframe', {
\r
7149 id : t.id + "_ifr",
\r
7150 src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7
\r
7151 frameBorder : '0',
\r
7158 t.contentAreaContainer = o.iframeContainer;
\r
7159 DOM.get(o.editorContainer).style.display = t.orgDisplay;
\r
7160 DOM.get(t.id).style.display = 'none';
\r
7162 // Safari 2.x requires us to wait for the load event and load a real HTML doc
\r
7163 if (tinymce.isOldWebKit) {
\r
7164 Event.add(n, 'load', t.setupIframe, t);
\r
7165 n.src = tinymce.baseURL + '/plugins/safari/blank.htm';
\r
7167 if (!isIE || !tinymce.relaxedDomain)
\r
7170 e = n = o = null; // Cleanup
\r
7174 setupIframe : function() {
\r
7175 var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b;
\r
7177 // Setup iframe body
\r
7178 if (!isIE || !tinymce.relaxedDomain) {
\r
7180 d.write(t.iframeHTML);
\r
7184 // Design mode needs to be added here Ctrl+A will fail otherwise
\r
7188 d.designMode = 'On';
\r
7190 // Will fail on Gecko if the editor is placed in an hidden container element
\r
7191 // The design mode will be set ones the editor is focused
\r
7195 // IE needs to use contentEditable or it will display non secure items for HTTPS
\r
7197 // It will not steal focus if we hide it while setting contentEditable
\r
7202 b.contentEditable = true;
\r
7208 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), {
\r
7209 keep_values : true,
\r
7210 url_converter : t.convertURL,
\r
7211 url_converter_scope : t,
\r
7212 hex_colors : s.force_hex_style_colors,
\r
7213 class_filter : s.class_filter,
\r
7214 update_styles : 1,
\r
7215 fix_ie_paragraphs : 1
\r
7218 t.serializer = new tinymce.dom.Serializer({
\r
7219 entity_encoding : s.entity_encoding,
\r
7220 entities : s.entities,
\r
7221 valid_elements : s.verify_html === false ? '*[*]' : s.valid_elements,
\r
7222 extended_valid_elements : s.extended_valid_elements,
\r
7223 valid_child_elements : s.valid_child_elements,
\r
7224 invalid_elements : s.invalid_elements,
\r
7225 fix_table_elements : s.fix_table_elements,
\r
7226 fix_list_elements : s.fix_list_elements,
\r
7227 fix_content_duplication : s.fix_content_duplication,
\r
7228 convert_fonts_to_spans : s.convert_fonts_to_spans,
\r
7229 font_size_classes : s.font_size_classes,
\r
7230 font_size_style_values : s.font_size_style_values,
\r
7231 apply_source_formatting : s.apply_source_formatting,
\r
7232 remove_linebreaks : s.remove_linebreaks,
\r
7233 element_format : s.element_format,
\r
7237 t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer);
\r
7238 t.forceBlocks = new tinymce.ForceBlocks(t, {
\r
7239 forced_root_block : s.forced_root_block
\r
7241 t.editorCommands = new tinymce.EditorCommands(t);
\r
7244 t.serializer.onPreProcess.add(function(se, o) {
\r
7245 return t.onPreProcess.dispatch(t, o, se);
\r
7248 t.serializer.onPostProcess.add(function(se, o) {
\r
7249 return t.onPostProcess.dispatch(t, o, se);
\r
7252 t.onPreInit.dispatch(t);
\r
7254 if (!s.gecko_spellcheck)
\r
7255 t.getBody().spellcheck = 0;
\r
7260 t.controlManager.onPostRender.dispatch(t, t.controlManager);
\r
7261 t.onPostRender.dispatch(t);
\r
7263 if (s.directionality)
\r
7264 t.getBody().dir = s.directionality;
\r
7267 t.getBody().style.whiteSpace = "nowrap";
\r
7269 if (s.auto_resize)
\r
7270 t.onNodeChange.add(t.resizeToContent, t);
\r
7272 if (s.custom_elements) {
\r
7273 function handleCustom(ed, o) {
\r
7274 each(explode(s.custom_elements), function(v) {
\r
7277 if (v.indexOf('~') === 0) {
\r
7278 v = v.substring(1);
\r
7283 o.content = o.content.replace(new RegExp('<(' + v + ')([^>]*)>', 'g'), '<' + n + ' mce_name="$1"$2>');
\r
7284 o.content = o.content.replace(new RegExp('</(' + v + ')>', 'g'), '</' + n + '>');
\r
7288 t.onBeforeSetContent.add(handleCustom);
\r
7289 t.onPostProcess.add(function(ed, o) {
\r
7291 handleCustom(ed, o)
\r
7295 if (s.handle_node_change_callback) {
\r
7296 t.onNodeChange.add(function(ed, cm, n) {
\r
7297 t.execCallback('handle_node_change_callback', t.id, n, -1, -1, true, t.selection.isCollapsed());
\r
7301 if (s.save_callback) {
\r
7302 t.onSaveContent.add(function(ed, o) {
\r
7303 var h = t.execCallback('save_callback', t.id, o.content, t.getBody());
\r
7310 if (s.onchange_callback) {
\r
7311 t.onChange.add(function(ed, l) {
\r
7312 t.execCallback('onchange_callback', t, l);
\r
7316 if (s.convert_newlines_to_brs) {
\r
7317 t.onBeforeSetContent.add(function(ed, o) {
\r
7319 o.content = o.content.replace(/\r?\n/g, '<br />');
\r
7323 if (s.fix_nesting && isIE) {
\r
7324 t.onBeforeSetContent.add(function(ed, o) {
\r
7325 o.content = t._fixNesting(o.content);
\r
7329 if (s.preformatted) {
\r
7330 t.onPostProcess.add(function(ed, o) {
\r
7331 o.content = o.content.replace(/^\s*<pre.*?>/, '');
\r
7332 o.content = o.content.replace(/<\/pre>\s*$/, '');
\r
7335 o.content = '<pre class="mceItemHidden">' + o.content + '</pre>';
\r
7339 if (s.verify_css_classes) {
\r
7340 t.serializer.attribValueFilter = function(n, v) {
\r
7343 if (n == 'class') {
\r
7344 // Build regexp for classes
\r
7345 if (!t.classesRE) {
\r
7346 cl = t.dom.getClasses();
\r
7348 if (cl.length > 0) {
\r
7351 each (cl, function(o) {
\r
7352 s += (s ? '|' : '') + o['class'];
\r
7355 t.classesRE = new RegExp('(' + s + ')', 'gi');
\r
7359 return !t.classesRE || /(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v) || t.classesRE.test(v) ? v : '';
\r
7366 if (s.convert_fonts_to_spans)
\r
7367 t._convertFonts();
\r
7369 if (s.inline_styles)
\r
7370 t._convertInlineElements();
\r
7372 if (s.cleanup_callback) {
\r
7373 t.onBeforeSetContent.add(function(ed, o) {
\r
7374 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
\r
7377 t.onPreProcess.add(function(ed, o) {
\r
7379 t.execCallback('cleanup_callback', 'insert_to_editor_dom', o.node, o);
\r
7382 t.execCallback('cleanup_callback', 'get_from_editor_dom', o.node, o);
\r
7385 t.onPostProcess.add(function(ed, o) {
\r
7387 o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
\r
7390 o.content = t.execCallback('cleanup_callback', 'get_from_editor', o.content, o);
\r
7394 if (s.save_callback) {
\r
7395 t.onGetContent.add(function(ed, o) {
\r
7397 o.content = t.execCallback('save_callback', t.id, o.content, t.getBody());
\r
7401 if (s.handle_event_callback) {
\r
7402 t.onEvent.add(function(ed, e, o) {
\r
7403 if (t.execCallback('handle_event_callback', e, ed, o) === false)
\r
7408 t.onSetContent.add(function() {
\r
7409 // Safari needs some time, it will crash the browser when a link is created otherwise
\r
7410 // I think this crash issue is resolved in the latest 3.0.4
\r
7411 //window.setTimeout(function() {
\r
7412 t.addVisual(t.getBody());
\r
7416 // Remove empty contents
\r
7417 if (s.padd_empty_editor) {
\r
7418 t.onPostProcess.add(function(ed, o) {
\r
7419 o.content = o.content.replace(/^(<p[^>]*>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, '');
\r
7423 if (isGecko && !s.readonly) {
\r
7425 // Design mode must be set here once again to fix a bug where
\r
7426 // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
\r
7427 d.designMode = 'Off';
\r
7428 d.designMode = 'On';
\r
7430 // Will fail on Gecko if the editor is placed in an hidden container element
\r
7431 // The design mode will be set ones the editor is focused
\r
7435 // A small timeout was needed since firefox will remove. Bug: #1838304
\r
7436 setTimeout(function () {
\r
7440 t.load({initial : true, format : (s.cleanup_on_startup ? 'html' : 'raw')});
\r
7441 t.startContent = t.getContent({format : 'raw'});
\r
7442 t.undoManager.add({initial : true});
\r
7443 t.initialized = true;
\r
7445 t.onInit.dispatch(t);
\r
7446 t.execCallback('setupcontent_callback', t.id, t.getBody(), t.getDoc());
\r
7447 t.execCallback('init_instance_callback', t);
\r
7449 t.nodeChanged({initial : 1});
\r
7451 // Load specified content CSS last
\r
7452 if (s.content_css) {
\r
7453 tinymce.each(explode(s.content_css), function(u) {
\r
7454 t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));
\r
7458 // Handle auto focus
\r
7459 if (s.auto_focus) {
\r
7460 setTimeout(function () {
\r
7461 var ed = EditorManager.get(s.auto_focus);
\r
7463 ed.selection.select(ed.getBody(), 1);
\r
7464 ed.selection.collapse(1);
\r
7465 ed.getWin().focus();
\r
7474 focus : function(sf) {
\r
7475 var oed, t = this, ce = t.settings.content_editable;
\r
7478 // Is not content editable or the selection is outside the area in IE
\r
7479 // the IE statement is needed to avoid bluring if element selections inside layers since
\r
7480 // the layer is like it's own document in IE
\r
7481 if (!ce && (!isIE || t.selection.getNode().ownerDocument != t.getDoc()))
\r
7482 t.getWin().focus();
\r
7486 if (EditorManager.activeEditor != t) {
\r
7487 if ((oed = EditorManager.activeEditor) != null)
\r
7488 oed.onDeactivate.dispatch(oed, t);
\r
7490 t.onActivate.dispatch(t, oed);
\r
7493 EditorManager._setActive(t);
\r
7496 execCallback : function(n) {
\r
7497 var t = this, f = t.settings[n], s;
\r
7502 // Look through lookup
\r
7503 if (t.callbackLookup && (s = t.callbackLookup[n])) {
\r
7508 if (is(f, 'string')) {
\r
7509 s = f.replace(/\.\w+$/, '');
\r
7510 s = s ? tinymce.resolve(s) : 0;
\r
7511 f = tinymce.resolve(f);
\r
7512 t.callbackLookup = t.callbackLookup || {};
\r
7513 t.callbackLookup[n] = {func : f, scope : s};
\r
7516 return f.apply(s || t, Array.prototype.slice.call(arguments, 1));
\r
7519 translate : function(s) {
\r
7520 var c = this.settings.language || 'en', i18n = EditorManager.i18n;
\r
7525 return i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
\r
7526 return i18n[c + '.' + b] || '{#' + b + '}';
\r
7530 getLang : function(n, dv) {
\r
7531 return EditorManager.i18n[(this.settings.language || 'en') + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
\r
7534 getParam : function(n, dv, ty) {
\r
7535 var tr = tinymce.trim, v = is(this.settings[n]) ? this.settings[n] : dv, o;
\r
7537 if (ty === 'hash') {
\r
7540 if (is(v, 'string')) {
\r
7541 each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) {
\r
7545 o[tr(v[0])] = tr(v[1]);
\r
7547 o[tr(v[0])] = tr(v);
\r
7558 nodeChanged : function(o) {
\r
7559 var t = this, s = t.selection, n = s.getNode() || t.getBody();
\r
7561 // Fix for bug #1896577 it seems that this can not be fired while the editor is loading
\r
7562 if (t.initialized) {
\r
7563 t.onNodeChange.dispatch(
\r
7565 o ? o.controlManager || t.controlManager : t.controlManager,
\r
7566 isIE && n.ownerDocument != t.getDoc() ? t.getBody() : n, // Fix for IE initial state
\r
7573 addButton : function(n, s) {
\r
7576 t.buttons = t.buttons || {};
\r
7580 addCommand : function(n, f, s) {
\r
7581 this.execCommands[n] = {func : f, scope : s || this};
\r
7584 addQueryStateHandler : function(n, f, s) {
\r
7585 this.queryStateCommands[n] = {func : f, scope : s || this};
\r
7588 addQueryValueHandler : function(n, f, s) {
\r
7589 this.queryValueCommands[n] = {func : f, scope : s || this};
\r
7592 addShortcut : function(pa, desc, cmd_func, sc) {
\r
7595 if (!t.settings.custom_shortcuts)
\r
7598 t.shortcuts = t.shortcuts || {};
\r
7600 if (is(cmd_func, 'string')) {
\r
7603 cmd_func = function() {
\r
7604 t.execCommand(c, false, null);
\r
7608 if (is(cmd_func, 'object')) {
\r
7611 cmd_func = function() {
\r
7612 t.execCommand(c[0], c[1], c[2]);
\r
7616 each(explode(pa), function(pa) {
\r
7619 scope : sc || this,
\r
7626 each(explode(pa, '+'), function(v) {
\r
7635 o.charCode = v.charCodeAt(0);
\r
7636 o.keyCode = v.toUpperCase().charCodeAt(0);
\r
7640 t.shortcuts[(o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode] = o;
\r
7646 execCommand : function(cmd, ui, val, a) {
\r
7647 var t = this, s = 0, o, st;
\r
7649 if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus))
\r
7653 t.onBeforeExecCommand.dispatch(t, cmd, ui, val, o);
\r
7657 // Command callback
\r
7658 if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
\r
7659 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7663 // Registred commands
\r
7664 if (o = t.execCommands[cmd]) {
\r
7665 st = o.func.call(o.scope, ui, val);
\r
7667 // Fall through on true
\r
7668 if (st !== true) {
\r
7669 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7674 // Plugin commands
\r
7675 each(t.plugins, function(p) {
\r
7676 if (p.execCommand && p.execCommand(cmd, ui, val)) {
\r
7677 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7687 if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
\r
7688 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7692 // Editor commands
\r
7693 if (t.editorCommands.execCommand(cmd, ui, val)) {
\r
7694 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7698 // Browser commands
\r
7699 t.getDoc().execCommand(cmd, ui, val);
\r
7700 t.onExecCommand.dispatch(t, cmd, ui, val, a);
\r
7703 queryCommandState : function(c) {
\r
7704 var t = this, o, s;
\r
7706 // Is hidden then return undefined
\r
7707 if (t._isHidden())
\r
7710 // Registred commands
\r
7711 if (o = t.queryStateCommands[c]) {
\r
7712 s = o.func.call(o.scope);
\r
7714 // Fall though on true
\r
7719 // Registred commands
\r
7720 o = t.editorCommands.queryCommandState(c);
\r
7724 // Browser commands
\r
7726 return this.getDoc().queryCommandState(c);
\r
7728 // Fails sometimes see bug: 1896577
\r
7732 queryCommandValue : function(c) {
\r
7733 var t = this, o, s;
\r
7735 // Is hidden then return undefined
\r
7736 if (t._isHidden())
\r
7739 // Registred commands
\r
7740 if (o = t.queryValueCommands[c]) {
\r
7741 s = o.func.call(o.scope);
\r
7743 // Fall though on true
\r
7748 // Registred commands
\r
7749 o = t.editorCommands.queryCommandValue(c);
\r
7753 // Browser commands
\r
7755 return this.getDoc().queryCommandValue(c);
\r
7757 // Fails sometimes see bug: 1896577
\r
7761 show : function() {
\r
7764 DOM.show(t.getContainer());
\r
7769 hide : function() {
\r
7770 var t = this, d = t.getDoc();
\r
7772 // Fixed bug where IE has a blinking cursor left from the editor
\r
7774 d.execCommand('SelectAll');
\r
7776 // We must save before we hide so Safari doesn't crash
\r
7778 DOM.hide(t.getContainer());
\r
7779 DOM.setStyle(t.id, 'display', t.orgDisplay);
\r
7782 isHidden : function() {
\r
7783 return !DOM.isHidden(this.id);
\r
7786 setProgressState : function(b, ti, o) {
\r
7787 this.onSetProgressState.dispatch(this, b, ti, o);
\r
7792 resizeToContent : function() {
\r
7795 DOM.setStyle(t.id + "_ifr", 'height', t.getBody().scrollHeight);
\r
7798 load : function(o) {
\r
7799 var t = this, e = t.getElement(), h;
\r
7805 h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
\r
7809 t.onLoadContent.dispatch(t, o);
\r
7811 o.element = e = null;
\r
7817 save : function(o) {
\r
7818 var t = this, e = t.getElement(), h, f;
\r
7820 if (!e || !t.initialized)
\r
7826 // Add undo level will trigger onchange event
\r
7827 if (!o.no_events) {
\r
7828 t.undoManager.typing = 0;
\r
7829 t.undoManager.add();
\r
7833 h = o.content = t.getContent(o);
\r
7836 t.onSaveContent.dispatch(t, o);
\r
7840 if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
\r
7843 // Update hidden form element
\r
7844 if (f = DOM.getParent(t.id, 'form')) {
\r
7845 each(f.elements, function(e) {
\r
7846 if (e.name == t.id) {
\r
7855 o.element = e = null;
\r
7860 setContent : function(h, o) {
\r
7864 o.format = o.format || 'html';
\r
7869 t.onBeforeSetContent.dispatch(t, o);
\r
7871 // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
\r
7872 // It will also be impossible to place the caret in the editor unless there is a BR element present
\r
7873 if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
\r
7874 o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />');
\r
7878 o.content = t.dom.setHTML(t.getBody(), tinymce.trim(o.content));
\r
7880 if (o.format != 'raw' && t.settings.cleanup) {
\r
7881 o.getInner = true;
\r
7882 o.content = t.dom.setHTML(t.getBody(), t.serializer.serialize(t.getBody(), o));
\r
7886 t.onSetContent.dispatch(t, o);
\r
7891 getContent : function(o) {
\r
7895 o.format = o.format || 'html';
\r
7899 t.onBeforeGetContent.dispatch(t, o);
\r
7901 if (o.format != 'raw' && t.settings.cleanup) {
\r
7902 o.getInner = true;
\r
7903 h = t.serializer.serialize(t.getBody(), o);
\r
7905 h = t.getBody().innerHTML;
\r
7907 h = h.replace(/^\s*|\s*$/g, '');
\r
7911 t.onGetContent.dispatch(t, o);
\r
7916 isDirty : function() {
\r
7919 return tinymce.trim(t.startContent) != tinymce.trim(t.getContent({format : 'raw', no_events : 1})) && !t.isNotDirty;
\r
7922 getContainer : function() {
\r
7926 t.container = DOM.get(t.editorContainer || t.id + '_parent');
\r
7928 return t.container;
\r
7931 getContentAreaContainer : function() {
\r
7932 return this.contentAreaContainer;
\r
7935 getElement : function() {
\r
7936 return DOM.get(this.settings.content_element || this.id);
\r
7939 getWin : function() {
\r
7942 if (!t.contentWindow) {
\r
7943 e = DOM.get(t.id + "_ifr");
\r
7946 t.contentWindow = e.contentWindow;
\r
7949 return t.contentWindow;
\r
7952 getDoc : function() {
\r
7955 if (!t.contentDocument) {
\r
7959 t.contentDocument = w.document;
\r
7962 return t.contentDocument;
\r
7965 getBody : function() {
\r
7966 return this.bodyElement || this.getDoc().body;
\r
7969 convertURL : function(u, n, e) {
\r
7970 var t = this, s = t.settings;
\r
7972 // Use callback instead
\r
7973 if (s.urlconverter_callback)
\r
7974 return t.execCallback('urlconverter_callback', u, e, true, n);
\r
7976 // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
\r
7977 if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
\r
7980 // Convert to relative
\r
7981 if (s.relative_urls)
\r
7982 return t.documentBaseURI.toRelative(u);
\r
7984 // Convert to absolute
\r
7985 u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);
\r
7990 addVisual : function(e) {
\r
7991 var t = this, s = t.settings;
\r
7993 e = e || t.getBody();
\r
7995 if (!is(t.hasVisual))
\r
7996 t.hasVisual = s.visual;
\r
7998 each(t.dom.select('table,a', e), function(e) {
\r
8001 switch (e.nodeName) {
\r
8003 v = t.dom.getAttrib(e, 'border');
\r
8005 if (!v || v == '0') {
\r
8007 t.dom.addClass(e, s.visual_table_class);
\r
8009 t.dom.removeClass(e, s.visual_table_class);
\r
8015 v = t.dom.getAttrib(e, 'name');
\r
8019 t.dom.addClass(e, 'mceItemAnchor');
\r
8021 t.dom.removeClass(e, 'mceItemAnchor');
\r
8028 t.onVisualAid.dispatch(t, e, t.hasVisual);
\r
8031 remove : function() {
\r
8032 var t = this, e = t.getContainer();
\r
8034 t.removed = 1; // Cancels post remove event execution
\r
8037 t.execCallback('remove_instance_callback', t);
\r
8038 t.onRemove.dispatch(t);
\r
8040 // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command
\r
8041 t.onExecCommand.listeners = [];
\r
8043 EditorManager.remove(t);
\r
8047 destroy : function(s) {
\r
8050 // One time is enough
\r
8055 tinymce.removeUnload(t.destroy);
\r
8056 tinyMCE.onBeforeUnload.remove(t._beforeUnload);
\r
8059 if (t.theme.destroy)
\r
8060 t.theme.destroy();
\r
8062 // Destroy controls, selection and dom
\r
8063 t.controlManager.destroy();
\r
8064 t.selection.destroy();
\r
8067 // Remove all events
\r
8069 // Don't clear the window or document if content editable
\r
8070 // is enabled since other instances might still be present
\r
8071 if (!t.settings.content_editable) {
\r
8072 Event.clear(t.getWin());
\r
8073 Event.clear(t.getDoc());
\r
8076 Event.clear(t.getBody());
\r
8077 Event.clear(t.formElement);
\r
8080 if (t.formElement) {
\r
8081 t.formElement.submit = t.formElement._mceOldSubmit;
\r
8082 t.formElement._mceOldSubmit = null;
\r
8085 t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null;
\r
8088 t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null;
\r
8093 // Internal functions
\r
8095 _addEvents : function() {
\r
8096 // 'focus', 'blur', 'dblclick', 'beforedeactivate', submit, reset
\r
8097 var t = this, i, s = t.settings, lo = {
\r
8098 mouseup : 'onMouseUp',
\r
8099 mousedown : 'onMouseDown',
\r
8100 click : 'onClick',
\r
8101 keyup : 'onKeyUp',
\r
8102 keydown : 'onKeyDown',
\r
8103 keypress : 'onKeyPress',
\r
8104 submit : 'onSubmit',
\r
8105 reset : 'onReset',
\r
8106 contextmenu : 'onContextMenu',
\r
8107 dblclick : 'onDblClick',
\r
8108 paste : 'onPaste' // Doesn't work in all browsers yet
\r
8111 function eventHandler(e, o) {
\r
8114 // Don't fire events when it's removed
\r
8118 // Generic event handler
\r
8119 if (t.onEvent.dispatch(t, e, o) !== false) {
\r
8120 // Specific event handler
\r
8121 t[lo[e.fakeType || e.type]].dispatch(t, e, o);
\r
8126 each(lo, function(v, k) {
\r
8128 case 'contextmenu':
\r
8129 if (tinymce.isOpera) {
\r
8130 // Fake contextmenu on Opera
\r
8131 Event.add(t.getBody(), 'mousedown', function(e) {
\r
8133 e.fakeType = 'contextmenu';
\r
8138 Event.add(t.getBody(), k, eventHandler);
\r
8142 Event.add(t.getBody(), k, function(e) {
\r
8145 // Get plain text data
\r
8146 if (e.clipboardData)
\r
8147 tx = e.clipboardData.getData('text/plain');
\r
8148 else if (tinymce.isIE)
\r
8149 tx = t.getWin().clipboardData.getData('Text');
\r
8152 /*if (tinymce.isIE) {
\r
8153 el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
\r
8154 r = DOM.doc.body.createTextRange();
\r
8155 r.moveToElementText(el);
\r
8156 r.execCommand('Paste');
\r
8161 eventHandler(e, {text : tx, html : h});
\r
8167 Event.add(t.getElement().form || DOM.getParent(t.id, 'form'), k, eventHandler);
\r
8171 Event.add(s.content_editable ? t.getBody() : t.getDoc(), k, eventHandler);
\r
8175 Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) {
\r
8180 // Fixes bug where a specified document_base_uri could result in broken images
\r
8181 // This will also fix drag drop of images in Gecko
\r
8182 if (tinymce.isGecko) {
\r
8183 // Convert all images to absolute URLs
\r
8184 /* t.onSetContent.add(function(ed, o) {
\r
8185 each(ed.dom.select('img'), function(e) {
\r
8188 if (v = e.getAttribute('mce_src'))
\r
8189 e.src = t.documentBaseURI.toAbsolute(v);
\r
8193 Event.add(t.getDoc(), 'DOMNodeInserted', function(e) {
\r
8198 if (e.nodeType === 1 && e.nodeName === 'IMG' && (v = e.getAttribute('mce_src')))
\r
8199 e.src = t.documentBaseURI.toAbsolute(v);
\r
8203 // Set various midas options in Gecko
\r
8205 function setOpts() {
\r
8206 var t = this, d = t.getDoc(), s = t.settings;
\r
8208 if (isGecko && !s.readonly) {
\r
8209 if (t._isHidden()) {
\r
8211 if (!s.content_editable)
\r
8212 d.designMode = 'On';
\r
8214 // Fails if it's hidden
\r
8219 // Try new Gecko method
\r
8220 d.execCommand("styleWithCSS", 0, false);
\r
8223 if (!t._isHidden())
\r
8224 try {d.execCommand("useCSS", 0, true);} catch (ex) {}
\r
8227 if (!s.table_inline_editing)
\r
8228 try {d.execCommand('enableInlineTableEditing', false, false);} catch (ex) {}
\r
8230 if (!s.object_resizing)
\r
8231 try {d.execCommand('enableObjectResizing', false, false);} catch (ex) {}
\r
8235 t.onBeforeExecCommand.add(setOpts);
\r
8236 t.onMouseDown.add(setOpts);
\r
8239 // Add node change handlers
\r
8240 t.onMouseUp.add(t.nodeChanged);
\r
8241 t.onClick.add(t.nodeChanged);
\r
8242 t.onKeyUp.add(function(ed, e) {
\r
8243 var c = e.keyCode;
\r
8245 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)
\r
8249 // Add reset handler
\r
8250 t.onReset.add(function() {
\r
8251 t.setContent(t.startContent, {format : 'raw'});
\r
8254 if (t.getParam('tab_focus')) {
\r
8255 function tabCancel(ed, e) {
\r
8256 if (e.keyCode === 9)
\r
8257 return Event.cancel(e);
\r
8260 function tabHandler(ed, e) {
\r
8261 var x, i, f, el, v;
\r
8263 function find(d) {
\r
8264 f = DOM.getParent(ed.id, 'form');
\r
8268 each(el, function(e, i) {
\r
8269 if (e.id == ed.id) {
\r
8276 for (i = x + 1; i < el.length; i++) {
\r
8277 if (el[i].type != 'hidden')
\r
8281 for (i = x - 1; i >= 0; i--) {
\r
8282 if (el[i].type != 'hidden')
\r
8291 if (e.keyCode === 9) {
\r
8292 v = explode(ed.getParam('tab_focus'));
\r
8294 if (v.length == 1) {
\r
8299 // Find element to focus
\r
8301 if (v[0] == ':prev')
\r
8304 el = DOM.get(v[0]);
\r
8306 if (v[1] == ':next')
\r
8309 el = DOM.get(v[1]);
\r
8313 if (ed = EditorManager.get(el.id || el.name))
\r
8316 window.setTimeout(function() {window.focus();el.focus();}, 10);
\r
8318 return Event.cancel(e);
\r
8323 t.onKeyUp.add(tabCancel);
\r
8326 t.onKeyPress.add(tabHandler);
\r
8327 t.onKeyDown.add(tabCancel);
\r
8329 t.onKeyDown.add(tabHandler);
\r
8333 if (s.custom_shortcuts) {
\r
8334 if (s.custom_undo_redo_keyboard_shortcuts) {
\r
8335 t.addShortcut('ctrl+z', t.getLang('undo_desc'), 'Undo');
\r
8336 t.addShortcut('ctrl+y', t.getLang('redo_desc'), 'Redo');
\r
8339 // Add default shortcuts for gecko
\r
8341 t.addShortcut('ctrl+b', t.getLang('bold_desc'), 'Bold');
\r
8342 t.addShortcut('ctrl+i', t.getLang('italic_desc'), 'Italic');
\r
8343 t.addShortcut('ctrl+u', t.getLang('underline_desc'), 'Underline');
\r
8346 // BlockFormat shortcuts keys
\r
8347 for (i=1; i<=6; i++)
\r
8348 t.addShortcut('ctrl+' + i, '', ['FormatBlock', false, '<h' + i + '>']);
\r
8350 t.addShortcut('ctrl+7', '', ['FormatBlock', false, '<p>']);
\r
8351 t.addShortcut('ctrl+8', '', ['FormatBlock', false, '<div>']);
\r
8352 t.addShortcut('ctrl+9', '', ['FormatBlock', false, '<address>']);
\r
8354 function find(e) {
\r
8357 if (!e.altKey && !e.ctrlKey && !e.metaKey)
\r
8360 each(t.shortcuts, function(o) {
\r
8361 if (tinymce.isMac && o.ctrl != e.metaKey)
\r
8363 else if (!tinymce.isMac && o.ctrl != e.ctrlKey)
\r
8366 if (o.alt != e.altKey)
\r
8369 if (o.shift != e.shiftKey)
\r
8372 if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) {
\r
8381 t.onKeyUp.add(function(ed, e) {
\r
8385 return Event.cancel(e);
\r
8388 t.onKeyPress.add(function(ed, e) {
\r
8392 return Event.cancel(e);
\r
8395 t.onKeyDown.add(function(ed, e) {
\r
8399 o.func.call(o.scope);
\r
8400 return Event.cancel(e);
\r
8405 if (tinymce.isIE) {
\r
8406 // Fix so resize will only update the width and height attributes not the styles of an image
\r
8407 // It will also block mceItemNoResize items
\r
8408 Event.add(t.getDoc(), 'controlselect', function(e) {
\r
8409 var re = t.resizeInfo, cb;
\r
8413 // Don't do this action for non image elements
\r
8414 if (e.nodeName !== 'IMG')
\r
8418 Event.remove(re.node, re.ev, re.cb);
\r
8420 if (!t.dom.hasClass(e, 'mceItemNoResize')) {
\r
8422 cb = Event.add(e, ev, function(e) {
\r
8427 if (v = t.dom.getStyle(e, 'width')) {
\r
8428 t.dom.setAttrib(e, 'width', v.replace(/[^0-9%]+/g, ''));
\r
8429 t.dom.setStyle(e, 'width', '');
\r
8432 if (v = t.dom.getStyle(e, 'height')) {
\r
8433 t.dom.setAttrib(e, 'height', v.replace(/[^0-9%]+/g, ''));
\r
8434 t.dom.setStyle(e, 'height', '');
\r
8438 ev = 'resizestart';
\r
8439 cb = Event.add(e, 'resizestart', Event.cancel, Event);
\r
8442 re = t.resizeInfo = {
\r
8449 t.onKeyDown.add(function(ed, e) {
\r
8450 switch (e.keyCode) {
\r
8452 // Fix IE control + backspace browser bug
\r
8453 if (t.selection.getRng().item) {
\r
8454 t.selection.getRng().item(0).removeNode();
\r
8455 return Event.cancel(e);
\r
8461 if (tinymce.isOpera) {
\r
8462 t.onClick.add(function(ed, e) {
\r
8467 // Add custom undo/redo handlers
\r
8468 if (s.custom_undo_redo) {
\r
8469 function addUndo() {
\r
8470 t.undoManager.typing = 0;
\r
8471 t.undoManager.add();
\r
8474 // Add undo level on editor blur
\r
8475 if (tinymce.isIE) {
\r
8476 Event.add(t.getWin(), 'blur', function(e) {
\r
8479 // Check added for fullscreen bug
\r
8480 if (t.selection) {
\r
8481 n = t.selection.getNode();
\r
8483 // Add undo level is selection was lost to another document
\r
8484 if (!t.removed && n.ownerDocument && n.ownerDocument != t.getDoc())
\r
8489 Event.add(t.getDoc(), 'blur', function() {
\r
8490 if (t.selection && !t.removed)
\r
8495 t.onMouseDown.add(addUndo);
\r
8497 t.onKeyUp.add(function(ed, e) {
\r
8498 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.ctrlKey) {
\r
8499 t.undoManager.typing = 0;
\r
8500 t.undoManager.add();
\r
8504 t.onKeyDown.add(function(ed, e) {
\r
8505 // Is caracter positon keys
\r
8506 if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45) {
\r
8507 if (t.undoManager.typing) {
\r
8508 t.undoManager.add();
\r
8509 t.undoManager.typing = 0;
\r
8515 if (!t.undoManager.typing) {
\r
8516 t.undoManager.add();
\r
8517 t.undoManager.typing = 1;
\r
8523 _convertInlineElements : function() {
\r
8524 var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp;
\r
8526 function convert(ed, o) {
\r
8527 if (!s.inline_styles)
\r
8531 each(t.dom.select('table,u,strike', o.node), function(n) {
\r
8532 switch (n.nodeName) {
\r
8534 if (v = dom.getAttrib(n, 'height')) {
\r
8535 dom.setStyle(n, 'height', v);
\r
8536 dom.setAttrib(n, 'height', '');
\r
8542 //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
\r
8543 n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
\r
8544 dom.setAttrib(n, 'mce_style', '');
\r
8545 dom.setAttrib(n, 'mce_name', 'span');
\r
8549 } else if (o.set) {
\r
8550 each(t.dom.select('table,span', o.node).reverse(), function(n) {
\r
8551 if (n.nodeName == 'TABLE') {
\r
8552 if (v = dom.getStyle(n, 'height'))
\r
8553 dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, ''));
\r
8555 // Convert spans to elements
\r
8556 if (n.style.textDecoration == 'underline')
\r
8558 else if (n.style.textDecoration == 'line-through')
\r
8564 n.style.textDecoration = '';
\r
8565 dom.setAttrib(n, 'mce_style', '');
\r
8567 e = dom.create(na, {
\r
8568 style : dom.getAttrib(n, 'style')
\r
8571 dom.replace(e, n, 1);
\r
8578 t.onPreProcess.add(convert);
\r
8580 if (!s.cleanup_on_startup) {
\r
8581 t.onSetContent.add(function(ed, o) {
\r
8583 convert(t, {node : t.getBody(), set : 1});
\r
8588 _convertFonts : function() {
\r
8589 var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl;
\r
8592 if (!s.inline_styles)
\r
8595 // Font pt values and font size names
\r
8596 fz = [8, 10, 12, 14, 18, 24, 36];
\r
8597 fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large'];
\r
8599 if (sl = s.font_size_style_values)
\r
8602 if (cl = s.font_size_classes)
\r
8605 function process(no) {
\r
8608 // Keep unit tests happy
\r
8609 if (!s.inline_styles)
\r
8612 nl = t.dom.select('font', no);
\r
8613 for (x = nl.length - 1; x >= 0; x--) {
\r
8616 sp = dom.create('span', {
\r
8617 style : dom.getAttrib(n, 'style'),
\r
8618 'class' : dom.getAttrib(n, 'class')
\r
8621 dom.setStyles(sp, {
\r
8622 fontFamily : dom.getAttrib(n, 'face'),
\r
8623 color : dom.getAttrib(n, 'color'),
\r
8624 backgroundColor : n.style.backgroundColor
\r
8629 dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
\r
8631 dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
\r
8634 dom.setAttrib(sp, 'mce_style', '');
\r
8635 dom.replace(sp, n, 1);
\r
8640 t.onPreProcess.add(function(ed, o) {
\r
8645 t.onSetContent.add(function(ed, o) {
\r
8651 _isHidden : function() {
\r
8657 // Weird, wheres that cursor selection?
\r
8658 s = this.selection.getSel();
\r
8659 return (!s || !s.rangeCount || s.rangeCount == 0);
\r
8662 // Fix for bug #1867292
\r
8663 _fixNesting : function(s) {
\r
8666 s = s.replace(/<(\/)?([^\s>]+)[^>]*?>/g, function(a, b, c) {
\r
8669 // Handle end element
\r
8674 if (c !== d[d.length - 1].tag) {
\r
8675 for (i=d.length - 1; i>=0; i--) {
\r
8676 if (d[i].tag === c) {
\r
8686 if (d.length && d[d.length - 1].close) {
\r
8687 a = a + '</' + d[d.length - 1].tag + '>';
\r
8693 if (/^(br|hr|input|meta|img|link|param)$/i.test(c))
\r
8696 // Ignore closed ones
\r
8697 if (/\/>$/.test(a))
\r
8700 d.push({tag : c}); // Push start element
\r
8706 // End all open tags
\r
8707 for (i=d.length - 1; i>=0; i--)
\r
8708 s += '</' + d[i].tag + '>';
\r
8716 /* file:jscripts/tiny_mce/classes/EditorCommands.js */
\r
8719 var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit;
\r
8721 function isBlock(n) {
\r
8722 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);
\r
8725 tinymce.create('tinymce.EditorCommands', {
\r
8726 EditorCommands : function(ed) {
\r
8730 execCommand : function(cmd, ui, val) {
\r
8731 var t = this, ed = t.editor, f;
\r
8738 ed.getDoc().execCommand(cmd, ui, val);
\r
8741 ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
\r
8743 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
\r
8746 ed.windowManager.alert(ed.getLang('clipboard_no_support'));
\r
8752 case 'mceResetDesignMode':
\r
8753 case 'mceBeginUndoLevel':
\r
8761 // Bundle these together
\r
8762 case 'JustifyLeft':
\r
8763 case 'JustifyCenter':
\r
8764 case 'JustifyRight':
\r
8765 case 'JustifyFull':
\r
8766 t.mceJustify(cmd, cmd.substring(7).toLowerCase());
\r
8769 case 'mceEndUndoLevel':
\r
8770 case 'mceAddUndoLevel':
\r
8771 ed.undoManager.add();
\r
8778 f.call(this, ui, val);
\r
8786 Indent : function() {
\r
8787 var ed = this.editor, d = ed.dom, s = ed.selection, e, iv, iu;
\r
8789 // Setup indent level
\r
8790 iv = ed.settings.indentation;
\r
8791 iu = /[a-z%]+$/i.exec(iv);
\r
8792 iv = parseInt(iv);
\r
8794 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
\r
8795 each(this._getSelectedBlocks(), function(e) {
\r
8796 d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu);
\r
8802 ed.getDoc().execCommand('Indent', false, null);
\r
8805 d.getParent(s.getNode(), function(n) {
\r
8806 if (n.nodeName == 'BLOCKQUOTE') {
\r
8807 n.dir = n.style.cssText = '';
\r
8813 Outdent : function() {
\r
8814 var ed = this.editor, d = ed.dom, s = ed.selection, e, v, iv, iu;
\r
8816 // Setup indent level
\r
8817 iv = ed.settings.indentation;
\r
8818 iu = /[a-z%]+$/i.exec(iv);
\r
8819 iv = parseInt(iv);
\r
8821 if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
\r
8822 each(this._getSelectedBlocks(), function(e) {
\r
8823 v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv);
\r
8824 d.setStyle(e, 'paddingLeft', v ? v + iu : '');
\r
8830 ed.getDoc().execCommand('Outdent', false, null);
\r
8833 mceSetAttribute : function(u, v) {
\r
8834 var ed = this.editor, d = ed.dom, e;
\r
8836 if (e = d.getParent(ed.selection.getNode(), d.isBlock))
\r
8837 d.setAttrib(e, v.name, v.value);
\r
8840 mceSetContent : function(u, v) {
\r
8841 this.editor.setContent(v);
\r
8844 mceToggleVisualAid : function() {
\r
8845 var ed = this.editor;
\r
8847 ed.hasVisual = !ed.hasVisual;
\r
8851 mceReplaceContent : function(u, v) {
\r
8852 var s = this.editor.selection;
\r
8854 s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'})));
\r
8857 mceInsertLink : function(u, v) {
\r
8858 var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A');
\r
8860 if (tinymce.is(v, 'string'))
\r
8864 each(v, function(v, k) {
\r
8865 ed.dom.setAttrib(e, k, v);
\r
8870 ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
\r
8871 each(ed.dom.select('a'), function(e) {
\r
8872 if (e.href == 'javascript:mctmp(0);')
\r
8879 ed.dom.remove(e, 1);
\r
8883 UnLink : function() {
\r
8884 var ed = this.editor, s = ed.selection;
\r
8886 if (s.isCollapsed())
\r
8887 s.select(s.getNode());
\r
8889 ed.getDoc().execCommand('unlink', false, null);
\r
8893 FontName : function(u, v) {
\r
8894 var t = this, ed = t.editor, s = ed.selection, e;
\r
8897 if (s.isCollapsed())
\r
8898 s.select(s.getNode());
\r
8902 if (ed.settings.convert_fonts_to_spans)
\r
8903 t._applyInlineStyle('span', {style : {fontFamily : v}});
\r
8905 ed.getDoc().execCommand('FontName', false, v);
\r
8909 FontSize : function(u, v) {
\r
8910 var ed = this.editor, s = ed.settings, fc, fs;
\r
8912 // Use style options instead
\r
8913 if (s.convert_fonts_to_spans && v >= 1 && v <= 7) {
\r
8914 fs = tinymce.explode(s.font_size_style_values);
\r
8915 fc = tinymce.explode(s.font_size_classes);
\r
8918 v = fc[v - 1] || v;
\r
8920 v = fs[v - 1] || v;
\r
8923 if (v >= 1 && v <= 7)
\r
8924 ed.getDoc().execCommand('FontSize', false, v);
\r
8926 this._applyInlineStyle('span', {style : {fontSize : v}});
\r
8929 queryCommandValue : function(c) {
\r
8930 var f = this['queryValue' + c];
\r
8933 return f.call(this, c);
\r
8938 queryCommandState : function(cmd) {
\r
8942 // Bundle these together
\r
8943 case 'JustifyLeft':
\r
8944 case 'JustifyCenter':
\r
8945 case 'JustifyRight':
\r
8946 case 'JustifyFull':
\r
8947 return this.queryStateJustify(cmd, cmd.substring(7).toLowerCase());
\r
8950 if (f = this['queryState' + cmd])
\r
8951 return f.call(this, cmd);
\r
8957 _queryState : function(c) {
\r
8959 return this.editor.getDoc().queryCommandState(c);
\r
8961 // Ignore exception
\r
8965 _queryVal : function(c) {
\r
8967 return this.editor.getDoc().queryCommandValue(c);
\r
8969 // Ignore exception
\r
8973 queryValueFontSize : function() {
\r
8974 var ed = this.editor, v = 0, p;
\r
8976 if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
\r
8977 v = p.style.fontSize;
\r
8979 if (!v && (isOpera || isWebKit)) {
\r
8980 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
\r
8986 return v || this._queryVal('FontSize');
\r
8989 queryValueFontName : function() {
\r
8990 var ed = this.editor, v = 0, p;
\r
8992 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
\r
8995 if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
\r
8996 v = p.style.fontFamily.replace(/, /g, ',').replace(/[\'\"]/g, '').toLowerCase();
\r
8999 v = this._queryVal('FontName');
\r
9004 mceJustify : function(c, v) {
\r
9005 var ed = this.editor, se = ed.selection, n = se.getNode(), nn = n.nodeName, bl, nb, dom = ed.dom, rm;
\r
9007 if (ed.settings.inline_styles && this.queryStateJustify(c, v))
\r
9010 bl = dom.getParent(n, ed.dom.isBlock);
\r
9012 if (nn == 'IMG') {
\r
9017 if (v == 'center')
\r
9018 dom.setStyle(bl || n.parentNode, 'textAlign', '');
\r
9020 dom.setStyle(n, 'float', '');
\r
9021 this.mceRepaint();
\r
9025 if (v == 'center') {
\r
9026 // Do not change table elements
\r
9027 if (bl && /^(TD|TH)$/.test(bl.nodeName))
\r
9030 if (!bl || bl.childNodes.length > 1) {
\r
9031 nb = dom.create('p');
\r
9032 nb.appendChild(n.cloneNode(false));
\r
9035 dom.insertAfter(nb, bl);
\r
9037 dom.insertAfter(nb, n);
\r
9040 n = nb.firstChild;
\r
9044 dom.setStyle(bl, 'textAlign', v);
\r
9045 dom.setStyle(n, 'float', '');
\r
9047 dom.setStyle(n, 'float', v);
\r
9048 dom.setStyle(bl || n.parentNode, 'textAlign', '');
\r
9051 this.mceRepaint();
\r
9055 // Handle the alignment outselfs, less quirks in all browsers
\r
9056 if (ed.settings.inline_styles && ed.settings.forced_root_block) {
\r
9060 each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
\r
9061 dom.setAttrib(e, 'align', '');
\r
9062 dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v);
\r
9067 ed.getDoc().execCommand(c, false, null);
\r
9069 if (ed.settings.inline_styles) {
\r
9071 dom.getParent(ed.selection.getNode(), function(n) {
\r
9072 if (n.style && n.style.textAlign)
\r
9073 dom.setStyle(n, 'textAlign', '');
\r
9079 each(dom.select('*'), function(n) {
\r
9086 dom.setStyle(n, 'textAlign', v);
\r
9087 dom.setAttrib(n, 'align', '');
\r
9093 mceSetCSSClass : function(u, v) {
\r
9094 this.mceSetStyleInfo(0, {command : 'setattrib', name : 'class', value : v});
\r
9097 getSelectedElement : function() {
\r
9098 var t = this, ed = t.editor, dom = ed.dom, se = ed.selection, r = se.getRng(), r1, r2, sc, ec, so, eo, e, sp, ep, re;
\r
9100 if (se.isCollapsed() || r.item)
\r
9101 return se.getNode();
\r
9104 re = ed.settings.merge_styles_invalid_parents;
\r
9105 if (tinymce.is(re, 'string'))
\r
9106 re = new RegExp(re, 'i');
\r
9109 r1 = r.duplicate();
\r
9110 r1.collapse(true);
\r
9111 sc = r1.parentElement();
\r
9113 r2 = r.duplicate();
\r
9114 r2.collapse(false);
\r
9115 ec = r2.parentElement();
\r
9118 r1.move('character', 1);
\r
9119 sc = r1.parentElement();
\r
9123 r1 = r.duplicate();
\r
9124 r1.moveToElementText(sc);
\r
9126 if (r1.compareEndPoints('StartToStart', r) == 0 && r1.compareEndPoints('EndToEnd', r) == 0)
\r
9127 return re && re.test(sc.nodeName) ? null : sc;
\r
9130 function getParent(n) {
\r
9131 return dom.getParent(n, function(n) {return n.nodeType == 1;});
\r
9134 sc = r.startContainer;
\r
9135 ec = r.endContainer;
\r
9136 so = r.startOffset;
\r
9139 if (!r.collapsed) {
\r
9141 if (so - eo < 2) {
\r
9142 if (sc.hasChildNodes()) {
\r
9143 sp = sc.childNodes[so];
\r
9144 return re && re.test(sp.nodeName) ? null : sp;
\r
9150 if (sc.nodeType != 3 || ec.nodeType != 3)
\r
9154 sp = getParent(sc);
\r
9156 if (sp && sp.firstChild != sc)
\r
9160 if (so == sc.nodeValue.length) {
\r
9161 e = sc.nextSibling;
\r
9163 if (e && e.nodeType == 1)
\r
9164 sp = sc.nextSibling;
\r
9168 e = ec.previousSibling;
\r
9170 if (e && e.nodeType == 1)
\r
9174 if (eo == ec.nodeValue.length) {
\r
9175 ep = getParent(ec);
\r
9177 if (ep && ep.lastChild != ec)
\r
9183 return re && sp && re.test(sp.nodeName) ? null : sp;
\r
9189 InsertHorizontalRule : function() {
\r
9190 // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
\r
9191 if (isGecko || isIE)
\r
9192 this.editor.selection.setContent('<hr />');
\r
9194 this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
\r
9197 RemoveFormat : function() {
\r
9198 var t = this, ed = t.editor, s = ed.selection, b;
\r
9200 // Safari breaks tables
\r
9202 s.setContent(s.getContent({format : 'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g, ''), {format : 'raw'});
\r
9204 ed.getDoc().execCommand('RemoveFormat', false, null);
\r
9206 t.mceSetStyleInfo(0, {command : 'removeformat'});
\r
9210 mceSetStyleInfo : function(u, v) {
\r
9211 var t = this, ed = t.editor, d = ed.getDoc(), dom = ed.dom, e, b, s = ed.selection, nn = v.wrapper || 'span', b = s.getBookmark(), re;
\r
9213 function set(n, e) {
\r
9214 if (n.nodeType == 1) {
\r
9215 switch (v.command) {
\r
9217 return dom.setAttrib(n, v.name, v.value);
\r
9220 return dom.setStyle(n, v.name, v.value);
\r
9222 case 'removeformat':
\r
9223 return dom.setAttrib(n, 'class', '');
\r
9229 re = ed.settings.merge_styles_invalid_parents;
\r
9230 if (tinymce.is(re, 'string'))
\r
9231 re = new RegExp(re, 'i');
\r
9233 // Set style info on selected element
\r
9234 if ((e = t.getSelectedElement()) && !ed.settings.force_span_wrappers)
\r
9237 // Generate wrappers and set styles on them
\r
9238 d.execCommand('FontName', false, '__');
\r
9239 each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
\r
9242 if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
\r
9243 sp = dom.create(nn, {mce_new : '1'});
\r
9247 each (n.childNodes, function(n) {
\r
9248 sp.appendChild(n.cloneNode(true));
\r
9251 dom.replace(sp, n);
\r
9256 // Remove wrappers inside new ones
\r
9257 each(dom.select(nn).reverse(), function(n) {
\r
9258 var p = n.parentNode;
\r
9260 // Check if it's an old span in a new wrapper
\r
9261 if (!dom.getAttrib(n, 'mce_new')) {
\r
9262 // Find new wrapper
\r
9263 p = dom.getParent(n, function(n) {
\r
9264 return n.nodeType == 1 && dom.getAttrib(n, 'mce_new');
\r
9272 // Merge wrappers with parent wrappers
\r
9273 each(dom.select(nn).reverse(), function(n) {
\r
9274 var p = n.parentNode;
\r
9276 if (!p || !dom.getAttrib(n, 'mce_new'))
\r
9279 if (ed.settings.force_span_wrappers && p.nodeName != 'SPAN')
\r
9282 // Has parent of the same type and only child
\r
9283 if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1)
\r
9284 return dom.remove(p, 1);
\r
9286 // Has parent that is more suitable to have the class and only child
\r
9287 if (n.nodeType == 1 && (!re || !re.test(p.nodeName)) && p.childNodes.length == 1) {
\r
9288 set(p); // Set style info on parent instead
\r
9289 dom.setAttrib(n, 'class', '');
\r
9293 // Remove empty wrappers
\r
9294 each(dom.select(nn).reverse(), function(n) {
\r
9295 if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) {
\r
9296 if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style'))
\r
9297 return dom.remove(n, 1);
\r
9299 dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker
\r
9303 s.moveToBookmark(b);
\r
9306 queryStateJustify : function(c, v) {
\r
9307 var ed = this.editor, n = ed.selection.getNode(), dom = ed.dom;
\r
9309 if (n && n.nodeName == 'IMG') {
\r
9310 if (dom.getStyle(n, 'float') == v)
\r
9313 return n.parentNode.style.textAlign == v;
\r
9316 n = dom.getParent(ed.selection.getStart(), function(n) {
\r
9317 return n.nodeType == 1 && n.style.textAlign;
\r
9323 if (ed.settings.inline_styles)
\r
9324 return (n && n.style.textAlign == v);
\r
9326 return this._queryState(c);
\r
9329 ForeColor : function(ui, v) {
\r
9330 var ed = this.editor;
\r
9332 if (ed.settings.convert_fonts_to_spans) {
\r
9333 this._applyInlineStyle('span', {style : {color : v}});
\r
9336 ed.getDoc().execCommand('ForeColor', false, v);
\r
9339 HiliteColor : function(ui, val) {
\r
9340 var t = this, ed = t.editor, d = ed.getDoc();
\r
9342 if (ed.settings.convert_fonts_to_spans) {
\r
9343 this._applyInlineStyle('span', {style : {backgroundColor : val}});
\r
9352 // Try new Gecko method
\r
9353 d.execCommand("styleWithCSS", 0, s);
\r
9356 d.execCommand("useCSS", 0, !s);
\r
9360 if (isGecko || isOpera) {
\r
9362 d.execCommand('hilitecolor', false, val);
\r
9365 d.execCommand('BackColor', false, val);
\r
9368 Undo : function() {
\r
9369 var ed = this.editor;
\r
9371 if (ed.settings.custom_undo_redo) {
\r
9372 ed.undoManager.undo();
\r
9375 ed.getDoc().execCommand('Undo', false, null);
\r
9378 Redo : function() {
\r
9379 var ed = this.editor;
\r
9381 if (ed.settings.custom_undo_redo) {
\r
9382 ed.undoManager.redo();
\r
9385 ed.getDoc().execCommand('Redo', false, null);
\r
9388 FormatBlock : function(ui, val) {
\r
9389 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b;
\r
9391 function isBlock(n) {
\r
9392 return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);
\r
9395 bl = dom.getParent(s.getNode(), function(n) {
\r
9396 return isBlock(n);
\r
9399 // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div>
\r
9400 // FF and Opera doesn't change parent DIV elements if you switch format
\r
9402 if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
\r
9403 // Rename block element
\r
9404 nb = ed.dom.create(val);
\r
9406 each(dom.getAttribs(bl), function(v) {
\r
9407 dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName));
\r
9410 b = s.getBookmark();
\r
9411 dom.replace(nb, bl, 1);
\r
9412 s.moveToBookmark(b);
\r
9418 val = ed.settings.forced_root_block ? (val || '<p>') : val;
\r
9420 if (val.indexOf('<') == -1)
\r
9421 val = '<' + val + '>';
\r
9423 if (tinymce.isGecko)
\r
9424 val = val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi, '$1');
\r
9426 ed.getDoc().execCommand('FormatBlock', false, val);
\r
9429 mceCleanup : function() {
\r
9430 var ed = this.editor, s = ed.selection, b = s.getBookmark();
\r
9431 ed.setContent(ed.getContent());
\r
9432 s.moveToBookmark(b);
\r
9435 mceRemoveNode : function(ui, val) {
\r
9436 var ed = this.editor, s = ed.selection, b, n = val || s.getNode();
\r
9438 // Make sure that the body node isn't removed
\r
9439 if (n == ed.getBody())
\r
9442 b = s.getBookmark();
\r
9443 ed.dom.remove(n, 1);
\r
9444 s.moveToBookmark(b);
\r
9448 mceSelectNodeDepth : function(ui, val) {
\r
9449 var ed = this.editor, s = ed.selection, c = 0;
\r
9451 ed.dom.getParent(s.getNode(), function(n) {
\r
9452 if (n.nodeType == 1 && c++ == val) {
\r
9460 mceSelectNode : function(u, v) {
\r
9461 this.editor.selection.select(v);
\r
9464 mceInsertContent : function(ui, val) {
\r
9465 this.editor.selection.setContent(val);
\r
9468 mceInsertRawHTML : function(ui, val) {
\r
9469 var ed = this.editor;
\r
9471 ed.selection.setContent('tiny_mce_marker');
\r
9472 ed.setContent(ed.getContent().replace(/tiny_mce_marker/g, val));
\r
9475 mceRepaint : function() {
\r
9476 var s, b, e = this.editor;
\r
9478 if (tinymce.isGecko) {
\r
9481 b = s.getBookmark(true);
\r
9484 s.getSel().selectAllChildren(e.getBody());
\r
9487 s.moveToBookmark(b);
\r
9494 queryStateUnderline : function() {
\r
9495 var ed = this.editor, n = ed.selection.getNode();
\r
9497 if (n && n.nodeName == 'A')
\r
9500 return this._queryState('Underline');
\r
9503 queryStateOutdent : function() {
\r
9504 var ed = this.editor, n;
\r
9506 if (ed.settings.inline_styles) {
\r
9507 if ((n = ed.dom.getParent(ed.selection.getStart(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
\r
9510 if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
\r
9514 return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList() || (!ed.settings.inline_styles && !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE'));
\r
9517 queryStateInsertUnorderedList : function() {
\r
9518 return this.editor.dom.getParent(this.editor.selection.getNode(), 'UL');
\r
9521 queryStateInsertOrderedList : function() {
\r
9522 return this.editor.dom.getParent(this.editor.selection.getNode(), 'OL');
\r
9525 queryStatemceBlockQuote : function() {
\r
9526 return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9529 mceBlockQuote : function() {
\r
9530 var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
\r
9532 function getBQ(e) {
\r
9533 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9536 // Get start/end block
\r
9537 sb = dom.getParent(s.getStart(), isBlock);
\r
9538 eb = dom.getParent(s.getEnd(), isBlock);
\r
9540 // Remove blockquote(s)
\r
9541 if (bq = getBQ(sb)) {
\r
9542 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
\r
9543 bm = s.getBookmark();
\r
9545 // Move all elements after the end block into new bq
\r
9547 bq2 = bq.cloneNode(false);
\r
9549 while (n = eb.nextSibling)
\r
9550 bq2.appendChild(n.parentNode.removeChild(n));
\r
9553 // Add new bq after
\r
9555 dom.insertAfter(bq2, bq);
\r
9557 // Move all selected blocks after the current bq
\r
9558 nl = t._getSelectedBlocks(sb, eb);
\r
9559 for (i = nl.length - 1; i >= 0; i--) {
\r
9560 dom.insertAfter(nl[i], bq);
\r
9563 // Empty bq, then remove it
\r
9564 if (/^\s*$/.test(bq.innerHTML))
\r
9565 dom.remove(bq, 1); // Keep children so boomark restoration works correctly
\r
9567 // Empty bq, then remote it
\r
9568 if (bq2 && /^\s*$/.test(bq2.innerHTML))
\r
9569 dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
\r
9572 // Move caret inside empty block element
\r
9574 r = ed.getDoc().createRange();
\r
9575 r.setStart(sb, 0);
\r
9582 // IE misses the empty block some times element so we must move back the caret
\r
9583 if (dom.getParent(s.getStart(), isBlock) != sb) {
\r
9585 r.move('character', -1);
\r
9590 t.editor.selection.moveToBookmark(bm);
\r
9595 // Since IE can start with a totally empty document we need to add the first bq and paragraph
\r
9596 if (isIE && !sb && !eb) {
\r
9597 t.editor.getDoc().execCommand('Indent');
\r
9598 n = getBQ(s.getNode());
\r
9599 n.style.margin = n.dir = ''; // IE adds margin and dir to bq
\r
9606 // If empty paragraph node then do not use bookmark
\r
9607 if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
\r
9608 bm = s.getBookmark();
\r
9610 // Move selected block elements into a bq
\r
9611 each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
\r
9612 // Found existing BQ add to this one
\r
9613 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
\r
9618 // No BQ found, create one
\r
9620 bq = dom.create('blockquote');
\r
9621 e.parentNode.insertBefore(bq, e);
\r
9624 // Add children from existing BQ
\r
9625 if (e.nodeName == 'BLOCKQUOTE' && bq) {
\r
9629 bq.appendChild(n.cloneNode(true));
\r
9630 n = n.nextSibling;
\r
9637 // Add non BQ element to BQ
\r
9638 bq.appendChild(dom.remove(e));
\r
9642 // Move caret inside empty block element
\r
9644 r = ed.getDoc().createRange();
\r
9645 r.setStart(sb, 0);
\r
9653 s.moveToBookmark(bm);
\r
9656 _applyInlineStyle : function(na, at, op) {
\r
9657 var t = this, ed = t.editor, dom = ed.dom, bm, lo = {}, kh;
\r
9659 na = na.toUpperCase();
\r
9661 if (op && op.check_classes && at['class'])
\r
9662 op.check_classes.push(at['class']);
\r
9664 function replaceFonts() {
\r
9667 each(dom.select(tinymce.isWebKit && !tinymce.isAir ? 'span' : 'font'), function(n) {
\r
9668 if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline') {
\r
9670 bm = ed.selection.getBookmark();
\r
9672 at._mce_new = '1';
\r
9673 dom.replace(dom.create(na, at), n, 1);
\r
9677 // Remove redundant elements
\r
9678 each(dom.select(na), function(n) {
\r
9679 if (n.getAttribute('_mce_new')) {
\r
9680 function removeStyle(n) {
\r
9681 if (n.nodeType == 1) {
\r
9682 each(at.style, function(v, k) {
\r
9683 dom.setStyle(n, k, '');
\r
9686 // Remove spans with the same class or marked classes
\r
9687 if (at['class'] && n.className && op) {
\r
9688 each(op.check_classes, function(c) {
\r
9689 if (dom.hasClass(n, c))
\r
9690 dom.removeClass(n, c);
\r
9696 // Remove specified style information from child elements
\r
9697 each(dom.select(na, n), removeStyle);
\r
9699 // Remove the specified style information on parent if current node is only child (IE)
\r
9700 if (n.parentNode && n.parentNode.nodeType == 1 && n.parentNode.childNodes.length == 1)
\r
9701 removeStyle(n.parentNode);
\r
9703 // Remove the child elements style info if a parent already has it
\r
9704 dom.getParent(n.parentNode, function(pn) {
\r
9705 if (pn.nodeType == 1) {
\r
9707 each(at.style, function(v, k) {
\r
9710 if (!lo[k] && (sv = dom.getStyle(pn, k))) {
\r
9712 dom.setStyle(n, k, '');
\r
9719 // Remove spans with the same class or marked classes
\r
9720 if (at['class'] && pn.className && op) {
\r
9721 each(op.check_classes, function(c) {
\r
9722 if (dom.hasClass(pn, c))
\r
9723 dom.removeClass(n, c);
\r
9731 n.removeAttribute('_mce_new');
\r
9735 // Remove empty span elements
\r
9736 each(dom.select(na).reverse(), function(n) {
\r
9739 // Check if there is any attributes
\r
9740 each(dom.getAttribs(n), function(an) {
\r
9741 if (an.nodeName.substring(0, 1) != '_' && dom.getAttrib(n, an.nodeName) != '') {
\r
9742 //console.log(dom.getOuterHTML(n), dom.getAttrib(n, an.nodeName));
\r
9747 // No attributes then remove the element and keep the children
\r
9752 ed.selection.moveToBookmark(bm);
\r
9757 // Create inline elements
\r
9759 ed.getDoc().execCommand('FontName', false, 'mceinline');
\r
9762 if (kh = t._applyInlineStyle.keyhandler) {
\r
9763 ed.onKeyUp.remove(kh);
\r
9764 ed.onKeyPress.remove(kh);
\r
9765 ed.onKeyDown.remove(kh);
\r
9766 ed.onSetContent.remove(t._applyInlineStyle.chandler);
\r
9769 if (ed.selection.isCollapsed()) {
\r
9770 // Start collecting styles
\r
9771 t._pendingStyles = tinymce.extend(t._pendingStyles || {}, at.style);
\r
9773 t._applyInlineStyle.chandler = ed.onSetContent.add(function() {
\r
9774 delete t._pendingStyles;
\r
9777 t._applyInlineStyle.keyhandler = kh = function(e) {
\r
9778 // Use pending styles
\r
9779 if (t._pendingStyles) {
\r
9780 at.style = t._pendingStyles;
\r
9781 delete t._pendingStyles;
\r
9784 if (replaceFonts()) {
\r
9785 ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);
\r
9786 ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);
\r
9789 if (e.type == 'keyup')
\r
9790 ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);
\r
9793 ed.onKeyDown.add(kh);
\r
9794 ed.onKeyPress.add(kh);
\r
9795 ed.onKeyUp.add(kh);
\r
9797 t._pendingStyles = 0;
\r
9801 _mceBlockQuote : function() {
\r
9802 var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom;
\r
9804 function findBQ(e) {
\r
9805 return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
\r
9808 // Remove blockquote(s)
\r
9809 if (findBQ(s.getStart())) {
\r
9810 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
\r
9811 // Found BQ lets remove it
\r
9812 if (e.nodeName == 'BLOCKQUOTE')
\r
9816 t.editor.selection.moveToBookmark(b);
\r
9820 each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
\r
9823 // Found existing BQ add to this one
\r
9824 if (e.nodeName == 'BLOCKQUOTE' && !bq) {
\r
9829 // No BQ found, create one
\r
9831 bq = dom.create('blockquote');
\r
9832 e.parentNode.insertBefore(bq, e);
\r
9835 // Add children from existing BQ
\r
9836 if (e.nodeName == 'BLOCKQUOTE' && bq) {
\r
9840 bq.appendChild(n.cloneNode(true));
\r
9841 n = n.nextSibling;
\r
9849 // Add non BQ element to BQ
\r
9850 bq.appendChild(dom.remove(e));
\r
9853 t.editor.selection.moveToBookmark(b);
\r
9856 _getSelectedBlocks : function(st, en) {
\r
9857 var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = [];
\r
9859 sb = dom.getParent(st || s.getStart(), isBlock);
\r
9860 eb = dom.getParent(en || s.getEnd(), isBlock);
\r
9865 if (sb && eb && sb != eb) {
\r
9868 while ((n = n.nextSibling) && n != eb) {
\r
9874 if (eb && sb != eb)
\r
9883 /* file:jscripts/tiny_mce/classes/UndoManager.js */
\r
9885 tinymce.create('tinymce.UndoManager', {
\r
9890 UndoManager : function(ed) {
\r
9891 var t = this, Dispatcher = tinymce.util.Dispatcher;
\r
9895 t.onAdd = new Dispatcher(this);
\r
9896 t.onUndo = new Dispatcher(this);
\r
9897 t.onRedo = new Dispatcher(this);
\r
9900 add : function(l) {
\r
9901 var t = this, i, ed = t.editor, b, s = ed.settings, la;
\r
9904 l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
\r
9906 // Add undo level if needed
\r
9907 l.content = l.content.replace(/^\s*|\s*$/g, '');
\r
9908 la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index];
\r
9909 if (!l.initial && la && l.content == la.content)
\r
9912 // Time to compress
\r
9913 if (s.custom_undo_redo_levels) {
\r
9914 if (t.data.length > s.custom_undo_redo_levels) {
\r
9915 for (i = 0; i < t.data.length - 1; i++)
\r
9916 t.data[i] = t.data[i + 1];
\r
9919 t.index = t.data.length;
\r
9923 if (s.custom_undo_redo_restore_selection && !l.initial)
\r
9924 l.bookmark = b = l.bookmark || ed.selection.getBookmark();
\r
9926 if (t.index < t.data.length)
\r
9929 // Only initial marked undo levels should be allowed as first item
\r
9930 // This to workaround a bug with Firefox and the blur event
\r
9931 if (t.data.length === 0 && !l.initial)
\r
9935 t.data.length = t.index + 1;
\r
9936 t.data[t.index++] = l;
\r
9941 // Set initial bookmark use first real undo level
\r
9942 if (t.data.length == 2 && t.data[0].initial)
\r
9943 t.data[0].bookmark = b;
\r
9945 t.onAdd.dispatch(t, l);
\r
9946 ed.isNotDirty = 0;
\r
9948 //console.dir(t.data);
\r
9953 undo : function() {
\r
9954 var t = this, ed = t.editor, l = l, i;
\r
9961 if (t.index > 0) {
\r
9962 // If undo on last index then take snapshot
\r
9963 if (t.index == t.data.length && t.index > 1) {
\r
9973 l = t.data[--t.index];
\r
9974 ed.setContent(l.content, {format : 'raw'});
\r
9975 ed.selection.moveToBookmark(l.bookmark);
\r
9977 t.onUndo.dispatch(t, l);
\r
9983 redo : function() {
\r
9984 var t = this, ed = t.editor, l = null;
\r
9986 if (t.index < t.data.length - 1) {
\r
9987 l = t.data[++t.index];
\r
9988 ed.setContent(l.content, {format : 'raw'});
\r
9989 ed.selection.moveToBookmark(l.bookmark);
\r
9991 t.onRedo.dispatch(t, l);
\r
9997 clear : function() {
\r
10003 t.add({initial : true});
\r
10006 hasUndo : function() {
\r
10007 return this.index != 0 || this.typing;
\r
10010 hasRedo : function() {
\r
10011 return this.index < this.data.length - 1;
\r
10015 /* file:jscripts/tiny_mce/classes/ForceBlocks.js */
\r
10019 var Event, isIE, isGecko, isOpera, each, extend;
\r
10021 Event = tinymce.dom.Event;
\r
10022 isIE = tinymce.isIE;
\r
10023 isGecko = tinymce.isGecko;
\r
10024 isOpera = tinymce.isOpera;
\r
10025 each = tinymce.each;
\r
10026 extend = tinymce.extend;
\r
10028 tinymce.create('tinymce.ForceBlocks', {
\r
10029 ForceBlocks : function(ed) {
\r
10030 var t = this, s = ed.settings, elm;
\r
10034 elm = (s.forced_root_block || 'p').toLowerCase();
\r
10035 s.element = elm.toUpperCase();
\r
10037 ed.onPreInit.add(t.setup, t);
\r
10039 t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi');
\r
10040 t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
\r
10041 t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
\r
10042 t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi');
\r
10043 t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
\r
10044 t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
\r
10046 function padd(ed, o) {
\r
10048 o.content = o.content.replace(t.reOpera, '</' + elm + '>');
\r
10050 o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>');
\r
10052 if (!isIE && !isOpera && o.set) {
\r
10053 // Use instead of BR in padded paragraphs
\r
10054 o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>');
\r
10055 o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>');
\r
10057 o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>');
\r
10058 o.content = o.content.replace(t.reTrailBr, '</' + elm + '>');
\r
10062 ed.onBeforeSetContent.add(padd);
\r
10063 ed.onPostProcess.add(padd);
\r
10065 if (s.forced_root_block) {
\r
10066 ed.onInit.add(t.forceRoots, t);
\r
10067 ed.onSetContent.add(t.forceRoots, t);
\r
10068 ed.onBeforeGetContent.add(t.forceRoots, t);
\r
10072 setup : function() {
\r
10073 var t = this, ed = t.editor, s = ed.settings;
\r
10075 // Force root blocks when typing and when getting output
\r
10076 if (s.forced_root_block) {
\r
10077 ed.onKeyUp.add(t.forceRoots, t);
\r
10078 ed.onPreProcess.add(t.forceRoots, t);
\r
10081 if (s.force_br_newlines) {
\r
10082 // Force IE to produce BRs on enter
\r
10084 ed.onKeyPress.add(function(ed, e) {
\r
10085 var n, s = ed.selection;
\r
10087 if (e.keyCode == 13 && s.getNode().nodeName != 'LI') {
\r
10088 s.setContent('<br id="__" /> ', {format : 'raw'});
\r
10089 n = ed.dom.get('__');
\r
10090 n.removeAttribute('id');
\r
10093 return Event.cancel(e);
\r
10101 if (!isIE && s.force_p_newlines) {
\r
10102 /* ed.onPreProcess.add(function(ed, o) {
\r
10103 each(ed.dom.select('br', o.node), function(n) {
\r
10104 var p = n.parentNode;
\r
10106 // Replace <p><br /></p> with <p> </p>
\r
10107 if (p && p.nodeName == 'p' && (p.childNodes.length == 1 || p.lastChild == n)) {
\r
10108 p.replaceChild(ed.getDoc().createTextNode('\u00a0'), n);
\r
10113 ed.onKeyPress.add(function(ed, e) {
\r
10114 if (e.keyCode == 13 && !e.shiftKey) {
\r
10115 if (!t.insertPara(e))
\r
10121 ed.onKeyDown.add(function(ed, e) {
\r
10122 if ((e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey)
\r
10123 t.backspaceDelete(e, e.keyCode == 8);
\r
10128 function ren(rn, na) {
\r
10129 var ne = ed.dom.create(na);
\r
10131 each(rn.attributes, function(a) {
\r
10132 if (a.specified && a.nodeValue)
\r
10133 ne.setAttribute(a.nodeName.toLowerCase(), a.nodeValue);
\r
10136 each(rn.childNodes, function(n) {
\r
10137 ne.appendChild(n.cloneNode(true));
\r
10140 rn.parentNode.replaceChild(ne, rn);
\r
10145 // Replaces IE:s auto generated paragraphs with the specified element name
\r
10146 if (isIE && s.element != 'P') {
\r
10147 ed.onKeyPress.add(function(ed, e) {
\r
10148 t.lastElm = ed.selection.getNode().nodeName;
\r
10151 ed.onKeyUp.add(function(ed, e) {
\r
10152 var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
\r
10154 if (b.childNodes.length === 1 && n.nodeName == 'P') {
\r
10155 n = ren(n, s.element);
\r
10158 ed.nodeChanged();
\r
10159 } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
\r
10160 bl = ed.dom.getParent(n, 'P');
\r
10163 ren(bl, s.element);
\r
10164 ed.nodeChanged();
\r
10171 find : function(n, t, s) {
\r
10172 var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, false), c = -1;
\r
10174 while (n = w.nextNode()) {
\r
10178 if (t == 0 && n == s)
\r
10182 if (t == 1 && c == s)
\r
10189 forceRoots : function(ed, e) {
\r
10190 var t = this, ed = t.editor, b = ed.getBody(), d = ed.getDoc(), se = ed.selection, s = se.getSel(), r = se.getRng(), si = -2, ei, so, eo, tr, c = -0xFFFFFF;
\r
10191 var nx, bl, bp, sp, le, nl = b.childNodes, i, n, eid;
\r
10193 // Fix for bug #1863847
\r
10194 //if (e && e.keyCode == 13)
\r
10197 // Wrap non blocks into blocks
\r
10198 for (i = nl.length - 1; i >= 0; i--) {
\r
10201 // Is text or non block element
\r
10202 if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
\r
10204 // Create new block but ignore whitespace
\r
10205 if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
\r
10206 // Store selection
\r
10207 if (si == -2 && r) {
\r
10209 // If selection is element then mark it
\r
10210 if (r.startContainer.nodeType == 1 && (n = r.startContainer.childNodes[r.startOffset]) && n.nodeType == 1) {
\r
10211 // Save the id of the selected element
\r
10212 eid = n.getAttribute("id");
\r
10213 n.setAttribute("id", "__mce");
\r
10215 // If element is inside body, might not be the case in contentEdiable mode
\r
10216 if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
\r
10217 so = r.startOffset;
\r
10218 eo = r.endOffset;
\r
10219 si = t.find(b, 0, r.startContainer);
\r
10220 ei = t.find(b, 0, r.endContainer);
\r
10224 tr = d.body.createTextRange();
\r
10225 tr.moveToElementText(b);
\r
10227 bp = tr.move('character', c) * -1;
\r
10229 tr = r.duplicate();
\r
10231 sp = tr.move('character', c) * -1;
\r
10233 tr = r.duplicate();
\r
10235 le = (tr.move('character', c) * -1) - sp;
\r
10242 bl = ed.dom.create(ed.settings.forced_root_block);
\r
10243 bl.appendChild(nx.cloneNode(1));
\r
10244 nx.parentNode.replaceChild(bl, nx);
\r
10247 if (bl.hasChildNodes())
\r
10248 bl.insertBefore(nx, bl.firstChild);
\r
10250 bl.appendChild(nx);
\r
10253 bl = null; // Time to create new block
\r
10256 // Restore selection
\r
10259 bl = b.getElementsByTagName(ed.settings.element)[0];
\r
10260 r = d.createRange();
\r
10262 // Select last location or generated block
\r
10264 r.setStart(t.find(b, 1, si), so);
\r
10266 r.setStart(bl, 0);
\r
10268 // Select last location or generated block
\r
10270 r.setEnd(t.find(b, 1, ei), eo);
\r
10275 s.removeAllRanges();
\r
10280 r = s.createRange();
\r
10281 r.moveToElementText(b);
\r
10283 r.moveStart('character', si);
\r
10284 r.moveEnd('character', ei);
\r
10290 } else if (!isIE && (n = ed.dom.get('__mce'))) {
\r
10291 // Restore the id of the selected element
\r
10293 n.setAttribute('id', eid);
\r
10295 n.removeAttribute('id');
\r
10297 // Move caret before selected element
\r
10298 r = d.createRange();
\r
10299 r.setStartBefore(n);
\r
10300 r.setEndBefore(n);
\r
10305 getParentBlock : function(n) {
\r
10306 var d = this.dom;
\r
10308 return d.getParent(n, d.isBlock);
\r
10311 insertPara : function(e) {
\r
10312 var t = this, ed = t.editor, dom = ed.dom, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body;
\r
10313 var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch, car;
\r
10315 function isEmpty(n) {
\r
10317 n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
\r
10318 n = n.replace(/<[^>]+>/g, ''); // Remove all tags
\r
10320 return n.replace(/[ \t\r\n]+/g, '') == '';
\r
10323 // If root blocks are forced then use Operas default behavior since it's really good
\r
10324 // Removed due to bug: #1853816
\r
10325 // if (se.forced_root_block && isOpera)
\r
10328 // Setup before range
\r
10329 rb = d.createRange();
\r
10331 // If is before the first block element and in body, then move it into first block element
\r
10332 rb.setStart(s.anchorNode, s.anchorOffset);
\r
10333 rb.collapse(true);
\r
10335 // Setup after range
\r
10336 ra = d.createRange();
\r
10338 // If is before the first block element and in body, then move it into first block element
\r
10339 ra.setStart(s.focusNode, s.focusOffset);
\r
10340 ra.collapse(true);
\r
10342 // Setup start/end points
\r
10343 dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
\r
10344 sn = dir ? s.anchorNode : s.focusNode;
\r
10345 so = dir ? s.anchorOffset : s.focusOffset;
\r
10346 en = dir ? s.focusNode : s.anchorNode;
\r
10347 eo = dir ? s.focusOffset : s.anchorOffset;
\r
10349 // If selection is in empty table cell
\r
10350 if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
\r
10351 dom.remove(sn.firstChild); // Remove BR
\r
10353 // Create two new block elements
\r
10354 ed.dom.add(sn, se.element, null, '<br />');
\r
10355 aft = ed.dom.add(sn, se.element, null, '<br />');
\r
10357 // Move caret into the last one
\r
10358 r = d.createRange();
\r
10359 r.selectNodeContents(aft);
\r
10361 ed.selection.setRng(r);
\r
10366 // If the caret is in an invalid location in FF we need to move it into the first block
\r
10367 if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
\r
10368 sn = en = sn.firstChild;
\r
10370 rb = d.createRange();
\r
10371 rb.setStart(sn, 0);
\r
10372 ra = d.createRange();
\r
10373 ra.setStart(en, 0);
\r
10376 // Never use body as start or end node
\r
10377 sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
\r
10378 sn = sn.nodeName == "BODY" ? sn.firstChild : sn;
\r
10379 en = en.nodeName == "HTML" ? d.body : en; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
\r
10380 en = en.nodeName == "BODY" ? en.firstChild : en;
\r
10382 // Get start and end blocks
\r
10383 sb = t.getParentBlock(sn);
\r
10384 eb = t.getParentBlock(en);
\r
10385 bn = sb ? sb.nodeName : se.element; // Get block name to create
\r
10387 // Return inside list use default browser behavior
\r
10388 if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
\r
10391 // If caption or absolute layers then always generate new blocks within
\r
10392 if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
\r
10397 // If caption or absolute layers then always generate new blocks within
\r
10398 if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
\r
10404 if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
\r
10409 // Setup new before and after blocks
\r
10410 bef = (sb && sb.nodeName == bn) ? sb.cloneNode(0) : ed.dom.create(bn);
\r
10411 aft = (eb && eb.nodeName == bn) ? eb.cloneNode(0) : ed.dom.create(bn);
\r
10413 // Remove id from after clone
\r
10414 aft.removeAttribute('id');
\r
10416 // Is header and cursor is at the end, then force paragraph under
\r
10417 if (/^(H[1-6])$/.test(bn) && sn.nodeValue && so == sn.nodeValue.length)
\r
10418 aft = ed.dom.create(se.element);
\r
10420 // Find start chop node
\r
10423 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
\r
10427 } while ((n = n.previousSibling ? n.previousSibling : n.parentNode));
\r
10429 // Find end chop node
\r
10432 if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
\r
10436 } while ((n = n.nextSibling ? n.nextSibling : n.parentNode));
\r
10438 // Place first chop part into before block element
\r
10439 if (sc.nodeName == bn)
\r
10440 rb.setStart(sc, 0);
\r
10442 rb.setStartBefore(sc);
\r
10444 rb.setEnd(sn, so);
\r
10445 bef.appendChild(rb.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
\r
10447 // Place secnd chop part within new block element
\r
10449 ra.setEndAfter(ec);
\r
10451 //console.debug(s.focusNode, s.focusOffset);
\r
10454 ra.setStart(en, eo);
\r
10455 aft.appendChild(ra.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
\r
10457 // Create range around everything
\r
10458 r = d.createRange();
\r
10459 if (!sc.previousSibling && sc.parentNode.nodeName == bn) {
\r
10460 r.setStartBefore(sc.parentNode);
\r
10462 if (rb.startContainer.nodeName == bn && rb.startOffset == 0)
\r
10463 r.setStartBefore(rb.startContainer);
\r
10465 r.setStart(rb.startContainer, rb.startOffset);
\r
10468 if (!ec.nextSibling && ec.parentNode.nodeName == bn)
\r
10469 r.setEndAfter(ec.parentNode);
\r
10471 r.setEnd(ra.endContainer, ra.endOffset);
\r
10473 // Delete and replace it with new block elements
\r
10474 r.deleteContents();
\r
10477 ed.getWin().scrollTo(0, vp.y);
\r
10479 // Never wrap blocks in blocks
\r
10480 if (bef.firstChild && bef.firstChild.nodeName == bn)
\r
10481 bef.innerHTML = bef.firstChild.innerHTML;
\r
10483 if (aft.firstChild && aft.firstChild.nodeName == bn)
\r
10484 aft.innerHTML = aft.firstChild.innerHTML;
\r
10486 // Padd empty blocks
\r
10487 if (isEmpty(bef))
\r
10488 bef.innerHTML = '<br />';
\r
10490 function appendStyles(e, en) {
\r
10491 var nl = [], nn, n, i;
\r
10493 e.innerHTML = '';
\r
10495 // Make clones of style elements
\r
10496 if (se.keep_styles) {
\r
10499 // We only want style specific elements
\r
10500 if (/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)) {
\r
10501 nn = n.cloneNode(false);
\r
10502 dom.setAttrib(nn, 'id', ''); // Remove ID since it needs to be unique
\r
10505 } while (n = n.parentNode);
\r
10508 // Append style elements to aft
\r
10509 if (nl.length > 0) {
\r
10510 for (i = nl.length - 1, nn = e; i >= 0; i--)
\r
10511 nn = nn.appendChild(nl[i]);
\r
10513 // Padd most inner style element
\r
10514 nl[0].innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
\r
10515 return nl[0]; // Move caret to most inner element
\r
10517 e.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there
\r
10520 // Fill empty afterblook with current style
\r
10521 if (isEmpty(aft))
\r
10522 car = appendStyles(aft, en);
\r
10524 // Opera needs this one backwards for older versions
\r
10525 if (isOpera && parseFloat(opera.version()) < 9.5) {
\r
10526 r.insertNode(bef);
\r
10527 r.insertNode(aft);
\r
10529 r.insertNode(aft);
\r
10530 r.insertNode(bef);
\r
10537 function first(n) {
\r
10538 return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n;
\r
10541 // Move cursor and scroll into view
\r
10542 r = d.createRange();
\r
10543 r.selectNodeContents(isGecko ? first(car || aft) : car || aft);
\r
10545 s.removeAllRanges();
\r
10548 // scrollIntoView seems to scroll the parent window in most browsers now including FF 3.0b4 so it's time to stop using it and do it our selfs
\r
10549 y = ed.dom.getPos(aft).y;
\r
10550 ch = aft.clientHeight;
\r
10552 // Is element within viewport
\r
10553 if (y < vp.y || y + ch > vp.y + vp.h) {
\r
10554 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
\r
10555 //console.debug('SCROLL!', 'vp.y: ' + vp.y, 'y' + y, 'vp.h' + vp.h, 'clientHeight' + aft.clientHeight, 'yyy: ' + (y < vp.y ? y : y - vp.h + aft.clientHeight));
\r
10561 backspaceDelete : function(e, bs) {
\r
10562 var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn;
\r
10564 // The caret sometimes gets stuck in Gecko if you delete empty paragraphs
\r
10565 // This workaround removes the element by hand and moves the caret to the previous element
\r
10566 if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) {
\r
10567 if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) {
\r
10568 // Find previous block element
\r
10570 while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ;
\r
10573 if (sc != b.firstChild) {
\r
10574 // Find last text node
\r
10575 w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
\r
10576 while (tn = w.nextNode())
\r
10579 // Place caret at the end of last text node
\r
10580 r = ed.getDoc().createRange();
\r
10581 r.setStart(n, n.nodeValue ? n.nodeValue.length : 0);
\r
10582 r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0);
\r
10585 // Remove the target container
\r
10586 ed.dom.remove(sc);
\r
10589 return Event.cancel(e);
\r
10594 // Gecko generates BR elements here and there, we don't like those so lets remove them
\r
10595 function handler(e) {
\r
10600 // A new BR was created in a block element, remove it
\r
10601 if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
\r
10602 pr = e.previousSibling;
\r
10604 Event.remove(b, 'DOMNodeInserted', handler);
\r
10606 // Is there whitespace at the end of the node before then we might need the pesky BR
\r
10607 // to place the caret at a correct location see bug: #2013943
\r
10608 if (pr && pr.nodeType == 3 && /\s+$/.test(pr.nodeValue))
\r
10611 // Only remove BR elements that got inserted in the middle of the text
\r
10612 if (e.previousSibling || e.nextSibling)
\r
10613 ed.dom.remove(e);
\r
10617 // Listen for new nodes
\r
10618 Event._add(b, 'DOMNodeInserted', handler);
\r
10620 // Remove listener
\r
10621 window.setTimeout(function() {
\r
10622 Event._remove(b, 'DOMNodeInserted', handler);
\r
10628 /* file:jscripts/tiny_mce/classes/ControlManager.js */
\r
10632 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend;
\r
10634 tinymce.create('tinymce.ControlManager', {
\r
10635 ControlManager : function(ed, s) {
\r
10641 t.onAdd = new tinymce.util.Dispatcher(t);
\r
10642 t.onPostRender = new tinymce.util.Dispatcher(t);
\r
10643 t.prefix = s.prefix || ed.id + '_';
\r
10646 t.onPostRender.add(function() {
\r
10647 each(t.controls, function(c) {
\r
10653 get : function(id) {
\r
10654 return this.controls[this.prefix + id] || this.controls[id];
\r
10657 setActive : function(id, s) {
\r
10660 if (c = this.get(id))
\r
10666 setDisabled : function(id, s) {
\r
10669 if (c = this.get(id))
\r
10670 c.setDisabled(s);
\r
10675 add : function(c) {
\r
10679 t.controls[c.id] = c;
\r
10680 t.onAdd.dispatch(c, t);
\r
10686 createControl : function(n) {
\r
10687 var c, t = this, ed = t.editor;
\r
10689 each(ed.plugins, function(p) {
\r
10690 if (p.createControl) {
\r
10691 c = p.createControl(n, t);
\r
10700 case "separator":
\r
10701 return t.createSeparator();
\r
10704 if (!c && ed.buttons && (c = ed.buttons[n]))
\r
10705 return t.createButton(n, c);
\r
10710 createDropMenu : function(id, s, cc) {
\r
10711 var t = this, ed = t.editor, c, bm, v, cls;
\r
10714 'class' : 'mceDropDown',
\r
10715 constrain : ed.settings.constrain_menus
\r
10718 s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin';
\r
10719 if (v = ed.getParam('skin_variant'))
\r
10720 s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1);
\r
10722 id = t.prefix + id;
\r
10723 cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu;
\r
10724 c = t.controls[id] = new cls(id, s);
\r
10725 c.onAddItem.add(function(c, o) {
\r
10726 var s = o.settings;
\r
10728 s.title = ed.getLang(s.title, s.title);
\r
10730 if (!s.onclick) {
\r
10731 s.onclick = function(v) {
\r
10732 ed.execCommand(s.cmd, s.ui || false, s.value);
\r
10737 ed.onRemove.add(function() {
\r
10741 // Fix for bug #1897785, #1898007
\r
10742 if (tinymce.isIE) {
\r
10743 c.onShowMenu.add(function() {
\r
10744 bm = ed.selection.getBookmark(1);
\r
10747 c.onHideMenu.add(function() {
\r
10749 ed.selection.moveToBookmark(bm);
\r
10756 createListBox : function(id, s, cc) {
\r
10757 var t = this, ed = t.editor, cmd, c, cls;
\r
10762 s.title = ed.translate(s.title);
\r
10763 s.scope = s.scope || ed;
\r
10765 if (!s.onselect) {
\r
10766 s.onselect = function(v) {
\r
10767 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10773 'class' : 'mce_' + id,
\r
10775 control_manager : t
\r
10778 id = t.prefix + id;
\r
10780 if (ed.settings.use_native_selects)
\r
10781 c = new tinymce.ui.NativeListBox(id, s);
\r
10783 cls = cc || t._cls.listbox || tinymce.ui.ListBox;
\r
10784 c = new cls(id, s);
\r
10787 t.controls[id] = c;
\r
10789 // Fix focus problem in Safari
\r
10790 if (tinymce.isWebKit) {
\r
10791 c.onPostRender.add(function(c, n) {
\r
10792 // Store bookmark on mousedown
\r
10793 Event.add(n, 'mousedown', function() {
\r
10794 ed.bookmark = ed.selection.getBookmark('simple');
\r
10797 // Restore on focus, since it might be lost
\r
10798 Event.add(n, 'focus', function() {
\r
10799 ed.selection.moveToBookmark(ed.bookmark);
\r
10800 ed.bookmark = null;
\r
10806 ed.onMouseDown.add(c.hideMenu, c);
\r
10811 createButton : function(id, s, cc) {
\r
10812 var t = this, ed = t.editor, o, c, cls;
\r
10817 s.title = ed.translate(s.title);
\r
10818 s.label = ed.translate(s.label);
\r
10819 s.scope = s.scope || ed;
\r
10821 if (!s.onclick && !s.menu_button) {
\r
10822 s.onclick = function() {
\r
10823 ed.execCommand(s.cmd, s.ui || false, s.value);
\r
10829 'class' : 'mce_' + id,
\r
10830 unavailable_prefix : ed.getLang('unavailable', ''),
\r
10832 control_manager : t
\r
10835 id = t.prefix + id;
\r
10837 if (s.menu_button) {
\r
10838 cls = cc || t._cls.menubutton || tinymce.ui.MenuButton;
\r
10839 c = new cls(id, s);
\r
10840 ed.onMouseDown.add(c.hideMenu, c);
\r
10842 cls = t._cls.button || tinymce.ui.Button;
\r
10843 c = new cls(id, s);
\r
10849 createMenuButton : function(id, s, cc) {
\r
10851 s.menu_button = 1;
\r
10853 return this.createButton(id, s, cc);
\r
10856 createSplitButton : function(id, s, cc) {
\r
10857 var t = this, ed = t.editor, cmd, c, cls;
\r
10862 s.title = ed.translate(s.title);
\r
10863 s.scope = s.scope || ed;
\r
10865 if (!s.onclick) {
\r
10866 s.onclick = function(v) {
\r
10867 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10871 if (!s.onselect) {
\r
10872 s.onselect = function(v) {
\r
10873 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10879 'class' : 'mce_' + id,
\r
10881 control_manager : t
\r
10884 id = t.prefix + id;
\r
10885 cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton;
\r
10886 c = t.add(new cls(id, s));
\r
10887 ed.onMouseDown.add(c.hideMenu, c);
\r
10892 createColorSplitButton : function(id, s, cc) {
\r
10893 var t = this, ed = t.editor, cmd, c, cls, bm;
\r
10898 s.title = ed.translate(s.title);
\r
10899 s.scope = s.scope || ed;
\r
10901 if (!s.onclick) {
\r
10902 s.onclick = function(v) {
\r
10903 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10907 if (!s.onselect) {
\r
10908 s.onselect = function(v) {
\r
10909 ed.execCommand(s.cmd, s.ui || false, v || s.value);
\r
10915 'class' : 'mce_' + id,
\r
10916 'menu_class' : ed.getParam('skin') + 'Skin',
\r
10918 more_colors_title : ed.getLang('more_colors')
\r
10921 id = t.prefix + id;
\r
10922 cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton;
\r
10923 c = new cls(id, s);
\r
10924 ed.onMouseDown.add(c.hideMenu, c);
\r
10926 // Remove the menu element when the editor is removed
\r
10927 ed.onRemove.add(function() {
\r
10931 // Fix for bug #1897785, #1898007
\r
10932 if (tinymce.isIE) {
\r
10933 c.onShowMenu.add(function() {
\r
10934 bm = ed.selection.getBookmark(1);
\r
10937 c.onHideMenu.add(function() {
\r
10939 ed.selection.moveToBookmark(bm);
\r
10948 createToolbar : function(id, s, cc) {
\r
10949 var c, t = this, cls;
\r
10951 id = t.prefix + id;
\r
10952 cls = cc || t._cls.toolbar || tinymce.ui.Toolbar;
\r
10953 c = new cls(id, s);
\r
10961 createSeparator : function(cc) {
\r
10962 var cls = cc || this._cls.separator || tinymce.ui.Separator;
\r
10964 return new cls();
\r
10967 setControlType : function(n, c) {
\r
10968 return this._cls[n.toLowerCase()] = c;
\r
10971 destroy : function() {
\r
10972 each(this.controls, function(c) {
\r
10976 this.controls = null;
\r
10982 /* file:jscripts/tiny_mce/classes/WindowManager.js */
\r
10985 var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera;
\r
10987 tinymce.create('tinymce.WindowManager', {
\r
10988 WindowManager : function(ed) {
\r
10992 t.onOpen = new Dispatcher(t);
\r
10993 t.onClose = new Dispatcher(t);
\r
10998 open : function(s, p) {
\r
10999 var t = this, f = '', x, y, mo = t.editor.settings.dialog_type == 'modal', w, sw, sh, vp = tinymce.DOM.getViewPort(), u;
\r
11001 // Default some options
\r
11004 sw = isOpera ? vp.w : screen.width; // Opera uses windows inside the Opera window
\r
11005 sh = isOpera ? vp.h : screen.height;
\r
11006 s.name = s.name || 'mc_' + new Date().getTime();
\r
11007 s.width = parseInt(s.width || 320);
\r
11008 s.height = parseInt(s.height || 240);
\r
11009 s.resizable = true;
\r
11010 s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0);
\r
11011 s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0);
\r
11012 p.inline = false;
\r
11013 p.mce_width = s.width;
\r
11014 p.mce_height = s.height;
\r
11015 p.mce_auto_focus = s.auto_focus;
\r
11021 s.dialogWidth = s.width + 'px';
\r
11022 s.dialogHeight = s.height + 'px';
\r
11023 s.scroll = s.scrollbars || false;
\r
11027 // Build features string
\r
11028 each(s, function(v, k) {
\r
11029 if (tinymce.is(v, 'boolean'))
\r
11030 v = v ? 'yes' : 'no';
\r
11032 if (!/^(name|url)$/.test(k)) {
\r
11034 f += (f ? ';' : '') + k + ':' + v;
\r
11036 f += (f ? ',' : '') + k + '=' + v;
\r
11042 t.onOpen.dispatch(t, s, p);
\r
11044 u = s.url || s.file;
\r
11045 if (tinymce.relaxedDomain)
\r
11046 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
\r
11048 u = tinymce._addVer(u);
\r
11051 if (isIE && mo) {
\r
11053 window.showModalDialog(u, window, f);
\r
11055 w = window.open(u, s.name, f);
\r
11061 alert(t.editor.getLang('popup_blocked'));
\r
11064 close : function(w) {
\r
11066 this.onClose.dispatch(this);
\r
11069 createInstance : function(cl, a, b, c, d, e) {
\r
11070 var f = tinymce.resolve(cl);
\r
11072 return new f(a, b, c, d, e);
\r
11075 confirm : function(t, cb, s, w) {
\r
11078 cb.call(s || this, w.confirm(this._decode(this.editor.getLang(t, t))));
\r
11081 alert : function(tx, cb, s, w) {
\r
11085 w.alert(t._decode(t.editor.getLang(tx, tx)));
\r
11091 // Internal functions
\r
11093 _decode : function(s) {
\r
11094 return tinymce.DOM.decode(s).replace(/\\n/g, '\n');
\r