X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fthemes%2Fadvanced%2Feditor_template_src.js;h=bee26e161025b55d7efa965e4dcf449c300f26f9;hb=eb5fb3f6c3b3e1d4d3d7ebbb92b8c60d70d13254;hp=a0217d19c4d93755b2f4713a8163b212b861c199;hpb=932f4feaa7b2afe4553e5e669e2312614d3f6140;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 old mode 100755 new mode 100644 index a0217d19c..bee26e161 --- a/webcit/tiny_mce/themes/advanced/editor_template_src.js +++ b/webcit/tiny_mce/themes/advanced/editor_template_src.js @@ -1,1516 +1,1358 @@ /** - * $Id: editor_template_src.js 256 2007-04-24 09:03:20Z spocke $ + * editor_template_src.js * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing */ -/* Import theme specific language pack */ -tinyMCE.importThemeLanguagePack('advanced'); - -var TinyMCE_AdvancedTheme = { - // Private theme fields - _defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF", - _autoImportCSSClasses : true, - _resizer : {}, - _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', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'], - ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'], - ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'], - ['justifyfull', 'justifyfull.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', 'forecolor', true], - ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true], - ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true], - ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', 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'] - ], - - _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells,delete_table', - - /** - * Returns HTML code for the specificed control. - */ - getControlHTML : function(button_name) { - var i, x, but; - - // Lookup button in button list - for (i=0; i 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); - - if (but[0] == button_name) - return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); - } - - // Custom controlls other than buttons - switch (button_name) { - case "formatselect": - var html = ''; - - return html; - - case "styleselect": - return ''; - - case "fontselect": - var fontHTML = ''; - return fontHTML; - - case "fontsizeselect": - return ''; - - case "|": - case "separator": - return ''; - - case "spacer": - return ''; - - case "rowseparator": - return '
'; - } + if (/^\s*\./.test(v)) + cl = v.replace(/\./g, ''); - return ""; - }, - - /** - * Theme specific execcommand handling. - */ - execCommand : function(editor_id, element, command, user_interface, value) { - switch (command) { - case 'mceHelp': - tinyMCE.openWindow({ - file : 'about.htm', - width : 480, - height : 380 - }, { - tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion, - tinymce_releasedate : tinyMCE.releaseDate, - inline : "yes" + o[k] = cl ? {'class' : cl} : {fontSize : v}; }); - return true; - - case "mceLink": - var inst = tinyMCE.getInstanceById(editor_id); - var doc = inst.getDoc(); - var selectedText = ""; - if (tinyMCE.isMSIE) { - var rng = doc.selection.createRange(); - selectedText = rng.text; - } else - selectedText = inst.getSel().toString(); - - if (!tinyMCE.linkElement) { - if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) - return true; - } - - var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; - - if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") - tinyMCE.linkElement = tinyMCE.selectedElement; - - // Is anchor not a link - if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") - tinyMCE.linkElement = null; - - if (tinyMCE.linkElement) { - href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); - target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); - title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); - - // Try old onclick to if copy/pasted content - if (onclick == "") - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - - onclick = tinyMCE.cleanupEventStr(onclick); + s.theme_advanced_font_sizes = o; + } - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); + if ((v = s.theme_advanced_path_location) && v != 'none') + s.theme_advanced_statusbar_location = s.theme_advanced_path_location; - // Use mce_href if defined - mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); - if (mceRealHref != "") { - href = mceRealHref; + if (s.theme_advanced_statusbar_location == 'none') + s.theme_advanced_statusbar_location = 0; - if (tinyMCE.getParam('convert_urls')) - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - } + if (ed.settings.content_css !== false) + ed.contentCSS.push(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css")); - action = "update"; + // Init editor + ed.onInit.add(function() { + if (!ed.settings.readonly) { + ed.onNodeChange.add(t._nodeChanged, t); + ed.onKeyUp.add(t._updateUndoStatus, t); + ed.onMouseUp.add(t._updateUndoStatus, t); + ed.dom.bind(ed.dom.getRoot(), 'dragend', function() { + t._updateUndoStatus(ed); + }); } + }); - var template = new Array(); + ed.onSetProgressState.add(function(ed, b, ti) { + var co, id = ed.id, tb; - template['file'] = 'link.htm'; - template['width'] = 310; - template['height'] = 200; + if (b) { + t.progressTimer = setTimeout(function() { + co = ed.getContainer(); + co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild); + tb = DOM.get(ed.id + '_tbl'); - // 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); - - if (inst.settings['insertlink_callback']) { - var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); - if (returnVal && returnVal['href']) - TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); + DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}}); + DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}}); + }, ti || 0); } else { - tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); - } - - return true; - - case "mceImage": - var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; - var title = "", onmouseover = "", onmouseout = "", action = "insert"; - var img = tinyMCE.imgElement; - var inst = tinyMCE.getInstanceById(editor_id); - - if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { - img = tinyMCE.selectedElement; - tinyMCE.imgElement = img; + DOM.remove(id + '_blocker'); + DOM.remove(id + '_progress'); + clearTimeout(t.progressTimer); } + }); - if (img) { - // Is it a internal MCE visual aid image, then skip this one. - if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) - return true; + DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css"); - src = tinyMCE.getAttrib(img, 'src'); - alt = tinyMCE.getAttrib(img, 'alt'); + if (s.skin_variant) + DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); + }, - // Try polling out the title - if (alt == "") - alt = tinyMCE.getAttrib(img, 'title'); + _isHighContrast : function() { + var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'}); - // Fix width/height attributes if the styles is specified - if (tinyMCE.isGecko) { - var w = img.style.width; - if (w != null && w != "") - img.setAttribute("width", w); + actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, ''); + DOM.remove(div); - var h = img.style.height; - if (h != null && h != "") - img.setAttribute("height", h); - } + return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56'; + }, - border = tinyMCE.getAttrib(img, 'border'); - hspace = tinyMCE.getAttrib(img, 'hspace'); - vspace = tinyMCE.getAttrib(img, 'vspace'); - width = tinyMCE.getAttrib(img, 'width'); - height = tinyMCE.getAttrib(img, 'height'); - align = tinyMCE.getAttrib(img, 'align'); - onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); - onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); - title = tinyMCE.getAttrib(img, 'title'); - - // Is realy specified? - if (tinyMCE.isMSIE) { - width = img.attributes['width'].specified ? width : ""; - height = img.attributes['height'].specified ? height : ""; - } + createControl : function(n, cf) { + var cd, c; - //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); - //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); + if (c = cf.createControl(n)) + return c; - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); + switch (n) { + case "styleselect": + return this._createStyleSelect(); - // Use mce_src if defined - mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); - if (mceRealSrc != "") { - src = mceRealSrc; + case "formatselect": + return this._createBlockFormats(); - if (tinyMCE.getParam('convert_urls')) - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - } + case "fontselect": + return this._createFontSelect(); - //if (onmouseover != "") - // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); + case "fontsizeselect": + return this._createFontSizeSelect(); - //if (onmouseout != "") - // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); + case "forecolor": + return this._createForeColorMenu(); - action = "update"; - } + case "backcolor": + return this._createBackColorMenu(); + } - var template = new Array(); + if ((cd = this.controls[n])) + return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]}); + }, - template['file'] = 'image.htm?src={$src}'; - template['width'] = 355; - template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); + execCommand : function(cmd, ui, val) { + var f = this['_' + cmd]; - // 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); + if (f) { + f.call(this, ui, val); + return true; + } - if (inst.settings['insertimage_callback']) { - var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); - if (returnVal && returnVal['src']) - TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); - } else - tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"}); + return false; + }, - return true; + _importClasses : function(e) { + var ed = this.editor, ctrl = ed.controlManager.get('styleselect'); - case "forecolor": - var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm; + if (ctrl.getLength() == 0) { + each(ed.dom.getClasses(), function(o, idx) { + var name = 'style_' + idx; - TinyMCE_AdvancedTheme._hideMenus(editor_id); + ed.formatter.register(name, { + inline : 'span', + attributes : {'class' : o['class']}, + selector : '*' + }); - if (!fcp.exists()) { - fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); - elm = fcp.getElement(); - elm._editor_id = editor_id; - elm._command = "forecolor"; - elm._switchId = editor_id + "_forecolor"; - tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); - } + ctrl.add(o['class'], name); + }); + } + }, - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); + _createStyleSelect : function(n) { + var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl; - fcp.moveTo(p.absLeft, p.absTop); - fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor; - fcp.show(); + // Setup style select box + ctrl = ctrlMan.createListBox('styleselect', { + title : 'advanced.style_select', + onselect : function(name) { + var matches, formatNames = []; - return false; + each(ctrl.items, function(item) { + formatNames.push(item.value); + }); - case "forecolorpicker": - this._pickColor(editor_id, 'forecolor'); - return true; + ed.focus(); + ed.undoManager.add(); - case "forecolorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); + // 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); - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_fcMenu'); + ed.undoManager.add(); + ed.nodeChanged(); - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor')); + return false; // No auto select + } + }); - tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl'); + // Handle specified format + ed.onInit.add(function() { + var counter = 0, formats = ed.getParam('style_formats'); - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); + if (formats) { + each(formats, function(fmt) { + var name, keys = 0; - if (tinyMCE.isOpera) - ml.moveBy(0, -2); + each(fmt, function() {keys++;}); - ml.show(); - return true; + 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; - case "HiliteColor": - var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img; + if (val) { + name = 'style_' + (counter++); - TinyMCE_AdvancedTheme._hideMenus(editor_id); + ed.formatter.register(name, { + inline : 'span', + classes : val, + selector : '*' + }); - if (!bcp.exists()) { - bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); - elm = bcp.getElement(); - elm._editor_id = editor_id; - elm._command = "HiliteColor"; - elm._switchId = editor_id + "_backcolor"; - tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); + 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); + }); + } - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); + return ctrl; + }, - bcp.moveTo(p.absLeft, p.absTop); - bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor; - bcp.show(); + _createFontSelect : function() { + var c, t = this, ed = t.editor; - return false; + c = ed.controlManager.createListBox('fontselect', { + title : 'advanced.fontdefault', + onselect : function(v) { + var cur = c.items[c.selectedIndex]; - case "HiliteColorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); + if (!v && cur) { + ed.execCommand('FontName', false, cur.value); + return; + } - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_bcMenu'); + ed.execCommand('FontName', false, v); - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor')); + // Fake selection, execCommand will fire a nodeChange and update the selection + c.select(function(sv) { + return v == sv; + }); - tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl'); + if (cur && cur.value == v) { + c.select(null); + } - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); + return false; // No auto select + } + }); - if (tinyMCE.isOpera) - ml.moveBy(0, -2); + if (c) { + each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) { + c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''}); + }); + } - ml.show(); - return true; - - case "backcolorpicker": - this._pickColor(editor_id, 'HiliteColor'); - return true; + return c; + }, - case "mceColorPicker": - if (user_interface) { - var template = []; - - if (!value['callback'] && !value['color']) - value['color'] = value['document'].getElementById(value['element_id']).value; + _createFontSizeSelect : function() { + var t = this, ed = t.editor, c, i = 0, cl = []; - template['file'] = 'color_picker.htm'; - template['width'] = 380; - template['height'] = 250; - template['close_previous'] = "no"; + c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) { + var cur = c.items[c.selectedIndex]; - template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); + if (!v && cur) { + cur = cur.value; - if (typeof(value['store_selection']) == "undefined") - value['store_selection'] = true; + if (cur['class']) { + ed.formatter.toggle('fontsize_class', {value : cur['class']}); + ed.undoManager.add(); + ed.nodeChanged(); + } else { + ed.execCommand('FontSize', false, cur.fontSize); + } - tinyMCE.lastColorPickerValue = value; - tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']}); - } else { - var savedVal = tinyMCE.lastColorPickerValue, elm; + return; + } - if (savedVal['callback']) { - savedVal['callback'](value); - return true; - } + if (v['class']) { + ed.focus(); + ed.undoManager.add(); + ed.formatter.toggle('fontsize_class', {value : v['class']}); + ed.undoManager.add(); + ed.nodeChanged(); + } else + ed.execCommand('FontSize', false, v.fontSize); - elm = savedVal['document'].getElementById(savedVal['element_id']); - elm.value = value; + // Fake selection, execCommand will fire a nodeChange and update the selection + c.select(function(sv) { + return v == sv; + }); - if (elm.onchange != null && elm.onchange != '') - eval('elm.onchange();'); + if (cur && (cur.value.fontSize == v.fontSize || cur.value['class'] == v['class'])) { + c.select(null); } - return true; - case "mceCodeEditor": - var template = new Array(); + return false; // No auto select + }}); - template['file'] = 'source_editor.htm'; - template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720)); - template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580)); + if (c) { + each(t.settings.theme_advanced_font_sizes, function(v, k) { + var fz = v.fontSize; - tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); - return true; + if (fz >= 1 && fz <= 7) + fz = t.sizes[parseInt(fz) - 1] + 'pt'; - case "mceCharMap": - var template = new Array(); + c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))}); + }); + } - template['file'] = 'charmap.htm'; - template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); - template['height'] = 250; + 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; + }}); - template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); + 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}); + }); + } - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; + return c; + }, - case "mceInsertAnchor": - var template = new Array(); + _createForeColorMenu : function() { + var c, t = this, s = t.settings, o = {}, v; - template['file'] = 'anchor.htm'; - template['width'] = 320; - template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; + } - template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); + if (v = s.theme_advanced_text_colors) + o.colors = v; - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; + if (s.theme_advanced_default_foreground_color) + o.default_color = s.theme_advanced_default_foreground_color; - case "mceNewDocument": - if (confirm(tinyMCE.getLang('lang_newdocument'))) - tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); + o.title = 'advanced.forecolor_desc'; + o.cmd = 'ForeColor'; + o.scope = this; - return true; - } + c = t.editor.controlManager.createColorSplitButton('forecolor', o); - return false; - }, + return c; + }, - /** - * Editor instance template function. - */ - getEditorTemplate : function(settings, editorId) { - function removeFromArray(in_array, remove_array) { - var outArray = new Array(), skip; - - for (var i=0; i 

