X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fthemes%2Fadvanced%2Feditor_template_src.js;h=bee26e161025b55d7efa965e4dcf449c300f26f9;hb=b05f4eef4014db3885787ef15107cba93c932ac9;hp=0a15b8018675b08b05129805f3477886cd9567e8;hpb=a66abf6cce7aa581b58007438671d7196a9d9f99;p=citadel.git diff --git a/webcit/tiny_mce/themes/advanced/editor_template_src.js b/webcit/tiny_mce/themes/advanced/editor_template_src.js index 0a15b8018..bee26e161 100644 --- a/webcit/tiny_mce/themes/advanced/editor_template_src.js +++ b/webcit/tiny_mce/themes/advanced/editor_template_src.js @@ -1,1192 +1,1358 @@ -/* Import theme specific language pack */ -tinyMCE.importThemeLanguagePack('advanced'); - -// Variable declarations -var TinyMCE_advanced_autoImportCSSClasses = true; -var TinyMCE_advanced_resizer = new Object(); -var TinyMCE_advanced_buttons = [ - // Control id, button img, button title, command, user_interface, value - ['bold', '{$lang_bold_img}', '{$lang_bold_desc}', 'Bold'], - ['italic', '{$lang_italic_img}', '{$lang_italic_desc}', 'Italic'], - ['underline', '{$lang_underline_img}', '{$lang_underline_desc}', 'Underline'], - ['strikethrough', 'strikethrough.gif', '{$lang_striketrough_desc}', 'Strikethrough'], - ['justifyleft', 'left.gif', '{$lang_justifyleft_desc}', 'JustifyLeft'], - ['justifycenter', 'center.gif', '{$lang_justifycenter_desc}', 'JustifyCenter'], - ['justifyright', 'right.gif', '{$lang_justifyright_desc}', 'JustifyRight'], - ['justifyfull', 'full.gif', '{$lang_justifyfull_desc}', 'JustifyFull'], - ['bullist', 'bullist.gif', '{$lang_bullist_desc}', 'InsertUnorderedList'], - ['numlist', 'numlist.gif', '{$lang_numlist_desc}', 'InsertOrderedList'], - ['outdent', 'outdent.gif', '{$lang_outdent_desc}', 'Outdent'], - ['indent', 'indent.gif', '{$lang_indent_desc}', 'Indent'], - ['cut', 'cut.gif', '{$lang_cut_desc}', 'Cut'], - ['copy', 'copy.gif', '{$lang_copy_desc}', 'Copy'], - ['paste', 'paste.gif', '{$lang_paste_desc}', 'Paste'], - ['undo', 'undo.gif', '{$lang_undo_desc}', 'Undo'], - ['redo', 'redo.gif', '{$lang_redo_desc}', 'Redo'], - ['link', 'link.gif', '{$lang_link_desc}', 'mceLink', true], - ['unlink', 'unlink.gif', '{$lang_unlink_desc}', 'unlink'], - ['image', 'image.gif', '{$lang_image_desc}', 'mceImage', true], - ['cleanup', 'cleanup.gif', '{$lang_cleanup_desc}', 'mceCleanup'], - ['help', 'help.gif', '{$lang_help_desc}', 'mceHelp'], - ['code', 'code.gif', '{$lang_theme_code_desc}', 'mceCodeEditor'], - ['hr', 'hr.gif', '{$lang_theme_hr_desc}', 'inserthorizontalrule'], - ['removeformat', 'removeformat.gif', '{$lang_theme_removeformat_desc}', 'removeformat'], - ['sub', 'sub.gif', '{$lang_theme_sub_desc}', 'subscript'], - ['sup', 'sup.gif', '{$lang_theme_sup_desc}', 'superscript'], - ['forecolor', 'forecolor.gif', '{$lang_theme_forecolor_desc}', 'mceForeColor', true], - ['backcolor', 'backcolor.gif', '{$lang_theme_backcolor_desc}', 'mceBackColor', true], - ['charmap', 'charmap.gif', '{$lang_theme_charmap_desc}', 'mceCharMap'], - ['visualaid', 'visualaid.gif', '{$lang_theme_visualaid_desc}', 'mceToggleVisualAid'], - ['anchor', 'anchor.gif', '{$lang_theme_anchor_desc}', 'mceInsertAnchor'], - ['newdocument', 'newdocument.gif', '{$lang_newdocument_desc}', 'mceNewDocument'] -]; - /** - * Returns HTML code for the specificed control. + * editor_template_src.js + * + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing */ -function TinyMCE_advanced_getControlHTML(button_name) -{ - var buttonTileMap = new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif', - 'charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif', - 'cut.gif','forecolor.gif','full.gif','help.gif','hr.gif', - 'image.gif','indent.gif','left.gif','link.gif','numlist.gif', - 'outdent.gif','paste.gif','redo.gif','removeformat.gif', - 'right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif', - 'unlink.gif','visualaid.gif'); - - // Lookup button in button list - for (var i=0; i'; - } - } - } - // Old style - return ''; - } - } - - // Custom controlls other than buttons - switch (button_name) - { - case "formatselect": - var html = ''; - //formatselect - return html; - - case "styleselect": - //styleselect - return ''; - - case "fontselect": - var fontHTML = ''; - return fontHTML; + DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css"); - case "fontsizeselect": - //fontsizeselect - return ''; + if (s.skin_variant) + DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); + }, - case "|": - case "separator": - return ''; + _isHighContrast : function() { + var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'}); - case "spacer": - return ''; + actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, ''); + DOM.remove(div); - case "rowseparator": - return '
'; - } + return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56'; + }, - return ""; -} + createControl : function(n, cf) { + var cd, c; -/** - * Theme specific exec command handeling. - */ -function TinyMCE_advanced_execCommand(editor_id, element, command, user_interface, value) -{ - switch (command) - { - case "mceForeColor": - var template = new Array(); - var elm = tinyMCE.selectedInstance.getFocusElement(); - var inputColor = tinyMCE.getAttrib(elm, "color"); + if (c = cf.createControl(n)) + return c; - if (inputColor == '') - inputColor = elm.style.color; + switch (n) { + case "styleselect": + return this._createStyleSelect(); - if (!inputColor) - inputColor = "#000000"; + case "formatselect": + return this._createBlockFormats(); - template['file'] = 'color_picker.htm'; - template['width'] = 220; - template['height'] = 190; + case "fontselect": + return this._createFontSelect(); - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor}); - return true; + case "fontsizeselect": + return this._createFontSizeSelect(); - case "mceBackColor": - var template = new Array(); - var elm = tinyMCE.selectedInstance.getFocusElement(); - var inputColor = elm.style.backgroundColor; + case "forecolor": + return this._createForeColorMenu(); - if (!inputColor) - inputColor = "#000000"; + case "backcolor": + return this._createBackColorMenu(); + } - template['file'] = 'color_picker.htm'; - template['width'] = 220; - template['height'] = 190; + if ((cd = this.controls[n])) + return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]}); + }, - template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); + execCommand : function(cmd, ui, val) { + var f = this['_' + cmd]; - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor}); - //mceBackColor - return true; + if (f) { + f.call(this, ui, val); + return true; + } - case "mceColorPicker": - if (user_interface) { - var template = new Array(); - var inputColor = value['document'].getElementById(value['element_id']).value; + return false; + }, - template['file'] = 'color_picker.htm'; - template['width'] = 220; - template['height'] = 190; - template['close_previous'] = "no"; + _importClasses : function(e) { + var ed = this.editor, ctrl = ed.controlManager.get('styleselect'); - template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); + if (ctrl.getLength() == 0) { + each(ed.dom.getClasses(), function(o, idx) { + var name = 'style_' + idx; - if (typeof(value['store_selection']) == "undefined") - value['store_selection'] = true; + ed.formatter.register(name, { + inline : 'span', + attributes : {'class' : o['class']}, + selector : '*' + }); - tinyMCE.lastColorPickerValue = value; - tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor}); - } else { - var savedVal = tinyMCE.lastColorPickerValue; - var elm = savedVal['document'].getElementById(savedVal['element_id']); - elm.value = value; - eval('elm.onchange();'); + ctrl.add(o['class'], name); + }); } - return true; + }, - case "mceCodeEditor": - var template = new Array(); + _createStyleSelect : function(n) { + var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl; - template['file'] = 'source_editor.htm'; - template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 500)); - template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 400)); + // Setup style select box + ctrl = ctrlMan.createListBox('styleselect', { + title : 'advanced.style_select', + onselect : function(name) { + var matches, formatNames = []; - tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); - //mceCodeEditor - return true; + each(ctrl.items, function(item) { + formatNames.push(item.value); + }); - case "mceCharMap": - var template = new Array(); + ed.focus(); + ed.undoManager.add(); - template['file'] = 'charmap.htm'; - template['width'] = 550; - template['height'] = 250; - - template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); + // Toggle off the current format + matches = ed.formatter.matchAll(formatNames); + if (!name || matches[0] == name) { + if (matches[0]) + ed.formatter.remove(matches[0]); + } else + ed.formatter.apply(name); - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - //mceCharMap - return true; + ed.undoManager.add(); + ed.nodeChanged(); - case "mceInsertAnchor": - var template = new Array(); + return false; // No auto select + } + }); + + // Handle specified format + ed.onInit.add(function() { + var counter = 0, formats = ed.getParam('style_formats'); + + if (formats) { + each(formats, function(fmt) { + var name, keys = 0; + + each(fmt, function() {keys++;}); + + if (keys > 1) { + name = fmt.name = fmt.name || 'style_' + (counter++); + ed.formatter.register(name, fmt); + ctrl.add(fmt.title, name); + } else + ctrl.add(fmt.title); + }); + } else { + each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) { + var name; + + if (val) { + name = 'style_' + (counter++); + + ed.formatter.register(name, { + inline : 'span', + classes : val, + selector : '*' + }); + + ctrl.add(t.editor.translate(key), name); + } + }); + } + }); + + // Auto import classes if the ctrl box is empty + if (ctrl.getLength() == 0) { + ctrl.onPostRender.add(function(ed, n) { + if (!ctrl.NativeListBox) { + Event.add(n.id + '_text', 'focus', t._importClasses, t); + Event.add(n.id + '_text', 'mousedown', t._importClasses, t); + Event.add(n.id + '_open', 'focus', t._importClasses, t); + Event.add(n.id + '_open', 'mousedown', t._importClasses, t); + } else + Event.add(n.id, 'focus', t._importClasses, t); + }); + } - template['file'] = 'anchor.htm'; - template['width'] = 320; - template['height'] = 90; + return ctrl; + }, - template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); + _createFontSelect : function() { + var c, t = this, ed = t.editor; - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; + c = ed.controlManager.createListBox('fontselect', { + title : 'advanced.fontdefault', + onselect : function(v) { + var cur = c.items[c.selectedIndex]; - case "mceNewDocument": - if (confirm(tinyMCE.getLang('lang_newdocument'))) - tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ''); + if (!v && cur) { + ed.execCommand('FontName', false, cur.value); + return; + } - return true; - } + ed.execCommand('FontName', false, v); - // Default behavior - return false; -} + // Fake selection, execCommand will fire a nodeChange and update the selection + c.select(function(sv) { + return v == sv; + }); -/** - * Editor instance template function. - */ -function TinyMCE_advanced_getEditorTemplate(settings, editorId) -{ - function removeFromArray(in_array, remove_array) - { - var outArray = new Array(); - - for (var i=0; i 

