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