2 * $Id: editor_template_src.js 960 2008-11-12 18:30:32Z spocke $
\r
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
\r
9 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;
\r
11 // Tell it to load theme specific language pack(s)
\r
12 tinymce.ThemeManager.requireLangPack('advanced');
\r
14 tinymce.create('tinymce.themes.AdvancedTheme', {
\r
15 sizes : [8, 10, 12, 14, 18, 24, 36],
\r
17 // Control name lookup, format: title, command
\r
19 bold : ['bold_desc', 'Bold'],
\r
20 italic : ['italic_desc', 'Italic'],
\r
21 underline : ['underline_desc', 'Underline'],
\r
22 strikethrough : ['striketrough_desc', 'Strikethrough'],
\r
23 justifyleft : ['justifyleft_desc', 'JustifyLeft'],
\r
24 justifycenter : ['justifycenter_desc', 'JustifyCenter'],
\r
25 justifyright : ['justifyright_desc', 'JustifyRight'],
\r
26 justifyfull : ['justifyfull_desc', 'JustifyFull'],
\r
27 bullist : ['bullist_desc', 'InsertUnorderedList'],
\r
28 numlist : ['numlist_desc', 'InsertOrderedList'],
\r
29 outdent : ['outdent_desc', 'Outdent'],
\r
30 indent : ['indent_desc', 'Indent'],
\r
31 cut : ['cut_desc', 'Cut'],
\r
32 copy : ['copy_desc', 'Copy'],
\r
33 paste : ['paste_desc', 'Paste'],
\r
34 undo : ['undo_desc', 'Undo'],
\r
35 redo : ['redo_desc', 'Redo'],
\r
36 link : ['link_desc', 'mceLink'],
\r
37 unlink : ['unlink_desc', 'unlink'],
\r
38 image : ['image_desc', 'mceImage'],
\r
39 cleanup : ['cleanup_desc', 'mceCleanup'],
\r
40 help : ['help_desc', 'mceHelp'],
\r
41 code : ['code_desc', 'mceCodeEditor'],
\r
42 hr : ['hr_desc', 'InsertHorizontalRule'],
\r
43 removeformat : ['removeformat_desc', 'RemoveFormat'],
\r
44 sub : ['sub_desc', 'subscript'],
\r
45 sup : ['sup_desc', 'superscript'],
\r
46 forecolor : ['forecolor_desc', 'ForeColor'],
\r
47 forecolorpicker : ['forecolor_desc', 'mceForeColor'],
\r
48 backcolor : ['backcolor_desc', 'HiliteColor'],
\r
49 backcolorpicker : ['backcolor_desc', 'mceBackColor'],
\r
50 charmap : ['charmap_desc', 'mceCharMap'],
\r
51 visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
\r
52 anchor : ['anchor_desc', 'mceInsertAnchor'],
\r
53 newdocument : ['newdocument_desc', 'mceNewDocument'],
\r
54 blockquote : ['blockquote_desc', 'mceBlockQuote']
\r
57 stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
\r
59 init : function(ed, url) {
\r
60 var t = this, s, v, o;
\r
64 t.onResolveName = new tinymce.util.Dispatcher(this);
\r
67 t.settings = s = extend({
\r
68 theme_advanced_path : true,
\r
69 theme_advanced_toolbar_location : 'bottom',
\r
70 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
\r
71 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
\r
72 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
\r
73 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
\r
74 theme_advanced_toolbar_align : "center",
\r
75 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
76 theme_advanced_more_colors : 1,
\r
77 theme_advanced_row_height : 23,
\r
78 theme_advanced_resize_horizontal : 1,
\r
79 theme_advanced_resizing_use_cookie : 1,
\r
80 theme_advanced_font_sizes : "1,2,3,4,5,6,7",
\r
81 readonly : ed.settings.readonly
\r
84 // Setup default font_size_style_values
\r
85 if (!s.font_size_style_values)
\r
86 s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt";
\r
88 if (tinymce.is(s.theme_advanced_font_sizes, 'string')) {
\r
89 s.font_size_style_values = tinymce.explode(s.font_size_style_values);
\r
90 s.font_size_classes = tinymce.explode(s.font_size_classes || '');
\r
92 // Parse string value
\r
94 ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes;
\r
95 each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) {
\r
98 if (k == v && v >= 1 && v <= 7) {
\r
99 k = v + ' (' + t.sizes[v - 1] + 'pt)';
\r
101 if (ed.settings.convert_fonts_to_spans) {
\r
102 cl = s.font_size_classes[v - 1];
\r
103 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 ed.onNodeChange.add(t._nodeChanged, t);
\r
126 if (ed.settings.content_css !== false)
\r
127 ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));
\r
130 ed.onSetProgressState.add(function(ed, b, ti) {
\r
131 var co, id = ed.id, tb;
\r
134 t.progressTimer = setTimeout(function() {
\r
135 co = ed.getContainer();
\r
136 co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
\r
137 tb = DOM.get(ed.id + '_tbl');
\r
139 DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
\r
140 DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
\r
143 DOM.remove(id + '_blocker');
\r
144 DOM.remove(id + '_progress');
\r
145 clearTimeout(t.progressTimer);
\r
149 DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css");
\r
151 if (s.skin_variant)
\r
152 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css");
\r
155 createControl : function(n, cf) {
\r
158 if (c = cf.createControl(n))
\r
162 case "styleselect":
\r
163 return this._createStyleSelect();
\r
165 case "formatselect":
\r
166 return this._createBlockFormats();
\r
169 return this._createFontSelect();
\r
171 case "fontsizeselect":
\r
172 return this._createFontSizeSelect();
\r
175 return this._createForeColorMenu();
\r
178 return this._createBackColorMenu();
\r
181 if ((cd = this.controls[n]))
\r
182 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
\r
185 execCommand : function(cmd, ui, val) {
\r
186 var f = this['_' + cmd];
\r
189 f.call(this, ui, val);
\r
196 _importClasses : function(e) {
\r
197 var ed = this.editor, c = ed.controlManager.get('styleselect');
\r
199 if (c.getLength() == 0) {
\r
200 each(ed.dom.getClasses(), function(o) {
\r
201 c.add(o['class'], o['class']);
\r
206 _createStyleSelect : function(n) {
\r
207 var t = this, ed = t.editor, cf = ed.controlManager, c = cf.createListBox('styleselect', {
\r
208 title : 'advanced.style_select',
\r
209 onselect : function(v) {
\r
210 if (c.selectedValue === v) {
\r
211 ed.execCommand('mceSetStyleInfo', 0, {command : 'removeformat'});
\r
215 ed.execCommand('mceSetCSSClass', 0, v);
\r
220 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(v, k) {
\r
222 c.add(t.editor.translate(k), v);
\r
225 c.onPostRender.add(function(ed, n) {
\r
226 if (!c.NativeListBox) {
\r
227 Event.add(n.id + '_text', 'focus', t._importClasses, t);
\r
228 Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
\r
229 Event.add(n.id + '_open', 'focus', t._importClasses, t);
\r
230 Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
\r
232 Event.add(n.id, 'focus', t._importClasses, t);
\r
239 _createFontSelect : function() {
\r
240 var c, t = this, ed = t.editor;
\r
242 c = ed.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'});
\r
244 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
\r
245 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
\r
252 _createFontSizeSelect : function() {
\r
253 var t = this, ed = t.editor, c, i = 0, cl = [];
\r
255 c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
\r
257 ed.execCommand('FontSize', false, v.fontSize);
\r
259 each(t.settings.theme_advanced_font_sizes, function(v, k) {
\r
261 cl.push(v['class']);
\r
264 ed.editorCommands._applyInlineStyle('span', {'class' : v['class']}, {check_classes : cl});
\r
269 each(t.settings.theme_advanced_font_sizes, function(v, k) {
\r
270 var fz = v.fontSize;
\r
272 if (fz >= 1 && fz <= 7)
\r
273 fz = t.sizes[parseInt(fz) - 1] + 'pt';
\r
275 c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
\r
282 _createBlockFormats : function() {
\r
284 p : 'advanced.paragraph',
\r
285 address : 'advanced.address',
\r
286 pre : 'advanced.pre',
\r
287 h1 : 'advanced.h1',
\r
288 h2 : 'advanced.h2',
\r
289 h3 : 'advanced.h3',
\r
290 h4 : 'advanced.h4',
\r
291 h5 : 'advanced.h5',
\r
292 h6 : 'advanced.h6',
\r
293 div : 'advanced.div',
\r
294 blockquote : 'advanced.blockquote',
\r
295 code : 'advanced.code',
\r
296 dt : 'advanced.dt',
\r
297 dd : 'advanced.dd',
\r
298 samp : 'advanced.samp'
\r
301 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
\r
303 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
\r
304 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
\r
311 _createForeColorMenu : function() {
\r
312 var c, t = this, s = t.settings, o = {}, v;
\r
314 if (s.theme_advanced_more_colors) {
\r
315 o.more_colors_func = function() {
\r
316 t._mceColorPicker(0, {
\r
318 func : function(co) {
\r
325 if (v = s.theme_advanced_text_colors)
\r
328 if (s.theme_advanced_default_foreground_color)
\r
329 o.default_color = s.theme_advanced_default_foreground_color;
\r
331 o.title = 'advanced.forecolor_desc';
\r
332 o.cmd = 'ForeColor';
\r
335 c = t.editor.controlManager.createColorSplitButton('forecolor', o);
\r
340 _createBackColorMenu : function() {
\r
341 var c, t = this, s = t.settings, o = {}, v;
\r
343 if (s.theme_advanced_more_colors) {
\r
344 o.more_colors_func = function() {
\r
345 t._mceColorPicker(0, {
\r
347 func : function(co) {
\r
354 if (v = s.theme_advanced_background_colors)
\r
357 if (s.theme_advanced_default_background_color)
\r
358 o.default_color = s.theme_advanced_default_background_color;
\r
360 o.title = 'advanced.backcolor_desc';
\r
361 o.cmd = 'HiliteColor';
\r
364 c = t.editor.controlManager.createColorSplitButton('backcolor', o);
\r
369 renderUI : function(o) {
\r
370 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
\r
372 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
375 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
\r
377 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
\r
378 n = tb = DOM.add(n, 'tbody');
\r
380 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
\r
382 ic = t._rowLayout(s, tb, o);
\r
385 case "customlayout":
\r
386 ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
\r
390 ic = t._simpleLayout(s, tb, o, p);
\r
395 // Add classes to first and last TRs
\r
396 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8
\r
397 DOM.addClass(nl[0], 'mceFirst');
\r
398 DOM.addClass(nl[nl.length - 1], 'mceLast');
\r
400 // Add classes to first and last TDs
\r
401 each(DOM.select('tr', tb), function(n) {
\r
402 DOM.addClass(n.firstChild, 'mceFirst');
\r
403 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
\r
406 if (DOM.get(s.theme_advanced_toolbar_container))
\r
407 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
\r
409 DOM.insertAfter(p, n);
\r
411 Event.add(ed.id + '_path_row', 'click', function(e) {
\r
414 if (e.nodeName == 'A') {
\r
415 t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
\r
417 return Event.cancel(e);
\r
421 if (DOM.get(ed.id + '_path_row')) {
\r
422 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
\r
427 if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
\r
428 re = DOM.get(ed.id + '_path_row');
\r
429 t.lastPath = re.innerHTML;
\r
430 DOM.setHTML(re, e.parentNode.title);
\r
434 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
\r
436 DOM.setHTML(ed.id + '_path_row', t.lastPath);
\r
443 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
\r
444 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
\r
446 if (s.theme_advanced_toolbar_location == 'external')
\r
449 t.deltaHeight = o.deltaHeight;
\r
450 o.targetNode = null;
\r
453 iframeContainer : ic,
\r
454 editorContainer : ed.id + '_parent',
\r
455 sizeContainer : sc,
\r
456 deltaHeight : o.deltaHeight
\r
460 getInfo : function() {
\r
462 longname : 'Advanced theme',
\r
463 author : 'Moxiecode Systems AB',
\r
464 authorurl : 'http://tinymce.moxiecode.com',
\r
465 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
469 resizeBy : function(dw, dh) {
\r
470 var e = DOM.get(this.editor.id + '_tbl');
\r
472 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
\r
475 resizeTo : function(w, h) {
\r
476 var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh;
\r
478 // Boundery fix box
\r
479 w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
\r
480 h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
\r
481 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
\r
482 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
\r
484 // Calc difference between iframe and container
\r
485 dh = e.clientHeight - ifr.clientHeight;
\r
487 // Resize iframe and container
\r
488 DOM.setStyle(ifr, 'height', h - dh);
\r
489 DOM.setStyles(e, {width : w, height : h});
\r
492 destroy : function() {
\r
493 var id = this.editor.id;
\r
495 Event.clear(id + '_resize');
\r
496 Event.clear(id + '_path_row');
\r
497 Event.clear(id + '_external_close');
\r
500 // Internal functions
\r
502 _simpleLayout : function(s, tb, o, p) {
\r
503 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
\r
506 n = DOM.add(tb, 'tr');
\r
507 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
511 // Create toolbar container at top
\r
513 t._addToolbars(tb, o);
\r
515 // Create external toolbar
\r
516 if (lo == 'external') {
\r
517 n = c = DOM.create('div', {style : 'position:relative'});
\r
518 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
\r
519 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
\r
520 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
\r
521 etb = DOM.add(n, 'tbody');
\r
523 if (p.firstChild.className == 'mceOldBoxModel')
\r
524 p.firstChild.appendChild(c);
\r
526 p.insertBefore(c, p.firstChild);
\r
528 t._addToolbars(etb, o);
\r
530 ed.onMouseUp.add(function() {
\r
531 var e = DOM.get(ed.id + '_external');
\r
534 DOM.hide(lastExtID);
\r
536 var f = Event.add(ed.id + '_external_close', 'click', function() {
\r
537 DOM.hide(ed.id + '_external');
\r
538 Event.remove(ed.id + '_external_close', 'click', f);
\r
542 DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
\r
544 // Fixes IE rendering bug
\r
547 e.style.filter = '';
\r
549 lastExtID = ed.id + '_external';
\r
556 t._addStatusBar(tb, o);
\r
558 // Create iframe container
\r
559 if (!s.theme_advanced_toolbar_container) {
\r
560 n = DOM.add(tb, 'tr');
\r
561 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
564 // Create toolbar container at bottom
\r
565 if (lo == 'bottom')
\r
566 t._addToolbars(tb, o);
\r
568 if (sl == 'bottom')
\r
569 t._addStatusBar(tb, o);
\r
574 _rowLayout : function(s, tb, o) {
\r
575 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
\r
577 dc = s.theme_advanced_containers_default_class || '';
\r
578 da = s.theme_advanced_containers_default_align || 'center';
\r
580 each(explode(s.theme_advanced_containers || ''), function(c, i) {
\r
581 var v = s['theme_advanced_container_' + c] || '';
\r
583 switch (v.toLowerCase()) {
\r
585 n = DOM.add(tb, 'tr');
\r
586 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
589 case 'mceelementpath':
\r
590 t._addStatusBar(tb, o);
\r
594 a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
\r
595 a = 'mce' + t._ufirst(a);
\r
597 n = DOM.add(DOM.add(tb, 'tr'), 'td', {
\r
598 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
\r
601 to = cf.createToolbar("toolbar" + i);
\r
602 t._addControls(v, to);
\r
603 DOM.setHTML(n, to.renderHTML());
\r
604 o.deltaHeight -= s.theme_advanced_row_height;
\r
611 _addControls : function(v, tb) {
\r
612 var t = this, s = t.settings, di, cf = t.editor.controlManager;
\r
614 if (s.theme_advanced_disable && !t._disabled) {
\r
617 each(explode(s.theme_advanced_disable), function(v) {
\r
625 each(explode(v), function(n) {
\r
631 // Compatiblity with 2.x
\r
632 if (n == 'tablecontrols') {
\r
633 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
634 n = t.createControl(n, cf);
\r
643 c = t.createControl(n, cf);
\r
650 _addToolbars : function(c, o) {
\r
651 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
\r
653 a = s.theme_advanced_toolbar_align.toLowerCase();
\r
654 a = 'mce' + t._ufirst(a);
\r
656 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
\r
658 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
\r
659 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
661 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
\r
663 // Create toolbar and add the controls
\r
664 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
\r
665 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
\r
667 if (s['theme_advanced_buttons' + i + '_add'])
\r
668 v += ',' + s['theme_advanced_buttons' + i + '_add'];
\r
670 if (s['theme_advanced_buttons' + i + '_add_before'])
\r
671 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
\r
673 t._addControls(v, tb);
\r
675 //n.appendChild(n = tb.render());
\r
676 h.push(tb.renderHTML());
\r
678 o.deltaHeight -= s.theme_advanced_row_height;
\r
681 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
682 DOM.setHTML(n, h.join(''));
\r
685 _addStatusBar : function(tb, o) {
\r
686 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
\r
688 n = DOM.add(tb, 'tr');
\r
689 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
\r
690 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' ');
\r
691 DOM.add(n, 'a', {href : '#', accesskey : 'x'});
\r
693 if (s.theme_advanced_resizing && !tinymce.isOldWebKit) {
\r
694 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
\r
696 if (s.theme_advanced_resizing_use_cookie) {
\r
697 ed.onPostRender.add(function() {
\r
698 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
\r
703 if (s.theme_advanced_resize_horizontal)
\r
704 c.style.width = Math.max(10, o.cw) + 'px';
\r
706 c.style.height = Math.max(10, o.ch) + 'px';
\r
707 DOM.get(ed.id + '_ifr').style.height = Math.max(10, parseInt(o.ch) + t.deltaHeight) + 'px';
\r
711 ed.onPostRender.add(function() {
\r
712 Event.add(ed.id + '_resize', 'mousedown', function(e) {
\r
713 var c, p, w, h, n, pa;
\r
715 // Measure container
\r
716 c = DOM.get(ed.id + '_tbl');
\r
718 h = c.clientHeight;
\r
720 miw = s.theme_advanced_resizing_min_width || 100;
\r
721 mih = s.theme_advanced_resizing_min_height || 100;
\r
722 maw = s.theme_advanced_resizing_max_width || 0xFFFF;
\r
723 mah = s.theme_advanced_resizing_max_height || 0xFFFF;
\r
725 // Setup placeholder
\r
726 p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});
\r
727 DOM.setStyles(p, {width : w, height : h});
\r
729 // Replace with placeholder
\r
733 // Create internal resize obj
\r
744 mf = Event.add(DOM.doc, 'mousemove', function(e) {
\r
747 // Calc delta values
\r
748 r.dx = e.screenX - r.x;
\r
749 r.dy = e.screenY - r.y;
\r
751 // Boundery fix box
\r
752 w = Math.max(miw, r.w + r.dx);
\r
753 h = Math.max(mih, r.h + r.dy);
\r
754 w = Math.min(maw, w);
\r
755 h = Math.min(mah, h);
\r
757 // Resize placeholder
\r
758 if (s.theme_advanced_resize_horizontal)
\r
759 p.style.width = w + 'px';
\r
761 p.style.height = h + 'px';
\r
763 return Event.cancel(e);
\r
766 me = Event.add(DOM.doc, 'mouseup', function(e) {
\r
770 Event.remove(DOM.doc, 'mousemove', mf);
\r
771 Event.remove(DOM.doc, 'mouseup', me);
\r
773 c.style.display = '';
\r
779 ifr = DOM.get(ed.id + '_ifr');
\r
781 if (s.theme_advanced_resize_horizontal)
\r
782 c.style.width = Math.max(10, r.w + r.dx) + 'px';
\r
784 c.style.height = Math.max(10, r.h + r.dy) + 'px';
\r
785 ifr.style.height = Math.max(10, ifr.clientHeight + r.dy) + 'px';
\r
787 if (s.theme_advanced_resizing_use_cookie) {
\r
788 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
\r
795 return Event.cancel(e);
\r
800 o.deltaHeight -= 21;
\r
804 _nodeChanged : function(ed, cm, n, co) {
\r
805 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn;
\r
810 tinymce.each(t.stateControls, function(c) {
\r
811 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
\r
814 cm.setActive('visualaid', ed.hasVisual);
\r
815 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
\r
816 cm.setDisabled('redo', !ed.undoManager.hasRedo());
\r
817 cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
\r
819 p = DOM.getParent(n, 'A');
\r
820 if (c = cm.get('link')) {
\r
821 if (!p || !p.name) {
\r
822 c.setDisabled(!p && co);
\r
827 if (c = cm.get('unlink')) {
\r
828 c.setDisabled(!p && co);
\r
829 c.setActive(!!p && !p.name);
\r
832 if (c = cm.get('anchor')) {
\r
833 c.setActive(!!p && p.name);
\r
835 if (tinymce.isWebKit) {
\r
836 p = DOM.getParent(n, 'IMG');
\r
837 c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a');
\r
841 p = DOM.getParent(n, 'IMG');
\r
842 if (c = cm.get('image'))
\r
843 c.setActive(!!p && n.className.indexOf('mceItem') == -1);
\r
845 if (c = cm.get('styleselect')) {
\r
847 t._importClasses();
\r
848 c.select(n.className);
\r
853 if (c = cm.get('formatselect')) {
\r
854 p = DOM.getParent(n, DOM.isBlock);
\r
857 c.select(p.nodeName.toLowerCase());
\r
860 if (ed.settings.convert_fonts_to_spans) {
\r
861 ed.dom.getParent(n, function(n) {
\r
862 if (n.nodeName === 'SPAN') {
\r
863 if (!cl && n.className)
\r
866 if (!fz && n.style.fontSize)
\r
867 fz = n.style.fontSize;
\r
869 if (!fn && n.style.fontFamily)
\r
870 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
\r
876 if (c = cm.get('fontselect')) {
\r
877 c.select(function(v) {
\r
878 return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
\r
882 if (c = cm.get('fontsizeselect')) {
\r
883 c.select(function(v) {
\r
884 if (v.fontSize && v.fontSize === fz)
\r
887 if (v['class'] && v['class'] === cl)
\r
892 if (c = cm.get('fontselect'))
\r
893 c.select(ed.queryCommandValue('FontName'));
\r
895 if (c = cm.get('fontsizeselect')) {
\r
896 v = ed.queryCommandValue('FontSize');
\r
897 c.select(function(iv) {
\r
898 return iv.fontSize == v;
\r
903 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
\r
904 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
\r
905 DOM.setHTML(p, '');
\r
907 ed.dom.getParent(n, function(n) {
\r
908 var na = n.nodeName.toLowerCase(), u, pi, ti = '';
\r
910 // Ignore non element and hidden elements
\r
911 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
\r
915 if (v = DOM.getAttrib(n, 'mce_name'))
\r
919 if (tinymce.isIE && n.scopeName !== 'HTML')
\r
920 na = n.scopeName + ':' + na;
\r
922 // Remove internal prefix
\r
923 na = na.replace(/mce\:/g, '');
\r
925 // Handle node name
\r
936 if (v = DOM.getAttrib(n, 'src'))
\r
937 ti += 'src: ' + v + ' ';
\r
942 if (v = DOM.getAttrib(n, 'name')) {
\r
943 ti += 'name: ' + v + ' ';
\r
947 if (v = DOM.getAttrib(n, 'href'))
\r
948 ti += 'href: ' + v + ' ';
\r
953 if (s.convert_fonts_to_spans)
\r
956 if (v = DOM.getAttrib(n, 'face'))
\r
957 ti += 'font: ' + v + ' ';
\r
959 if (v = DOM.getAttrib(n, 'size'))
\r
960 ti += 'size: ' + v + ' ';
\r
962 if (v = DOM.getAttrib(n, 'color'))
\r
963 ti += 'color: ' + v + ' ';
\r
968 if (v = DOM.getAttrib(n, 'style'))
\r
969 ti += 'style: ' + v + ' ';
\r
974 if (v = DOM.getAttrib(n, 'id'))
\r
975 ti += 'id: ' + v + ' ';
\r
977 if (v = n.className) {
\r
978 v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, '');
\r
980 if (v && v.indexOf('mceItem') == -1) {
\r
981 ti += 'class: ' + v + ' ';
\r
983 if (DOM.isBlock(n) || na == 'img' || na == 'span')
\r
988 na = na.replace(/(html:)/g, '');
\r
989 na = {name : na, node : n, title : ti};
\r
990 t.onResolveName.dispatch(t, na);
\r
994 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
\r
995 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
\r
997 if (p.hasChildNodes()) {
\r
998 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);
\r
999 p.insertBefore(pi, p.firstChild);
\r
1001 p.appendChild(pi);
\r
1006 // Commands gets called by execCommand
\r
1008 _sel : function(v) {
\r
1009 this.editor.execCommand('mceSelectNodeDepth', false, v);
\r
1012 _mceInsertAnchor : function(ui, v) {
\r
1013 var ed = this.editor;
\r
1015 ed.windowManager.open({
\r
1016 url : tinymce.baseURL + '/themes/advanced/anchor.htm',
\r
1017 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
\r
1018 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
\r
1021 theme_url : this.url
\r
1025 _mceCharMap : function() {
\r
1026 var ed = this.editor;
\r
1028 ed.windowManager.open({
\r
1029 url : tinymce.baseURL + '/themes/advanced/charmap.htm',
\r
1030 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
\r
1031 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
\r
1034 theme_url : this.url
\r
1038 _mceHelp : function() {
\r
1039 var ed = this.editor;
\r
1041 ed.windowManager.open({
\r
1042 url : tinymce.baseURL + '/themes/advanced/about.htm',
\r
1047 theme_url : this.url
\r
1051 _mceColorPicker : function(u, v) {
\r
1052 var ed = this.editor;
\r
1056 ed.windowManager.open({
\r
1057 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
\r
1058 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
\r
1059 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
\r
1060 close_previous : false,
\r
1063 input_color : v.color,
\r
1065 theme_url : this.url
\r
1069 _mceCodeEditor : function(ui, val) {
\r
1070 var ed = this.editor;
\r
1072 ed.windowManager.open({
\r
1073 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
\r
1074 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
\r
1075 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
\r
1078 maximizable : true
\r
1080 theme_url : this.url
\r
1084 _mceImage : function(ui, val) {
\r
1085 var ed = this.editor;
\r
1087 // Internal image object like a flash placeholder
\r
1088 if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
\r
1091 ed.windowManager.open({
\r
1092 url : tinymce.baseURL + '/themes/advanced/image.htm',
\r
1093 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
\r
1094 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
\r
1097 theme_url : this.url
\r
1101 _mceLink : function(ui, val) {
\r
1102 var ed = this.editor;
\r
1104 ed.windowManager.open({
\r
1105 url : tinymce.baseURL + '/themes/advanced/link.htm',
\r
1106 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
\r
1107 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
\r
1110 theme_url : this.url
\r
1114 _mceNewDocument : function() {
\r
1115 var ed = this.editor;
\r
1117 ed.windowManager.confirm('advanced.newdocument', function(s) {
\r
1119 ed.execCommand('mceSetContent', false, '');
\r
1123 _mceForeColor : function() {
\r
1126 this._mceColorPicker(0, {
\r
1128 func : function(co) {
\r
1130 t.editor.execCommand('ForeColor', false, co);
\r
1135 _mceBackColor : function() {
\r
1138 this._mceColorPicker(0, {
\r
1140 func : function(co) {
\r
1142 t.editor.execCommand('HiliteColor', false, co);
\r
1147 _ufirst : function(s) {
\r
1148 return s.substring(0, 1).toUpperCase() + s.substring(1);
\r
1152 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
\r