thomascube
2011-04-20 a9251be2f09fb5f18a85d201c67668c70980efe3
commit | author | age
d9344f 1 /**
69d05c 2  * editor_template_src.js
d9344f 3  *
69d05c 4  * Copyright 2009, Moxiecode Systems AB
A 5  * Released under LGPL License.
6  *
7  * License: http://tinymce.moxiecode.com/license
8  * Contributing: http://tinymce.moxiecode.com/contributing
d9344f 9  */
S 10
29da64 11 (function(tinymce) {
d9344f 12     var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;
S 13
14     // Tell it to load theme specific language pack(s)
15     tinymce.ThemeManager.requireLangPack('advanced');
16
17     tinymce.create('tinymce.themes.AdvancedTheme', {
29da64 18         sizes : [8, 10, 12, 14, 18, 24, 36],
A 19
d9344f 20         // Control name lookup, format: title, command
S 21         controls : {
22             bold : ['bold_desc', 'Bold'],
23             italic : ['italic_desc', 'Italic'],
24             underline : ['underline_desc', 'Underline'],
25             strikethrough : ['striketrough_desc', 'Strikethrough'],
26             justifyleft : ['justifyleft_desc', 'JustifyLeft'],
27             justifycenter : ['justifycenter_desc', 'JustifyCenter'],
28             justifyright : ['justifyright_desc', 'JustifyRight'],
29             justifyfull : ['justifyfull_desc', 'JustifyFull'],
30             bullist : ['bullist_desc', 'InsertUnorderedList'],
31             numlist : ['numlist_desc', 'InsertOrderedList'],
32             outdent : ['outdent_desc', 'Outdent'],
33             indent : ['indent_desc', 'Indent'],
34             cut : ['cut_desc', 'Cut'],
35             copy : ['copy_desc', 'Copy'],
36             paste : ['paste_desc', 'Paste'],
37             undo : ['undo_desc', 'Undo'],
38             redo : ['redo_desc', 'Redo'],
39             link : ['link_desc', 'mceLink'],
40             unlink : ['unlink_desc', 'unlink'],
41             image : ['image_desc', 'mceImage'],
42             cleanup : ['cleanup_desc', 'mceCleanup'],
43             help : ['help_desc', 'mceHelp'],
44             code : ['code_desc', 'mceCodeEditor'],
45             hr : ['hr_desc', 'InsertHorizontalRule'],
46             removeformat : ['removeformat_desc', 'RemoveFormat'],
47             sub : ['sub_desc', 'subscript'],
48             sup : ['sup_desc', 'superscript'],
49             forecolor : ['forecolor_desc', 'ForeColor'],
50             forecolorpicker : ['forecolor_desc', 'mceForeColor'],
51             backcolor : ['backcolor_desc', 'HiliteColor'],
52             backcolorpicker : ['backcolor_desc', 'mceBackColor'],
53             charmap : ['charmap_desc', 'mceCharMap'],
54             visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
55             anchor : ['anchor_desc', 'mceInsertAnchor'],
56             newdocument : ['newdocument_desc', 'mceNewDocument'],
57             blockquote : ['blockquote_desc', 'mceBlockQuote']
58         },
59
60         stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
61
62         init : function(ed, url) {
29da64 63             var t = this, s, v, o;
d9344f 64     
S 65             t.editor = ed;
66             t.url = url;
67             t.onResolveName = new tinymce.util.Dispatcher(this);
68
a9251b 69             ed.forcedHighContrastMode = ed.settings.detect_highcontrast && t._isHighContrast();
T 70             ed.settings.skin = ed.forcedHighContrastMode ? 'highcontrast' : ed.settings.skin;
71
d9344f 72             // Default settings
S 73             t.settings = s = extend({
74                 theme_advanced_path : true,
75                 theme_advanced_toolbar_location : 'bottom',
76                 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
77                 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
78                 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
79                 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
80                 theme_advanced_toolbar_align : "center",
81                 theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
82                 theme_advanced_more_colors : 1,
83                 theme_advanced_row_height : 23,
84                 theme_advanced_resize_horizontal : 1,
29da64 85                 theme_advanced_resizing_use_cookie : 1,
A 86                 theme_advanced_font_sizes : "1,2,3,4,5,6,7",
a9251b 87                 theme_advanced_font_selector : "span",
T 88                 theme_advanced_show_current_color: 0,
29da64 89                 readonly : ed.settings.readonly
d9344f 90             }, ed.settings);
29da64 91
A 92             // Setup default font_size_style_values
93             if (!s.font_size_style_values)
94                 s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt";
95
96             if (tinymce.is(s.theme_advanced_font_sizes, 'string')) {
97                 s.font_size_style_values = tinymce.explode(s.font_size_style_values);
98                 s.font_size_classes = tinymce.explode(s.font_size_classes || '');
99
100                 // Parse string value
101                 o = {};
102                 ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes;
103                 each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) {
104                     var cl;
105
106                     if (k == v && v >= 1 && v <= 7) {
107                         k = v + ' (' + t.sizes[v - 1] + 'pt)';
69d05c 108                         cl = s.font_size_classes[v - 1];
A 109                         v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt');
29da64 110                     }
A 111
112                     if (/^\s*\./.test(v))
113                         cl = v.replace(/\./g, '');
114
115                     o[k] = cl ? {'class' : cl} : {fontSize : v};
116                 });
117
118                 s.theme_advanced_font_sizes = o;
119             }
d9344f 120
S 121             if ((v = s.theme_advanced_path_location) && v != 'none')
122                 s.theme_advanced_statusbar_location = s.theme_advanced_path_location;
123
124             if (s.theme_advanced_statusbar_location == 'none')
125                 s.theme_advanced_statusbar_location = 0;
126
a9251b 127             if (ed.settings.content_css !== false)
T 128                 ed.contentCSS.push(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css"));
129
d9344f 130             // Init editor
S 131             ed.onInit.add(function() {
a9251b 132                 if (!ed.settings.readonly) {
69d05c 133                     ed.onNodeChange.add(t._nodeChanged, t);
a9251b 134                     ed.onKeyUp.add(t._updateUndoStatus, t);
T 135                     ed.onMouseUp.add(t._updateUndoStatus, t);
136                     ed.dom.bind(ed.dom.getRoot(), 'dragend', function() {
137                         t._updateUndoStatus(ed);
138                     });
139                 }
d9344f 140             });
S 141
142             ed.onSetProgressState.add(function(ed, b, ti) {
143                 var co, id = ed.id, tb;
144
145                 if (b) {
146                     t.progressTimer = setTimeout(function() {
147                         co = ed.getContainer();
148                         co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
149                         tb = DOM.get(ed.id + '_tbl');
150
151                         DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
152                         DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
153                     }, ti || 0);
154                 } else {
155                     DOM.remove(id + '_blocker');
156                     DOM.remove(id + '_progress');
157                     clearTimeout(t.progressTimer);
158                 }
159             });
160
29da64 161             DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css");
d9344f 162
S 163             if (s.skin_variant)
29da64 164                 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css");
a9251b 165         },
T 166
167         _isHighContrast : function() {
168             var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'});
169
170             actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, '');
171             DOM.remove(div);
172
173             return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56';
d9344f 174         },
S 175
176         createControl : function(n, cf) {
177             var cd, c;
178
179             if (c = cf.createControl(n))
180                 return c;
181
182             switch (n) {
183                 case "styleselect":
184                     return this._createStyleSelect();
185
186                 case "formatselect":
187                     return this._createBlockFormats();
188
189                 case "fontselect":
190                     return this._createFontSelect();
191
192                 case "fontsizeselect":
193                     return this._createFontSizeSelect();
194
195                 case "forecolor":
196                     return this._createForeColorMenu();
197
198                 case "backcolor":
199                     return this._createBackColorMenu();
200             }
201
202             if ((cd = this.controls[n]))
203                 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
204         },
205
206         execCommand : function(cmd, ui, val) {
207             var f = this['_' + cmd];
208
209             if (f) {
210                 f.call(this, ui, val);
211                 return true;
212             }
213
214             return false;
215         },
216
18240a 217         _importClasses : function(e) {
69d05c 218             var ed = this.editor, ctrl = ed.controlManager.get('styleselect');
d9344f 219
69d05c 220             if (ctrl.getLength() == 0) {
A 221                 each(ed.dom.getClasses(), function(o, idx) {
222                     var name = 'style_' + idx;
223
224                     ed.formatter.register(name, {
225                         inline : 'span',
2011be 226                         attributes : {'class' : o['class']},
69d05c 227                         selector : '*'
A 228                     });
229
230                     ctrl.add(o['class'], name);
d9344f 231                 });
S 232             }
233         },
234
235         _createStyleSelect : function(n) {
69d05c 236             var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl;
A 237
238             // Setup style select box
239             ctrl = ctrlMan.createListBox('styleselect', {
d9344f 240                 title : 'advanced.style_select',
69d05c 241                 onselect : function(name) {
2011be 242                     var matches, formatNames = [];
A 243
244                     each(ctrl.items, function(item) {
245                         formatNames.push(item.value);
246                     });
247
248                     ed.focus();
249                     ed.undoManager.add();
250
251                     // Toggle off the current format
252                     matches = ed.formatter.matchAll(formatNames);
a9251b 253                     if (!name || matches[0] == name) {
T 254                         if (matches[0]) 
255                             ed.formatter.remove(matches[0]);
256                     } else
2011be 257                         ed.formatter.apply(name);
A 258
259                     ed.undoManager.add();
260                     ed.nodeChanged();
69d05c 261
A 262                     return false; // No auto select
d9344f 263                 }
S 264             });
265
69d05c 266             // Handle specified format
A 267             ed.onInit.add(function() {
268                 var counter = 0, formats = ed.getParam('style_formats');
d9344f 269
69d05c 270                 if (formats) {
A 271                     each(formats, function(fmt) {
272                         var name, keys = 0;
273
274                         each(fmt, function() {keys++;});
275
276                         if (keys > 1) {
277                             name = fmt.name = fmt.name || 'style_' + (counter++);
278                             ed.formatter.register(name, fmt);
279                             ctrl.add(fmt.title, name);
280                         } else
281                             ctrl.add(fmt.title);
282                     });
283                 } else {
284                     each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) {
285                         var name;
286
287                         if (val) {
288                             name = 'style_' + (counter++);
289
290                             ed.formatter.register(name, {
291                                 inline : 'span',
2011be 292                                 classes : val,
A 293                                 selector : '*'
69d05c 294                             });
A 295
296                             ctrl.add(t.editor.translate(key), name);
297                         }
298                     });
299                 }
300             });
301
302             // Auto import classes if the ctrl box is empty
303             if (ctrl.getLength() == 0) {
304                 ctrl.onPostRender.add(function(ed, n) {
305                     if (!ctrl.NativeListBox) {
29da64 306                         Event.add(n.id + '_text', 'focus', t._importClasses, t);
A 307                         Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
308                         Event.add(n.id + '_open', 'focus', t._importClasses, t);
309                         Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
310                     } else
311                         Event.add(n.id, 'focus', t._importClasses, t);
d9344f 312                 });
S 313             }
314
69d05c 315             return ctrl;
d9344f 316         },
S 317
318         _createFontSelect : function() {
319             var c, t = this, ed = t.editor;
320
69d05c 321             c = ed.controlManager.createListBox('fontselect', {
A 322                 title : 'advanced.fontdefault',
323                 onselect : function(v) {
a9251b 324                     var cur = c.items[c.selectedIndex];
T 325
326                     if (!v && cur) {
327                         ed.execCommand('FontName', false, cur.value);
328                         return;
329                     }
330
69d05c 331                     ed.execCommand('FontName', false, v);
2011be 332
A 333                     // Fake selection, execCommand will fire a nodeChange and update the selection
334                     c.select(function(sv) {
335                         return v == sv;
336                     });
a9251b 337
T 338                     if (cur && cur.value == v) {
339                         c.select(null);
340                     }
2011be 341
69d05c 342                     return false; // No auto select
A 343                 }
344             });
345
d9344f 346             if (c) {
S 347                 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
348                     c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
349                 });
350             }
351
352             return c;
353         },
354
355         _createFontSizeSelect : function() {
29da64 356             var t = this, ed = t.editor, c, i = 0, cl = [];
d9344f 357
29da64 358             c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
a9251b 359                 var cur = c.items[c.selectedIndex];
T 360
361                 if (!v && cur) {
362                     cur = cur.value;
363
364                     if (cur['class']) {
365                         ed.formatter.toggle('fontsize_class', {value : cur['class']});
366                         ed.undoManager.add();
367                         ed.nodeChanged();
368                     } else {
369                         ed.execCommand('FontSize', false, cur.fontSize);
370                     }
371
372                     return;
373                 }
374
2011be 375                 if (v['class']) {
A 376                     ed.focus();
377                     ed.undoManager.add();
378                     ed.formatter.toggle('fontsize_class', {value : v['class']});
379                     ed.undoManager.add();
380                     ed.nodeChanged();
381                 } else
29da64 382                     ed.execCommand('FontSize', false, v.fontSize);
A 383
2011be 384                 // Fake selection, execCommand will fire a nodeChange and update the selection
A 385                 c.select(function(sv) {
386                     return v == sv;
387                 });
a9251b 388
T 389                 if (cur && (cur.value.fontSize == v.fontSize || cur.value['class'] == v['class'])) {
390                     c.select(null);
391                 }
69d05c 392
A 393                 return false; // No auto select
29da64 394             }});
A 395
d9344f 396             if (c) {
29da64 397                 each(t.settings.theme_advanced_font_sizes, function(v, k) {
A 398                     var fz = v.fontSize;
399
400                     if (fz >= 1 && fz <= 7)
401                         fz = t.sizes[parseInt(fz) - 1] + 'pt';
402
403                     c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
d9344f 404                 });
S 405             }
406
407             return c;
408         },
409
410         _createBlockFormats : function() {
411             var c, fmts = {
412                 p : 'advanced.paragraph',
413                 address : 'advanced.address',
414                 pre : 'advanced.pre',
415                 h1 : 'advanced.h1',
416                 h2 : 'advanced.h2',
417                 h3 : 'advanced.h3',
418                 h4 : 'advanced.h4',
419                 h5 : 'advanced.h5',
420                 h6 : 'advanced.h6',
421                 div : 'advanced.div',
422                 blockquote : 'advanced.blockquote',
423                 code : 'advanced.code',
424                 dt : 'advanced.dt',
425                 dd : 'advanced.dd',
426                 samp : 'advanced.samp'
427             }, t = this;
428
a9251b 429             c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', onselect : function(v) {
T 430                 t.editor.execCommand('FormatBlock', false, v);
431                 return false;
432             }});
433
d9344f 434             if (c) {
S 435                 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
436                     c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
437                 });
438             }
439
440             return c;
441         },
442
443         _createForeColorMenu : function() {
444             var c, t = this, s = t.settings, o = {}, v;
445
446             if (s.theme_advanced_more_colors) {
447                 o.more_colors_func = function() {
448                     t._mceColorPicker(0, {
449                         color : c.value,
450                         func : function(co) {
451                             c.setColor(co);
452                         }
453                     });
454                 };
455             }
456
457             if (v = s.theme_advanced_text_colors)
458                 o.colors = v;
459
29da64 460             if (s.theme_advanced_default_foreground_color)
A 461                 o.default_color = s.theme_advanced_default_foreground_color;
462
d9344f 463             o.title = 'advanced.forecolor_desc';
S 464             o.cmd = 'ForeColor';
465             o.scope = this;
466
467             c = t.editor.controlManager.createColorSplitButton('forecolor', o);
468
469             return c;
470         },
471
472         _createBackColorMenu : function() {
473             var c, t = this, s = t.settings, o = {}, v;
474
475             if (s.theme_advanced_more_colors) {
476                 o.more_colors_func = function() {
477                     t._mceColorPicker(0, {
478                         color : c.value,
479                         func : function(co) {
480                             c.setColor(co);
481                         }
482                     });
483                 };
484             }
485
486             if (v = s.theme_advanced_background_colors)
487                 o.colors = v;
29da64 488
A 489             if (s.theme_advanced_default_background_color)
490                 o.default_color = s.theme_advanced_default_background_color;
d9344f 491
S 492             o.title = 'advanced.backcolor_desc';
493             o.cmd = 'HiliteColor';
494             o.scope = this;
495
496             c = t.editor.controlManager.createColorSplitButton('backcolor', o);
497
498             return c;
499         },
500
501         renderUI : function(o) {
502             var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
503
a9251b 504             if (ed.settings) {
T 505                 ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut');
506             }
507
508             // TODO: ACC Should have an aria-describedby attribute which is user-configurable to describe what this field is actually for.
509             // Maybe actually inherit it from the original textara?
510             n = p = DOM.create('span', {role : 'application', 'aria-labelledby' : ed.id + '_voice', id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')});
511             DOM.add(n, 'span', {'class': 'mceVoiceLabel', 'style': 'display:none;', id: ed.id + '_voice'}, s.aria_label);
d9344f 512
S 513             if (!DOM.boxModel)
514                 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
515
a9251b 516             n = sc = DOM.add(n, 'table', {role : "presentation", id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
d9344f 517             n = tb = DOM.add(n, 'tbody');
S 518
519             switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
520                 case "rowlayout":
521                     ic = t._rowLayout(s, tb, o);
522                     break;
523
524                 case "customlayout":
525                     ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
526                     break;
527
528                 default:
529                     ic = t._simpleLayout(s, tb, o, p);
530             }
531
532             n = o.targetNode;
533
534             // Add classes to first and last TRs
a9251b 535             nl = sc.rows;
d9344f 536             DOM.addClass(nl[0], 'mceFirst');
S 537             DOM.addClass(nl[nl.length - 1], 'mceLast');
538
539             // Add classes to first and last TDs
540             each(DOM.select('tr', tb), function(n) {
541                 DOM.addClass(n.firstChild, 'mceFirst');
542                 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
543             });
544
545             if (DOM.get(s.theme_advanced_toolbar_container))
546                 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
547             else
548                 DOM.insertAfter(p, n);
549
550             Event.add(ed.id + '_path_row', 'click', function(e) {
551                 e = e.target;
552
553                 if (e.nodeName == 'A') {
554                     t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
555
556                     return Event.cancel(e);
557                 }
558             });
559 /*
560             if (DOM.get(ed.id + '_path_row')) {
561                 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
562                     var re;
563     
564                     e = e.target;
565
566                     if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
567                         re = DOM.get(ed.id + '_path_row');
568                         t.lastPath = re.innerHTML;
569                         DOM.setHTML(re, e.parentNode.title);
570                     }
571                 });
572
573                 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
574                     if (t.lastPath) {
575                         DOM.setHTML(ed.id + '_path_row', t.lastPath);
576                         t.lastPath = 0;
577                     }
578                 });
579             }
580 */
581
29da64 582             if (!ed.getParam('accessibility_focus'))
d9344f 583                 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
S 584
585             if (s.theme_advanced_toolbar_location == 'external')
586                 o.deltaHeight = 0;
587
588             t.deltaHeight = o.deltaHeight;
589             o.targetNode = null;
590
a9251b 591             ed.onKeyDown.add(function(ed, evt) {
T 592                 var DOM_VK_F10 = 121, DOM_VK_F11 = 122;
593
594                 if (evt.altKey) {
595                      if (evt.keyCode === DOM_VK_F10) {
596                         t.toolbarGroup.focus();
597                         return Event.cancel(evt);
598                     } else if (evt.keyCode === DOM_VK_F11) {
599                         DOM.get(ed.id + '_path_row').focus();
600                         return Event.cancel(evt);
601                     }
602                 }
603             });
604
605             // alt+0 is the UK recommended shortcut for accessing the list of access controls.
606             ed.addShortcut('alt+0', '', 'mceShortcuts', t);
607
d9344f 608             return {
S 609                 iframeContainer : ic,
610                 editorContainer : ed.id + '_parent',
611                 sizeContainer : sc,
612                 deltaHeight : o.deltaHeight
613             };
614         },
615
616         getInfo : function() {
617             return {
618                 longname : 'Advanced theme',
619                 author : 'Moxiecode Systems AB',
620                 authorurl : 'http://tinymce.moxiecode.com',
621                 version : tinymce.majorVersion + "." + tinymce.minorVersion
622             }
623         },
624
625         resizeBy : function(dw, dh) {
a9251b 626             var e = DOM.get(this.editor.id + '_ifr');
d9344f 627
S 628             this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
629         },
630
a9251b 631         resizeTo : function(w, h, store) {
799907 632             var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr');
d9344f 633
S 634             // Boundery fix box
635             w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
636             h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
637             w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
638             h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
639
640             // Resize iframe and container
799907 641             DOM.setStyle(e, 'height', '');
A 642             DOM.setStyle(ifr, 'height', h);
643
644             if (s.theme_advanced_resize_horizontal) {
645                 DOM.setStyle(e, 'width', '');
646                 DOM.setStyle(ifr, 'width', w);
647
648                 // Make sure that the size is never smaller than the over all ui
a9251b 649                 if (w < e.clientWidth) {
T 650                     w = e.clientWidth;
799907 651                     DOM.setStyle(ifr, 'width', e.clientWidth);
a9251b 652                 }
T 653             }
654
655             // Store away the size
656             if (store && s.theme_advanced_resizing_use_cookie) {
657                 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
658                     cw : w,
659                     ch : h
660                 });
799907 661             }
d9344f 662         },
S 663
664         destroy : function() {
665             var id = this.editor.id;
666
667             Event.clear(id + '_resize');
668             Event.clear(id + '_path_row');
669             Event.clear(id + '_external_close');
670         },
671
672         // Internal functions
673
674         _simpleLayout : function(s, tb, o, p) {
675             var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
29da64 676
A 677             if (s.readonly) {
678                 n = DOM.add(tb, 'tr');
679                 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
680                 return ic;
681             }
d9344f 682
S 683             // Create toolbar container at top
684             if (lo == 'top')
685                 t._addToolbars(tb, o);
686
687             // Create external toolbar
688             if (lo == 'external') {
689                 n = c = DOM.create('div', {style : 'position:relative'});
690                 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
691                 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
692                 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
693                 etb = DOM.add(n, 'tbody');
694
695                 if (p.firstChild.className == 'mceOldBoxModel')
696                     p.firstChild.appendChild(c);
697                 else
698                     p.insertBefore(c, p.firstChild);
699
700                 t._addToolbars(etb, o);
701
702                 ed.onMouseUp.add(function() {
703                     var e = DOM.get(ed.id + '_external');
704                     DOM.show(e);
705
706                     DOM.hide(lastExtID);
707
708                     var f = Event.add(ed.id + '_external_close', 'click', function() {
709                         DOM.hide(ed.id + '_external');
710                         Event.remove(ed.id + '_external_close', 'click', f);
711                     });
712
713                     DOM.show(e);
714                     DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
715
716                     // Fixes IE rendering bug
717                     DOM.hide(e);
718                     DOM.show(e);
719                     e.style.filter = '';
720
721                     lastExtID = ed.id + '_external';
722
723                     e = null;
724                 });
725             }
726
727             if (sl == 'top')
728                 t._addStatusBar(tb, o);
729
730             // Create iframe container
731             if (!s.theme_advanced_toolbar_container) {
732                 n = DOM.add(tb, 'tr');
733                 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
734             }
735
736             // Create toolbar container at bottom
737             if (lo == 'bottom')
738                 t._addToolbars(tb, o);
739
740             if (sl == 'bottom')
741                 t._addStatusBar(tb, o);
742
743             return ic;
744         },
745
746         _rowLayout : function(s, tb, o) {
747             var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
748
749             dc = s.theme_advanced_containers_default_class || '';
750             da = s.theme_advanced_containers_default_align || 'center';
751
752             each(explode(s.theme_advanced_containers || ''), function(c, i) {
753                 var v = s['theme_advanced_container_' + c] || '';
754
a9251b 755                 switch (c.toLowerCase()) {
d9344f 756                     case 'mceeditor':
S 757                         n = DOM.add(tb, 'tr');
758                         n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
759                         break;
760
761                     case 'mceelementpath':
762                         t._addStatusBar(tb, o);
763                         break;
764
765                     default:
18240a 766                         a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
d9344f 767                         a = 'mce' + t._ufirst(a);
S 768
769                         n = DOM.add(DOM.add(tb, 'tr'), 'td', {
770                             'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
771                         });
772
773                         to = cf.createToolbar("toolbar" + i);
774                         t._addControls(v, to);
775                         DOM.setHTML(n, to.renderHTML());
776                         o.deltaHeight -= s.theme_advanced_row_height;
777                 }
778             });
779
780             return ic;
781         },
782
783         _addControls : function(v, tb) {
784             var t = this, s = t.settings, di, cf = t.editor.controlManager;
785
786             if (s.theme_advanced_disable && !t._disabled) {
787                 di = {};
788
789                 each(explode(s.theme_advanced_disable), function(v) {
790                     di[v] = 1;
791                 });
792
793                 t._disabled = di;
794             } else
795                 di = t._disabled;
796
797             each(explode(v), function(n) {
798                 var c;
799
800                 if (di && di[n])
801                     return;
802
803                 // Compatiblity with 2.x
804                 if (n == 'tablecontrols') {
805                     each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
806                         n = t.createControl(n, cf);
807
808                         if (n)
809                             tb.add(n);
810                     });
811
812                     return;
813                 }
814
815                 c = t.createControl(n, cf);
816
817                 if (c)
818                     tb.add(c);
819             });
820         },
821
822         _addToolbars : function(c, o) {
a9251b 823             var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a, toolbarGroup;
T 824
825             toolbarGroup = cf.createToolbarGroup('toolbargroup', {
826                 'name': ed.getLang('advanced.toolbar'),
827                 'tab_focus_toolbar':ed.getParam('theme_advanced_tab_focus_toolbar')
828             });
829
830             t.toolbarGroup = toolbarGroup;
d9344f 831
S 832             a = s.theme_advanced_toolbar_align.toLowerCase();
833             a = 'mce' + t._ufirst(a);
834
a9251b 835             n = DOM.add(DOM.add(c, 'tr', {role: 'presentation'}), 'td', {'class' : 'mceToolbar ' + a, "role":"presentation"});
d9344f 836
S 837             // Create toolbar and add the controls
838             for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
839                 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
840
841                 if (s['theme_advanced_buttons' + i + '_add'])
842                     v += ',' + s['theme_advanced_buttons' + i + '_add'];
843
844                 if (s['theme_advanced_buttons' + i + '_add_before'])
845                     v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
846
847                 t._addControls(v, tb);
a9251b 848                 toolbarGroup.add(tb);
d9344f 849
S 850                 o.deltaHeight -= s.theme_advanced_row_height;
851             }
a9251b 852             h.push(toolbarGroup.renderHTML());
d9344f 853             h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
S 854             DOM.setHTML(n, h.join(''));
855         },
856
857         _addStatusBar : function(tb, o) {
858             var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
859
860             n = DOM.add(tb, 'tr');
a9251b 861             n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); 
T 862             n = DOM.add(n, 'div', {id : ed.id + '_path_row', 'role': 'group', 'aria-labelledby': ed.id + '_path_voice'});
863             if (s.theme_advanced_path) {
864                 DOM.add(n, 'span', {id: ed.id + '_path_voice'}, ed.translate('advanced.path'));
865                 DOM.add(n, 'span', {}, ': ');
866             } else {
867                 DOM.add(n, 'span', {}, '&#160;');
868             }
869             
d9344f 870
29da64 871             if (s.theme_advanced_resizing) {
d9344f 872                 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
S 873
874                 if (s.theme_advanced_resizing_use_cookie) {
875                     ed.onPostRender.add(function() {
876                         var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
877
878                         if (!o)
879                             return;
880
69d05c 881                         t.resizeTo(o.cw, o.ch);
d9344f 882                     });
S 883                 }
884
885                 ed.onPostRender.add(function() {
a9251b 886                     Event.add(ed.id + '_resize', 'click', function(e) {
T 887                         e.preventDefault();
888                     });
889
d9344f 890                     Event.add(ed.id + '_resize', 'mousedown', function(e) {
799907 891                         var mouseMoveHandler1, mouseMoveHandler2,
A 892                             mouseUpHandler1, mouseUpHandler2,
69d05c 893                             startX, startY, startWidth, startHeight, width, height, ifrElm;
d9344f 894
69d05c 895                         function resizeOnMove(e) {
a9251b 896                             e.preventDefault();
T 897
69d05c 898                             width = startWidth + (e.screenX - startX);
A 899                             height = startHeight + (e.screenY - startY);
d9344f 900
69d05c 901                             t.resizeTo(width, height);
799907 902                         };
A 903
904                         function endResize(e) {
905                             // Stop listening
906                             Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1);
907                             Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2);
908                             Event.remove(DOM.doc, 'mouseup', mouseUpHandler1);
909                             Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2);
910
a9251b 911                             width = startWidth + (e.screenX - startX);
T 912                             height = startHeight + (e.screenY - startY);
913                             t.resizeTo(width, height, true);
d9344f 914                         };
S 915
69d05c 916                         e.preventDefault();
d9344f 917
69d05c 918                         // Get the current rect size
A 919                         startX = e.screenX;
920                         startY = e.screenY;
921                         ifrElm = DOM.get(t.editor.id + '_ifr');
922                         startWidth = width = ifrElm.clientWidth;
923                         startHeight = height = ifrElm.clientHeight;
d9344f 924
69d05c 925                         // Register envent handlers
A 926                         mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove);
927                         mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove);
799907 928                         mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize);
A 929                         mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize);
d9344f 930                     });
S 931                 });
932             }
933
934             o.deltaHeight -= 21;
935             n = tb = null;
936         },
937
a9251b 938         _updateUndoStatus : function(ed) {
T 939             var cm = ed.controlManager;
940
941             cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
942             cm.setDisabled('redo', !ed.undoManager.hasRedo());
943         },
944
69d05c 945         _nodeChanged : function(ed, cm, n, co, ob) {
a9251b 946             var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, fc, bc, formatNames, matches;
d9344f 947
S 948             tinymce.each(t.stateControls, function(c) {
949                 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
950             });
69d05c 951
A 952             function getParent(name) {
953                 var i, parents = ob.parents, func = name;
954
955                 if (typeof(name) == 'string') {
956                     func = function(node) {
957                         return node.nodeName == name;
958                     };
959                 }
960
961                 for (i = 0; i < parents.length; i++) {
962                     if (func(parents[i]))
963                         return parents[i];
964                 }
965             };
d9344f 966
S 967             cm.setActive('visualaid', ed.hasVisual);
a9251b 968             t._updateUndoStatus(ed);
d9344f 969             cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
S 970
69d05c 971             p = getParent('A');
d9344f 972             if (c = cm.get('link')) {
S 973                 if (!p || !p.name) {
974                     c.setDisabled(!p && co);
975                     c.setActive(!!p);
976                 }
977             }
978
979             if (c = cm.get('unlink')) {
980                 c.setDisabled(!p && co);
981                 c.setActive(!!p && !p.name);
982             }
983
984             if (c = cm.get('anchor')) {
a9251b 985                 c.setActive(!co && !!p && p.name);
d9344f 986             }
S 987
69d05c 988             p = getParent('IMG');
d9344f 989             if (c = cm.get('image'))
a9251b 990                 c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1);
d9344f 991
S 992             if (c = cm.get('styleselect')) {
69d05c 993                 t._importClasses();
A 994
799907 995                 formatNames = [];
A 996                 each(c.items, function(item) {
997                     formatNames.push(item.value);
69d05c 998                 });
799907 999
A 1000                 matches = ed.formatter.matchAll(formatNames);
1001                 c.select(matches[0]);
d9344f 1002             }
S 1003
1004             if (c = cm.get('formatselect')) {
69d05c 1005                 p = getParent(DOM.isBlock);
d9344f 1006
S 1007                 if (p)
1008                     c.select(p.nodeName.toLowerCase());
1009             }
1010
69d05c 1011             // Find out current fontSize, fontFamily and fontClass
A 1012             getParent(function(n) {
1013                 if (n.nodeName === 'SPAN') {
1014                     if (!cl && n.className)
1015                         cl = n.className;
a9251b 1016                 }
d9344f 1017
a9251b 1018                 if (ed.dom.is(n, s.theme_advanced_font_selector)) {
69d05c 1019                     if (!fz && n.style.fontSize)
A 1020                         fz = n.style.fontSize;
29da64 1021
69d05c 1022                     if (!fn && n.style.fontFamily)
A 1023                         fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
a9251b 1024                     
T 1025                     if (!fc && n.style.color)
1026                         fc = n.style.color;
1027
1028                     if (!bc && n.style.backgroundColor)
1029                         bc = n.style.backgroundColor;
69d05c 1030                 }
29da64 1031
69d05c 1032                 return false;
A 1033             });
1034
1035             if (c = cm.get('fontselect')) {
1036                 c.select(function(v) {
1037                     return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
29da64 1038                 });
69d05c 1039             }
29da64 1040
69d05c 1041             // Select font size
A 1042             if (c = cm.get('fontsizeselect')) {
1043                 // Use computed style
1044                 if (s.theme_advanced_runtime_fontsize && !fz && !cl)
1045                     fz = ed.dom.getStyle(n, 'fontSize', true);
29da64 1046
69d05c 1047                 c.select(function(v) {
A 1048                     if (v.fontSize && v.fontSize === fz)
1049                         return true;
29da64 1050
69d05c 1051                     if (v['class'] && v['class'] === cl)
A 1052                         return true;
1053                 });
29da64 1054             }
a9251b 1055             
T 1056             if (s.theme_advanced_show_current_color) {
1057                 function updateColor(controlId, color) {
1058                     if (c = cm.get(controlId)) {
1059                         if (!color)
1060                             color = c.settings.default_color;
1061                         if (color !== c.value) {
1062                             c.displayColor(color);
1063                         }
1064                     }
1065                 }
1066                 updateColor('forecolor', fc);
1067                 updateColor('backcolor', bc);
1068             }
1069
1070             if (s.theme_advanced_show_current_color) {
1071                 function updateColor(controlId, color) {
1072                     if (c = cm.get(controlId)) {
1073                         if (!color)
1074                             color = c.settings.default_color;
1075                         if (color !== c.value) {
1076                             c.displayColor(color);
1077                         }
1078                     }
1079                 };
1080
1081                 updateColor('forecolor', fc);
1082                 updateColor('backcolor', bc);
1083             }
d9344f 1084
S 1085             if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
1086                 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
a9251b 1087
T 1088                 if (t.statusKeyboardNavigation) {
1089                     t.statusKeyboardNavigation.destroy();
1090                     t.statusKeyboardNavigation = null;
1091                 }
1092
d9344f 1093                 DOM.setHTML(p, '');
S 1094
69d05c 1095                 getParent(function(n) {
d9344f 1096                     var na = n.nodeName.toLowerCase(), u, pi, ti = '';
S 1097
a9251b 1098                     if (n.getAttribute('data-mce-bogus'))
69d05c 1099                         return;
a9251b 1100
d9344f 1101                     // Ignore non element and hidden elements
29da64 1102                     if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
d9344f 1103                         return;
29da64 1104
d9344f 1105                     // Handle prefix
S 1106                     if (tinymce.isIE && n.scopeName !== 'HTML')
1107                         na = n.scopeName + ':' + na;
1108
1109                     // Remove internal prefix
1110                     na = na.replace(/mce\:/g, '');
1111
1112                     // Handle node name
1113                     switch (na) {
1114                         case 'b':
1115                             na = 'strong';
1116                             break;
1117
1118                         case 'i':
1119                             na = 'em';
1120                             break;
1121
1122                         case 'img':
1123                             if (v = DOM.getAttrib(n, 'src'))
1124                                 ti += 'src: ' + v + ' ';
1125
1126                             break;
1127
1128                         case 'a':
1129                             if (v = DOM.getAttrib(n, 'name')) {
1130                                 ti += 'name: ' + v + ' ';
1131                                 na += '#' + v;
1132                             }
1133
1134                             if (v = DOM.getAttrib(n, 'href'))
1135                                 ti += 'href: ' + v + ' ';
1136
1137                             break;
1138
1139                         case 'font':
1140                             if (v = DOM.getAttrib(n, 'face'))
1141                                 ti += 'font: ' + v + ' ';
1142
1143                             if (v = DOM.getAttrib(n, 'size'))
1144                                 ti += 'size: ' + v + ' ';
1145
1146                             if (v = DOM.getAttrib(n, 'color'))
1147                                 ti += 'color: ' + v + ' ';
1148
1149                             break;
1150
1151                         case 'span':
1152                             if (v = DOM.getAttrib(n, 'style'))
1153                                 ti += 'style: ' + v + ' ';
1154
1155                             break;
1156                     }
1157
1158                     if (v = DOM.getAttrib(n, 'id'))
1159                         ti += 'id: ' + v + ' ';
1160
1161                     if (v = n.className) {
69d05c 1162                         v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '')
d9344f 1163
69d05c 1164                         if (v) {
d9344f 1165                             ti += 'class: ' + v + ' ';
S 1166
1167                             if (DOM.isBlock(n) || na == 'img' || na == 'span')
1168                                 na += '.' + v;
1169                         }
1170                     }
1171
1172                     na = na.replace(/(html:)/g, '');
1173                     na = {name : na, node : n, title : ti};
1174                     t.onResolveName.dispatch(t, na);
1175                     ti = na.title;
1176                     na = na.name;
1177
1178                     //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
a9251b 1179                     pi = DOM.create('a', {'href' : "javascript:;", role: 'button', onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
d9344f 1180
S 1181                     if (p.hasChildNodes()) {
a9251b 1182                         p.insertBefore(DOM.create('span', {'aria-hidden': 'true'}, '\u00a0\u00bb '), p.firstChild);
d9344f 1183                         p.insertBefore(pi, p.firstChild);
S 1184                     } else
1185                         p.appendChild(pi);
1186                 }, ed.getBody());
a9251b 1187
T 1188                 if (DOM.select('a', p).length > 0) {
1189                     t.statusKeyboardNavigation = new tinymce.ui.KeyboardNavigation({
1190                         root: ed.id + "_path_row",
1191                         items: DOM.select('a', p),
1192                         excludeFromTabOrder: true,
1193                         onCancel: function() {
1194                             ed.focus();
1195                         }
1196                     }, DOM);
1197                 }
d9344f 1198             }
S 1199         },
1200
1201         // Commands gets called by execCommand
1202
1203         _sel : function(v) {
1204             this.editor.execCommand('mceSelectNodeDepth', false, v);
1205         },
1206
1207         _mceInsertAnchor : function(ui, v) {
1208             var ed = this.editor;
1209
1210             ed.windowManager.open({
a9251b 1211                 url : this.url + '/anchor.htm',
d9344f 1212                 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
S 1213                 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
1214                 inline : true
1215             }, {
1216                 theme_url : this.url
1217             });
1218         },
1219
1220         _mceCharMap : function() {
1221             var ed = this.editor;
1222
1223             ed.windowManager.open({
a9251b 1224                 url : this.url + '/charmap.htm',
d9344f 1225                 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
S 1226                 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
1227                 inline : true
1228             }, {
1229                 theme_url : this.url
1230             });
1231         },
1232
1233         _mceHelp : function() {
1234             var ed = this.editor;
1235
1236             ed.windowManager.open({
a9251b 1237                 url : this.url + '/about.htm',
d9344f 1238                 width : 480,
S 1239                 height : 380,
1240                 inline : true
1241             }, {
1242                 theme_url : this.url
a9251b 1243             });
T 1244         },
1245
1246         _mceShortcuts : function() {
1247             var ed = this.editor;
1248             ed.windowManager.open({
1249                 url: this.url + '/shortcuts.htm',
1250                 width: 480,
1251                 height: 380,
1252                 inline: true
1253             }, {
1254                 theme_url: this.url
d9344f 1255             });
S 1256         },
1257
1258         _mceColorPicker : function(u, v) {
1259             var ed = this.editor;
1260
1261             v = v || {};
1262
1263             ed.windowManager.open({
a9251b 1264                 url : this.url + '/color_picker.htm',
d9344f 1265                 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
S 1266                 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
1267                 close_previous : false,
1268                 inline : true
1269             }, {
1270                 input_color : v.color,
1271                 func : v.func,
1272                 theme_url : this.url
1273             });
1274         },
1275
1276         _mceCodeEditor : function(ui, val) {
1277             var ed = this.editor;
1278
1279             ed.windowManager.open({
a9251b 1280                 url : this.url + '/source_editor.htm',
d9344f 1281                 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
S 1282                 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
1283                 inline : true,
1284                 resizable : true,
1285                 maximizable : true
1286             }, {
1287                 theme_url : this.url
1288             });
1289         },
1290
1291         _mceImage : function(ui, val) {
1292             var ed = this.editor;
1293
1294             // Internal image object like a flash placeholder
1295             if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
1296                 return;
1297
1298             ed.windowManager.open({
a9251b 1299                 url : this.url + '/image.htm',
d9344f 1300                 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
S 1301                 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
1302                 inline : true
1303             }, {
1304                 theme_url : this.url
1305             });
1306         },
1307
1308         _mceLink : function(ui, val) {
1309             var ed = this.editor;
1310
1311             ed.windowManager.open({
a9251b 1312                 url : this.url + '/link.htm',
d9344f 1313                 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
S 1314                 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
1315                 inline : true
1316             }, {
1317                 theme_url : this.url
1318             });
1319         },
1320
1321         _mceNewDocument : function() {
1322             var ed = this.editor;
1323
1324             ed.windowManager.confirm('advanced.newdocument', function(s) {
1325                 if (s)
1326                     ed.execCommand('mceSetContent', false, '');
1327             });
1328         },
1329
1330         _mceForeColor : function() {
1331             var t = this;
1332
1333             this._mceColorPicker(0, {
18240a 1334                 color: t.fgColor,
d9344f 1335                 func : function(co) {
18240a 1336                     t.fgColor = co;
d9344f 1337                     t.editor.execCommand('ForeColor', false, co);
S 1338                 }
1339             });
1340         },
1341
1342         _mceBackColor : function() {
1343             var t = this;
1344
1345             this._mceColorPicker(0, {
18240a 1346                 color: t.bgColor,
d9344f 1347                 func : function(co) {
18240a 1348                     t.bgColor = co;
d9344f 1349                     t.editor.execCommand('HiliteColor', false, co);
S 1350                 }
1351             });
1352         },
1353
1354         _ufirst : function(s) {
1355             return s.substring(0, 1).toUpperCase() + s.substring(1);
1356         }
1357     });
1358
1359     tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
a9251b 1360 }(tinymce));