'; - var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); + if (cur['class']) { + ed.formatter.toggle('fontsize_class', {value : cur['class']}); + ed.undoManager.add(); + ed.nodeChanged(); + } else { + ed.execCommand('FontSize', false, cur.fontSize); + } - // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY! - var styleSelectHTML = ''; - if (settings['theme_advanced_styles']) - { - var stylesAr = settings['theme_advanced_styles'].split(';'); - - for (var i=0; i' + key + ''; - } + return false; // No auto select + }}); - TinyMCE_advanced_autoImportCSSClasses = false; - } - - switch(layoutManager) - { - case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)... - var toolbarHTML = ""; - var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom"); - var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center"); - var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity - var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation); - var defVals = { - theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect", - theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code", - theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap" - }; + if (c) { + each(t.settings.theme_advanced_font_sizes, function(v, k) { + var fz = v.fontSize; - // Add accessibility control - toolbarHTML += ''; + if (fz >= 1 && fz <= 7) + fz = t.sizes[parseInt(fz) - 1] + 'pt'; - // Render rows - for (var i=1; i<100; i++) { - var def = defVals["theme_advanced_buttons" + i]; + c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))}); + }); + } - buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ','); - if (buttons.length == 0) - break; + return c; + }, + + _createBlockFormats : function() { + var c, fmts = { + p : 'advanced.paragraph', + address : 'advanced.address', + pre : 'advanced.pre', + h1 : 'advanced.h1', + h2 : 'advanced.h2', + h3 : 'advanced.h3', + h4 : 'advanced.h4', + h5 : 'advanced.h5', + h6 : 'advanced.h6', + div : 'advanced.div', + blockquote : 'advanced.blockquote', + code : 'advanced.code', + dt : 'advanced.dt', + dd : 'advanced.dd', + samp : 'advanced.samp' + }, t = this; + + c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', onselect : function(v) { + t.editor.execCommand('FormatBlock', false, v); + return false; + }}); + + if (c) { + each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) { + c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v}); + }); + } - buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); - buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ',')); - buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons); + return c; + }, + + _createForeColorMenu : function() { + var c, t = this, s = t.settings, o = {}, v; + + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; + } - for (var b=0; b 0) { - toolbarHTML += "
"; - deltaHeight -= 23; - } - } + if (s.theme_advanced_default_foreground_color) + o.default_color = s.theme_advanced_default_foreground_color; - // Add accessibility control - toolbarHTML += ''; + o.title = 'advanced.forecolor_desc'; + o.cmd = 'ForeColor'; + o.scope = this; - // Setup template html - template['html'] = ''; + c = t.editor.controlManager.createColorSplitButton('forecolor', o); - if (toolbarLocation == "top") - { - template['html'] += ''; - } + return c; + }, - if (statusbarLocation == "top") - { - template['html'] += ''; - deltaHeight -= 23; + _createBackColorMenu : function() { + var c, t = this, s = t.settings, o = {}, v; + + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; } - template['html'] += ''; + if (v = s.theme_advanced_background_colors) + o.colors = v; + + if (s.theme_advanced_default_background_color) + o.default_color = s.theme_advanced_default_background_color; + + o.title = 'advanced.backcolor_desc'; + o.cmd = 'HiliteColor'; + o.scope = this; - if (toolbarLocation == "bottom") - { - template['html'] += ''; + c = t.editor.controlManager.createColorSplitButton('backcolor', o); + + return c; + }, + + renderUI : function(o) { + var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; + + if (ed.settings) { + ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut'); } - // External toolbar changes - if (toolbarLocation == "external") - { - var bod = document.body; - var elm = document.createElement ("div"); - - toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCE.settings); - toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCELang); - toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML); - toolbarHTML = tinyMCE.replaceVar(toolbarHTML, "editor_id", editorId); - toolbarHTML = tinyMCE.applyTemplate(toolbarHTML); - - elm.className = "mceToolbarExternal"; - elm.id = editorId+"_toolbar"; - elm.innerHTML = '
' + toolbarHTML + '
' + statusbarHTML + '
' + toolbarHTML + '
'+toolbarHTML+'
'; - bod.appendChild (elm); - // bod.style.marginTop = elm.offsetHeight + "px"; - - deltaHeight = 0; - tinyMCE.getInstanceById(editorId).toolbarElement = elm; - - //template['html'] = '
'+toolbarHTML+'
' + template["html"]; + // TODO: ACC Should have an aria-describedby attribute which is user-configurable to describe what this field is actually for. + // Maybe actually inherit it from the original textara? + n = p = DOM.create('span', {role : 'application', 'aria-labelledby' : ed.id + '_voice', id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')}); + DOM.add(n, 'span', {'class': 'mceVoiceLabel', 'style': 'display:none;', id: ed.id + '_voice'}, s.aria_label); + + if (!DOM.boxModel) + n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); + + n = sc = DOM.add(n, 'table', {role : "presentation", id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); + n = tb = DOM.add(n, 'tbody'); + + switch ((s.theme_advanced_layout_manager || '').toLowerCase()) { + case "rowlayout": + ic = t._rowLayout(s, tb, o); + break; + + case "customlayout": + ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p); + break; + + default: + ic = t._simpleLayout(s, tb, o, p); } + + n = o.targetNode; + + // Add classes to first and last TRs + nl = sc.rows; + DOM.addClass(nl[0], 'mceFirst'); + DOM.addClass(nl[nl.length - 1], 'mceLast'); + + // Add classes to first and last TDs + each(DOM.select('tr', tb), function(n) { + DOM.addClass(n.firstChild, 'mceFirst'); + DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast'); + }); + + if (DOM.get(s.theme_advanced_toolbar_container)) + DOM.get(s.theme_advanced_toolbar_container).appendChild(p); else - { - tinyMCE.getInstanceById(editorId).toolbarElement = null; - } + DOM.insertAfter(p, n); - if (statusbarLocation == "bottom") - { - template['html'] += '' + statusbarHTML + ''; - deltaHeight -= 23; - } + Event.add(ed.id + '_path_row', 'click', function(e) { + e = e.target; + + if (e.nodeName == 'A') { + t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1')); - template['html'] += ''; - //"SimpleLayout" - break; - - case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom. - template['html'] = ''; - - var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ","); - var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container"); - var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center"); - - //Render Containers: - for (var i = 0; i < containers.length; i++) - { - if (containers[i] == "mceEditor") //Exceptions for mceEditor and ... - { - template['html'] += ''; + return Event.cancel(e); } - else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath: - { - var pathClass = "mceStatusbar"; + }); +/* + if (DOM.get(ed.id + '_path_row')) { + Event.add(ed.id + '_tbl', 'mouseover', function(e) { + var re; + + e = e.target; - if (i == containers.length-1) - { - pathClass = "mceStatusbarBottom"; - } - else if (i == 0) - { - pathClass = "mceStatusbar"; - } - else - { - deltaHeight-=2; + if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) { + re = DOM.get(ed.id + '_path_row'); + t.lastPath = re.innerHTML; + DOM.setHTML(re, e.parentNode.title); } + }); - template['html'] += ''; - deltaHeight -= 22; - } - else //Render normal Container: - { - var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ','); - var curContainerHTML = ""; - var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign); - var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS); - - for (var j=0; j'), 'focus', function() {tinyMCE.get(ed.id).focus();}); + + if (s.theme_advanced_toolbar_location == 'external') + o.deltaHeight = 0; - if (curContainer.length > 0) - { - curContainerHTML += "
"; - deltaHeight -= 23; + t.deltaHeight = o.deltaHeight; + o.targetNode = null; + + ed.onKeyDown.add(function(ed, evt) { + var DOM_VK_F10 = 121, DOM_VK_F11 = 122; + + if (evt.altKey) { + if (evt.keyCode === DOM_VK_F10) { + window.focus(); + t.toolbarGroup.focus(); + return Event.cancel(evt); + } else if (evt.keyCode === DOM_VK_F11) { + DOM.get(ed.id + '_path_row').focus(); + return Event.cancel(evt); } + } + }); + + // alt+0 is the UK recommended shortcut for accessing the list of access controls. + ed.addShortcut('alt+0', '', 'mceShortcuts', t); + + return { + iframeContainer : ic, + editorContainer : ed.id + '_parent', + sizeContainer : sc, + deltaHeight : o.deltaHeight + }; + }, + + getInfo : function() { + return { + longname : 'Advanced theme', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + version : tinymce.majorVersion + "." + tinymce.minorVersion + } + }, + + resizeBy : function(dw, dh) { + var e = DOM.get(this.editor.id + '_ifr'); + + this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); + }, - template['html'] += '
'; + resizeTo : function(w, h, store) { + var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); + + // Boundery fix box + w = Math.max(s.theme_advanced_resizing_min_width || 100, w); + h = Math.max(s.theme_advanced_resizing_min_height || 100, h); + w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w); + h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h); + + // Resize iframe and container + DOM.setStyle(e, 'height', ''); + DOM.setStyle(ifr, 'height', h); + + if (s.theme_advanced_resize_horizontal) { + DOM.setStyle(e, 'width', ''); + DOM.setStyle(ifr, 'width', w); + + // Make sure that the size is never smaller than the over all ui + if (w < e.clientWidth) { + w = e.clientWidth; + DOM.setStyle(ifr, 'width', e.clientWidth); } } - template['html'] += '
\ - \ -
' + statusbarHTML + '
' + curContainerHTML + '
'; - //RowLayout - break; + // Store away the size + if (store && s.theme_advanced_resizing_use_cookie) { + Cookie.setHash("TinyMCE_" + ed.id + "_size", { + cw : w, + ch : h + }); + } + }, - case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java... - // Not implemented yet... - break; + destroy : function() { + var id = this.editor.id; - case "CustomLayout" : //User defined layout callback... - var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); - - if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") - { - template = eval(customLayout + "(template);"); + Event.clear(id + '_resize'); + Event.clear(id + '_path_row'); + Event.clear(id + '_external_close'); + }, + + // Internal functions + + _simpleLayout : function(s, tb, o, p) { + var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c; + + if (s.readonly) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + return ic; } - break; - - default: - alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!'); - //CustomLayout - break; - } - template['html'] += '
'; - template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); - template['delta_width'] = 0; - template['delta_height'] = deltaHeight; + // Create toolbar container at top + if (lo == 'top') + t._addToolbars(tb, o); - return template; -} + // Create external toolbar + if (lo == 'external') { + n = c = DOM.create('div', {style : 'position:relative'}); + n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'}); + DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'}); + n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0}); + etb = DOM.add(n, 'tbody'); -/** - * Starts/stops the editor resizing. - */ -function TinyMCE_advanced_setResizing(e, editor_id, state) { - e = typeof(e) == "undefined" ? window.event : e; - - var resizer = TinyMCE_advanced_resizer; - var editorContainer = document.getElementById(editor_id + '_parent'); - var editorArea = document.getElementById(editor_id + '_parent').firstChild; - var resizeBox = document.getElementById(editor_id + '_resize_box'); - var inst = tinyMCE.getInstanceById(editor_id); - - if (state) { - // Place box over editor area - var width = editorArea.clientWidth; - var height = editorArea.clientHeight; - - resizeBox.style.width = width + "px"; - resizeBox.style.height = height + "px"; - - resizer.iframeWidth = inst.iframeElement.clientWidth; - resizer.iframeHeight = inst.iframeElement.clientHeight; - - // Hide editor and show resize box - editorArea.style.display = "none"; - resizeBox.style.display = "block"; - - // Add event handlers, only once - if (!resizer.eventHandlers) { - if (tinyMCE.isMSIE) - tinyMCE.addEvent(document, "mousemove", TinyMCE_advanced_resizeEventHandler); - else - tinyMCE.addEvent(window, "mousemove", TinyMCE_advanced_resizeEventHandler); + if (p.firstChild.className == 'mceOldBoxModel') + p.firstChild.appendChild(c); + else + p.insertBefore(c, p.firstChild); - tinyMCE.addEvent(document, "mouseup", TinyMCE_advanced_resizeEventHandler); + t._addToolbars(etb, o); - resizer.eventHandlers = true; - } + ed.onMouseUp.add(function() { + var e = DOM.get(ed.id + '_external'); + DOM.show(e); - resizer.resizing = true; - resizer.downX = e.screenX; - resizer.downY = e.screenY; - resizer.width = parseInt(resizeBox.style.width); - resizer.height = parseInt(resizeBox.style.height); - resizer.editorId = editor_id; - resizer.resizeBox = resizeBox; - resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true); - } else { - resizer.resizing = false; - resizeBox.style.display = "none"; - editorArea.style.display = tinyMCE.isMSIE ? "block" : "table"; - tinyMCE.execCommand('mceResetDesignMode'); - } -} - -function TinyMCE_advanced_initInstance(inst) { - if (tinyMCE.getParam("theme_advanced_resizing", false)) { - var w = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_width"); - var h = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_height"); - - TinyMCE_advanced_resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true)); - } -} - -function TinyMCE_advanced_setCookie(name, value, expires, path, domain, secure) { - var curCookie = name + "=" + escape(value) + - ((expires) ? "; expires=" + expires.toGMTString() : "") + - ((path) ? "; path=" + escape(path) : "") + - ((domain) ? "; domain=" + domain : "") + - ((secure) ? "; secure" : ""); - - document.cookie = curCookie; -} - -function TinyMCE_advanced_getCookie(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); - - if (begin == -1) { - begin = dc.indexOf(prefix); - - if (begin != 0) - return null; - } else - begin += 2; - - var end = document.cookie.indexOf(";", begin); - - if (end == -1) - end = dc.length; - - return unescape(dc.substring(begin + prefix.length, end)); -} - -function TinyMCE_advanced_resizeTo(inst, w, h, set_w) { - var editorContainer = document.getElementById(inst.editorId + '_parent'); - var tableElm = editorContainer.firstChild; - var iframe = inst.iframeElement; - - if (w == null || w == "null") { - set_w = false; - w = 0; - } - - if (h == null || h == "null") - return; - - w = parseInt(w); - h = parseInt(h); - - if (tinyMCE.isGecko) { - w += 2; - h += 2; - } - - var dx = w - tableElm.clientWidth; - var dy = h - tableElm.clientHeight; - - if (set_w) - tableElm.style.width = w + "px"; - - tableElm.style.height = h + "px"; - - iw = iframe.clientWidth + dx; - ih = iframe.clientHeight + dy; - - if (tinyMCE.isGecko) { - iw -= 2; - ih -= 2; - } - - if (set_w) - iframe.style.width = iw + "px"; - - iframe.style.height = ih + "px"; - - // Is it to small, make it bigger again - if (set_w) { - var tableBodyElm = tableElm.firstChild; - var minIframeWidth = tableBodyElm.scrollWidth; - if (inst.iframeElement.clientWidth < minIframeWidth) { - dx = minIframeWidth - inst.iframeElement.clientWidth; - - inst.iframeElement.style.width = (iw + dx) + "px"; - } - } -} + DOM.hide(lastExtID); -/** - * Handles resizing events. - */ -function TinyMCE_advanced_resizeEventHandler(e) { - var resizer = TinyMCE_advanced_resizer; + var f = Event.add(ed.id + '_external_close', 'click', function() { + DOM.hide(ed.id + '_external'); + Event.remove(ed.id + '_external_close', 'click', f); + }); - // Do nothing - if (!resizer.resizing) - return; + DOM.show(e); + DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1); - e = typeof(e) == "undefined" ? window.event : e; + // Fixes IE rendering bug + DOM.hide(e); + DOM.show(e); + e.style.filter = ''; - var dx = e.screenX - resizer.downX; - var dy = e.screenY - resizer.downY; - var resizeBox = resizer.resizeBox; - var editorId = resizer.editorId; + lastExtID = ed.id + '_external'; - switch (e.type) { - case "mousemove": - if (resizer.horizontal) - resizeBox.style.width = (resizer.width + dx) + "px"; + e = null; + }); + } - resizeBox.style.height = (resizer.height + dy) + "px"; - break; + if (sl == 'top') + t._addStatusBar(tb, o); - case "mouseup": - TinyMCE_advanced_setResizing(e, editorId, false); - TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal); + // Create iframe container + if (!s.theme_advanced_toolbar_container) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + } - // Expire in a month - var expires = new Date(); - expires.setTime(expires.getTime() + 3600000 * 24 * 30); + // Create toolbar container at bottom + if (lo == 'bottom') + t._addToolbars(tb, o); - // Set the cookies - TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires); - TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires); - break; - } -} + if (sl == 'bottom') + t._addStatusBar(tb, o); -/** - * Insert link template function. - */ -function TinyMCE_advanced_getInsertLinkTemplate() -{ - var template = new Array(); + return ic; + }, - template['file'] = 'link.htm'; - template['width'] = 330; - template['height'] = 170; + _rowLayout : function(s, tb, o) { + var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a; - // Language specific width and height addons - template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); + dc = s.theme_advanced_containers_default_class || ''; + da = s.theme_advanced_containers_default_align || 'center'; - return template; -}; + each(explode(s.theme_advanced_containers || ''), function(c, i) { + var v = s['theme_advanced_container_' + c] || ''; -/** - * Insert image template function. - */ -function TinyMCE_advanced_getInsertImageTemplate() -{ - var template = new Array(); + switch (c.toLowerCase()) { + case 'mceeditor': + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + break; - template['file'] = 'image.htm?src={$src}'; - template['width'] = 340; - template['height'] = 245; + case 'mceelementpath': + t._addStatusBar(tb, o); + break; - // Language specific width and height addons - template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); + default: + a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase(); + a = 'mce' + t._ufirst(a); - return template; -}; + n = DOM.add(DOM.add(tb, 'tr'), 'td', { + 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da + }); -/** - * Node change handler. - */ -function TinyMCE_advanced_handleNodeChange (editor_id, node, undo_index, - undo_levels, visual_aid, any_selection) -{ - function selectByValue(select_elm, value) - { - if (select_elm) - { - for (var i=0; i')); + DOM.setHTML(n, h.join('')); + }, + + _addStatusBar : function(tb, o) { + var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; + + n = DOM.add(tb, 'tr'); + n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); + n = DOM.add(n, 'div', {id : ed.id + '_path_row', 'role': 'group', 'aria-labelledby': ed.id + '_path_voice'}); + if (s.theme_advanced_path) { + DOM.add(n, 'span', {id: ed.id + '_path_voice'}, ed.translate('advanced.path')); + DOM.add(n, 'span', {}, ': '); + } else { + DOM.add(n, 'span', {}, ' '); } + + + if (s.theme_advanced_resizing) { + DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize', tabIndex:"-1"}); - // Only append element nodes to path - if (parentNode.nodeType == 1) - { - path[path.length] = parentNode; + if (s.theme_advanced_resizing_use_cookie) { + ed.onPostRender.add(function() { + var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl'); + + if (!o) + return; + + t.resizeTo(o.cw, o.ch); + }); + } + + ed.onPostRender.add(function() { + Event.add(ed.id + '_resize', 'click', function(e) { + e.preventDefault(); + }); + + Event.add(ed.id + '_resize', 'mousedown', function(e) { + var mouseMoveHandler1, mouseMoveHandler2, + mouseUpHandler1, mouseUpHandler2, + startX, startY, startWidth, startHeight, width, height, ifrElm; + + function resizeOnMove(e) { + e.preventDefault(); + + width = startWidth + (e.screenX - startX); + height = startHeight + (e.screenY - startY); + + t.resizeTo(width, height); + }; + + function endResize(e) { + // Stop listening + Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1); + Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2); + Event.remove(DOM.doc, 'mouseup', mouseUpHandler1); + Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2); + + width = startWidth + (e.screenX - startX); + height = startHeight + (e.screenY - startY); + t.resizeTo(width, height, true); + }; + + e.preventDefault(); + + // Get the current rect size + startX = e.screenX; + startY = e.screenY; + ifrElm = DOM.get(t.editor.id + '_ifr'); + startWidth = width = ifrElm.clientWidth; + startHeight = height = ifrElm.clientHeight; + + // Register envent handlers + mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove); + mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove); + mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize); + mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize); + }); + }); } - parentNode = parentNode.parentNode; - } + o.deltaHeight -= 21; + n = tb = null; + }, + + _updateUndoStatus : function(ed) { + var cm = ed.controlManager, um = ed.undoManager; + + cm.setDisabled('undo', !um.hasUndo() && !um.typing); + cm.setDisabled('redo', !um.hasRedo()); + }, + + _nodeChanged : function(ed, cm, n, co, ob) { + var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, fc, bc, formatNames, matches; + + tinymce.each(t.stateControls, function(c) { + cm.setActive(c, ed.queryCommandState(t.controls[c][1])); + }); + + function getParent(name) { + var i, parents = ob.parents, func = name; + + if (typeof(name) == 'string') { + func = function(node) { + return node.nodeName == name; + }; + } + + for (i = 0; i < parents.length; i++) { + if (func(parents[i])) + return parents[i]; + } + }; - // Setup HTML - var html = ""; - for (var i=path.length-1; i>=0; i--) - { - var nodeName = path[i].nodeName.toLowerCase(); - var nodeData = ""; + cm.setActive('visualaid', ed.hasVisual); + t._updateUndoStatus(ed); + cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); - if (nodeName == "b") - { - nodeName = "strong"; + p = getParent('A'); + if (c = cm.get('link')) { + if (!p || !p.name) { + c.setDisabled(!p && co); + c.setActive(!!p); + } } - if (nodeName == "i") - { - nodeName = "em"; + if (c = cm.get('unlink')) { + c.setDisabled(!p && co); + c.setActive(!!p && !p.name); } - if (getAttrib(path[i], 'id') != "") - { - nodeData += "id: " + path[i].getAttribute('id') + " "; + if (c = cm.get('anchor')) { + c.setActive(!co && !!p && p.name); } - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) - nodeData += "class: " + className + " "; + p = getParent('IMG'); + if (c = cm.get('image')) + c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1); - if (getAttrib(path[i], 'src') != "") - { - nodeData += "src: " + path[i].getAttribute('src') + " "; - } + if (c = cm.get('styleselect')) { + t._importClasses(); - if (getAttrib(path[i], 'href') != "") - { - nodeData += "href: " + path[i].getAttribute('href') + " "; - } + formatNames = []; + each(c.items, function(item) { + formatNames.push(item.value); + }); - if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) - { - nodeName = "flash"; - nodeData = ""; + matches = ed.formatter.matchAll(formatNames); + c.select(matches[0]); } - if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") - { - nodeName = "a"; - nodeName += "#" + anchor; - nodeData = ""; + if (c = cm.get('formatselect')) { + p = getParent(DOM.isBlock); + + if (p) + c.select(p.nodeName.toLowerCase()); } - if (getAttrib(path[i], 'name').indexOf("mce_") != 0) - { - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) - nodeName += "." + className; + // Find out current fontSize, fontFamily and fontClass + getParent(function(n) { + if (n.nodeName === 'SPAN') { + if (!cl && n.className) + cl = n.className; + } + + if (ed.dom.is(n, s.theme_advanced_font_selector)) { + if (!fz && n.style.fontSize) + fz = n.style.fontSize; + + if (!fn && n.style.fontFamily) + fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); + + if (!fc && n.style.color) + fc = n.style.color; + + if (!bc && n.style.backgroundColor) + bc = n.style.backgroundColor; + } + + return false; + }); + + if (c = cm.get('fontselect')) { + c.select(function(v) { + return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn; + }); } - if (tinyMCE.isMSIE) - { - html += '' + nodeName + ''; + // Select font size + if (c = cm.get('fontsizeselect')) { + // Use computed style + if (s.theme_advanced_runtime_fontsize && !fz && !cl) + fz = ed.dom.getStyle(n, 'fontSize', true); + + c.select(function(v) { + if (v.fontSize && v.fontSize === fz) + return true; + + if (v['class'] && v['class'] === cl) + return true; + }); } - else - { - html += '' + nodeName + ''; + + if (s.theme_advanced_show_current_color) { + function updateColor(controlId, color) { + if (c = cm.get(controlId)) { + if (!color) + color = c.settings.default_color; + if (color !== c.value) { + c.displayColor(color); + } + } + } + updateColor('forecolor', fc); + updateColor('backcolor', bc); } - if (i > 0) - { - html += " » "; + if (s.theme_advanced_show_current_color) { + function updateColor(controlId, color) { + if (c = cm.get(controlId)) { + if (!color) + color = c.settings.default_color; + if (color !== c.value) { + c.displayColor(color); + } + } + }; + + updateColor('forecolor', fc); + updateColor('backcolor', bc); } - } - pathElm.innerHTML = '' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; - } - - // Reset old states - tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_link', 'mceButtonDisabled', true); - tinyMCE.switchClassSticky(editor_id + '_unlink', 'mceButtonDisabled', true); - tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonDisabled', true); - tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonNormal'); - - if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1) - tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonSelected'); - - // Get link - var anchorLink = tinyMCE.getParentElement(node, "a", "href"); - - if (anchorLink || any_selection) - { - tinyMCE.switchClassSticky(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false); - tinyMCE.switchClassSticky(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false); - } - - // Handle visual aid - tinyMCE.switchClassSticky(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal', false); - - if (undo_levels != -1) - { - tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonDisabled', true); - tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonDisabled', true); - } - - // Within li, blockquote - if (tinyMCE.getParentElement(node, "li,blockquote")) - { - tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonNormal', false); - } - - // Has redo levels - if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0)) - { - tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonNormal', false); - } - - // Has undo levels - if (undo_index != -1 && (undo_index > 0 && undo_levels > 0)) - { - tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonNormal', false); - } - - // Select class in select box - var selectElm = document.getElementById(editor_id + "_styleSelect"); - - if (selectElm) - { - TinyMCE_advanced_setupCSSClasses(editor_id); - - classNode = node; - breakOut = false; - var index = 0; - - do - { - if (classNode && classNode.className) - { - for (var i=0; i"); - } - else - { - selectByValue(selectElm, ""); - } - } - - // Select fontselect - var selectElm = document.getElementById(editor_id + "_fontNameSelect"); - if (selectElm) { - var elm = tinyMCE.getParentElement(node); - - if (elm) { - var family = tinyMCE.getAttrib(elm, "face"); - if (family == '') - family = '' + elm.style.fontFamily; - - if (!selectByValue(selectElm, family)) - selectByValue(selectElm, ""); - } else - selectByValue(selectElm, ""); - } - - // Select fontsize - var selectElm = document.getElementById(editor_id + "_fontSizeSelect"); - if (selectElm) { - var elm = tinyMCE.getParentElement(node); - - if (elm) { - var size = tinyMCE.getAttrib(elm, "size"); - if (size == '') { - var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px'); - - size = '' + elm.style.fontSize; - - for (var i=0; i