'; - var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); - - // 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 + ''; - } + renderUI : function(o) { + var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; - TinyMCE_AdvancedTheme._autoImportCSSClasses = false; - } + if (ed.settings) { + ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut'); + } - 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" - }; + // 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); - // Add accessibility control - toolbarHTML += ' 0) { - toolbarHTML += "
"; - deltaHeight -= 23; - } - } + // 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'); + }); - // Add accessibility control - toolbarHTML += '
'; + if (DOM.get(s.theme_advanced_toolbar_container)) + DOM.get(s.theme_advanced_toolbar_container).appendChild(p); + else + DOM.insertAfter(p, n); - // Setup template html - template['html'] = ''; + Event.add(ed.id + '_path_row', 'click', function(e) { + e = e.target; - if (toolbarLocation == "top") - template['html'] += ''; + if (e.nodeName == 'A') { + t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1')); - if (statusbarLocation == "top") { - template['html'] += ''; - deltaHeight -= 23; + return Event.cancel(e); } + }); +/* + if (DOM.get(ed.id + '_path_row')) { + Event.add(ed.id + '_tbl', 'mouseover', function(e) { + var re; + + e = e.target; - template['html'] += ''; - - if (toolbarLocation == "bottom") - template['html'] += ''; + 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); + } + }); - // External toolbar changes - if (toolbarLocation == "external") { - var bod = document.body; - var elm = document.createElement ("div"); + Event.add(ed.id + '_tbl', 'mouseout', function(e) { + if (t.lastPath) { + DOM.setHTML(ed.id + '_path_row', t.lastPath); + t.lastPath = 0; + } + }); + } +*/ - toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML); - toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId}); + if (!ed.getParam('accessibility_focus')) + Event.add(DOM.add(p, 'a', {href : '#'}, ''), 'focus', function() {tinyMCE.get(ed.id).focus();}); - elm.className = "mceToolbarExternal"; - elm.id = editorId+"_toolbar"; - elm.innerHTML = '
' + toolbarHTML + '
' + statusbarHTML + '
' + toolbarHTML + '
'+toolbarHTML+'
'; - bod.appendChild (elm); - // bod.style.marginTop = elm.offsetHeight + "px"; + if (s.theme_advanced_toolbar_location == 'external') + o.deltaHeight = 0; - deltaHeight = 0; - tinyMCE.getInstanceById(editorId).toolbarElement = elm; + t.deltaHeight = o.deltaHeight; + o.targetNode = null; - //template['html'] = '
'+toolbarHTML+'
' + template["html"]; - } else { - tinyMCE.getInstanceById(editorId).toolbarElement = null; - } + ed.onKeyDown.add(function(ed, evt) { + var DOM_VK_F10 = 121, DOM_VK_F11 = 122; - if (statusbarLocation == "bottom") { - template['html'] += '' + statusbarHTML + ''; - deltaHeight -= 23; + 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 + } + }, - 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'] += ''; - else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath: - { - var pathClass = "mceStatusbar"; - - if (i == containers.length-1) - { - pathClass = "mceStatusbarBottom"; - } - else if (i == 0) - { - pathClass = "mceStatusbar"; - } - else - { - deltaHeight-=2; - } - - 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); - - curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); + resizeBy : function(dw, dh) { + var e = DOM.get(this.editor.id + '_ifr'); - for (var j=0; j 0) { - curContainerHTML += "
"; - deltaHeight -= 23; - } + resizeTo : function(w, h, store) { + var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); - template['html'] += '
'; - } - } + // 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); - template['html'] += '
' + statusbarHTML + '
' + curContainerHTML + '
'; - //RowLayout - break; + // Resize iframe and container + DOM.setStyle(e, 'height', ''); + DOM.setStyle(ifr, 'height', h); - case "CustomLayout" : //User defined layout callback... - var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); + if (s.theme_advanced_resize_horizontal) { + DOM.setStyle(e, 'width', ''); + DOM.setStyle(ifr, 'width', w); - if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") { - template = eval(customLayout + "(template);"); + // 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); } - break; - } - - if (resizing) - template['html'] += ''; + } - template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); + // Store away the size + if (store && s.theme_advanced_resizing_use_cookie) { + Cookie.setHash("TinyMCE_" + ed.id + "_size", { + cw : w, + ch : h + }); + } + }, - // Set to default values - if (!template['delta_width']) - template['delta_width'] = 0; + destroy : function() { + var id = this.editor.id; - if (!template['delta_height']) - template['delta_height'] = deltaHeight; + Event.clear(id + '_resize'); + Event.clear(id + '_path_row'); + Event.clear(id + '_external_close'); + }, - return template; - }, + // Internal functions - initInstance : function(inst) { - if (tinyMCE.getParam("theme_advanced_resizing", false)) { - if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { - var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width"); - var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height"); + _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; - TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true)); + if (s.readonly) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + return ic; } - } - inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink'); - }, + // Create toolbar container at top + if (lo == 'top') + t._addToolbars(tb, o); - removeInstance : function(inst) { - new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); - new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); - }, + // 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'); - hideInstance : function(inst) { - TinyMCE_AdvancedTheme._hideMenus(inst.editorId); - }, + if (p.firstChild.className == 'mceOldBoxModel') + p.firstChild.appendChild(c); + else + p.insertBefore(c, p.firstChild); - _handleMenuEvent : function(e) { - var te = tinyMCE.isMSIE ? window.event.srcElement : e.target; - tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId)); + t._addToolbars(etb, o); - if (e.type == "click") - tinyMCE.execInstanceCommand(te._editor_id, te._command); - }, + ed.onMouseUp.add(function() { + var e = DOM.get(ed.id + '_external'); + DOM.show(e); - _hideMenus : function(id) { - var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu'); + DOM.hide(lastExtID); - if (fcml.exists() && fcml.isVisible()) { - tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton'); - fcml.hide(); - } + var f = Event.add(ed.id + '_external_close', 'click', function() { + DOM.hide(ed.id + '_external'); + Event.remove(ed.id + '_external_close', 'click', f); + }); - if (bcml.exists() && bcml.isVisible()) { - tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton'); - bcml.hide(); - } - }, + DOM.show(e); + DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1); - /** - * Node change handler. - */ - handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) { - var alignNode, breakOut, classNode; + // Fixes IE rendering bug + DOM.hide(e); + DOM.show(e); + e.style.filter = ''; - function selectByValue(select_elm, value, first_index) { - first_index = typeof(first_index) == "undefined" ? false : true; + lastExtID = ed.id + '_external'; - if (select_elm) { - for (var i=0; i=0; i--) { - var nodeName = path[i].nodeName.toLowerCase(); - var nodeData = ""; + // Create toolbar container at bottom + if (lo == 'bottom') + t._addToolbars(tb, o); - if (nodeName.indexOf("html:") == 0) - nodeName = nodeName.substring(5); + if (sl == 'bottom') + t._addStatusBar(tb, o); - if (nodeName == "b") { - nodeName = "strong"; - } + return ic; + }, - if (nodeName == "i") { - nodeName = "em"; - } + _rowLayout : function(s, tb, o) { + var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a; - if (nodeName == "span") { - var cn = tinyMCE.getAttrib(path[i], "class"); - if (cn != "" && cn.indexOf('mceItem') == -1) - nodeData += "class: " + cn + " "; + dc = s.theme_advanced_containers_default_class || ''; + da = s.theme_advanced_containers_default_align || 'center'; - var st = tinyMCE.getAttrib(path[i], "style"); - if (st != "") { - st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st)); - nodeData += "style: " + tinyMCE.xmlEncode(st) + " "; - } - } + each(explode(s.theme_advanced_containers || ''), function(c, i) { + var v = s['theme_advanced_container_' + c] || ''; - if (nodeName == "font") { - if (tinyMCE.getParam("convert_fonts_to_spans")) - nodeName = "span"; + switch (c.toLowerCase()) { + case 'mceeditor': + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + break; - var face = tinyMCE.getAttrib(path[i], "face"); - if (face != "") - nodeData += "font: " + tinyMCE.xmlEncode(face) + " "; + case 'mceelementpath': + t._addStatusBar(tb, o); + break; - var size = tinyMCE.getAttrib(path[i], "size"); - if (size != "") - nodeData += "size: " + tinyMCE.xmlEncode(size) + " "; + default: + a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase(); + a = 'mce' + t._ufirst(a); - var color = tinyMCE.getAttrib(path[i], "color"); - if (color != "") - nodeData += "color: " + tinyMCE.xmlEncode(color) + " "; - } + n = DOM.add(DOM.add(tb, 'tr'), 'td', { + 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da + }); - if (tinyMCE.getAttrib(path[i], 'id') != "") { - nodeData += "id: " + path[i].getAttribute('id') + " "; + to = cf.createToolbar("toolbar" + i); + t._addControls(v, to); + DOM.setHTML(n, to.renderHTML()); + o.deltaHeight -= s.theme_advanced_row_height; } + }); - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) - nodeData += "class: " + className + " "; + return ic; + }, - if (tinyMCE.getAttrib(path[i], 'src') != "") { - var src = tinyMCE.getAttrib(path[i], "mce_src"); + _addControls : function(v, tb) { + var t = this, s = t.settings, di, cf = t.editor.controlManager; - if (src == "") - src = tinyMCE.getAttrib(path[i], "src"); + if (s.theme_advanced_disable && !t._disabled) { + di = {}; - nodeData += "src: " + tinyMCE.xmlEncode(src) + " "; - } + each(explode(s.theme_advanced_disable), function(v) { + di[v] = 1; + }); - if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") { - var href = tinyMCE.getAttrib(path[i], "mce_href"); + t._disabled = di; + } else + di = t._disabled; - if (href == "") - href = tinyMCE.getAttrib(path[i], "href"); + each(explode(v), function(n) { + var c; - nodeData += "href: " + tinyMCE.xmlEncode(href) + " "; - } + if (di && di[n]) + return; - className = tinyMCE.getAttrib(path[i], "class"); - if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) { - nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase(); - nodeData = path[i].getAttribute('title'); - } + // Compatiblity with 2.x + if (n == 'tablecontrols') { + each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) { + n = t.createControl(n, cf); - if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { - nodeName = "a"; - nodeName += "#" + tinyMCE.xmlEncode(anchor); - nodeData = ""; - } + if (n) + tb.add(n); + }); - if (tinyMCE.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; - } + return; } - var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');'; - html += '' + nodeName + ''; + c = t.createControl(n, cf); - if (i > 0) { - html += " » "; - } - } + if (c) + tb.add(c); + }); + }, - pathElm.innerHTML = '' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; - } + _addToolbars : function(c, o) { + var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a, toolbarGroup; - // Reset old states - tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal'); - - if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1) - tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected'); - - // Get link - var anchorLink = tinyMCE.getParentElement(node, "a", "href"); - - if (anchorLink || any_selection) { - tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - } + toolbarGroup = cf.createToolbarGroup('toolbargroup', { + 'name': ed.getLang('advanced.toolbar'), + 'tab_focus_toolbar':ed.getParam('theme_advanced_tab_focus_toolbar') + }); - // Handle visual aid - tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal'); + t.toolbarGroup = toolbarGroup; - if (undo_levels != -1) { - tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled'); - } + a = s.theme_advanced_toolbar_align.toLowerCase(); + a = 'mce' + t._ufirst(a); - // Within li, blockquote - if (tinyMCE.getParentElement(node, "li,blockquote")) - tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal'); - - // Has redo levels - if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0)) - tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal'); - - // Has undo levels - if (undo_index != -1 && (undo_index > 0 && undo_levels > 0)) - tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal'); - - // Select class in select box - var selectElm = document.getElementById(editor_id + "_styleSelect"); - - if (selectElm) { - TinyMCE_AdvancedTheme._setupCSSClasses(editor_id); - - classNode = node; - breakOut = false; - var index = 0; - - do { - if (classNode && classNode.className) { - for (var i=0; i"); - else - selectByValue(selectElm, ""); - } + n = DOM.add(DOM.add(c, 'tr', {role: 'presentation'}), 'td', {'class' : 'mceToolbar ' + a, "role":"presentation"}); - // Select fontselect - var selectElm = document.getElementById(editor_id + "_fontNameSelect"); - if (selectElm) { - if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) { - var face = inst.queryCommandValue('FontName'); + // Create toolbar and add the controls + for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { + tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i}); - face = face == null || face == "" ? "" : face; - - selectByValue(selectElm, face, face != ""); - } else { - var elm = tinyMCE.getParentElement(node, "font", "face"); + if (s['theme_advanced_buttons' + i + '_add']) + v += ',' + s['theme_advanced_buttons' + i + '_add']; - if (elm) { - var family = tinyMCE.getAttrib(elm, "face"); + if (s['theme_advanced_buttons' + i + '_add_before']) + v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; - if (family == '') - family = '' + elm.style.fontFamily; + t._addControls(v, tb); + toolbarGroup.add(tb); - if (!selectByValue(selectElm, family, family != "")) - selectByValue(selectElm, ""); - } else - selectByValue(selectElm, ""); + o.deltaHeight -= s.theme_advanced_row_height; } - } - - // Select fontsize - var selectElm = document.getElementById(editor_id + "_fontSizeSelect"); - if (selectElm) { - if (!tinyMCE.isSafari && !tinyMCE.isOpera) { - var size = inst.queryCommandValue('FontSize'); - selectByValue(selectElm, size == null || size == "" ? "0" : size); + h.push(toolbarGroup.renderHTML()); + h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '')); + 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 { - var elm = tinyMCE.getParentElement(node, "font", "size"); - 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 0) - selectElm.setAttribute('cssImported', 'true'); - } - }, + o.deltaHeight -= 21; + n = tb = null; + }, - _setCookie : function(name, value, expires, path, domain, secure) { - var curCookie = name + "=" + escape(value) + - ((expires) ? "; expires=" + expires.toGMTString() : "") + - ((path) ? "; path=" + escape(path) : "") + - ((domain) ? "; domain=" + domain : "") + - ((secure) ? "; secure" : ""); + _updateUndoStatus : function(ed) { + var cm = ed.controlManager, um = ed.undoManager; - document.cookie = curCookie; - }, + cm.setDisabled('undo', !um.hasUndo() && !um.typing); + cm.setDisabled('redo', !um.hasRedo()); + }, - _getCookie : function(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); + _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; - if (begin == -1) { - begin = dc.indexOf(prefix); + tinymce.each(t.stateControls, function(c) { + cm.setActive(c, ed.queryCommandState(t.controls[c][1])); + }); - if (begin != 0) - return null; - } else - begin += 2; + function getParent(name) { + var i, parents = ob.parents, func = name; - var end = document.cookie.indexOf(";", begin); - - if (end == -1) - end = dc.length; + if (typeof(name) == 'string') { + func = function(node) { + return node.nodeName == name; + }; + } - return unescape(dc.substring(begin + prefix.length, end)); - }, + for (i = 0; i < parents.length; i++) { + if (func(parents[i])) + return parents[i]; + } + }; - _resizeTo : function(inst, w, h, set_w) { - var editorContainer = document.getElementById(inst.editorId + '_parent'); - var tableElm = editorContainer.firstChild; - var iframe = inst.iframeElement; + cm.setActive('visualaid', ed.hasVisual); + t._updateUndoStatus(ed); + cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); - if (w == null || w == "null") { - set_w = false; - w = 0; - } + p = getParent('A'); + if (c = cm.get('link')) { + if (!p || !p.name) { + c.setDisabled(!p && co); + c.setActive(!!p); + } + } - if (h == null || h == "null") - return; + if (c = cm.get('unlink')) { + c.setDisabled(!p && co); + c.setActive(!!p && !p.name); + } - w = parseInt(w); - h = parseInt(h); + if (c = cm.get('anchor')) { + c.setActive(!co && !!p && p.name); + } - if (tinyMCE.isGecko) { - w += 2; - h += 2; - } + p = getParent('IMG'); + if (c = cm.get('image')) + c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1); - var dx = w - tableElm.clientWidth; - var dy = h - tableElm.clientHeight; + if (c = cm.get('styleselect')) { + t._importClasses(); - w = w < 1 ? 30 : w; - h = h < 1 ? 30 : h; + formatNames = []; + each(c.items, function(item) { + formatNames.push(item.value); + }); - if (set_w) - tableElm.style.width = w + "px"; + matches = ed.formatter.matchAll(formatNames); + c.select(matches[0]); + } - tableElm.style.height = h + "px"; + if (c = cm.get('formatselect')) { + p = getParent(DOM.isBlock); - iw = iframe.clientWidth + dx; - ih = iframe.clientHeight + dy; + if (p) + c.select(p.nodeName.toLowerCase()); + } - iw = iw < 1 ? 30 : iw; - ih = ih < 1 ? 30 : ih; + // Find out current fontSize, fontFamily and fontClass + getParent(function(n) { + if (n.nodeName === 'SPAN') { + if (!cl && n.className) + cl = n.className; + } - if (tinyMCE.isGecko) { - iw -= 2; - ih -= 2; - } + if (ed.dom.is(n, s.theme_advanced_font_selector)) { + if (!fz && n.style.fontSize) + fz = n.style.fontSize; - if (set_w) - iframe.style.width = iw + "px"; + if (!fn && n.style.fontFamily) + fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); + + if (!fc && n.style.color) + fc = n.style.color; - iframe.style.height = ih + "px"; + if (!bc && n.style.backgroundColor) + bc = n.style.backgroundColor; + } - // 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; + return false; + }); - inst.iframeElement.style.width = (iw + dx) + "px"; + if (c = cm.get('fontselect')) { + c.select(function(v) { + return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn; + }); } - } - // Remove pesky table controls - inst.useCSS = false; - }, + // 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); - /** - * Handles resizing events. - */ - _resizeEventHandler : function(e) { - var resizer = TinyMCE_AdvancedTheme._resizer; + c.select(function(v) { + if (v.fontSize && v.fontSize === fz) + return true; - // Do nothing - if (!resizer.resizing) - return; + if (v['class'] && v['class'] === cl) + return true; + }); + } + + 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); + } - e = typeof(e) == "undefined" ? window.event : e; + 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); + } + } + }; - var dx = e.screenX - resizer.downX; - var dy = e.screenY - resizer.downY; - var resizeBox = resizer.resizeBox; - var editorId = resizer.editorId; + updateColor('forecolor', fc); + updateColor('backcolor', bc); + } - switch (e.type) { - case "mousemove": - var w, h; + if (s.theme_advanced_path && s.theme_advanced_statusbar_location) { + p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'}); - w = resizer.width + dx; - h = resizer.height + dy; + if (t.statusKeyboardNavigation) { + t.statusKeyboardNavigation.destroy(); + t.statusKeyboardNavigation = null; + } - w = w < 1 ? 1 : w; - h = h < 1 ? 1 : h; + DOM.setHTML(p, ''); - if (resizer.horizontal) - resizeBox.style.width = w + "px"; + getParent(function(n) { + var na = n.nodeName.toLowerCase(), u, pi, ti = ''; - resizeBox.style.height = h + "px"; - break; + // Ignore non element and bogus/hidden elements + if (n.nodeType != 1 || na === 'br' || n.getAttribute('data-mce-bogus') || DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')) + return; - case "mouseup": - TinyMCE_AdvancedTheme._setResizing(e, editorId, false); - TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal); + // Handle prefix + if (tinymce.isIE && n.scopeName !== 'HTML') + na = n.scopeName + ':' + na; - // Expire in a month - if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { - var expires = new Date(); - expires.setTime(expires.getTime() + 3600000 * 24 * 30); + // Remove internal prefix + na = na.replace(/mce\:/g, ''); - // Set the cookies - TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires); - TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires); - } - break; - } - }, - - /** - * Starts/stops the editor resizing. - */ - _setResizing : function(e, editor_id, state) { - e = typeof(e) == "undefined" ? window.event : e; - - var resizer = TinyMCE_AdvancedTheme._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_AdvancedTheme._resizeEventHandler); - else - tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler); + // Handle node name + switch (na) { + case 'b': + na = 'strong'; + break; - tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler); + case 'i': + na = 'em'; + break; - resizer.eventHandlers = true; - } + case 'img': + if (v = DOM.getAttrib(n, 'src')) + ti += 'src: ' + v + ' '; - 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 && !tinyMCE.isOpera ? "block" : "table"; - tinyMCE.execCommand('mceResetDesignMode'); - } - }, + break; - _getColorHTML : function(id, n, cm) { - var i, h, cl; + case 'a': + if (v = DOM.getAttrib(n, 'name')) { + ti += 'name: ' + v + ' '; + na += '#' + v; + } - h = ''; - cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(','); + if (v = DOM.getAttrib(n, 'href')) + ti += 'href: ' + v + ' '; - h += ''; - for (i=0; i'; + break; - if ((i+1) % 8 == 0) - h += ''; - } + case 'font': + if (v = DOM.getAttrib(n, 'face')) + ti += 'font: ' + v + ' '; - h += '
'; - - if (tinyMCE.getParam("theme_advanced_more_colors", true)) - h += '' + tinyMCE.getLang('lang_more_colors') + ''; - - return h; - }, - - _pickColor : function(id, cm) { - var inputColor, inst = tinyMCE.selectedInstance; - - if (cm == 'forecolor' && inst) - inputColor = inst.foreColor; - - if ((cm == 'backcolor' || cm == 'HiliteColor') && inst) - inputColor = inst.backColor; - - tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) { - tinyMCE.execInstanceCommand(id, cm, false, c); - }}); - }, - - _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { - tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', { - src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src), // Force absolute - mce_src : src, - alt : alt, - border : border, - hspace : hspace, - vspace : vspace, - width : width, - height : height, - align : align, - title : title, - onmouseover : onmouseover, - onmouseout : onmouseout - })); - }, - - _insertLink : function(href, target, title, onclick, style_class) { - tinyMCE.execCommand('mceBeginUndoLevel'); - - if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { - var doc = tinyMCE.selectedInstance.getDoc(); - var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a"); - var newLink = false; - - if (!linkElement) { - linkElement = doc.createElement("a"); - newLink = true; - } + if (v = DOM.getAttrib(n, 'size')) + ti += 'size: ' + v + ' '; - var mhref = href; - var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; + if (v = DOM.getAttrib(n, 'color')) + ti += 'color: ' + v + ' '; - tinyMCE.setAttrib(linkElement, 'href', thref); - tinyMCE.setAttrib(linkElement, 'mce_href', mhref); - tinyMCE.setAttrib(linkElement, 'target', target); - tinyMCE.setAttrib(linkElement, 'title', title); - tinyMCE.setAttrib(linkElement, 'onclick', onclick); - tinyMCE.setAttrib(linkElement, 'class', style_class); + break; - if (newLink) { - linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true)); - tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement); - } + case 'span': + if (v = DOM.getAttrib(n, 'style')) + ti += 'style: ' + v + ' '; - return; - } + break; + } - if (!tinyMCE.linkElement && tinyMCE.selectedInstance) { - if (tinyMCE.isSafari) { - tinyMCE.execCommand("mceInsertContent", false, '' + tinyMCE.selectedInstance.selection.getSelectedHTML() + ''); - } else - tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); + if (v = DOM.getAttrib(n, 'id')) + ti += 'id: ' + v + ' '; - tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); + if (v = n.className) { + v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '') - var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); + if (v) { + ti += 'class: ' + v + ' '; - for (var i=0; i 0) { + t.statusKeyboardNavigation = new tinymce.ui.KeyboardNavigation({ + root: ed.id + "_path_row", + items: DOM.select('a', p), + excludeFromTabOrder: true, + onCancel: function() { + ed.focus(); + } + }, DOM); + } } + }, + + // Commands gets called by execCommand + + _sel : function(v) { + this.editor.execCommand('mceSelectNodeDepth', false, v); + }, + + _mceInsertAnchor : function(ui, v) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/anchor.htm', + width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)), + height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceCharMap : function() { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/charmap.htm', + width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)), + height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceHelp : function() { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/about.htm', + width : 480, + height : 380, + inline : true + }, { + theme_url : this.url + }); + }, + + _mceShortcuts : function() { + var ed = this.editor; + ed.windowManager.open({ + url: this.url + '/shortcuts.htm', + width: 480, + height: 380, + inline: true + }, { + theme_url: this.url + }); + }, + + _mceColorPicker : function(u, v) { + var ed = this.editor; + + v = v || {}; + + ed.windowManager.open({ + url : this.url + '/color_picker.htm', + width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)), + height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)), + close_previous : false, + inline : true + }, { + input_color : v.color, + func : v.func, + theme_url : this.url + }); + }, + + _mceCodeEditor : function(ui, val) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/source_editor.htm', + width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)), + height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)), + inline : true, + resizable : true, + maximizable : true + }, { + theme_url : this.url + }); + }, + + _mceImage : function(ui, val) { + var ed = this.editor; + + // Internal image object like a flash placeholder + if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1) + return; + + ed.windowManager.open({ + url : this.url + '/image.htm', + width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)), + height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceLink : function(ui, val) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/link.htm', + width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)), + height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceNewDocument : function() { + var ed = this.editor; + + ed.windowManager.confirm('advanced.newdocument', function(s) { + if (s) + ed.execCommand('mceSetContent', false, ''); + }); + }, + + _mceForeColor : function() { + var t = this; + + this._mceColorPicker(0, { + color: t.fgColor, + func : function(co) { + t.fgColor = co; + t.editor.execCommand('ForeColor', false, co); + } + }); + }, - tinyMCE.linkElement = elementArray[0]; - } - - if (tinyMCE.linkElement) { - var mhref = href; - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; - - tinyMCE.setAttrib(tinyMCE.linkElement, 'href', href); - tinyMCE.setAttrib(tinyMCE.linkElement, 'mce_href', mhref); - tinyMCE.setAttrib(tinyMCE.linkElement, 'target', target); - tinyMCE.setAttrib(tinyMCE.linkElement, 'title', title); - tinyMCE.setAttrib(tinyMCE.linkElement, 'onclick', onclick); - tinyMCE.setAttrib(tinyMCE.linkElement, 'class', style_class); - } + _mceBackColor : function() { + var t = this; - tinyMCE.execCommand('mceEndUndoLevel'); - } -}; + this._mceColorPicker(0, { + color: t.bgColor, + func : function(co) { + t.bgColor = co; + t.editor.execCommand('HiliteColor', false, co); + } + }); + }, -tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme); + _ufirst : function(s) { + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + }); -// Add default buttons maps for advanced theme and all internal plugins -tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap); + tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme); +}(tinymce));