2 * $Id: editor_template_src.js 766 2008-04-03 20:37:06Z 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 // Control name lookup, format: title, command
\r
17 bold : ['bold_desc', 'Bold'],
\r
18 italic : ['italic_desc', 'Italic'],
\r
19 underline : ['underline_desc', 'Underline'],
\r
20 strikethrough : ['striketrough_desc', 'Strikethrough'],
\r
21 justifyleft : ['justifyleft_desc', 'JustifyLeft'],
\r
22 justifycenter : ['justifycenter_desc', 'JustifyCenter'],
\r
23 justifyright : ['justifyright_desc', 'JustifyRight'],
\r
24 justifyfull : ['justifyfull_desc', 'JustifyFull'],
\r
25 bullist : ['bullist_desc', 'InsertUnorderedList'],
\r
26 numlist : ['numlist_desc', 'InsertOrderedList'],
\r
27 outdent : ['outdent_desc', 'Outdent'],
\r
28 indent : ['indent_desc', 'Indent'],
\r
29 cut : ['cut_desc', 'Cut'],
\r
30 copy : ['copy_desc', 'Copy'],
\r
31 paste : ['paste_desc', 'Paste'],
\r
32 undo : ['undo_desc', 'Undo'],
\r
33 redo : ['redo_desc', 'Redo'],
\r
34 link : ['link_desc', 'mceLink'],
\r
35 unlink : ['unlink_desc', 'unlink'],
\r
36 image : ['image_desc', 'mceImage'],
\r
37 cleanup : ['cleanup_desc', 'mceCleanup'],
\r
38 help : ['help_desc', 'mceHelp'],
\r
39 code : ['code_desc', 'mceCodeEditor'],
\r
40 hr : ['hr_desc', 'InsertHorizontalRule'],
\r
41 removeformat : ['removeformat_desc', 'RemoveFormat'],
\r
42 sub : ['sub_desc', 'subscript'],
\r
43 sup : ['sup_desc', 'superscript'],
\r
44 forecolor : ['forecolor_desc', 'ForeColor'],
\r
45 forecolorpicker : ['forecolor_desc', 'mceForeColor'],
\r
46 backcolor : ['backcolor_desc', 'HiliteColor'],
\r
47 backcolorpicker : ['backcolor_desc', 'mceBackColor'],
\r
48 charmap : ['charmap_desc', 'mceCharMap'],
\r
49 visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
\r
50 anchor : ['anchor_desc', 'mceInsertAnchor'],
\r
51 newdocument : ['newdocument_desc', 'mceNewDocument'],
\r
52 blockquote : ['blockquote_desc', 'mceBlockQuote']
\r
55 stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
\r
57 init : function(ed, url) {
\r
62 t.onResolveName = new tinymce.util.Dispatcher(this);
\r
65 t.settings = s = extend({
\r
66 theme_advanced_path : true,
\r
67 theme_advanced_toolbar_location : 'bottom',
\r
68 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
\r
69 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
\r
70 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
\r
71 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
\r
72 theme_advanced_toolbar_align : "center",
\r
73 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
74 theme_advanced_font_sizes : "1,2,3,4,5,6,7",
\r
75 theme_advanced_more_colors : 1,
\r
76 theme_advanced_row_height : 23,
\r
77 theme_advanced_resize_horizontal : 1,
\r
78 theme_advanced_resizing_use_cookie : 1
\r
81 if ((v = s.theme_advanced_path_location) && v != 'none')
\r
82 s.theme_advanced_statusbar_location = s.theme_advanced_path_location;
\r
84 if (s.theme_advanced_statusbar_location == 'none')
\r
85 s.theme_advanced_statusbar_location = 0;
\r
88 ed.onInit.add(function() {
\r
89 ed.onNodeChange.add(t._nodeChanged, t);
\r
91 if (ed.settings.content_css !== false)
\r
92 ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));
\r
95 ed.onSetProgressState.add(function(ed, b, ti) {
\r
96 var co, id = ed.id, tb;
\r
99 t.progressTimer = setTimeout(function() {
\r
100 co = ed.getContainer();
\r
101 co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
\r
102 tb = DOM.get(ed.id + '_tbl');
\r
104 DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
\r
105 DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
\r
108 DOM.remove(id + '_blocker');
\r
109 DOM.remove(id + '_progress');
\r
110 clearTimeout(t.progressTimer);
\r
114 DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui.css"));
\r
116 if (s.skin_variant)
\r
117 DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"));
\r
120 createControl : function(n, cf) {
\r
123 if (c = cf.createControl(n))
\r
127 case "styleselect":
\r
128 return this._createStyleSelect();
\r
130 case "formatselect":
\r
131 return this._createBlockFormats();
\r
134 return this._createFontSelect();
\r
136 case "fontsizeselect":
\r
137 return this._createFontSizeSelect();
\r
140 return this._createForeColorMenu();
\r
143 return this._createBackColorMenu();
\r
146 if ((cd = this.controls[n]))
\r
147 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
\r
150 execCommand : function(cmd, ui, val) {
\r
151 var f = this['_' + cmd];
\r
154 f.call(this, ui, val);
\r
161 _importClasses : function() {
\r
162 var ed = this.editor, c = ed.controlManager.get('styleselect');
\r
164 if (c.getLength() == 0) {
\r
165 each(ed.dom.getClasses(), function(o) {
\r
166 c.add(o['class'], o['class']);
\r
171 _createStyleSelect : function(n) {
\r
172 var t = this, ed = t.editor, cf = ed.controlManager, c = cf.createListBox('styleselect', {
\r
173 title : 'advanced.style_select',
\r
174 onselect : function(v) {
\r
175 if (c.selectedValue === v) {
\r
176 ed.execCommand('mceSetStyleInfo', 0, {command : 'removeformat'});
\r
180 ed.execCommand('mceSetCSSClass', 0, v);
\r
185 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(v, k) {
\r
187 c.add(t.editor.translate(k), v);
\r
190 c.onPostRender.add(function(ed, n) {
\r
191 Event.add(n, 'focus', t._importClasses, t);
\r
192 Event.add(n, 'mousedown', t._importClasses, t);
\r
199 _createFontSelect : function() {
\r
200 var c, t = this, ed = t.editor;
\r
202 c = ed.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'});
\r
204 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
\r
205 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
\r
212 _createFontSizeSelect : function() {
\r
213 var c, t = this, lo = [
\r
221 ], fz = [8, 10, 12, 14, 18, 24, 36];
\r
223 c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'});
\r
225 each(explode(t.settings.theme_advanced_font_sizes), function(v) {
\r
226 c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'mceFontSize' + v});
\r
233 _createBlockFormats : function() {
\r
235 p : 'advanced.paragraph',
\r
236 address : 'advanced.address',
\r
237 pre : 'advanced.pre',
\r
238 h1 : 'advanced.h1',
\r
239 h2 : 'advanced.h2',
\r
240 h3 : 'advanced.h3',
\r
241 h4 : 'advanced.h4',
\r
242 h5 : 'advanced.h5',
\r
243 h6 : 'advanced.h6',
\r
244 div : 'advanced.div',
\r
245 blockquote : 'advanced.blockquote',
\r
246 code : 'advanced.code',
\r
247 dt : 'advanced.dt',
\r
248 dd : 'advanced.dd',
\r
249 samp : 'advanced.samp'
\r
252 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
\r
254 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
\r
255 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
\r
262 _createForeColorMenu : function() {
\r
263 var c, t = this, s = t.settings, o = {}, v;
\r
265 if (s.theme_advanced_more_colors) {
\r
266 o.more_colors_func = function() {
\r
267 t._mceColorPicker(0, {
\r
269 func : function(co) {
\r
276 if (v = s.theme_advanced_text_colors)
\r
279 o.title = 'advanced.forecolor_desc';
\r
280 o.cmd = 'ForeColor';
\r
283 c = t.editor.controlManager.createColorSplitButton('forecolor', o);
\r
288 _createBackColorMenu : function() {
\r
289 var c, t = this, s = t.settings, o = {}, v;
\r
291 if (s.theme_advanced_more_colors) {
\r
292 o.more_colors_func = function() {
\r
293 t._mceColorPicker(0, {
\r
295 func : function(co) {
\r
302 if (v = s.theme_advanced_background_colors)
\r
305 o.title = 'advanced.backcolor_desc';
\r
306 o.cmd = 'HiliteColor';
\r
309 c = t.editor.controlManager.createColorSplitButton('backcolor', o);
\r
314 renderUI : function(o) {
\r
315 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
\r
317 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
320 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
\r
322 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
\r
323 n = tb = DOM.add(n, 'tbody');
\r
325 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
\r
327 ic = t._rowLayout(s, tb, o);
\r
330 case "customlayout":
\r
331 ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
\r
335 ic = t._simpleLayout(s, tb, o, p);
\r
340 // Add classes to first and last TRs
\r
341 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8
\r
342 DOM.addClass(nl[0], 'mceFirst');
\r
343 DOM.addClass(nl[nl.length - 1], 'mceLast');
\r
345 // Add classes to first and last TDs
\r
346 each(DOM.select('tr', tb), function(n) {
\r
347 DOM.addClass(n.firstChild, 'mceFirst');
\r
348 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
\r
351 if (DOM.get(s.theme_advanced_toolbar_container))
\r
352 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
\r
354 DOM.insertAfter(p, n);
\r
356 Event.add(ed.id + '_path_row', 'click', function(e) {
\r
359 if (e.nodeName == 'A') {
\r
360 t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
\r
362 return Event.cancel(e);
\r
366 if (DOM.get(ed.id + '_path_row')) {
\r
367 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
\r
372 if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
\r
373 re = DOM.get(ed.id + '_path_row');
\r
374 t.lastPath = re.innerHTML;
\r
375 DOM.setHTML(re, e.parentNode.title);
\r
379 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
\r
381 DOM.setHTML(ed.id + '_path_row', t.lastPath);
\r
388 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
\r
389 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
\r
391 if (s.theme_advanced_toolbar_location == 'external')
\r
394 t.deltaHeight = o.deltaHeight;
\r
395 o.targetNode = null;
\r
398 iframeContainer : ic,
\r
399 editorContainer : ed.id + '_parent',
\r
400 sizeContainer : sc,
\r
401 deltaHeight : o.deltaHeight
\r
405 getInfo : function() {
\r
407 longname : 'Advanced theme',
\r
408 author : 'Moxiecode Systems AB',
\r
409 authorurl : 'http://tinymce.moxiecode.com',
\r
410 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
414 resizeBy : function(dw, dh) {
\r
415 var e = DOM.get(this.editor.id + '_tbl');
\r
417 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
\r
420 resizeTo : function(w, h) {
\r
421 var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh;
\r
423 // Boundery fix box
\r
424 w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
\r
425 h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
\r
426 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
\r
427 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
\r
429 // Calc difference between iframe and container
\r
430 dh = e.clientHeight - ifr.clientHeight;
\r
432 // Resize iframe and container
\r
433 DOM.setStyle(ifr, 'height', h - dh);
\r
434 DOM.setStyles(e, {width : w, height : h});
\r
437 destroy : function() {
\r
438 var id = this.editor.id;
\r
440 Event.clear(id + '_resize');
\r
441 Event.clear(id + '_path_row');
\r
442 Event.clear(id + '_external_close');
\r
445 // Internal functions
\r
447 _simpleLayout : function(s, tb, o, p) {
\r
448 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
\r
450 // Create toolbar container at top
\r
452 t._addToolbars(tb, o);
\r
454 // Create external toolbar
\r
455 if (lo == 'external') {
\r
456 n = c = DOM.create('div', {style : 'position:relative'});
\r
457 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
\r
458 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
\r
459 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
\r
460 etb = DOM.add(n, 'tbody');
\r
462 if (p.firstChild.className == 'mceOldBoxModel')
\r
463 p.firstChild.appendChild(c);
\r
465 p.insertBefore(c, p.firstChild);
\r
467 t._addToolbars(etb, o);
\r
469 ed.onMouseUp.add(function() {
\r
470 var e = DOM.get(ed.id + '_external');
\r
473 DOM.hide(lastExtID);
\r
475 var f = Event.add(ed.id + '_external_close', 'click', function() {
\r
476 DOM.hide(ed.id + '_external');
\r
477 Event.remove(ed.id + '_external_close', 'click', f);
\r
481 DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
\r
483 // Fixes IE rendering bug
\r
486 e.style.filter = '';
\r
488 lastExtID = ed.id + '_external';
\r
495 t._addStatusBar(tb, o);
\r
497 // Create iframe container
\r
498 if (!s.theme_advanced_toolbar_container) {
\r
499 n = DOM.add(tb, 'tr');
\r
500 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
503 // Create toolbar container at bottom
\r
504 if (lo == 'bottom')
\r
505 t._addToolbars(tb, o);
\r
507 if (sl == 'bottom')
\r
508 t._addStatusBar(tb, o);
\r
513 _rowLayout : function(s, tb, o) {
\r
514 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
\r
516 dc = s.theme_advanced_containers_default_class || '';
\r
517 da = s.theme_advanced_containers_default_align || 'center';
\r
519 each(explode(s.theme_advanced_containers || ''), function(c, i) {
\r
520 var v = s['theme_advanced_container_' + c] || '';
\r
522 switch (c.toLowerCase()) {
\r
524 n = DOM.add(tb, 'tr');
\r
525 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
\r
528 case 'mceelementpath':
\r
529 t._addStatusBar(tb, o);
\r
533 a = s['theme_advanced_container_' + c + '_align'].toLowerCase();
\r
534 a = 'mce' + t._ufirst(a);
\r
536 n = DOM.add(DOM.add(tb, 'tr'), 'td', {
\r
537 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
\r
540 to = cf.createToolbar("toolbar" + i);
\r
541 t._addControls(v, to);
\r
542 DOM.setHTML(n, to.renderHTML());
\r
543 o.deltaHeight -= s.theme_advanced_row_height;
\r
550 _addControls : function(v, tb) {
\r
551 var t = this, s = t.settings, di, cf = t.editor.controlManager;
\r
553 if (s.theme_advanced_disable && !t._disabled) {
\r
556 each(explode(s.theme_advanced_disable), function(v) {
\r
564 each(explode(v), function(n) {
\r
570 // Compatiblity with 2.x
\r
571 if (n == 'tablecontrols') {
\r
572 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
573 n = t.createControl(n, cf);
\r
582 c = t.createControl(n, cf);
\r
589 _addToolbars : function(c, o) {
\r
590 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
\r
592 a = s.theme_advanced_toolbar_align.toLowerCase();
\r
593 a = 'mce' + t._ufirst(a);
\r
595 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
\r
597 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
\r
598 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
600 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
\r
602 // Create toolbar and add the controls
\r
603 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
\r
604 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
\r
606 if (s['theme_advanced_buttons' + i + '_add'])
\r
607 v += ',' + s['theme_advanced_buttons' + i + '_add'];
\r
609 if (s['theme_advanced_buttons' + i + '_add_before'])
\r
610 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
\r
612 t._addControls(v, tb);
\r
614 //n.appendChild(n = tb.render());
\r
615 h.push(tb.renderHTML());
\r
617 o.deltaHeight -= s.theme_advanced_row_height;
\r
620 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
\r
621 DOM.setHTML(n, h.join(''));
\r
624 _addStatusBar : function(tb, o) {
\r
625 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
\r
627 n = DOM.add(tb, 'tr');
\r
628 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
\r
629 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' ');
\r
630 DOM.add(n, 'a', {href : '#', accesskey : 'x'});
\r
632 if (s.theme_advanced_resizing && !tinymce.isOldWebKit) {
\r
633 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
\r
635 if (s.theme_advanced_resizing_use_cookie) {
\r
636 ed.onPostRender.add(function() {
\r
637 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
\r
642 if (s.theme_advanced_resize_horizontal)
\r
643 c.style.width = Math.max(10, o.cw) + 'px';
\r
645 c.style.height = Math.max(10, o.ch) + 'px';
\r
646 DOM.get(ed.id + '_ifr').style.height = Math.max(10, parseInt(o.ch) + t.deltaHeight) + 'px';
\r
650 ed.onPostRender.add(function() {
\r
651 Event.add(ed.id + '_resize', 'mousedown', function(e) {
\r
652 var c, p, w, h, n, pa;
\r
654 // Measure container
\r
655 c = DOM.get(ed.id + '_tbl');
\r
657 h = c.clientHeight;
\r
659 miw = s.theme_advanced_resizing_min_width || 100;
\r
660 mih = s.theme_advanced_resizing_min_height || 100;
\r
661 maw = s.theme_advanced_resizing_max_width || 0xFFFF;
\r
662 mah = s.theme_advanced_resizing_max_height || 0xFFFF;
\r
664 // Setup placeholder
\r
665 p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});
\r
666 DOM.setStyles(p, {width : w, height : h});
\r
668 // Replace with placeholder
\r
672 // Create internal resize obj
\r
683 mf = Event.add(DOM.doc, 'mousemove', function(e) {
\r
686 // Calc delta values
\r
687 r.dx = e.screenX - r.x;
\r
688 r.dy = e.screenY - r.y;
\r
690 // Boundery fix box
\r
691 w = Math.max(miw, r.w + r.dx);
\r
692 h = Math.max(mih, r.h + r.dy);
\r
693 w = Math.min(maw, w);
\r
694 h = Math.min(mah, h);
\r
696 // Resize placeholder
\r
697 if (s.theme_advanced_resize_horizontal)
\r
698 p.style.width = w + 'px';
\r
700 p.style.height = h + 'px';
\r
702 return Event.cancel(e);
\r
705 me = Event.add(DOM.doc, 'mouseup', function(e) {
\r
709 Event.remove(DOM.doc, 'mousemove', mf);
\r
710 Event.remove(DOM.doc, 'mouseup', me);
\r
712 c.style.display = '';
\r
718 ifr = DOM.get(ed.id + '_ifr');
\r
720 if (s.theme_advanced_resize_horizontal)
\r
721 c.style.width = Math.max(10, r.w + r.dx) + 'px';
\r
723 c.style.height = Math.max(10, r.h + r.dy) + 'px';
\r
724 ifr.style.height = Math.max(10, ifr.clientHeight + r.dy) + 'px';
\r
726 if (s.theme_advanced_resizing_use_cookie) {
\r
727 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
\r
734 return Event.cancel(e);
\r
739 o.deltaHeight -= 21;
\r
743 _nodeChanged : function(ed, cm, n, co) {
\r
744 var t = this, p, de = 0, v, c, s = t.settings;
\r
746 tinymce.each(t.stateControls, function(c) {
\r
747 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
\r
750 cm.setActive('visualaid', ed.hasVisual);
\r
751 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
\r
752 cm.setDisabled('redo', !ed.undoManager.hasRedo());
\r
753 cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
\r
755 p = DOM.getParent(n, 'A');
\r
756 if (c = cm.get('link')) {
\r
757 if (!p || !p.name) {
\r
758 c.setDisabled(!p && co);
\r
763 if (c = cm.get('unlink')) {
\r
764 c.setDisabled(!p && co);
\r
765 c.setActive(!!p && !p.name);
\r
768 if (c = cm.get('anchor')) {
\r
769 c.setActive(!!p && p.name);
\r
771 if (tinymce.isWebKit) {
\r
772 p = DOM.getParent(n, 'IMG');
\r
773 c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a');
\r
777 p = DOM.getParent(n, 'IMG');
\r
778 if (c = cm.get('image'))
\r
779 c.setActive(!!p && n.className.indexOf('mceItem') == -1);
\r
781 if (c = cm.get('styleselect')) {
\r
783 t._importClasses();
\r
784 c.select(n.className);
\r
789 if (c = cm.get('formatselect')) {
\r
790 p = DOM.getParent(n, DOM.isBlock);
\r
793 c.select(p.nodeName.toLowerCase());
\r
796 if (c = cm.get('fontselect'))
\r
797 c.select(ed.queryCommandValue('FontName'));
\r
799 if (c = cm.get('fontsizeselect'))
\r
800 c.select(ed.queryCommandValue('FontSize'));
\r
802 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
\r
803 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
\r
804 DOM.setHTML(p, '');
\r
806 ed.dom.getParent(n, function(n) {
\r
807 var na = n.nodeName.toLowerCase(), u, pi, ti = '';
\r
809 // Ignore non element and hidden elements
\r
810 if (n.nodeType != 1 || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
\r
814 if (v = DOM.getAttrib(n, 'mce_name'))
\r
818 if (tinymce.isIE && n.scopeName !== 'HTML')
\r
819 na = n.scopeName + ':' + na;
\r
821 // Remove internal prefix
\r
822 na = na.replace(/mce\:/g, '');
\r
824 // Handle node name
\r
835 if (v = DOM.getAttrib(n, 'src'))
\r
836 ti += 'src: ' + v + ' ';
\r
841 if (v = DOM.getAttrib(n, 'name')) {
\r
842 ti += 'name: ' + v + ' ';
\r
846 if (v = DOM.getAttrib(n, 'href'))
\r
847 ti += 'href: ' + v + ' ';
\r
852 if (s.convert_fonts_to_spans)
\r
855 if (v = DOM.getAttrib(n, 'face'))
\r
856 ti += 'font: ' + v + ' ';
\r
858 if (v = DOM.getAttrib(n, 'size'))
\r
859 ti += 'size: ' + v + ' ';
\r
861 if (v = DOM.getAttrib(n, 'color'))
\r
862 ti += 'color: ' + v + ' ';
\r
867 if (v = DOM.getAttrib(n, 'style'))
\r
868 ti += 'style: ' + v + ' ';
\r
873 if (v = DOM.getAttrib(n, 'id'))
\r
874 ti += 'id: ' + v + ' ';
\r
876 if (v = n.className) {
\r
877 v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, '');
\r
879 if (v && v.indexOf('mceItem') == -1) {
\r
880 ti += 'class: ' + v + ' ';
\r
882 if (DOM.isBlock(n) || na == 'img' || na == 'span')
\r
887 na = na.replace(/(html:)/g, '');
\r
888 na = {name : na, node : n, title : ti};
\r
889 t.onResolveName.dispatch(t, na);
\r
893 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
\r
894 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
\r
896 if (p.hasChildNodes()) {
\r
897 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);
\r
898 p.insertBefore(pi, p.firstChild);
\r
905 // Commands gets called by execCommand
\r
907 _sel : function(v) {
\r
908 this.editor.execCommand('mceSelectNodeDepth', false, v);
\r
911 _mceInsertAnchor : function(ui, v) {
\r
912 var ed = this.editor;
\r
914 ed.windowManager.open({
\r
915 url : tinymce.baseURL + '/themes/advanced/anchor.htm',
\r
916 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
\r
917 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
\r
920 theme_url : this.url
\r
924 _mceCharMap : function() {
\r
925 var ed = this.editor;
\r
927 ed.windowManager.open({
\r
928 url : tinymce.baseURL + '/themes/advanced/charmap.htm',
\r
929 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
\r
930 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
\r
933 theme_url : this.url
\r
937 _mceHelp : function() {
\r
938 var ed = this.editor;
\r
940 ed.windowManager.open({
\r
941 url : tinymce.baseURL + '/themes/advanced/about.htm',
\r
946 theme_url : this.url
\r
950 _mceColorPicker : function(u, v) {
\r
951 var ed = this.editor;
\r
955 ed.windowManager.open({
\r
956 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
\r
957 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
\r
958 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
\r
959 close_previous : false,
\r
962 input_color : v.color,
\r
964 theme_url : this.url
\r
968 _mceCodeEditor : function(ui, val) {
\r
969 var ed = this.editor;
\r
971 ed.windowManager.open({
\r
972 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
\r
973 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
\r
974 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
\r
979 theme_url : this.url
\r
983 _mceImage : function(ui, val) {
\r
984 var ed = this.editor;
\r
986 // Internal image object like a flash placeholder
\r
987 if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
\r
990 ed.windowManager.open({
\r
991 url : tinymce.baseURL + '/themes/advanced/image.htm',
\r
992 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
\r
993 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
\r
996 theme_url : this.url
\r
1000 _mceLink : function(ui, val) {
\r
1001 var ed = this.editor;
\r
1003 ed.windowManager.open({
\r
1004 url : tinymce.baseURL + '/themes/advanced/link.htm',
\r
1005 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
\r
1006 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
\r
1009 theme_url : this.url
\r
1013 _mceNewDocument : function() {
\r
1014 var ed = this.editor;
\r
1016 ed.windowManager.confirm('advanced.newdocument', function(s) {
\r
1018 ed.execCommand('mceSetContent', false, '');
\r
1022 _mceForeColor : function() {
\r
1025 this._mceColorPicker(0, {
\r
1026 func : function(co) {
\r
1027 t.editor.execCommand('ForeColor', false, co);
\r
1032 _mceBackColor : function() {
\r
1035 this._mceColorPicker(0, {
\r
1036 func : function(co) {
\r
1037 t.editor.execCommand('HiliteColor', false, co);
\r
1042 _ufirst : function(s) {
\r
1043 return s.substring(0, 1).toUpperCase() + s.substring(1);
\r
1047 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
\r