2 * editor_template_src.js
\r
4 * Copyright 2009, Moxiecode Systems AB
\r
5 * Released under LGPL License.
\r
7 * License: http://tinymce.moxiecode.com/license
\r
8 * Contributing: http://tinymce.moxiecode.com/contributing
\r
11 (function(tinymce) {
\r
12 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;
\r
14 // Tell it to load theme specific language pack(s)
\r
15 tinymce.ThemeManager.requireLangPack('advanced');
\r
17 tinymce.create('tinymce.themes.AdvancedTheme', {
\r
18 sizes : [8, 10, 12, 14, 18, 24, 36],
\r
20 // Control name lookup, format: title, command
\r
22 bold : ['bold_desc', 'Bold'],
\r
23 italic : ['italic_desc', 'Italic'],
\r
24 underline : ['underline_desc', 'Underline'],
\r
25 strikethrough : ['striketrough_desc', 'Strikethrough'],
\r
26 justifyleft : ['justifyleft_desc', 'JustifyLeft'],
\r
27 justifycenter : ['justifycenter_desc', 'JustifyCenter'],
\r
28 justifyright : ['justifyright_desc', 'JustifyRight'],
\r
29 justifyfull : ['justifyfull_desc', 'JustifyFull'],
\r
30 bullist : ['bullist_desc', 'InsertUnorderedList'],
\r
31 numlist : ['numlist_desc', 'InsertOrderedList'],
\r
32 outdent : ['outdent_desc', 'Outdent'],
\r
33 indent : ['indent_desc', 'Indent'],
\r
34 cut : ['cut_desc', 'Cut'],
\r
35 copy : ['copy_desc', 'Copy'],
\r
36 paste : ['paste_desc', 'Paste'],
\r
37 undo : ['undo_desc', 'Undo'],
\r
38 redo : ['redo_desc', 'Redo'],
\r
39 link : ['link_desc', 'mceLink'],
\r
40 unlink : ['unlink_desc', 'unlink'],
\r
41 image : ['image_desc', 'mceImage'],
\r
42 cleanup : ['cleanup_desc', 'mceCleanup'],
\r
43 help : ['help_desc', 'mceHelp'],
\r
44 code : ['code_desc', 'mceCodeEditor'],
\r
45 hr : ['hr_desc', 'InsertHorizontalRule'],
\r
46 removeformat : ['removeformat_desc', 'RemoveFormat'],
\r
47 sub : ['sub_desc', 'subscript'],
\r
48 sup : ['sup_desc', 'superscript'],
\r
49 forecolor : ['forecolor_desc', 'ForeColor'],
\r
50 forecolorpicker : ['forecolor_desc', 'mceForeColor'],
\r
51 backcolor : ['backcolor_desc', 'HiliteColor'],
\r
52 backcolorpicker : ['backcolor_desc', 'mceBackColor'],
\r
53 charmap : ['charmap_desc', 'mceCharMap'],
\r
54 visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
\r
55 anchor : ['anchor_desc', 'mceInsertAnchor'],
\r
56 newdocument : ['newdocument_desc', 'mceNewDocument'],
\r
57 blockquote : ['blockquote_desc', 'mceBlockQuote']
\r
60 stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
\r
62 init : function(ed, url) {
\r
63 var t = this, s, v, o;
\r
67 t.onResolveName = new tinymce.util.Dispatcher(this);
\r
70 t.settings = s = extend({
\r
71 theme_advanced_path : true,
\r
72 theme_advanced_toolbar_location : 'bottom',
\r
73 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
\r
74 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
\r
75 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
\r
76 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
\r
77 theme_advanced_toolbar_align : "center",
\r
78 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",
\r
79 theme_advanced_more_colors : 1,
\r
80 theme_advanced_row_height : 23,
\r
81 theme_advanced_resize_horizontal : 1,
\r
82 theme_advanced_resizing_use_cookie : 1,
\r
83 theme_advanced_font_sizes : "1,2,3,4,5,6,7",
\r
84 readonly : ed.settings.readonly
\r
87 // Setup default font_size_style_values
\r
88 if (!s.font_size_style_values)
\r
89 s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt";
\r
91 if (tinymce.is(s.theme_advanced_font_sizes, 'string')) {
\r
92 s.font_size_style_values = tinymce.explode(s.font_size_style_values);
\r
93 s.font_size_classes = tinymce.explode(s.font_size_classes || '');
\r
95 // Parse string value
\r
97 ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes;
\r
98 each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) {
\r
101 if (k == v && v >= 1 && v <= 7) {
\r
102 k = v + ' (' + t.sizes[v - 1] + 'pt)';
\r
103 cl = s.font_size_classes[v - 1];
\r
104 v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt');
\r
107 if (/^\s*\./.test(v))
\r
108 cl = v.replace(/\./g, '');
\r
110 o[k] = cl ? {'class' : cl} : {fontSize : v};
\r
113 s.theme_advanced_font_sizes = o;
\r
116 if ((v = s.theme_advanced_path_location) && v != 'none')
\r
117 s.theme_advanced_statusbar_location = s.theme_advanced_path_location;
\r
119 if (s.theme_advanced_statusbar_location == 'none')
\r
120 s.theme_advanced_statusbar_location = 0;
\r
123 ed.onInit.add(function() {
\r
124 if (!ed.settings.readonly)
\r
125 ed.onNodeChange.add(t._nodeChanged, t);
\r
127 if (ed.settings.content_css !== false)
\r
128 ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));
\r
131 ed.onSetProgressState.add(function(ed, b, ti) {
\r
132 var co, id = ed.id, tb;
\r
135 t.progressTimer = setTimeout(function() {
\r
136 co = ed.getContainer();
\r
137 co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
\r
138 tb = DOM.get(ed.id + '_tbl');
\r
140 DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
\r
141 DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
\r
144 DOM.remove(id + '_blocker');
\r
145 DOM.remove(id + '_progress');
\r
146 clearTimeout(t.progressTimer);
\r
150 DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css");
\r
152 if (s.skin_variant)
\r
153 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css");
\r
156 createControl : function(n, cf) {
\r
159 if (c = cf.createControl(n))
\r
163 case "styleselect":
\r
164 return this._createStyleSelect();
\r
166 case "formatselect":
\r
167 return this._createBlockFormats();
\r
170 return this._createFontSelect();
\r
172 case "fontsizeselect":
\r
173 return this._createFontSizeSelect();
\r
176 return this._createForeColorMenu();
\r
179 return this._createBackColorMenu();
\r
182 if ((cd = this.controls[n]))
\r
183 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
\r
186 execCommand : function(cmd, ui, val) {
\r
187 var f = this['_' + cmd];
\r
190 f.call(this, ui, val);
\r
197 _importClasses : function(e) {
\r
198 var ed = this.editor, ctrl = ed.controlManager.get('styleselect');
\r
200 if (ctrl.getLength() == 0) {
\r
201 each(ed.dom.getClasses(), function(o, idx) {
\r
202 var name = 'style_' + idx;
\r
204 ed.formatter.register(name, {
\r
206 attributes : {'class' : o['class']},
\r
210 ctrl.add(o['class'], name);
\r
215 _createStyleSelect : function(n) {
\r
216 var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl;
\r
218 // Setup style select box
\r
219 ctrl = ctrlMan.createListBox('styleselect', {
\r
220 title : 'advanced.style_select',
\r
221 onselect : function(name) {
\r
222 var matches, formatNames = [];
\r
224 each(ctrl.items, function(item) {
\r
225 formatNames.push(item.value);
\r
229 ed.undoManager.add();
\r
231 // Toggle off the current format
\r
232 matches = ed.formatter.matchAll(formatNames);
\r
233 if (!name || matches[0] == name)
\r
234 ed.formatter.remove(matches[0]);
\r
236 ed.formatter.apply(name);
\r
238 ed.undoManager.add();
\r
241 return false; // No auto select
\r
245 // Handle specified format
\r
246 ed.onInit.add(function() {
\r
247 var counter = 0, formats = ed.getParam('style_formats');
\r
250 each(formats, function(fmt) {
\r
251 var name, keys = 0;
\r
253 each(fmt, function() {keys++;});
\r
256 name = fmt.name = fmt.name || 'style_' + (counter++);
\r
257 ed.formatter.register(name, fmt);
\r
258 ctrl.add(fmt.title, name);
\r
260 ctrl.add(fmt.title);
\r
263 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) {
\r
267 name = 'style_' + (counter++);
\r
269 ed.formatter.register(name, {
\r
275 ctrl.add(t.editor.translate(key), name);
\r
281 // Auto import classes if the ctrl box is empty
\r
282 if (ctrl.getLength() == 0) {
\r
283 ctrl.onPostRender.add(function(ed, n) {
\r
284 if (!ctrl.NativeListBox) {
\r
285 Event.add(n.id + '_text', 'focus', t._importClasses, t);
\r
286 Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
\r
287 Event.add(n.id + '_open', 'focus', t._importClasses, t);
\r
288 Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
\r
290 Event.add(n.id, 'focus', t._importClasses, t);
\r
297 _createFontSelect : function() {
\r
298 var c, t = this, ed = t.editor;
\r
300 c = ed.controlManager.createListBox('fontselect', {
\r
301 title : 'advanced.fontdefault',
\r
302 onselect : function(v) {
\r
303 var cur = c.items[c.selectedIndex];
\r
306 ed.execCommand('FontName', false, cur.value);
\r
310 ed.execCommand('FontName', false, v);
\r
312 // Fake selection, execCommand will fire a nodeChange and update the selection
\r
313 c.select(function(sv) {
\r
317 return false; // No auto select
\r
322 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
\r
323 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
\r
330 _createFontSizeSelect : function() {
\r
331 var t = this, ed = t.editor, c, i = 0, cl = [];
\r
333 c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
\r
334 var cur = c.items[c.selectedIndex];
\r
339 if (cur['class']) {
\r
340 ed.formatter.toggle('fontsize_class', {value : cur['class']});
\r
341 ed.undoManager.add();
\r
344 ed.execCommand('FontSize', false, cur.fontSize);
\r
352 ed.undoManager.add();
\r
353 ed.formatter.toggle('fontsize_class', {value : v['class']});
\r
354 ed.undoManager.add();
\r
357 ed.execCommand('FontSize', false, v.fontSize);
\r
359 // Fake selection, execCommand will fire a nodeChange and update the selection
\r
360 c.select(function(sv) {
\r
364 return false; // No auto select
\r
368 each(t.settings.theme_advanced_font_sizes, function(v, k) {
\r
369 var fz = v.fontSize;
\r
371 if (fz >= 1 && fz <= 7)
\r
372 fz = t.sizes[parseInt(fz) - 1] + 'pt';
\r
374 c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
\r
381 _createBlockFormats : function() {
\r
383 p : 'advanced.paragraph',
\r
384 address : 'advanced.address',
\r
385 pre : 'advanced.pre',
\r
386 h1 : 'advanced.h1',
\r
387 h2 : 'advanced.h2',
\r
388 h3 : 'advanced.h3',
\r
389 h4 : 'advanced.h4',
\r
390 h5 : 'advanced.h5',
\r
391 h6 : 'advanced.h6',
\r
392 div : 'advanced.div',
\r
393 blockquote : 'advanced.blockquote',
\r
394 code : 'advanced.code',
\r
395 dt : 'advanced.dt',
\r
396 dd : 'advanced.dd',
\r
397 samp : 'advanced.samp'
\r
400 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
\r
402 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
\r
403 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
\r
410 _createForeColorMenu : function() {
\r
411 var c, t = this, s = t.settings, o = {}, v;
\r
413 if (s.theme_advanced_more_colors) {
\r
414 o.more_colors_func = function() {
\r
415 t._mceColorPicker(0, {
\r
417 func : function(co) {
\r
424 if (v = s.theme_advanced_text_colors)
\r
427 if (s.theme_advanced_default_foreground_color)
\r
428 o.default_color = s.theme_advanced_default_foreground_color;
\r
430 o.title = 'advanced.forecolor_desc';
\r
431 o.cmd = 'ForeColor';
\r
434 c = t.editor.controlManager.createColorSplitButton('forecolor', o);
\r
439 _createBackColorMenu : function() {
\r
440 var c, t = this, s = t.settings, o = {}, v;
\r
442 if (s.theme_advanced_more_colors) {
\r
443 o.more_colors_func = function() {
\r
444 t._mceColorPicker(0, {
\r
446 func : function(co) {
\r
453 if (v = s.theme_advanced_background_colors)
\r
456 if (s.theme_advanced_default_background_color)
\r
457 o.default_color = s.theme_advanced_default_background_color;
\r
459 o.title = 'advanced.backcolor_desc';
\r
460 o.cmd = 'HiliteColor';
\r
463 c = t.editor.controlManager.createColorSplitButton('backcolor', o);
\r
468 renderUI : function(o) {
\r
469 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
\r
471 n = p = DOM.create('span', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')});
\r
474 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
\r
476 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
\r
477 n = tb = DOM.add(n, 'tbody');
\r
479 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
\r
481 ic = t._rowLayout(s, tb, o);
\r
484 case "customlayout":
\r
485 ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
\r
489 ic = t._simpleLayout(s, tb, o, p);
\r
494 // Add classes to first and last TRs
\r
495 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8
\r
496 DOM.addClass(nl[0], 'mceFirst');
\r
497 DOM.addClass(nl[nl.length - 1], 'mceLast');
\r
499 // Add classes to first and last TDs
\r
500 each(DOM.select('tr', tb), function(n) {
\r
501 DOM.addClass(n.firstChild, 'mceFirst');
\r
502 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
\r
505 if (DOM.get(s.theme_advanced_toolbar_container))
\r
506 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
\r
508 DOM.insertAfter(p, n);
\r
510 Event.add(ed.id + '_path_row', 'click', function(e) {
\r
513 if (e.nodeName == 'A') {
\r
514 t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
\r
516 return Event.cancel(e);
\r
520 if (DOM.get(ed.id + '_path_row')) {
\r
521 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
\r
526 if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
\r
527 re = DOM.get(ed.id + '_path_row');
\r
528 t.lastPath = re.innerHTML;
\r
529 DOM.setHTML(re, e.parentNode.title);
\r
533 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
\r
535 DOM.setHTML(ed.id + '_path_row', t.lastPath);
\r
542 if (!ed.getParam('accessibility_focus'))
\r
543 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
\r
545 if (s.theme_advanced_toolbar_location == 'external')
\r
548 t.deltaHeight = o.deltaHeight;
\r
549 o.targetNode = null;
\r
552 iframeContainer : ic,
\r
553 editorContainer : ed.id + '_parent',
\r
554 sizeContainer : sc,
\r
555 deltaHeight : o.deltaHeight
\r
559 getInfo : function() {
\r
561 longname : 'Advanced theme',
\r
562 author : 'Moxiecode Systems AB',
\r
563 authorurl : 'http://tinymce.moxiecode.com',
\r
564 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
568 resizeBy : function(dw, dh) {
\r
569 var e = DOM.get(this.editor.id + '_tbl');
\r
571 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
\r
574 resizeTo : function(w, h) {
\r
575 var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr');
\r
577 // Boundery fix box
\r
578 w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
\r
579 h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
\r
580 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
\r
581 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
\r
583 // Resize iframe and container
\r
584 DOM.setStyle(e, 'height', '');
\r
585 DOM.setStyle(ifr, 'height', h);
\r
587 if (s.theme_advanced_resize_horizontal) {
\r
588 DOM.setStyle(e, 'width', '');
\r
589 DOM.setStyle(ifr, 'width', w);
\r
591 // Make sure that the size is never smaller than the over all ui
\r
592 if (w < e.clientWidth)
\r
593 DOM.setStyle(ifr, 'width', e.clientWidth);
\r
597 destroy : function() {
\r
598 var id = this.editor.id;
\r
600 Event.clear(id + '_resize');
\r
601 Event.clear(id + '_path_row');
\r
602 Event.clear(id + '_external_close');
\r
605 // Internal functions
\r
607 _simpleLayout : function(s, tb, o, p) {
\r
608 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
\r
611 n = DOM.add(tb, 'tr');
\r
612 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
616 // Create toolbar container at top
\r
618 t._addToolbars(tb, o);
\r
620 // Create external toolbar
\r
621 if (lo == 'external') {
\r
622 n = c = DOM.create('div', {style : 'position:relative'});
\r
623 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
\r
624 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
\r
625 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
\r
626 etb = DOM.add(n, 'tbody');
\r
628 if (p.firstChild.className == 'mceOldBoxModel')
\r
629 p.firstChild.appendChild(c);
\r
631 p.insertBefore(c, p.firstChild);
\r
633 t._addToolbars(etb, o);
\r
635 ed.onMouseUp.add(function() {
\r
636 var e = DOM.get(ed.id + '_external');
\r
639 DOM.hide(lastExtID);
\r
641 var f = Event.add(ed.id + '_external_close', 'click', function() {
\r
642 DOM.hide(ed.id + '_external');
\r
643 Event.remove(ed.id + '_external_close', 'click', f);
\r
647 DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
\r
649 // Fixes IE rendering bug
\r
652 e.style.filter = '';
\r
654 lastExtID = ed.id + '_external';
\r
661 t._addStatusBar(tb, o);
\r
663 // Create iframe container
\r
664 if (!s.theme_advanced_toolbar_container) {
\r
665 n = DOM.add(tb, 'tr');
\r
666 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
669 // Create toolbar container at bottom
\r
670 if (lo == 'bottom')
\r
671 t._addToolbars(tb, o);
\r
673 if (sl == 'bottom')
\r
674 t._addStatusBar(tb, o);
\r
679 _rowLayout : function(s, tb, o) {
\r
680 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
\r
682 dc = s.theme_advanced_containers_default_class || '';
\r
683 da = s.theme_advanced_containers_default_align || 'center';
\r
685 each(explode(s.theme_advanced_containers || ''), function(c, i) {
\r
686 var v = s['theme_advanced_container_' + c] || '';
\r
688 switch (v.toLowerCase()) {
\r
690 n = DOM.add(tb, 'tr');
\r
691 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
694 case 'mceelementpath':
\r
695 t._addStatusBar(tb, o);
\r
699 a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
\r
700 a = 'mce' + t._ufirst(a);
\r
702 n = DOM.add(DOM.add(tb, 'tr'), 'td', {
\r
703 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
\r
706 to = cf.createToolbar("toolbar" + i);
\r
707 t._addControls(v, to);
\r
708 DOM.setHTML(n, to.renderHTML());
\r
709 o.deltaHeight -= s.theme_advanced_row_height;
\r
716 _addControls : function(v, tb) {
\r
717 var t = this, s = t.settings, di, cf = t.editor.controlManager;
\r
719 if (s.theme_advanced_disable && !t._disabled) {
\r
722 each(explode(s.theme_advanced_disable), function(v) {
\r
730 each(explode(v), function(n) {
\r
736 // Compatiblity with 2.x
\r
737 if (n == 'tablecontrols') {
\r
738 each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
\r
739 n = t.createControl(n, cf);
\r
748 c = t.createControl(n, cf);
\r
755 _addToolbars : function(c, o) {
\r
756 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
\r
758 a = s.theme_advanced_toolbar_align.toLowerCase();
\r
759 a = 'mce' + t._ufirst(a);
\r
761 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
\r
763 if (!ed.getParam('accessibility_focus'))
\r
764 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
766 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
\r
768 // Create toolbar and add the controls
\r
769 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
\r
770 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
\r
772 if (s['theme_advanced_buttons' + i + '_add'])
\r
773 v += ',' + s['theme_advanced_buttons' + i + '_add'];
\r
775 if (s['theme_advanced_buttons' + i + '_add_before'])
\r
776 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
\r
778 t._addControls(v, tb);
\r
780 //n.appendChild(n = tb.render());
\r
781 h.push(tb.renderHTML());
\r
783 o.deltaHeight -= s.theme_advanced_row_height;
\r
786 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
787 DOM.setHTML(n, h.join(''));
\r
790 _addStatusBar : function(tb, o) {
\r
791 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
\r
793 n = DOM.add(tb, 'tr');
\r
794 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
\r
795 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' ');
\r
796 DOM.add(n, 'a', {href : '#', accesskey : 'x'});
\r
798 if (s.theme_advanced_resizing) {
\r
799 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
\r
801 if (s.theme_advanced_resizing_use_cookie) {
\r
802 ed.onPostRender.add(function() {
\r
803 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
\r
808 t.resizeTo(o.cw, o.ch);
\r
812 ed.onPostRender.add(function() {
\r
813 Event.add(ed.id + '_resize', 'mousedown', function(e) {
\r
814 var mouseMoveHandler1, mouseMoveHandler2,
\r
815 mouseUpHandler1, mouseUpHandler2,
\r
816 startX, startY, startWidth, startHeight, width, height, ifrElm;
\r
818 function resizeOnMove(e) {
\r
819 width = startWidth + (e.screenX - startX);
\r
820 height = startHeight + (e.screenY - startY);
\r
822 t.resizeTo(width, height);
\r
825 function endResize(e) {
\r
827 Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1);
\r
828 Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2);
\r
829 Event.remove(DOM.doc, 'mouseup', mouseUpHandler1);
\r
830 Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2);
\r
832 // Store away the size
\r
833 if (s.theme_advanced_resizing_use_cookie) {
\r
834 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
\r
841 e.preventDefault();
\r
843 // Get the current rect size
\r
844 startX = e.screenX;
\r
845 startY = e.screenY;
\r
846 ifrElm = DOM.get(t.editor.id + '_ifr');
\r
847 startWidth = width = ifrElm.clientWidth;
\r
848 startHeight = height = ifrElm.clientHeight;
\r
850 // Register envent handlers
\r
851 mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove);
\r
852 mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove);
\r
853 mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize);
\r
854 mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize);
\r
859 o.deltaHeight -= 21;
\r
863 _nodeChanged : function(ed, cm, n, co, ob) {
\r
864 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, formatNames, matches;
\r
866 tinymce.each(t.stateControls, function(c) {
\r
867 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
\r
870 function getParent(name) {
\r
871 var i, parents = ob.parents, func = name;
\r
873 if (typeof(name) == 'string') {
\r
874 func = function(node) {
\r
875 return node.nodeName == name;
\r
879 for (i = 0; i < parents.length; i++) {
\r
880 if (func(parents[i]))
\r
885 cm.setActive('visualaid', ed.hasVisual);
\r
886 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
\r
887 cm.setDisabled('redo', !ed.undoManager.hasRedo());
\r
888 cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
\r
890 p = getParent('A');
\r
891 if (c = cm.get('link')) {
\r
892 if (!p || !p.name) {
\r
893 c.setDisabled(!p && co);
\r
898 if (c = cm.get('unlink')) {
\r
899 c.setDisabled(!p && co);
\r
900 c.setActive(!!p && !p.name);
\r
903 if (c = cm.get('anchor')) {
\r
904 c.setActive(!!p && p.name);
\r
907 p = getParent('IMG');
\r
908 if (c = cm.get('image'))
\r
909 c.setActive(!!p && n.className.indexOf('mceItem') == -1);
\r
911 if (c = cm.get('styleselect')) {
\r
912 t._importClasses();
\r
915 each(c.items, function(item) {
\r
916 formatNames.push(item.value);
\r
919 matches = ed.formatter.matchAll(formatNames);
\r
920 c.select(matches[0]);
\r
923 if (c = cm.get('formatselect')) {
\r
924 p = getParent(DOM.isBlock);
\r
927 c.select(p.nodeName.toLowerCase());
\r
930 // Find out current fontSize, fontFamily and fontClass
\r
931 getParent(function(n) {
\r
932 if (n.nodeName === 'SPAN') {
\r
933 if (!cl && n.className)
\r
936 if (!fz && n.style.fontSize)
\r
937 fz = n.style.fontSize;
\r
939 if (!fn && n.style.fontFamily)
\r
940 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
\r
946 if (c = cm.get('fontselect')) {
\r
947 c.select(function(v) {
\r
948 return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
\r
952 // Select font size
\r
953 if (c = cm.get('fontsizeselect')) {
\r
954 // Use computed style
\r
955 if (s.theme_advanced_runtime_fontsize && !fz && !cl)
\r
956 fz = ed.dom.getStyle(n, 'fontSize', true);
\r
958 c.select(function(v) {
\r
959 if (v.fontSize && v.fontSize === fz)
\r
962 if (v['class'] && v['class'] === cl)
\r
967 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
\r
968 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
\r
969 DOM.setHTML(p, '');
\r
971 getParent(function(n) {
\r
972 var na = n.nodeName.toLowerCase(), u, pi, ti = '';
\r
974 /*if (n.getAttribute('_mce_bogus'))
\r
977 // Ignore non element and hidden elements
\r
978 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
\r
982 if (v = DOM.getAttrib(n, 'mce_name'))
\r
986 if (tinymce.isIE && n.scopeName !== 'HTML')
\r
987 na = n.scopeName + ':' + na;
\r
989 // Remove internal prefix
\r
990 na = na.replace(/mce\:/g, '');
\r
992 // Handle node name
\r
1003 if (v = DOM.getAttrib(n, 'src'))
\r
1004 ti += 'src: ' + v + ' ';
\r
1009 if (v = DOM.getAttrib(n, 'name')) {
\r
1010 ti += 'name: ' + v + ' ';
\r
1014 if (v = DOM.getAttrib(n, 'href'))
\r
1015 ti += 'href: ' + v + ' ';
\r
1020 if (v = DOM.getAttrib(n, 'face'))
\r
1021 ti += 'font: ' + v + ' ';
\r
1023 if (v = DOM.getAttrib(n, 'size'))
\r
1024 ti += 'size: ' + v + ' ';
\r
1026 if (v = DOM.getAttrib(n, 'color'))
\r
1027 ti += 'color: ' + v + ' ';
\r
1032 if (v = DOM.getAttrib(n, 'style'))
\r
1033 ti += 'style: ' + v + ' ';
\r
1038 if (v = DOM.getAttrib(n, 'id'))
\r
1039 ti += 'id: ' + v + ' ';
\r
1041 if (v = n.className) {
\r
1042 v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '')
\r
1045 ti += 'class: ' + v + ' ';
\r
1047 if (DOM.isBlock(n) || na == 'img' || na == 'span')
\r
1052 na = na.replace(/(html:)/g, '');
\r
1053 na = {name : na, node : n, title : ti};
\r
1054 t.onResolveName.dispatch(t, na);
\r
1058 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
\r
1059 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
\r
1061 if (p.hasChildNodes()) {
\r
1062 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);
\r
1063 p.insertBefore(pi, p.firstChild);
\r
1065 p.appendChild(pi);
\r
1070 // Commands gets called by execCommand
\r
1072 _sel : function(v) {
\r
1073 this.editor.execCommand('mceSelectNodeDepth', false, v);
\r
1076 _mceInsertAnchor : function(ui, v) {
\r
1077 var ed = this.editor;
\r
1079 ed.windowManager.open({
\r
1080 url : tinymce.baseURL + '/themes/advanced/anchor.htm',
\r
1081 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
\r
1082 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
\r
1085 theme_url : this.url
\r
1089 _mceCharMap : function() {
\r
1090 var ed = this.editor;
\r
1092 ed.windowManager.open({
\r
1093 url : tinymce.baseURL + '/themes/advanced/charmap.htm',
\r
1094 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
\r
1095 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
\r
1098 theme_url : this.url
\r
1102 _mceHelp : function() {
\r
1103 var ed = this.editor;
\r
1105 ed.windowManager.open({
\r
1106 url : tinymce.baseURL + '/themes/advanced/about.htm',
\r
1111 theme_url : this.url
\r
1115 _mceColorPicker : function(u, v) {
\r
1116 var ed = this.editor;
\r
1120 ed.windowManager.open({
\r
1121 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
\r
1122 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
\r
1123 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
\r
1124 close_previous : false,
\r
1127 input_color : v.color,
\r
1129 theme_url : this.url
\r
1133 _mceCodeEditor : function(ui, val) {
\r
1134 var ed = this.editor;
\r
1136 ed.windowManager.open({
\r
1137 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
\r
1138 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
\r
1139 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
\r
1142 maximizable : true
\r
1144 theme_url : this.url
\r
1148 _mceImage : function(ui, val) {
\r
1149 var ed = this.editor;
\r
1151 // Internal image object like a flash placeholder
\r
1152 if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
\r
1155 ed.windowManager.open({
\r
1156 url : tinymce.baseURL + '/themes/advanced/image.htm',
\r
1157 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
\r
1158 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
\r
1161 theme_url : this.url
\r
1165 _mceLink : function(ui, val) {
\r
1166 var ed = this.editor;
\r
1168 ed.windowManager.open({
\r
1169 url : tinymce.baseURL + '/themes/advanced/link.htm',
\r
1170 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
\r
1171 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
\r
1174 theme_url : this.url
\r
1178 _mceNewDocument : function() {
\r
1179 var ed = this.editor;
\r
1181 ed.windowManager.confirm('advanced.newdocument', function(s) {
\r
1183 ed.execCommand('mceSetContent', false, '');
\r
1187 _mceForeColor : function() {
\r
1190 this._mceColorPicker(0, {
\r
1192 func : function(co) {
\r
1194 t.editor.execCommand('ForeColor', false, co);
\r
1199 _mceBackColor : function() {
\r
1202 this._mceColorPicker(0, {
\r
1204 func : function(co) {
\r
1206 t.editor.execCommand('HiliteColor', false, co);
\r
1211 _ufirst : function(s) {
\r
1212 return s.substring(0, 1).toUpperCase() + s.substring(1);
\r
1216 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
\r