bgneal@312: /** bgneal@312: * editor_template_src.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: (function(tinymce) { bgneal@312: var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode; bgneal@312: bgneal@312: // Tell it to load theme specific language pack(s) bgneal@312: tinymce.ThemeManager.requireLangPack('advanced'); bgneal@312: bgneal@312: tinymce.create('tinymce.themes.AdvancedTheme', { bgneal@312: sizes : [8, 10, 12, 14, 18, 24, 36], bgneal@312: bgneal@312: // Control name lookup, format: title, command bgneal@312: controls : { bgneal@312: bold : ['bold_desc', 'Bold'], bgneal@312: italic : ['italic_desc', 'Italic'], bgneal@312: underline : ['underline_desc', 'Underline'], bgneal@312: strikethrough : ['striketrough_desc', 'Strikethrough'], bgneal@312: justifyleft : ['justifyleft_desc', 'JustifyLeft'], bgneal@312: justifycenter : ['justifycenter_desc', 'JustifyCenter'], bgneal@312: justifyright : ['justifyright_desc', 'JustifyRight'], bgneal@312: justifyfull : ['justifyfull_desc', 'JustifyFull'], bgneal@312: bullist : ['bullist_desc', 'InsertUnorderedList'], bgneal@312: numlist : ['numlist_desc', 'InsertOrderedList'], bgneal@312: outdent : ['outdent_desc', 'Outdent'], bgneal@312: indent : ['indent_desc', 'Indent'], bgneal@312: cut : ['cut_desc', 'Cut'], bgneal@312: copy : ['copy_desc', 'Copy'], bgneal@312: paste : ['paste_desc', 'Paste'], bgneal@312: undo : ['undo_desc', 'Undo'], bgneal@312: redo : ['redo_desc', 'Redo'], bgneal@312: link : ['link_desc', 'mceLink'], bgneal@312: unlink : ['unlink_desc', 'unlink'], bgneal@312: image : ['image_desc', 'mceImage'], bgneal@312: cleanup : ['cleanup_desc', 'mceCleanup'], bgneal@312: help : ['help_desc', 'mceHelp'], bgneal@312: code : ['code_desc', 'mceCodeEditor'], bgneal@312: hr : ['hr_desc', 'InsertHorizontalRule'], bgneal@312: removeformat : ['removeformat_desc', 'RemoveFormat'], bgneal@312: sub : ['sub_desc', 'subscript'], bgneal@312: sup : ['sup_desc', 'superscript'], bgneal@312: forecolor : ['forecolor_desc', 'ForeColor'], bgneal@312: forecolorpicker : ['forecolor_desc', 'mceForeColor'], bgneal@312: backcolor : ['backcolor_desc', 'HiliteColor'], bgneal@312: backcolorpicker : ['backcolor_desc', 'mceBackColor'], bgneal@312: charmap : ['charmap_desc', 'mceCharMap'], bgneal@312: visualaid : ['visualaid_desc', 'mceToggleVisualAid'], bgneal@312: anchor : ['anchor_desc', 'mceInsertAnchor'], bgneal@312: newdocument : ['newdocument_desc', 'mceNewDocument'], bgneal@312: blockquote : ['blockquote_desc', 'mceBlockQuote'] bgneal@312: }, bgneal@312: bgneal@312: stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'], bgneal@312: bgneal@312: init : function(ed, url) { bgneal@312: var t = this, s, v, o; bgneal@312: bgneal@312: t.editor = ed; bgneal@312: t.url = url; bgneal@312: t.onResolveName = new tinymce.util.Dispatcher(this); bgneal@312: bgneal@312: // Default settings bgneal@312: t.settings = s = extend({ bgneal@312: theme_advanced_path : true, bgneal@312: theme_advanced_toolbar_location : 'bottom', bgneal@312: theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", bgneal@312: theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code", bgneal@312: theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap", bgneal@312: theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6", bgneal@312: theme_advanced_toolbar_align : "center", bgneal@312: 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", bgneal@312: theme_advanced_more_colors : 1, bgneal@312: theme_advanced_row_height : 23, bgneal@312: theme_advanced_resize_horizontal : 1, bgneal@312: theme_advanced_resizing_use_cookie : 1, bgneal@312: theme_advanced_font_sizes : "1,2,3,4,5,6,7", bgneal@312: readonly : ed.settings.readonly bgneal@312: }, ed.settings); bgneal@312: bgneal@312: // Setup default font_size_style_values bgneal@312: if (!s.font_size_style_values) bgneal@312: s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt"; bgneal@312: bgneal@312: if (tinymce.is(s.theme_advanced_font_sizes, 'string')) { bgneal@312: s.font_size_style_values = tinymce.explode(s.font_size_style_values); bgneal@312: s.font_size_classes = tinymce.explode(s.font_size_classes || ''); bgneal@312: bgneal@312: // Parse string value bgneal@312: o = {}; bgneal@312: ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes; bgneal@312: each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) { bgneal@312: var cl; bgneal@312: bgneal@312: if (k == v && v >= 1 && v <= 7) { bgneal@312: k = v + ' (' + t.sizes[v - 1] + 'pt)'; bgneal@312: cl = s.font_size_classes[v - 1]; bgneal@312: v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt'); bgneal@312: } bgneal@312: bgneal@312: if (/^\s*\./.test(v)) bgneal@312: cl = v.replace(/\./g, ''); bgneal@312: bgneal@312: o[k] = cl ? {'class' : cl} : {fontSize : v}; bgneal@312: }); bgneal@312: bgneal@312: s.theme_advanced_font_sizes = o; bgneal@312: } bgneal@312: bgneal@312: if ((v = s.theme_advanced_path_location) && v != 'none') bgneal@312: s.theme_advanced_statusbar_location = s.theme_advanced_path_location; bgneal@312: bgneal@312: if (s.theme_advanced_statusbar_location == 'none') bgneal@312: s.theme_advanced_statusbar_location = 0; bgneal@312: bgneal@312: // Init editor bgneal@312: ed.onInit.add(function() { bgneal@312: if (!ed.settings.readonly) bgneal@312: ed.onNodeChange.add(t._nodeChanged, t); bgneal@312: bgneal@312: if (ed.settings.content_css !== false) bgneal@312: ed.dom.loadCSS(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css")); bgneal@312: }); bgneal@312: bgneal@312: ed.onSetProgressState.add(function(ed, b, ti) { bgneal@312: var co, id = ed.id, tb; bgneal@312: bgneal@312: if (b) { bgneal@312: t.progressTimer = setTimeout(function() { bgneal@312: co = ed.getContainer(); bgneal@312: co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild); bgneal@312: tb = DOM.get(ed.id + '_tbl'); bgneal@312: bgneal@312: DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}}); bgneal@312: DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}}); bgneal@312: }, ti || 0); bgneal@312: } else { bgneal@312: DOM.remove(id + '_blocker'); bgneal@312: DOM.remove(id + '_progress'); bgneal@312: clearTimeout(t.progressTimer); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css"); bgneal@312: bgneal@312: if (s.skin_variant) bgneal@312: DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); bgneal@312: }, bgneal@312: bgneal@312: createControl : function(n, cf) { bgneal@312: var cd, c; bgneal@312: bgneal@312: if (c = cf.createControl(n)) bgneal@312: return c; bgneal@312: bgneal@312: switch (n) { bgneal@312: case "styleselect": bgneal@312: return this._createStyleSelect(); bgneal@312: bgneal@312: case "formatselect": bgneal@312: return this._createBlockFormats(); bgneal@312: bgneal@312: case "fontselect": bgneal@312: return this._createFontSelect(); bgneal@312: bgneal@312: case "fontsizeselect": bgneal@312: return this._createFontSizeSelect(); bgneal@312: bgneal@312: case "forecolor": bgneal@312: return this._createForeColorMenu(); bgneal@312: bgneal@312: case "backcolor": bgneal@312: return this._createBackColorMenu(); bgneal@312: } bgneal@312: bgneal@312: if ((cd = this.controls[n])) bgneal@312: return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]}); bgneal@312: }, bgneal@312: bgneal@312: execCommand : function(cmd, ui, val) { bgneal@312: var f = this['_' + cmd]; bgneal@312: bgneal@312: if (f) { bgneal@312: f.call(this, ui, val); bgneal@312: return true; bgneal@312: } bgneal@312: bgneal@312: return false; bgneal@312: }, bgneal@312: bgneal@312: _importClasses : function(e) { bgneal@312: var ed = this.editor, ctrl = ed.controlManager.get('styleselect'); bgneal@312: bgneal@312: if (ctrl.getLength() == 0) { bgneal@312: each(ed.dom.getClasses(), function(o, idx) { bgneal@312: var name = 'style_' + idx; bgneal@312: bgneal@312: ed.formatter.register(name, { bgneal@312: inline : 'span', bgneal@312: attributes : {'class' : o['class']}, bgneal@312: selector : '*' bgneal@312: }); bgneal@312: bgneal@312: ctrl.add(o['class'], name); bgneal@312: }); bgneal@312: } bgneal@312: }, bgneal@312: bgneal@312: _createStyleSelect : function(n) { bgneal@312: var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl; bgneal@312: bgneal@312: // Setup style select box bgneal@312: ctrl = ctrlMan.createListBox('styleselect', { bgneal@312: title : 'advanced.style_select', bgneal@312: onselect : function(name) { bgneal@312: var matches, formatNames = []; bgneal@312: bgneal@312: each(ctrl.items, function(item) { bgneal@312: formatNames.push(item.value); bgneal@312: }); bgneal@312: bgneal@312: ed.focus(); bgneal@312: ed.undoManager.add(); bgneal@312: bgneal@312: // Toggle off the current format bgneal@312: matches = ed.formatter.matchAll(formatNames); bgneal@312: if (!name || matches[0] == name) bgneal@312: ed.formatter.remove(matches[0]); bgneal@312: else bgneal@312: ed.formatter.apply(name); bgneal@312: bgneal@312: ed.undoManager.add(); bgneal@312: ed.nodeChanged(); bgneal@312: bgneal@312: return false; // No auto select bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Handle specified format bgneal@312: ed.onInit.add(function() { bgneal@312: var counter = 0, formats = ed.getParam('style_formats'); bgneal@312: bgneal@312: if (formats) { bgneal@312: each(formats, function(fmt) { bgneal@312: var name, keys = 0; bgneal@312: bgneal@312: each(fmt, function() {keys++;}); bgneal@312: bgneal@312: if (keys > 1) { bgneal@312: name = fmt.name = fmt.name || 'style_' + (counter++); bgneal@312: ed.formatter.register(name, fmt); bgneal@312: ctrl.add(fmt.title, name); bgneal@312: } else bgneal@312: ctrl.add(fmt.title); bgneal@312: }); bgneal@312: } else { bgneal@312: each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) { bgneal@312: var name; bgneal@312: bgneal@312: if (val) { bgneal@312: name = 'style_' + (counter++); bgneal@312: bgneal@312: ed.formatter.register(name, { bgneal@312: inline : 'span', bgneal@312: classes : val, bgneal@312: selector : '*' bgneal@312: }); bgneal@312: bgneal@312: ctrl.add(t.editor.translate(key), name); bgneal@312: } bgneal@312: }); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Auto import classes if the ctrl box is empty bgneal@312: if (ctrl.getLength() == 0) { bgneal@312: ctrl.onPostRender.add(function(ed, n) { bgneal@312: if (!ctrl.NativeListBox) { bgneal@312: Event.add(n.id + '_text', 'focus', t._importClasses, t); bgneal@312: Event.add(n.id + '_text', 'mousedown', t._importClasses, t); bgneal@312: Event.add(n.id + '_open', 'focus', t._importClasses, t); bgneal@312: Event.add(n.id + '_open', 'mousedown', t._importClasses, t); bgneal@312: } else bgneal@312: Event.add(n.id, 'focus', t._importClasses, t); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: return ctrl; bgneal@312: }, bgneal@312: bgneal@312: _createFontSelect : function() { bgneal@312: var c, t = this, ed = t.editor; bgneal@312: bgneal@312: c = ed.controlManager.createListBox('fontselect', { bgneal@312: title : 'advanced.fontdefault', bgneal@312: onselect : function(v) { bgneal@312: var cur = c.items[c.selectedIndex]; bgneal@312: bgneal@312: if (!v && cur) { bgneal@312: ed.execCommand('FontName', false, cur.value); bgneal@312: return; bgneal@312: } bgneal@312: bgneal@312: ed.execCommand('FontName', false, v); bgneal@312: bgneal@312: // Fake selection, execCommand will fire a nodeChange and update the selection bgneal@312: c.select(function(sv) { bgneal@312: return v == sv; bgneal@312: }); bgneal@312: bgneal@312: return false; // No auto select bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: if (c) { bgneal@312: each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) { bgneal@312: c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''}); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: return c; bgneal@312: }, bgneal@312: bgneal@312: _createFontSizeSelect : function() { bgneal@312: var t = this, ed = t.editor, c, i = 0, cl = []; bgneal@312: bgneal@312: c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) { bgneal@312: var cur = c.items[c.selectedIndex]; bgneal@312: bgneal@312: if (!v && cur) { bgneal@312: cur = cur.value; bgneal@312: bgneal@312: if (cur['class']) { bgneal@312: ed.formatter.toggle('fontsize_class', {value : cur['class']}); bgneal@312: ed.undoManager.add(); bgneal@312: ed.nodeChanged(); bgneal@312: } else { bgneal@312: ed.execCommand('FontSize', false, cur.fontSize); bgneal@312: } bgneal@312: bgneal@312: return; bgneal@312: } bgneal@312: bgneal@312: if (v['class']) { bgneal@312: ed.focus(); bgneal@312: ed.undoManager.add(); bgneal@312: ed.formatter.toggle('fontsize_class', {value : v['class']}); bgneal@312: ed.undoManager.add(); bgneal@312: ed.nodeChanged(); bgneal@312: } else bgneal@312: ed.execCommand('FontSize', false, v.fontSize); bgneal@312: bgneal@312: // Fake selection, execCommand will fire a nodeChange and update the selection bgneal@312: c.select(function(sv) { bgneal@312: return v == sv; bgneal@312: }); bgneal@312: bgneal@312: return false; // No auto select bgneal@312: }}); bgneal@312: bgneal@312: if (c) { bgneal@312: each(t.settings.theme_advanced_font_sizes, function(v, k) { bgneal@312: var fz = v.fontSize; bgneal@312: bgneal@312: if (fz >= 1 && fz <= 7) bgneal@312: fz = t.sizes[parseInt(fz) - 1] + 'pt'; bgneal@312: bgneal@312: c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))}); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: return c; bgneal@312: }, bgneal@312: bgneal@312: _createBlockFormats : function() { bgneal@312: var c, fmts = { bgneal@312: p : 'advanced.paragraph', bgneal@312: address : 'advanced.address', bgneal@312: pre : 'advanced.pre', bgneal@312: h1 : 'advanced.h1', bgneal@312: h2 : 'advanced.h2', bgneal@312: h3 : 'advanced.h3', bgneal@312: h4 : 'advanced.h4', bgneal@312: h5 : 'advanced.h5', bgneal@312: h6 : 'advanced.h6', bgneal@312: div : 'advanced.div', bgneal@312: blockquote : 'advanced.blockquote', bgneal@312: code : 'advanced.code', bgneal@312: dt : 'advanced.dt', bgneal@312: dd : 'advanced.dd', bgneal@312: samp : 'advanced.samp' bgneal@312: }, t = this; bgneal@312: bgneal@312: c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'}); bgneal@312: if (c) { bgneal@312: each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) { bgneal@312: c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v}); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: return c; bgneal@312: }, bgneal@312: bgneal@312: _createForeColorMenu : function() { bgneal@312: var c, t = this, s = t.settings, o = {}, v; bgneal@312: bgneal@312: if (s.theme_advanced_more_colors) { bgneal@312: o.more_colors_func = function() { bgneal@312: t._mceColorPicker(0, { bgneal@312: color : c.value, bgneal@312: func : function(co) { bgneal@312: c.setColor(co); bgneal@312: } bgneal@312: }); bgneal@312: }; bgneal@312: } bgneal@312: bgneal@312: if (v = s.theme_advanced_text_colors) bgneal@312: o.colors = v; bgneal@312: bgneal@312: if (s.theme_advanced_default_foreground_color) bgneal@312: o.default_color = s.theme_advanced_default_foreground_color; bgneal@312: bgneal@312: o.title = 'advanced.forecolor_desc'; bgneal@312: o.cmd = 'ForeColor'; bgneal@312: o.scope = this; bgneal@312: bgneal@312: c = t.editor.controlManager.createColorSplitButton('forecolor', o); bgneal@312: bgneal@312: return c; bgneal@312: }, bgneal@312: bgneal@312: _createBackColorMenu : function() { bgneal@312: var c, t = this, s = t.settings, o = {}, v; bgneal@312: bgneal@312: if (s.theme_advanced_more_colors) { bgneal@312: o.more_colors_func = function() { bgneal@312: t._mceColorPicker(0, { bgneal@312: color : c.value, bgneal@312: func : function(co) { bgneal@312: c.setColor(co); bgneal@312: } bgneal@312: }); bgneal@312: }; bgneal@312: } bgneal@312: bgneal@312: if (v = s.theme_advanced_background_colors) bgneal@312: o.colors = v; bgneal@312: bgneal@312: if (s.theme_advanced_default_background_color) bgneal@312: o.default_color = s.theme_advanced_default_background_color; bgneal@312: bgneal@312: o.title = 'advanced.backcolor_desc'; bgneal@312: o.cmd = 'HiliteColor'; bgneal@312: o.scope = this; bgneal@312: bgneal@312: c = t.editor.controlManager.createColorSplitButton('backcolor', o); bgneal@312: bgneal@312: return c; bgneal@312: }, bgneal@312: bgneal@312: renderUI : function(o) { bgneal@312: var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; bgneal@312: bgneal@312: 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) : '')}); bgneal@312: bgneal@312: if (!DOM.boxModel) bgneal@312: n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); bgneal@312: bgneal@312: n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); bgneal@312: n = tb = DOM.add(n, 'tbody'); bgneal@312: bgneal@312: switch ((s.theme_advanced_layout_manager || '').toLowerCase()) { bgneal@312: case "rowlayout": bgneal@312: ic = t._rowLayout(s, tb, o); bgneal@312: break; bgneal@312: bgneal@312: case "customlayout": bgneal@312: ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p); bgneal@312: break; bgneal@312: bgneal@312: default: bgneal@312: ic = t._simpleLayout(s, tb, o, p); bgneal@312: } bgneal@312: bgneal@312: n = o.targetNode; bgneal@312: bgneal@312: // Add classes to first and last TRs bgneal@312: nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8 bgneal@312: DOM.addClass(nl[0], 'mceFirst'); bgneal@312: DOM.addClass(nl[nl.length - 1], 'mceLast'); bgneal@312: bgneal@312: // Add classes to first and last TDs bgneal@312: each(DOM.select('tr', tb), function(n) { bgneal@312: DOM.addClass(n.firstChild, 'mceFirst'); bgneal@312: DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast'); bgneal@312: }); bgneal@312: bgneal@312: if (DOM.get(s.theme_advanced_toolbar_container)) bgneal@312: DOM.get(s.theme_advanced_toolbar_container).appendChild(p); bgneal@312: else bgneal@312: DOM.insertAfter(p, n); bgneal@312: bgneal@312: Event.add(ed.id + '_path_row', 'click', function(e) { bgneal@312: e = e.target; bgneal@312: bgneal@312: if (e.nodeName == 'A') { bgneal@312: t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1')); bgneal@312: bgneal@312: return Event.cancel(e); bgneal@312: } bgneal@312: }); bgneal@312: /* bgneal@312: if (DOM.get(ed.id + '_path_row')) { bgneal@312: Event.add(ed.id + '_tbl', 'mouseover', function(e) { bgneal@312: var re; bgneal@312: bgneal@312: e = e.target; bgneal@312: bgneal@312: if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) { bgneal@312: re = DOM.get(ed.id + '_path_row'); bgneal@312: t.lastPath = re.innerHTML; bgneal@312: DOM.setHTML(re, e.parentNode.title); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: Event.add(ed.id + '_tbl', 'mouseout', function(e) { bgneal@312: if (t.lastPath) { bgneal@312: DOM.setHTML(ed.id + '_path_row', t.lastPath); bgneal@312: t.lastPath = 0; bgneal@312: } bgneal@312: }); bgneal@312: } bgneal@312: */ bgneal@312: bgneal@312: if (!ed.getParam('accessibility_focus')) bgneal@312: Event.add(DOM.add(p, 'a', {href : '#'}, ''), 'focus', function() {tinyMCE.get(ed.id).focus();}); bgneal@312: bgneal@312: if (s.theme_advanced_toolbar_location == 'external') bgneal@312: o.deltaHeight = 0; bgneal@312: bgneal@312: t.deltaHeight = o.deltaHeight; bgneal@312: o.targetNode = null; bgneal@312: bgneal@312: return { bgneal@312: iframeContainer : ic, bgneal@312: editorContainer : ed.id + '_parent', bgneal@312: sizeContainer : sc, bgneal@312: deltaHeight : o.deltaHeight bgneal@312: }; bgneal@312: }, bgneal@312: bgneal@312: getInfo : function() { bgneal@312: return { bgneal@312: longname : 'Advanced theme', bgneal@312: author : 'Moxiecode Systems AB', bgneal@312: authorurl : 'http://tinymce.moxiecode.com', bgneal@312: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@312: } bgneal@312: }, bgneal@312: bgneal@312: resizeBy : function(dw, dh) { bgneal@312: var e = DOM.get(this.editor.id + '_tbl'); bgneal@312: bgneal@312: this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); bgneal@312: }, bgneal@312: bgneal@312: resizeTo : function(w, h) { bgneal@312: var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); bgneal@312: bgneal@312: // Boundery fix box bgneal@312: w = Math.max(s.theme_advanced_resizing_min_width || 100, w); bgneal@312: h = Math.max(s.theme_advanced_resizing_min_height || 100, h); bgneal@312: w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w); bgneal@312: h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h); bgneal@312: bgneal@312: // Resize iframe and container bgneal@312: DOM.setStyle(e, 'height', ''); bgneal@312: DOM.setStyle(ifr, 'height', h); bgneal@312: bgneal@312: if (s.theme_advanced_resize_horizontal) { bgneal@312: DOM.setStyle(e, 'width', ''); bgneal@312: DOM.setStyle(ifr, 'width', w); bgneal@312: bgneal@312: // Make sure that the size is never smaller than the over all ui bgneal@312: if (w < e.clientWidth) bgneal@312: DOM.setStyle(ifr, 'width', e.clientWidth); bgneal@312: } bgneal@312: }, bgneal@312: bgneal@312: destroy : function() { bgneal@312: var id = this.editor.id; bgneal@312: bgneal@312: Event.clear(id + '_resize'); bgneal@312: Event.clear(id + '_path_row'); bgneal@312: Event.clear(id + '_external_close'); bgneal@312: }, bgneal@312: bgneal@312: // Internal functions bgneal@312: bgneal@312: _simpleLayout : function(s, tb, o, p) { bgneal@312: var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c; bgneal@312: bgneal@312: if (s.readonly) { bgneal@312: n = DOM.add(tb, 'tr'); bgneal@312: n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); bgneal@312: return ic; bgneal@312: } bgneal@312: bgneal@312: // Create toolbar container at top bgneal@312: if (lo == 'top') bgneal@312: t._addToolbars(tb, o); bgneal@312: bgneal@312: // Create external toolbar bgneal@312: if (lo == 'external') { bgneal@312: n = c = DOM.create('div', {style : 'position:relative'}); bgneal@312: n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'}); bgneal@312: DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'}); bgneal@312: n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0}); bgneal@312: etb = DOM.add(n, 'tbody'); bgneal@312: bgneal@312: if (p.firstChild.className == 'mceOldBoxModel') bgneal@312: p.firstChild.appendChild(c); bgneal@312: else bgneal@312: p.insertBefore(c, p.firstChild); bgneal@312: bgneal@312: t._addToolbars(etb, o); bgneal@312: bgneal@312: ed.onMouseUp.add(function() { bgneal@312: var e = DOM.get(ed.id + '_external'); bgneal@312: DOM.show(e); bgneal@312: bgneal@312: DOM.hide(lastExtID); bgneal@312: bgneal@312: var f = Event.add(ed.id + '_external_close', 'click', function() { bgneal@312: DOM.hide(ed.id + '_external'); bgneal@312: Event.remove(ed.id + '_external_close', 'click', f); bgneal@312: }); bgneal@312: bgneal@312: DOM.show(e); bgneal@312: DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1); bgneal@312: bgneal@312: // Fixes IE rendering bug bgneal@312: DOM.hide(e); bgneal@312: DOM.show(e); bgneal@312: e.style.filter = ''; bgneal@312: bgneal@312: lastExtID = ed.id + '_external'; bgneal@312: bgneal@312: e = null; bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: if (sl == 'top') bgneal@312: t._addStatusBar(tb, o); bgneal@312: bgneal@312: // Create iframe container bgneal@312: if (!s.theme_advanced_toolbar_container) { bgneal@312: n = DOM.add(tb, 'tr'); bgneal@312: n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); bgneal@312: } bgneal@312: bgneal@312: // Create toolbar container at bottom bgneal@312: if (lo == 'bottom') bgneal@312: t._addToolbars(tb, o); bgneal@312: bgneal@312: if (sl == 'bottom') bgneal@312: t._addStatusBar(tb, o); bgneal@312: bgneal@312: return ic; bgneal@312: }, bgneal@312: bgneal@312: _rowLayout : function(s, tb, o) { bgneal@312: var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a; bgneal@312: bgneal@312: dc = s.theme_advanced_containers_default_class || ''; bgneal@312: da = s.theme_advanced_containers_default_align || 'center'; bgneal@312: bgneal@312: each(explode(s.theme_advanced_containers || ''), function(c, i) { bgneal@312: var v = s['theme_advanced_container_' + c] || ''; bgneal@312: bgneal@312: switch (v.toLowerCase()) { bgneal@312: case 'mceeditor': bgneal@312: n = DOM.add(tb, 'tr'); bgneal@312: n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); bgneal@312: break; bgneal@312: bgneal@312: case 'mceelementpath': bgneal@312: t._addStatusBar(tb, o); bgneal@312: break; bgneal@312: bgneal@312: default: bgneal@312: a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase(); bgneal@312: a = 'mce' + t._ufirst(a); bgneal@312: bgneal@312: n = DOM.add(DOM.add(tb, 'tr'), 'td', { bgneal@312: 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da bgneal@312: }); bgneal@312: bgneal@312: to = cf.createToolbar("toolbar" + i); bgneal@312: t._addControls(v, to); bgneal@312: DOM.setHTML(n, to.renderHTML()); bgneal@312: o.deltaHeight -= s.theme_advanced_row_height; bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: return ic; bgneal@312: }, bgneal@312: bgneal@312: _addControls : function(v, tb) { bgneal@312: var t = this, s = t.settings, di, cf = t.editor.controlManager; bgneal@312: bgneal@312: if (s.theme_advanced_disable && !t._disabled) { bgneal@312: di = {}; bgneal@312: bgneal@312: each(explode(s.theme_advanced_disable), function(v) { bgneal@312: di[v] = 1; bgneal@312: }); bgneal@312: bgneal@312: t._disabled = di; bgneal@312: } else bgneal@312: di = t._disabled; bgneal@312: bgneal@312: each(explode(v), function(n) { bgneal@312: var c; bgneal@312: bgneal@312: if (di && di[n]) bgneal@312: return; bgneal@312: bgneal@312: // Compatiblity with 2.x bgneal@312: if (n == 'tablecontrols') { bgneal@312: each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) { bgneal@312: n = t.createControl(n, cf); bgneal@312: bgneal@312: if (n) bgneal@312: tb.add(n); bgneal@312: }); bgneal@312: bgneal@312: return; bgneal@312: } bgneal@312: bgneal@312: c = t.createControl(n, cf); bgneal@312: bgneal@312: if (c) bgneal@312: tb.add(c); bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _addToolbars : function(c, o) { bgneal@312: var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a; bgneal@312: bgneal@312: a = s.theme_advanced_toolbar_align.toLowerCase(); bgneal@312: a = 'mce' + t._ufirst(a); bgneal@312: bgneal@312: n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a}); bgneal@312: bgneal@312: if (!ed.getParam('accessibility_focus')) bgneal@312: h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '')); bgneal@312: bgneal@312: h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '')); bgneal@312: bgneal@312: // Create toolbar and add the controls bgneal@312: for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { bgneal@312: tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i}); bgneal@312: bgneal@312: if (s['theme_advanced_buttons' + i + '_add']) bgneal@312: v += ',' + s['theme_advanced_buttons' + i + '_add']; bgneal@312: bgneal@312: if (s['theme_advanced_buttons' + i + '_add_before']) bgneal@312: v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; bgneal@312: bgneal@312: t._addControls(v, tb); bgneal@312: bgneal@312: //n.appendChild(n = tb.render()); bgneal@312: h.push(tb.renderHTML()); bgneal@312: bgneal@312: o.deltaHeight -= s.theme_advanced_row_height; bgneal@312: } bgneal@312: bgneal@312: h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '')); bgneal@312: DOM.setHTML(n, h.join('')); bgneal@312: }, bgneal@312: bgneal@312: _addStatusBar : function(tb, o) { bgneal@312: var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; bgneal@312: bgneal@312: n = DOM.add(tb, 'tr'); bgneal@312: n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); bgneal@312: n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' '); bgneal@312: DOM.add(n, 'a', {href : '#', accesskey : 'x'}); bgneal@312: bgneal@312: if (s.theme_advanced_resizing) { bgneal@312: DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'}); bgneal@312: bgneal@312: if (s.theme_advanced_resizing_use_cookie) { bgneal@312: ed.onPostRender.add(function() { bgneal@312: var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl'); bgneal@312: bgneal@312: if (!o) bgneal@312: return; bgneal@312: bgneal@312: t.resizeTo(o.cw, o.ch); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: ed.onPostRender.add(function() { bgneal@312: Event.add(ed.id + '_resize', 'mousedown', function(e) { bgneal@312: var mouseMoveHandler1, mouseMoveHandler2, bgneal@312: mouseUpHandler1, mouseUpHandler2, bgneal@312: startX, startY, startWidth, startHeight, width, height, ifrElm; bgneal@312: bgneal@312: function resizeOnMove(e) { bgneal@312: width = startWidth + (e.screenX - startX); bgneal@312: height = startHeight + (e.screenY - startY); bgneal@312: bgneal@312: t.resizeTo(width, height); bgneal@312: }; bgneal@312: bgneal@312: function endResize(e) { bgneal@312: // Stop listening bgneal@312: Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1); bgneal@312: Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2); bgneal@312: Event.remove(DOM.doc, 'mouseup', mouseUpHandler1); bgneal@312: Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2); bgneal@312: bgneal@312: // Store away the size bgneal@312: if (s.theme_advanced_resizing_use_cookie) { bgneal@312: Cookie.setHash("TinyMCE_" + ed.id + "_size", { bgneal@312: cw : width, bgneal@312: ch : height bgneal@312: }); bgneal@312: } bgneal@312: }; bgneal@312: bgneal@312: e.preventDefault(); bgneal@312: bgneal@312: // Get the current rect size bgneal@312: startX = e.screenX; bgneal@312: startY = e.screenY; bgneal@312: ifrElm = DOM.get(t.editor.id + '_ifr'); bgneal@312: startWidth = width = ifrElm.clientWidth; bgneal@312: startHeight = height = ifrElm.clientHeight; bgneal@312: bgneal@312: // Register envent handlers bgneal@312: mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove); bgneal@312: mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove); bgneal@312: mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize); bgneal@312: mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize); bgneal@312: }); bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: o.deltaHeight -= 21; bgneal@312: n = tb = null; bgneal@312: }, bgneal@312: bgneal@312: _nodeChanged : function(ed, cm, n, co, ob) { bgneal@312: var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, formatNames, matches; bgneal@312: bgneal@312: tinymce.each(t.stateControls, function(c) { bgneal@312: cm.setActive(c, ed.queryCommandState(t.controls[c][1])); bgneal@312: }); bgneal@312: bgneal@312: function getParent(name) { bgneal@312: var i, parents = ob.parents, func = name; bgneal@312: bgneal@312: if (typeof(name) == 'string') { bgneal@312: func = function(node) { bgneal@312: return node.nodeName == name; bgneal@312: }; bgneal@312: } bgneal@312: bgneal@312: for (i = 0; i < parents.length; i++) { bgneal@312: if (func(parents[i])) bgneal@312: return parents[i]; bgneal@312: } bgneal@312: }; bgneal@312: bgneal@312: cm.setActive('visualaid', ed.hasVisual); bgneal@312: cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing); bgneal@312: cm.setDisabled('redo', !ed.undoManager.hasRedo()); bgneal@312: cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); bgneal@312: bgneal@312: p = getParent('A'); bgneal@312: if (c = cm.get('link')) { bgneal@312: if (!p || !p.name) { bgneal@312: c.setDisabled(!p && co); bgneal@312: c.setActive(!!p); bgneal@312: } bgneal@312: } bgneal@312: bgneal@312: if (c = cm.get('unlink')) { bgneal@312: c.setDisabled(!p && co); bgneal@312: c.setActive(!!p && !p.name); bgneal@312: } bgneal@312: bgneal@312: if (c = cm.get('anchor')) { bgneal@312: c.setActive(!!p && p.name); bgneal@312: } bgneal@312: bgneal@312: p = getParent('IMG'); bgneal@312: if (c = cm.get('image')) bgneal@312: c.setActive(!!p && n.className.indexOf('mceItem') == -1); bgneal@312: bgneal@312: if (c = cm.get('styleselect')) { bgneal@312: t._importClasses(); bgneal@312: bgneal@312: formatNames = []; bgneal@312: each(c.items, function(item) { bgneal@312: formatNames.push(item.value); bgneal@312: }); bgneal@312: bgneal@312: matches = ed.formatter.matchAll(formatNames); bgneal@312: c.select(matches[0]); bgneal@312: } bgneal@312: bgneal@312: if (c = cm.get('formatselect')) { bgneal@312: p = getParent(DOM.isBlock); bgneal@312: bgneal@312: if (p) bgneal@312: c.select(p.nodeName.toLowerCase()); bgneal@312: } bgneal@312: bgneal@312: // Find out current fontSize, fontFamily and fontClass bgneal@312: getParent(function(n) { bgneal@312: if (n.nodeName === 'SPAN') { bgneal@312: if (!cl && n.className) bgneal@312: cl = n.className; bgneal@312: bgneal@312: if (!fz && n.style.fontSize) bgneal@312: fz = n.style.fontSize; bgneal@312: bgneal@312: if (!fn && n.style.fontFamily) bgneal@312: fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); bgneal@312: } bgneal@312: bgneal@312: return false; bgneal@312: }); bgneal@312: bgneal@312: if (c = cm.get('fontselect')) { bgneal@312: c.select(function(v) { bgneal@312: return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn; bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: // Select font size bgneal@312: if (c = cm.get('fontsizeselect')) { bgneal@312: // Use computed style bgneal@312: if (s.theme_advanced_runtime_fontsize && !fz && !cl) bgneal@312: fz = ed.dom.getStyle(n, 'fontSize', true); bgneal@312: bgneal@312: c.select(function(v) { bgneal@312: if (v.fontSize && v.fontSize === fz) bgneal@312: return true; bgneal@312: bgneal@312: if (v['class'] && v['class'] === cl) bgneal@312: return true; bgneal@312: }); bgneal@312: } bgneal@312: bgneal@312: if (s.theme_advanced_path && s.theme_advanced_statusbar_location) { bgneal@312: p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'}); bgneal@312: DOM.setHTML(p, ''); bgneal@312: bgneal@312: getParent(function(n) { bgneal@312: var na = n.nodeName.toLowerCase(), u, pi, ti = ''; bgneal@312: bgneal@312: /*if (n.getAttribute('_mce_bogus')) bgneal@312: return; bgneal@312: */ bgneal@312: // Ignore non element and hidden elements bgneal@312: if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved'))) bgneal@312: return; bgneal@312: bgneal@312: // Fake name bgneal@312: if (v = DOM.getAttrib(n, 'mce_name')) bgneal@312: na = v; bgneal@312: bgneal@312: // Handle prefix bgneal@312: if (tinymce.isIE && n.scopeName !== 'HTML') bgneal@312: na = n.scopeName + ':' + na; bgneal@312: bgneal@312: // Remove internal prefix bgneal@312: na = na.replace(/mce\:/g, ''); bgneal@312: bgneal@312: // Handle node name bgneal@312: switch (na) { bgneal@312: case 'b': bgneal@312: na = 'strong'; bgneal@312: break; bgneal@312: bgneal@312: case 'i': bgneal@312: na = 'em'; bgneal@312: break; bgneal@312: bgneal@312: case 'img': bgneal@312: if (v = DOM.getAttrib(n, 'src')) bgneal@312: ti += 'src: ' + v + ' '; bgneal@312: bgneal@312: break; bgneal@312: bgneal@312: case 'a': bgneal@312: if (v = DOM.getAttrib(n, 'name')) { bgneal@312: ti += 'name: ' + v + ' '; bgneal@312: na += '#' + v; bgneal@312: } bgneal@312: bgneal@312: if (v = DOM.getAttrib(n, 'href')) bgneal@312: ti += 'href: ' + v + ' '; bgneal@312: bgneal@312: break; bgneal@312: bgneal@312: case 'font': bgneal@312: if (v = DOM.getAttrib(n, 'face')) bgneal@312: ti += 'font: ' + v + ' '; bgneal@312: bgneal@312: if (v = DOM.getAttrib(n, 'size')) bgneal@312: ti += 'size: ' + v + ' '; bgneal@312: bgneal@312: if (v = DOM.getAttrib(n, 'color')) bgneal@312: ti += 'color: ' + v + ' '; bgneal@312: bgneal@312: break; bgneal@312: bgneal@312: case 'span': bgneal@312: if (v = DOM.getAttrib(n, 'style')) bgneal@312: ti += 'style: ' + v + ' '; bgneal@312: bgneal@312: break; bgneal@312: } bgneal@312: bgneal@312: if (v = DOM.getAttrib(n, 'id')) bgneal@312: ti += 'id: ' + v + ' '; bgneal@312: bgneal@312: if (v = n.className) { bgneal@312: v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '') bgneal@312: bgneal@312: if (v) { bgneal@312: ti += 'class: ' + v + ' '; bgneal@312: bgneal@312: if (DOM.isBlock(n) || na == 'img' || na == 'span') bgneal@312: na += '.' + v; bgneal@312: } bgneal@312: } bgneal@312: bgneal@312: na = na.replace(/(html:)/g, ''); bgneal@312: na = {name : na, node : n, title : ti}; bgneal@312: t.onResolveName.dispatch(t, na); bgneal@312: ti = na.title; bgneal@312: na = na.name; bgneal@312: bgneal@312: //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; bgneal@312: pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na); bgneal@312: bgneal@312: if (p.hasChildNodes()) { bgneal@312: p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild); bgneal@312: p.insertBefore(pi, p.firstChild); bgneal@312: } else bgneal@312: p.appendChild(pi); bgneal@312: }, ed.getBody()); bgneal@312: } bgneal@312: }, bgneal@312: bgneal@312: // Commands gets called by execCommand bgneal@312: bgneal@312: _sel : function(v) { bgneal@312: this.editor.execCommand('mceSelectNodeDepth', false, v); bgneal@312: }, bgneal@312: bgneal@312: _mceInsertAnchor : function(ui, v) { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/anchor.htm', bgneal@312: width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)), bgneal@312: height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)), bgneal@312: inline : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceCharMap : function() { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/charmap.htm', bgneal@312: width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)), bgneal@312: height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)), bgneal@312: inline : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceHelp : function() { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/about.htm', bgneal@312: width : 480, bgneal@312: height : 380, bgneal@312: inline : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceColorPicker : function(u, v) { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: v = v || {}; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/color_picker.htm', bgneal@312: width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)), bgneal@312: height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)), bgneal@312: close_previous : false, bgneal@312: inline : true bgneal@312: }, { bgneal@312: input_color : v.color, bgneal@312: func : v.func, bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceCodeEditor : function(ui, val) { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/source_editor.htm', bgneal@312: width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)), bgneal@312: height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)), bgneal@312: inline : true, bgneal@312: resizable : true, bgneal@312: maximizable : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceImage : function(ui, val) { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: // Internal image object like a flash placeholder bgneal@312: if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1) bgneal@312: return; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/image.htm', bgneal@312: width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)), bgneal@312: height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)), bgneal@312: inline : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceLink : function(ui, val) { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.open({ bgneal@312: url : this.url + '/link.htm', bgneal@312: width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)), bgneal@312: height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)), bgneal@312: inline : true bgneal@312: }, { bgneal@312: theme_url : this.url bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceNewDocument : function() { bgneal@312: var ed = this.editor; bgneal@312: bgneal@312: ed.windowManager.confirm('advanced.newdocument', function(s) { bgneal@312: if (s) bgneal@312: ed.execCommand('mceSetContent', false, ''); bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceForeColor : function() { bgneal@312: var t = this; bgneal@312: bgneal@312: this._mceColorPicker(0, { bgneal@312: color: t.fgColor, bgneal@312: func : function(co) { bgneal@312: t.fgColor = co; bgneal@312: t.editor.execCommand('ForeColor', false, co); bgneal@312: } bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _mceBackColor : function() { bgneal@312: var t = this; bgneal@312: bgneal@312: this._mceColorPicker(0, { bgneal@312: color: t.bgColor, bgneal@312: func : function(co) { bgneal@312: t.bgColor = co; bgneal@312: t.editor.execCommand('HiliteColor', false, co); bgneal@312: } bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: _ufirst : function(s) { bgneal@312: return s.substring(0, 1).toUpperCase() + s.substring(1); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme); bgneal@312: }(tinymce));