diff -r c72b545f1304 -r 67bd3121a12e includes/clientside/tinymce/themes/advanced/editor_template_src.js --- a/includes/clientside/tinymce/themes/advanced/editor_template_src.js Wed Dec 26 00:37:26 2007 -0500 +++ b/includes/clientside/tinymce/themes/advanced/editor_template_src.js Thu Dec 27 22:09:33 2007 -0500 @@ -1,1574 +1,990 @@ /** - * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $ + * $Id: editor_template_src.js 492 2007-12-13 14:11:51Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ -/* Import theme specific language pack */ -tinyMCE.importThemeLanguagePack('advanced'); +(function() { + var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID; + + // Tell it to load theme specific language pack(s) + tinymce.ThemeManager.requireLangPack('advanced'); + + tinymce.create('tinymce.themes.AdvancedTheme', { + // Control name lookup, format: title, command + controls : { + bold : ['bold_desc', 'Bold'], + italic : ['italic_desc', 'Italic'], + underline : ['underline_desc', 'Underline'], + strikethrough : ['striketrough_desc', 'Strikethrough'], + justifyleft : ['justifyleft_desc', 'JustifyLeft'], + justifycenter : ['justifycenter_desc', 'JustifyCenter'], + justifyright : ['justifyright_desc', 'JustifyRight'], + justifyfull : ['justifyfull_desc', 'JustifyFull'], + bullist : ['bullist_desc', 'InsertUnorderedList'], + numlist : ['numlist_desc', 'InsertOrderedList'], + outdent : ['outdent_desc', 'Outdent'], + indent : ['indent_desc', 'Indent'], + cut : ['cut_desc', 'Cut'], + copy : ['copy_desc', 'Copy'], + paste : ['paste_desc', 'Paste'], + undo : ['undo_desc', 'Undo'], + redo : ['redo_desc', 'Redo'], + link : ['link_desc', 'mceLink'], + unlink : ['unlink_desc', 'unlink'], + image : ['image_desc', 'mceImage'], + cleanup : ['cleanup_desc', 'mceCleanup'], + help : ['help_desc', 'mceHelp'], + code : ['code_desc', 'mceCodeEditor'], + hr : ['hr_desc', 'InsertHorizontalRule'], + removeformat : ['removeformat_desc', 'RemoveFormat'], + sub : ['sub_desc', 'subscript'], + sup : ['sup_desc', 'superscript'], + forecolor : ['forecolor_desc', 'ForeColor'], + forecolorpicker : ['forecolor_desc', 'mceForeColor'], + backcolor : ['backcolor_desc', 'HiliteColor'], + backcolorpicker : ['backcolor_desc', 'mceBackColor'], + charmap : ['charmap_desc', 'mceCharMap'], + visualaid : ['visualaid_desc', 'mceToggleVisualAid'], + anchor : ['anchor_desc', 'mceInsertAnchor'], + newdocument : ['newdocument_desc', 'mceNewDocument'], + blockquote : ['blockquote_desc', 'mceBlockQuote'] + }, + + stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'], + + init : function(ed, url) { + var t = this, s; + + t.editor = ed; + t.url = url; + t.onResolveName = new tinymce.util.Dispatcher(this); -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'] - ], + // Default settings + t.settings = s = extend({ + theme_advanced_path : true, + theme_advanced_toolbar_location : 'bottom', + theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", + theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code", + theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap", + theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6", + theme_advanced_toolbar_align : "center", + theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats", + theme_advanced_font_sizes : "1,2,3,4,5,6,7", + theme_advanced_more_colors : 1, + theme_advanced_row_height : 23, + theme_advanced_resize_horizontal : 1, + theme_advanced_resizing_use_cookie : 1 + }, ed.settings); + + // Init editor + ed.onInit.add(function() { + ed.onNodeChange.add(t._nodeChanged, t); + ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css")); + }); + + ed.onSetProgressState.add(function(ed, b, ti) { + var co, id = ed.id, tb; + + 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'); - _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', + 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 { + DOM.remove(id + '_blocker'); + DOM.remove(id + '_progress'); + clearTimeout(t.progressTimer); + } + }); + + DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui.css")); + }, + + createControl : function(n, cf) { + var cd, c; + + if (c = cf.createControl(n)) + return c; - /** - * Returns HTML code for the specificed control. - */ - getControlHTML : function(button_name) { - var i, x, but; + switch (n) { + case "styleselect": + return this._createStyleSelect(); + + case "formatselect": + return this._createBlockFormats(); + + case "fontselect": + return this._createFontSelect(); - // Lookup button in button list - for (i=0; i 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); + execCommand : function(cmd, ui, val) { + var f = this['_' + cmd]; + + if (f) { + f.call(this, ui, val); + return true; + } - 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)); - } + return false; + }, + + _importClasses : function() { + var ed = this.editor, c = ed.controlManager.get('styleselect'); + + if (c.getLength() == 0) { + each(ed.dom.getClasses(), function(o) { + c.add(o['class'], o['class']); + }); + } + }, - // Custom controlls other than buttons - switch (button_name) { - case "formatselect": - var html = ''; + c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'}); - return html; + each(t.settings.theme_advanced_font_sizes.split(','), function(v) { + c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'fontSize' + v}); + }); + + return c; + }, - case "styleselect": - return ''; + _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', cmd : 'FormatBlock'}); - case "fontselect": - var fontHTML = ''; - return fontHTML; + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; + } + + if (v = s.theme_advanced_text_colors) + o.colors = v; - case "fontsizeselect": - return ''; + o.title = 'advanced.forecolor_desc'; + o.cmd = 'ForeColor'; + o.scope = this; + + c = t.editor.controlManager.createColorSplitButton('forecolor', o); + + return c; + }, + + _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); + } + }); + }; + } + + if (v = s.theme_advanced_background_colors) + o.colors = v; + + o.title = 'advanced.backcolor_desc'; + o.cmd = 'HiliteColor'; + o.scope = this; - case "|": - case "separator": - return ''; + c = t.editor.controlManager.createColorSplitButton('backcolor', o); + + return c; + }, - case "spacer": - return ''; + renderUI : function(o) { + var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; + + n = p = DOM.create('div', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin'}); + + if (!DOM.boxModel) + n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); - case "rowseparator": - return '
'; - } + n = sc = DOM.add(n, 'table', {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; - return ""; - }, + 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; - /** - * 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" - }); - return true; + // Add classes to first and last TRs + nl = sc.rows; + DOM.addClass(nl[0], 'first'); + DOM.addClass(nl[nl.length - 1], 'last'); + + // Add classes to first and last TDs + each(DOM.select('tr', tb), function(n) { + DOM.addClass(n.firstChild, 'first'); + DOM.addClass(n.childNodes[n.childNodes.length - 1], 'last'); + }); + + if (DOM.get(s.theme_advanced_toolbar_container)) + DOM.get(s.theme_advanced_toolbar_container).appendChild(p); + else + DOM.insertAfter(p, n); + + Event.add(ed.id + '_path_row', 'click', function(e) { + e = e.target; + + if (e.nodeName == 'A') { + t._sel(e.href.replace(/^[^#]*#/, '')); + + return Event.cancel(e); + } + }); +/* + if (DOM.get(ed.id + '_path_row')) { + Event.add(ed.id + '_tbl', 'mouseover', function(e) { + var re; + + e = e.target; - case "mceLink": - var inst = tinyMCE.getInstanceById(editor_id); - var doc = inst.getDoc(); - var selectedText = ""; + 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); + } + }); + + Event.add(ed.id + '_tbl', 'mouseout', function(e) { + if (t.lastPath) { + DOM.setHTML(ed.id + '_path_row', t.lastPath); + t.lastPath = 0; + } + }); + } +*/ + if (s.theme_advanced_toolbar_location == 'external') + o.deltaHeight = 0; - if (tinyMCE.isMSIE) { - var rng = doc.selection.createRange(); - selectedText = rng.text; - } else - selectedText = inst.getSel().toString(); + t.deltaHeight = o.deltaHeight; + o.targetNode = null; - if (!tinyMCE.linkElement) { - if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) - return true; - } + return { + iframeContainer : ic, + editorContainer : ed.id + '_parent', + sizeContainer : sc, + deltaHeight : o.deltaHeight + }; + }, - var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; + getInfo : function() { + return { + longname : 'Simple theme', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + version : tinymce.majorVersion + "." + tinymce.minorVersion + } + }, - if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") - tinyMCE.linkElement = tinyMCE.selectedElement; + _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; + + // Create toolbar container at top + if (lo == 'top') + t._addToolbars(tb, o); - // Is anchor not a link - if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") - tinyMCE.linkElement = null; + // 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'); - 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'); + if (p.firstChild.className == 'mceOldBoxModel') + p.firstChild.appendChild(c); + else + p.insertBefore(c, p.firstChild); + + t._addToolbars(etb, o); + + ed.onMouseUp.add(function() { + var e = DOM.get(ed.id + '_external'); + DOM.show(e); + + DOM.hide(lastExtID); + + var f = Event.add(ed.id + '_external_close', 'click', function() { + DOM.hide(ed.id + '_external'); + Event.remove(ed.id + '_external_close', 'click', f); + }); - // Try old onclick to if copy/pasted content - if (onclick == "") - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); + DOM.show(e); + DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1); - onclick = tinyMCE.cleanupEventStr(onclick); + // Fixes IE rendering bug + DOM.hide(e); + DOM.show(e); + e.style.filter = ''; - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); + lastExtID = ed.id + '_external'; + + e = null; + }); + } - // Use mce_href if defined - mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); - if (mceRealHref != "") { - href = mceRealHref; + if (sl == 'top') + t._addStatusBar(tb, o); + + // Create iframe container + if (!s.theme_advanced_toolbar_container) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + } - if (tinyMCE.getParam('convert_urls')) - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - } + // Create toolbar container at bottom + if (lo == 'bottom') + t._addToolbars(tb, o); + + if (sl == 'bottom') + t._addStatusBar(tb, o); + + return ic; + }, - action = "update"; - } + _rowLayout : function(s, tb, o) { + var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to; + + dc = s.theme_advanced_containers_default_class || ''; + da = s.theme_advanced_containers_default_align || 'center'; - var template = new Array(); + each((s.theme_advanced_containers || '').split(','), function(c, i) { + var v = s['theme_advanced_container_' + c].toLowerCase(); + + switch (v) { + case 'mceeditor': + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + break; - template['file'] = 'link.htm'; - template['width'] = 310; - template['height'] = 200; + case 'mceelementpath': + t._addStatusBar(tb, o); + break; - // 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); + default: + n = DOM.add(DOM.add(tb, 'tr'), 'td', { + 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc), + align : s['theme_advanced_container_' + c + '_align'] || da + }); + + to = cf.createToolbar("toolbar" + i); + t._addControls(v, to); + n.innerHTML = to.renderHTML(); + o.deltaHeight -= s.theme_advanced_row_height; + } + }); - 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']); - } else { - tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); - } + return ic; + }, + + _addControls : function(v, tb) { + var t = this, s = t.settings, di, cf = t.editor.controlManager; - return true; + if (s.theme_advanced_disable && !t._disabled) { + di = {}; + + each(s.theme_advanced_disable.split(','), function(v) { + di[v] = 1; + }); + + t._disabled = di; + } else + di = t._disabled; - 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); + each(v.split(','), function(n) { + var c; + + if (di && di[n]) + return; - if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { - img = tinyMCE.selectedElement; - tinyMCE.imgElement = img; + // 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 (n) + tb.add(n); + }); + + return; } - if (img) { - // Is it a internal MCE visual aid image, then skip this one. - if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) - return true; + c = t.createControl(n, cf); - src = tinyMCE.getAttrib(img, 'src'); - alt = tinyMCE.getAttrib(img, 'alt'); + if (c) + tb.add(c); + }); + }, - // Try polling out the title - if (alt == "") - alt = tinyMCE.getAttrib(img, 'title'); + _addToolbars : function(c, o) { + var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = []; - // 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); + n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar', align : s.theme_advanced_toolbar_align}); + + if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus')) + h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '')); - var h = img.style.height; - if (h != null && h != "") - img.setAttribute("height", h); - } + h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '')); + + // Create toolbar and add the controls + for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { + tb = cf.createToolbar("toolbar" + i); - 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'); + if (s['theme_advanced_buttons' + i + '_add']) + v += ',' + s['theme_advanced_buttons' + i + '_add']; - // Is realy specified? - if (tinyMCE.isMSIE) { - width = img.attributes['width'].specified ? width : ""; - height = img.attributes['height'].specified ? height : ""; - } + if (s['theme_advanced_buttons' + i + '_add_before']) + v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; - //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); - //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); + t._addControls(v, tb, di); - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); + //n.appendChild(n = tb.render()); + h.push(tb.renderHTML()); - // Use mce_src if defined - mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); - if (mceRealSrc != "") { - src = mceRealSrc; + o.deltaHeight -= s.theme_advanced_row_height; + } - if (tinyMCE.getParam('convert_urls')) - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - } + h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '')); - //if (onmouseover != "") - // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); + n.innerHTML = h.join(''); + }, - //if (onmouseout != "") - // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); - - action = "update"; - } + _addStatusBar : function(tb, o) { + var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; - var template = new Array(); - - template['file'] = 'image.htm?src={$src}'; - template['width'] = 355; - template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); + n = DOM.add(tb, 'tr'); + n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); + n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' '); + DOM.add(n, 'a', {href : '#', accesskey : 'x'}); - // 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 (s.theme_advanced_resizing && !tinymce.isOldWebKit) { + DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'resize'}); - 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 true; + 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'); - case "forecolor": - var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm; - - TinyMCE_AdvancedTheme._hideMenus(editor_id); + if (!o) + return; - 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); + if (s.theme_advanced_resize_horizontal) + c.style.width = o.cw + 'px'; + + c.style.height = o.ch + 'px'; + DOM.get(ed.id + '_ifr').style.height = (parseInt(o.ch) + t.deltaHeight) + 'px'; + }); } - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); - - fcp.moveTo(p.absLeft, p.absTop); - fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor; - fcp.show(); - - return false; + ed.onPostRender.add(function() { + Event.add(ed.id + '_resize', 'mousedown', function(e) { + var c, p, w, h, n, pa; - case "forecolorpicker": - this._pickColor(editor_id, 'forecolor'); - return true; - - case "forecolorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); - - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_fcMenu'); + // Measure container + c = DOM.get(ed.id + '_tbl'); + w = c.clientWidth; + h = c.clientHeight; - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor')); - - tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl'); - - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); + miw = s.theme_advanced_resizing_min_width || 100; + mih = s.theme_advanced_resizing_min_height || 100; + maw = s.theme_advanced_resizing_max_width || 0xFFFF; + mah = s.theme_advanced_resizing_max_height || 0xFFFF; - if (tinyMCE.isOpera) - ml.moveBy(0, -2); + // Setup placeholder + p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'}); + DOM.setStyles(p, {width : w, height : h}); - ml.show(); - return true; - - case "HiliteColor": - var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img; - - TinyMCE_AdvancedTheme._hideMenus(editor_id); + // Replace with placeholder + DOM.hide(c); + DOM.show(p); - 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); - } + // Create internal resize obj + r = { + x : e.screenX, + y : e.screenY, + w : w, + h : h, + dx : null, + dy : null + }; - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); - - bcp.moveTo(p.absLeft, p.absTop); - bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor; - bcp.show(); - - return false; - - case "HiliteColorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); + // Start listening + mf = Event.add(document, 'mousemove', function(e) { + var w, h; - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_bcMenu'); - - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor')); - - tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl'); - - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); - - if (tinyMCE.isOpera) - ml.moveBy(0, -2); + // Calc delta values + r.dx = e.screenX - r.x; + r.dy = e.screenY - r.y; - ml.show(); - return true; - - case "backcolorpicker": - this._pickColor(editor_id, 'HiliteColor'); - return true; + // Boundery fix box + w = Math.max(miw, r.w + r.dx); + h = Math.max(mih, r.h + r.dy); + w = Math.min(maw, w); + h = Math.min(mah, h); - case "mceColorPicker": - if (user_interface) { - var template = []; - - if (!value['callback'] && !value['color']) - value['color'] = value['document'].getElementById(value['element_id']).value; + // Resize placeholder + if (s.theme_advanced_resize_horizontal) + p.style.width = w + 'px'; + + p.style.height = h + 'px'; + + return Event.cancel(e); + }); - template['file'] = 'color_picker.htm'; - template['width'] = 380; - template['height'] = 250; - template['close_previous'] = "no"; - - template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); + me = Event.add(document, 'mouseup', function(e) { + var ifr; - if (typeof(value['store_selection']) == "undefined") - value['store_selection'] = true; + // Stop listening + Event.remove(document, 'mousemove', mf); + Event.remove(document, 'mouseup', me); - 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; - - if (savedVal['callback']) { - savedVal['callback'](value); - return true; - } + c.style.display = ''; + DOM.remove(p); - elm = savedVal['document'].getElementById(savedVal['element_id']); - elm.value = value; + if (r.dx === null) + return; - if (elm.onchange != null && elm.onchange != '') - eval('elm.onchange();'); - } - return true; - - case "mceCodeEditor": - var template = new Array(); + ifr = DOM.get(ed.id + '_ifr'); - 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)); - - tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); - return true; + if (s.theme_advanced_resize_horizontal) + c.style.width = (r.w + r.dx) + 'px'; - case "mceCharMap": - var template = new Array(); - - template['file'] = 'charmap.htm'; - template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); - template['height'] = 250; + c.style.height = (r.h + r.dy) + 'px'; + ifr.style.height = (ifr.clientHeight + r.dy) + 'px'; - template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); - - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; - - case "mceInsertAnchor": - var template = new Array(); + if (s.theme_advanced_resizing_use_cookie) { + Cookie.setHash("TinyMCE_" + ed.id + "_size", { + cw : r.w + r.dx, + ch : r.h + r.dy + }); + } + }); - template['file'] = 'anchor.htm'; - template['width'] = 320; - template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); - - template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); + return Event.cancel(e); + }); + }); + } - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; - - case "mceNewDocument": - if (confirm(tinyMCE.getLang('lang_newdocument'))) - tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); + o.deltaHeight -= 21; + n = tb = null; + }, - return true; - } + _nodeChanged : function(ed, cm, n, co) { + var t = this, p, de = 0, v, c, s = t.settings; - return false; - }, + tinymce.each(t.stateControls, function(c) { + cm.setActive(c, ed.queryCommandState(t.controls[c][1])); + }); - /** - * 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 + ''; + if (c = cm.get('unlink')) { + c.setDisabled(!p && co); + c.setActive(!!p && !p.name); } - TinyMCE_AdvancedTheme._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" - }; - - // Add accessibility control - toolbarHTML += ' 0) { - toolbarHTML += "
"; - deltaHeight -= 23; - } - } - - // Add accessibility control - toolbarHTML += '
'; - - // Setup template html - template['html'] = ''; - - if (toolbarLocation == "top") - template['html'] += ''; - - if (statusbarLocation == "top") { - template['html'] += ''; - deltaHeight -= 23; - } - - template['html'] += ''; - - if (toolbarLocation == "bottom") - template['html'] += ''; - - // External toolbar changes - if (toolbarLocation == "external") { - var bod = document.body; - var elm = document.createElement ("div"); - - toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML); - toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId}); - - 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"]; - } else { - tinyMCE.getInstanceById(editorId).toolbarElement = null; - } - - if (statusbarLocation == "bottom") { - template['html'] += '' + statusbarHTML + ''; - deltaHeight -= 23; - } - - 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, ',')); - - for (var j=0; j 0) { - curContainerHTML += "
"; - deltaHeight -= 23; - } - - template['html'] += '
'; - } - } - - template['html'] += '
' + statusbarHTML + '
' + curContainerHTML + '
'; - //RowLayout - break; - - case "CustomLayout" : //User defined layout callback... - var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); - - if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") { - template = eval(customLayout + "(template);"); - } - break; - } - - if (resizing) - template['html'] += ''; - - template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); - - // Set to default values - if (!template['delta_width']) - template['delta_width'] = 0; - - if (!template['delta_height']) - template['delta_height'] = deltaHeight; - - return template; - }, - - 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"); - - TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true)); - } - } + if (c = cm.get('anchor')) { + c.setActive(!!p && p.name); - inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink'); - }, - - removeInstance : function(inst) { - new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); - new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); - }, - - hideInstance : function(inst) { - TinyMCE_AdvancedTheme._hideMenus(inst.editorId); - }, - - _handleMenuEvent : function(e) { - var te = tinyMCE.isMSIE ? window.event.srcElement : e.target; - tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId)); - - if (e.type == "click") - tinyMCE.execInstanceCommand(te._editor_id, te._command); - }, - - _hideMenus : function(id) { - var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu'); - - if (fcml.exists() && fcml.isVisible()) { - tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton'); - fcml.hide(); - } - - if (bcml.exists() && bcml.isVisible()) { - tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton'); - bcml.hide(); - } - }, - - /** - * Node change handler. - */ - handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) { - var alignNode, breakOut, classNode; - - function selectByValue(select_elm, value, first_index) { - first_index = typeof(first_index) == "undefined" ? false : true; - - if (select_elm) { - for (var i=0; i=0; i--) { - var nodeName = path[i].nodeName.toLowerCase(); - var nodeData = ""; - - if (nodeName.indexOf("html:") == 0) - nodeName = nodeName.substring(5); - - if (nodeName == "b") { - nodeName = "strong"; - } - - if (nodeName == "i") { - nodeName = "em"; - } - - if (nodeName == "span") { - var cn = tinyMCE.getAttrib(path[i], "class"); - if (cn != "" && cn.indexOf('mceItem') == -1) - nodeData += "class: " + cn + " "; - - var st = tinyMCE.getAttrib(path[i], "style"); - if (st != "") { - st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st)); - nodeData += "style: " + tinyMCE.xmlEncode(st) + " "; - } - } - - if (nodeName == "font") { - if (tinyMCE.getParam("convert_fonts_to_spans")) - nodeName = "span"; - - var face = tinyMCE.getAttrib(path[i], "face"); - if (face != "") - nodeData += "font: " + tinyMCE.xmlEncode(face) + " "; - - var size = tinyMCE.getAttrib(path[i], "size"); - if (size != "") - nodeData += "size: " + tinyMCE.xmlEncode(size) + " "; - - var color = tinyMCE.getAttrib(path[i], "color"); - if (color != "") - nodeData += "color: " + tinyMCE.xmlEncode(color) + " "; - } - - if (tinyMCE.getAttrib(path[i], 'id') != "") { - nodeData += "id: " + path[i].getAttribute('id') + " "; - } - - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) - nodeData += "class: " + className + " "; - - if (tinyMCE.getAttrib(path[i], 'src') != "") { - var src = tinyMCE.getAttrib(path[i], "mce_src"); - - if (src == "") - src = tinyMCE.getAttrib(path[i], "src"); - - nodeData += "src: " + tinyMCE.xmlEncode(src) + " "; - } - - if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") { - var href = tinyMCE.getAttrib(path[i], "mce_href"); - - if (href == "") - href = tinyMCE.getAttrib(path[i], "href"); - - nodeData += "href: " + tinyMCE.xmlEncode(href) + " "; - } - - 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'); - } - - if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { - nodeName = "a"; - nodeName += "#" + tinyMCE.xmlEncode(anchor); - nodeData = ""; - } - - 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; - } - } - - var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');'; - html += '' + nodeName + ''; - - if (i > 0) { - html += " » "; + if (tinymce.isWebKit) { + p = DOM.getParent(n, 'IMG'); + c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a'); } } - pathElm.innerHTML = '' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; - } + p = DOM.getParent(n, 'IMG'); + if (c = cm.get('image')) + c.setActive(!!p && n.className.indexOf('mceItem') == -1); + + if (c = cm.get('styleselect')) { + if (n.className) { + t._importClasses(); + c.select(n.className); + } else + c.select(); + } - // 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 (c = cm.get('formatselect')) { + p = DOM.getParent(n, DOM.isBlock); - if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1) - tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected'); + if (p) + c.select(p.nodeName.toLowerCase()); + } - // Get link - var anchorLink = tinyMCE.getParentElement(node, "a", "href"); + if (c = cm.get('fontselect')) + c.select(ed.queryCommandValue('FontName')); + + if (c = cm.get('fontsizeselect')) + c.select(ed.queryCommandValue('FontSize')); - if (anchorLink || any_selection) { - tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - } - - // Handle visual aid - tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal'); + 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'}); + p.innerHTML = ''; - if (undo_levels != -1) { - tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled'); - } + ed.dom.getParent(n, function(n) { + var na = n.nodeName.toLowerCase(), u, pi, ti = ''; - // Within li, blockquote - if (tinyMCE.getParentElement(node, "li,blockquote")) - tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal'); + // Ignore non element and hidden elements + if (n.nodeType != 1 || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved'))) + return; - // 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'); + // Fake name + if (v = DOM.getAttrib(n, 'mce_name')) + na = v; + + // Handle prefix + if (tinymce.isIE && n.scopeName !== 'HTML') + na = n.scopeName + ':' + na; - // Select class in select box - var selectElm = document.getElementById(editor_id + "_styleSelect"); - - if (selectElm) { - TinyMCE_AdvancedTheme._setupCSSClasses(editor_id); + // Remove internal prefix + na = na.replace(/mce\:/g, ''); - classNode = node; - breakOut = false; - var index = 0; + // Handle node name + switch (na) { + case 'b': + na = 'strong'; + break; - do { - if (classNode && classNode.className) { - for (var i=0; i"); - else - selectByValue(selectElm, ""); - } + if (v = DOM.getAttrib(n, 'href')) + ti += 'href: ' + v + ' '; - // Select fontselect - var selectElm = document.getElementById(editor_id + "_fontNameSelect"); - if (selectElm) { - if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) { - var face = inst.queryCommandValue('FontName'); + break; - face = face == null || face == "" ? "" : face; + case 'font': + if (s.convert_fonts_to_spans) + na = 'span'; - selectByValue(selectElm, face, face != ""); - } else { - var elm = tinyMCE.getParentElement(node, "font", "face"); + if (v = DOM.getAttrib(n, 'face')) + ti += 'font: ' + v + ' '; - if (elm) { - var family = tinyMCE.getAttrib(elm, "face"); + if (v = DOM.getAttrib(n, 'size')) + ti += 'size: ' + v + ' '; - if (family == '') - family = '' + elm.style.fontFamily; + if (v = DOM.getAttrib(n, 'color')) + ti += 'color: ' + v + ' '; - if (!selectByValue(selectElm, family, family != "")) - selectByValue(selectElm, ""); - } else - selectByValue(selectElm, ""); - } - } + break; + + case 'span': + if (v = DOM.getAttrib(n, 'style')) + ti += 'style: ' + v + ' '; - // 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); - } else { - var elm = tinyMCE.getParentElement(node, "font", "size"); - if (elm) { - var size = tinyMCE.getAttrib(elm, "size"); + break; + } + + if (v = DOM.getAttrib(n, 'id')) + ti += 'id: ' + v + ' '; - if (size == '') { - var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px'); - - size = '' + elm.style.fontSize; + if (v = n.className) { + v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, ''); - for (var i=0; i 0) - selectElm.setAttribute('cssImported', 'true'); - } - }, + _mceHelp : function() { + var ed = this.editor; - _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" : ""); + ed.windowManager.open({ + url : tinymce.baseURL + '/themes/advanced/about.htm', + width : 480, + height : 380, + inline : true + }, { + theme_url : this.url + }); + }, - document.cookie = curCookie; - }, + _mceColorPicker : function(u, v) { + var ed = this.editor; - _getCookie : function(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); - - if (begin == -1) { - begin = dc.indexOf(prefix); + v = v || {}; - 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)); - }, + ed.windowManager.open({ + url : tinymce.baseURL + '/themes/advanced/color_picker.htm', + width : 375 + Number(ed.getLang('advanced.colorpicker_delta_width', 0)), + height : 250 + Number(ed.getLang('advanced.colorpicker_delta_height', 0)), + close_previous : false, + inline : true + }, { + input_color : v.color, + func : v.func, + theme_url : this.url + }); + }, - _resizeTo : function(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); + _mceCodeEditor : function(ui, val) { + var ed = this.editor; - if (tinyMCE.isGecko) { - w += 2; - h += 2; - } - - var dx = w - tableElm.clientWidth; - var dy = h - tableElm.clientHeight; - - w = w < 1 ? 30 : w; - h = h < 1 ? 30 : h; - - if (set_w) - tableElm.style.width = w + "px"; - - tableElm.style.height = h + "px"; + ed.windowManager.open({ + url : tinymce.baseURL + '/themes/advanced/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 + }); + }, - iw = iframe.clientWidth + dx; - ih = iframe.clientHeight + dy; - - iw = iw < 1 ? 30 : iw; - ih = ih < 1 ? 30 : ih; + _mceImage : function(ui, val) { + var ed = this.editor; - if (tinyMCE.isGecko) { - iw -= 2; - ih -= 2; - } - - if (set_w) - iframe.style.width = iw + "px"; - - iframe.style.height = ih + "px"; + ed.windowManager.open({ + url : tinymce.baseURL + '/themes/advanced/image.htm', + width : 355 + Number(ed.getLang('advanced.image_delta_width', 0)), + height : 275 + Number(ed.getLang('advanced.image_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, - // 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"; - } - } + _mceLink : function(ui, val) { + var ed = this.editor; - // Remove pesky table controls - inst.useCSS = false; - }, + ed.windowManager.open({ + url : tinymce.baseURL + '/themes/advanced/link.htm', + width : 310 + Number(ed.getLang('advanced.link_delta_width', 0)), + height : 200 + Number(ed.getLang('advanced.link_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, - /** - * Handles resizing events. - */ - _resizeEventHandler : function(e) { - var resizer = TinyMCE_AdvancedTheme._resizer; - - // Do nothing - if (!resizer.resizing) - return; - - e = typeof(e) == "undefined" ? window.event : e; + _mceNewDocument : function() { + var ed = this.editor; - var dx = e.screenX - resizer.downX; - var dy = e.screenY - resizer.downY; - var resizeBox = resizer.resizeBox; - var editorId = resizer.editorId; - - switch (e.type) { - case "mousemove": - var w, h; + ed.windowManager.confirm('advanced.newdocument', function(s) { + if (s) + ed.execCommand('mceSetContent', false, ''); + }); + }, - w = resizer.width + dx; - h = resizer.height + dy; - - w = w < 1 ? 1 : w; - h = h < 1 ? 1 : h; - - if (resizer.horizontal) - resizeBox.style.width = w + "px"; + _mceForeColor : function() { + var t = this; - resizeBox.style.height = h + "px"; - break; - - case "mouseup": - TinyMCE_AdvancedTheme._setResizing(e, editorId, false); - TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal); + this._mceColorPicker(0, { + func : function(co) { + t.editor.execCommand('ForeColor', false, co); + } + }); + }, - // Expire in a month - if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { - var expires = new Date(); - expires.setTime(expires.getTime() + 3600000 * 24 * 30); + _mceBackColor : function() { + var t = this; - // 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); + this._mceColorPicker(0, { + func : function(co) { + t.editor.execCommand('HiliteColor', false, co); } - 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); - - tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler); - - resizer.eventHandlers = true; - } - - 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'); - } - }, - - _getColorHTML : function(id, n, cm) { - var i, h, cl; - - h = ''; - cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(','); - - h += ''; - for (i=0; i'; - - if ((i+1) % 8 == 0) - h += ''; - } - - 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('mceBeginUndoLevel'); - - if (src == "") - return; - - if (!tinyMCE.imgElement && tinyMCE.isSafari) { - var html = ""; - - html += '' + alt + ''; - - tinyMCE.execCommand("mceInsertContent", false, html); - } else { - if (!tinyMCE.imgElement && tinyMCE.selectedInstance) { - if (tinyMCE.isSafari) - tinyMCE.execCommand("mceInsertContent", false, ''); - else - tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); - - tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); - } - } - - if (tinyMCE.imgElement) { - var needsRepaint = false; - var msrc = src; + }); - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); - - if (tinyMCE.getParam('convert_urls')) - msrc = src; - - if (onmouseover && onmouseover != "") - onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; - - if (onmouseout && onmouseout != "") - onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; - - // Use alt as title if it's undefined - if (typeof(title) == "undefined") - title = alt; - - if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align")) - needsRepaint = true; - - tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src); - tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc); - tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt); - tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title); - tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align); - tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover); - tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout); - - // Fix for bug #989846 - Image resize bug - if (width && width != "") - tinyMCE.imgElement.style.pixelWidth = width; - - if (height && height != "") - tinyMCE.imgElement.style.pixelHeight = height; - - if (needsRepaint) - tinyMCE.selectedInstance.repaint(); - } - - tinyMCE.execCommand('mceEndUndoLevel'); - }, - - _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; - } - - var mhref = href; - var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; - - 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); - - if (newLink) { - linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true)); - tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement); - } - - return; - } - - 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); - - tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - for (var i=0; i