1 /* Import theme specific language pack */
2 tinyMCE.importThemeLanguagePack('advanced');
4 // Variable declarations
5 var TinyMCE_advanced_autoImportCSSClasses = true;
6 var TinyMCE_advanced_resizer = new Object();
7 var TinyMCE_advanced_buttons = [
8 // Control id, button img, button title, command, user_interface, value
9 ['bold', '{$lang_bold_img}', '{$lang_bold_desc}', 'Bold'],
10 ['italic', '{$lang_italic_img}', '{$lang_italic_desc}', 'Italic'],
11 ['underline', '{$lang_underline_img}', '{$lang_underline_desc}', 'Underline'],
12 ['strikethrough', 'strikethrough.gif', '{$lang_striketrough_desc}', 'Strikethrough'],
13 ['justifyleft', 'justifyleft.gif', '{$lang_justifyleft_desc}', 'JustifyLeft'],
14 ['justifycenter', 'justifycenter.gif', '{$lang_justifycenter_desc}', 'JustifyCenter'],
15 ['justifyright', 'justifyright.gif', '{$lang_justifyright_desc}', 'JustifyRight'],
16 ['justifyfull', 'justifyfull.gif', '{$lang_justifyfull_desc}', 'JustifyFull'],
17 ['bullist', 'bullist.gif', '{$lang_bullist_desc}', 'InsertUnorderedList'],
18 ['numlist', 'numlist.gif', '{$lang_numlist_desc}', 'InsertOrderedList'],
19 ['outdent', 'outdent.gif', '{$lang_outdent_desc}', 'Outdent'],
20 ['indent', 'indent.gif', '{$lang_indent_desc}', 'Indent'],
21 ['cut', 'cut.gif', '{$lang_cut_desc}', 'Cut'],
22 ['copy', 'copy.gif', '{$lang_copy_desc}', 'Copy'],
23 ['paste', 'paste.gif', '{$lang_paste_desc}', 'Paste'],
24 ['undo', 'undo.gif', '{$lang_undo_desc}', 'Undo'],
25 ['redo', 'redo.gif', '{$lang_redo_desc}', 'Redo'],
26 ['link', 'link.gif', '{$lang_link_desc}', 'mceLink', true],
27 ['unlink', 'unlink.gif', '{$lang_unlink_desc}', 'unlink'],
28 ['image', 'image.gif', '{$lang_image_desc}', 'mceImage', true],
29 ['cleanup', 'cleanup.gif', '{$lang_cleanup_desc}', 'mceCleanup'],
30 ['help', 'help.gif', '{$lang_help_desc}', 'mceHelp'],
31 ['code', 'code.gif', '{$lang_theme_code_desc}', 'mceCodeEditor'],
32 ['hr', 'hr.gif', '{$lang_theme_hr_desc}', 'inserthorizontalrule'],
33 ['removeformat', 'removeformat.gif', '{$lang_theme_removeformat_desc}', 'removeformat'],
34 ['sub', 'sub.gif', '{$lang_theme_sub_desc}', 'subscript'],
35 ['sup', 'sup.gif', '{$lang_theme_sup_desc}', 'superscript'],
36 ['forecolor', 'forecolor.gif', '{$lang_theme_forecolor_desc}', 'mceForeColor', true],
37 ['backcolor', 'backcolor.gif', '{$lang_theme_backcolor_desc}', 'mceBackColor', true],
38 ['charmap', 'charmap.gif', '{$lang_theme_charmap_desc}', 'mceCharMap'],
39 ['visualaid', 'visualaid.gif', '{$lang_theme_visualaid_desc}', 'mceToggleVisualAid'],
40 ['anchor', 'anchor.gif', '{$lang_theme_anchor_desc}', 'mceInsertAnchor'],
41 ['newdocument', 'newdocument.gif', '{$lang_newdocument_desc}', 'mceNewDocument']
45 * Returns HTML code for the specificed control.
47 function TinyMCE_advanced_getControlHTML(button_name)
49 var buttonTileMap = new Array('anchor.gif','backcolor.gif','bullist.gif','justifycenter.gif',
50 'charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif',
51 'cut.gif','forecolor.gif','justifyfull.gif','help.gif','hr.gif',
52 'image.gif','indent.gif','justifyleft.gif','link.gif','numlist.gif',
53 'outdent.gif','paste.gif','redo.gif','removeformat.gif',
54 'justifyright.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif',
55 'unlink.gif','visualaid.gif');
57 // Lookup button in button list
58 for (var i=0; i<TinyMCE_advanced_buttons.length; i++)
60 var but = TinyMCE_advanced_buttons[i];
62 if (but[0] == button_name)
64 // Check for it in tilemap
65 if (tinyMCE.settings['button_tile_map'])
67 for (var x=0; !tinyMCE.isMSIE && x<buttonTileMap.length; x++)
69 if (buttonTileMap[x] == but[1])
71 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\',' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ',\'' + but[5] + '\'' : '') + ')';
72 return '<a href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_' + but[0] +'" src="{$themeurl}/images/spacer.gif" style="background-image:url({$themeurl}/images/buttons.gif); background-position: ' + (0-(x*20)) + 'px 0px" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
78 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\',' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ',\'' + but[5] + '\'' : '') + ')';
79 return '<a href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_' + but[0] + '" src="{$themeurl}/images/' + but[1] + '" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
83 // Custom controlls other than buttons
87 var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
88 var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
90 ['p', '{$lang_theme_paragraph}'],
91 ['address', '{$lang_theme_address}'],
92 ['pre', '{$lang_theme_pre}'],
93 ['h1', '{$lang_theme_h1}'],
94 ['h2', '{$lang_theme_h2}'],
95 ['h3', '{$lang_theme_h3}'],
96 ['h4', '{$lang_theme_h4}'],
97 ['h5', '{$lang_theme_h5}'],
98 ['h6', '{$lang_theme_h6}']
101 html += '<option value="">{$lang_theme_block}</option>';
103 // Build format select
104 for (var i=0; i<formats.length; i++)
106 for (var x=0; x<lookup.length; x++)
108 if (formats[i] == lookup[x][0])
110 html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';
121 return '<select id="{$editor_id}_styleSelect" onmousedown="TinyMCE_advanced_setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
124 var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
125 var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
126 var nFonts = '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,sand;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';
127 var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
128 for (var i=0; i<fonts.length; i++) {
129 if (fonts[i] != '') {
130 var parts = fonts[i].split('=');
131 fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
135 fontHTML += '</select>';
138 case "fontsizeselect":
140 return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
141 <option value="0">{$lang_theme_font_size}</option>\
142 <option value="1">1 (8 pt)</option>\
143 <option value="2">2 (10 pt)</option>\
144 <option value="3">3 (12 pt)</option>\
145 <option value="4">4 (14 pt)</option>\
146 <option value="5">5 (18 pt)</option>\
147 <option value="6">6 (24 pt)</option>\
148 <option value="7">7 (36 pt)</option>\
153 return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';
156 return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
166 * Theme specific exec command handeling.
168 function TinyMCE_advanced_execCommand(editor_id, element, command, user_interface, value)
173 var template = new Array();
174 var elm = tinyMCE.selectedInstance.getFocusElement();
175 var inputColor = tinyMCE.getAttrib(elm, "color");
177 if (inputColor == '')
178 inputColor = elm.style.color;
181 inputColor = "#000000";
183 template['file'] = 'color_picker.htm';
184 template['width'] = 220;
185 template['height'] = 190;
187 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
191 var template = new Array();
192 var elm = tinyMCE.selectedInstance.getFocusElement();
193 var inputColor = elm.style.backgroundColor;
196 inputColor = "#000000";
198 template['file'] = 'color_picker.htm';
199 template['width'] = 220;
200 template['height'] = 190;
202 template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
203 template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
205 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
209 case "mceColorPicker":
210 if (user_interface) {
211 var template = new Array();
212 var inputColor = value['document'].getElementById(value['element_id']).value;
214 template['file'] = 'color_picker.htm';
215 template['width'] = 220;
216 template['height'] = 190;
217 template['close_previous'] = "no";
219 template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
220 template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);
222 if (typeof(value['store_selection']) == "undefined")
223 value['store_selection'] = true;
225 tinyMCE.lastColorPickerValue = value;
226 tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
228 var savedVal = tinyMCE.lastColorPickerValue;
229 var elm = savedVal['document'].getElementById(savedVal['element_id']);
231 eval('elm.onchange();');
235 case "mceCodeEditor":
236 var template = new Array();
238 template['file'] = 'source_editor.htm';
239 template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 500));
240 template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 400));
242 tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
247 var template = new Array();
249 template['file'] = 'charmap.htm';
250 template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
251 template['height'] = 250;
253 template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
254 template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);
256 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
260 case "mceInsertAnchor":
261 var template = new Array();
263 template['file'] = 'anchor.htm';
264 template['width'] = 320;
265 template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);
267 template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
268 template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);
270 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
273 case "mceNewDocument":
274 if (confirm(tinyMCE.getLang('lang_newdocument')))
275 tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, '');
285 * Editor instance template function.
287 function TinyMCE_advanced_getEditorTemplate(settings, editorId)
289 function removeFromArray(in_array, remove_array)
291 var outArray = new Array();
293 for (var i=0; i<in_array.length; i++)
297 for (var j=0; j<remove_array.length; j++)
299 if (in_array[i] == remove_array[j])
307 outArray[outArray.length] = in_array[i];
314 function addToArray(in_array, add_array)
316 for (var i=0; i<add_array.length; i++)
318 in_array[in_array.length] = add_array[i];
324 var template = new Array();
327 var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
328 var path = tinyMCE.getParam("theme_advanced_path", true);
329 var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '"> </div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
330 var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
332 // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
333 var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
334 if (settings['theme_advanced_styles']) {
335 var stylesAr = settings['theme_advanced_styles'].split(';');
337 for (var i=0; i<stylesAr.length; i++) {
340 key = stylesAr[i].split('=')[0];
341 value = stylesAr[i].split('=')[1];
343 styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
346 TinyMCE_advanced_autoImportCSSClasses = false;
349 switch(layoutManager) {
350 case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
351 var toolbarHTML = "";
352 var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
353 var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
354 var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity
355 var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
357 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
358 theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
359 theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
362 // Add accessibility control
363 toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"></a>';
366 for (var i=1; i<100; i++) {
367 var def = defVals["theme_advanced_buttons" + i];
369 var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
370 if (buttons.length == 0)
373 buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
374 buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
375 buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);
377 for (var b=0; b<buttons.length; b++)
378 toolbarHTML += tinyMCE.getControlHTML(buttons[b]);
380 if (buttons.length > 0) {
381 toolbarHTML += "<br />";
386 // Add accessibility control
387 toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
389 // Setup template html
390 template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
392 if (toolbarLocation == "top")
394 template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
397 if (statusbarLocation == "top")
399 template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
403 template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
405 if (toolbarLocation == "bottom")
407 template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
410 // External toolbar changes
411 if (toolbarLocation == "external")
413 var bod = document.body;
414 var elm = document.createElement ("div");
416 toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCE.settings);
417 toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCELang);
418 toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
419 toolbarHTML = tinyMCE.replaceVar(toolbarHTML, "editor_id", editorId);
420 toolbarHTML = tinyMCE.applyTemplate(toolbarHTML);
422 elm.className = "mceToolbarExternal";
423 elm.id = editorId+"_toolbar";
424 elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
425 bod.appendChild (elm);
426 // bod.style.marginTop = elm.offsetHeight + "px";
429 tinyMCE.getInstanceById(editorId).toolbarElement = elm;
431 //template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
435 tinyMCE.getInstanceById(editorId).toolbarElement = null;
438 if (statusbarLocation == "bottom")
440 template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
444 template['html'] += '</tbody></table>';
448 case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
449 template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
451 var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
452 var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
453 var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
456 for (var i = 0; i < containers.length; i++)
458 if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
460 template['html'] += '<tr><td align="center" class="mceEditor_border">\
461 <span id="{$editor_id}"></span>\
464 else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
466 var pathClass = "mceStatusbar";
468 if (i == containers.length-1)
470 pathClass = "mceStatusbarBottom";
474 pathClass = "mceStatusbar";
481 template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
484 else //Render normal Container:
486 var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
487 var curContainerHTML = "";
488 var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
489 var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
491 for (var j=0; j<curContainer.length; j++)
493 curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
496 if (curContainer.length > 0)
498 curContainerHTML += "<br />";
502 template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
506 template['html'] += '</tbody></table>';
510 case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java...
511 // Not implemented yet...
514 case "CustomLayout" : //User defined layout callback...
515 var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
517 if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined")
519 template = eval(customLayout + "(template);");
524 alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');
530 template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
532 template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
533 template['delta_width'] = 0;
534 template['delta_height'] = deltaHeight;
540 * Starts/stops the editor resizing.
542 function TinyMCE_advanced_setResizing(e, editor_id, state) {
543 e = typeof(e) == "undefined" ? window.event : e;
545 var resizer = TinyMCE_advanced_resizer;
546 var editorContainer = document.getElementById(editor_id + '_parent');
547 var editorArea = document.getElementById(editor_id + '_parent').firstChild;
548 var resizeBox = document.getElementById(editor_id + '_resize_box');
549 var inst = tinyMCE.getInstanceById(editor_id);
552 // Place box over editor area
553 var width = editorArea.clientWidth;
554 var height = editorArea.clientHeight;
556 resizeBox.style.width = width + "px";
557 resizeBox.style.height = height + "px";
559 resizer.iframeWidth = inst.iframeElement.clientWidth;
560 resizer.iframeHeight = inst.iframeElement.clientHeight;
562 // Hide editor and show resize box
563 editorArea.style.display = "none";
564 resizeBox.style.display = "block";
566 // Add event handlers, only once
567 if (!resizer.eventHandlers) {
569 tinyMCE.addEvent(document, "mousemove", TinyMCE_advanced_resizeEventHandler);
571 tinyMCE.addEvent(window, "mousemove", TinyMCE_advanced_resizeEventHandler);
573 tinyMCE.addEvent(document, "mouseup", TinyMCE_advanced_resizeEventHandler);
575 resizer.eventHandlers = true;
578 resizer.resizing = true;
579 resizer.downX = e.screenX;
580 resizer.downY = e.screenY;
581 resizer.width = parseInt(resizeBox.style.width);
582 resizer.height = parseInt(resizeBox.style.height);
583 resizer.editorId = editor_id;
584 resizer.resizeBox = resizeBox;
585 resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
587 resizer.resizing = false;
588 resizeBox.style.display = "none";
589 editorArea.style.display = tinyMCE.isMSIE ? "block" : "table";
590 tinyMCE.execCommand('mceResetDesignMode');
594 function TinyMCE_advanced_initInstance(inst) {
595 if (tinyMCE.getParam("theme_advanced_resizing", false)) {
596 if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
597 var w = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_width");
598 var h = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_height");
600 TinyMCE_advanced_resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
605 function TinyMCE_advanced_setCookie(name, value, expires, path, domain, secure) {
606 var curCookie = name + "=" + escape(value) +
607 ((expires) ? "; expires=" + expires.toGMTString() : "") +
608 ((path) ? "; path=" + escape(path) : "") +
609 ((domain) ? "; domain=" + domain : "") +
610 ((secure) ? "; secure" : "");
612 document.cookie = curCookie;
615 function TinyMCE_advanced_getCookie(name) {
616 var dc = document.cookie;
617 var prefix = name + "=";
618 var begin = dc.indexOf("; " + prefix);
621 begin = dc.indexOf(prefix);
628 var end = document.cookie.indexOf(";", begin);
633 return unescape(dc.substring(begin + prefix.length, end));
636 function TinyMCE_advanced_resizeTo(inst, w, h, set_w) {
637 var editorContainer = document.getElementById(inst.editorId + '_parent');
638 var tableElm = editorContainer.firstChild;
639 var iframe = inst.iframeElement;
641 if (w == null || w == "null") {
646 if (h == null || h == "null")
652 if (tinyMCE.isGecko) {
657 var dx = w - tableElm.clientWidth;
658 var dy = h - tableElm.clientHeight;
664 tableElm.style.width = w + "px";
666 tableElm.style.height = h + "px";
668 iw = iframe.clientWidth + dx;
669 ih = iframe.clientHeight + dy;
671 iw = iw < 1 ? 30 : iw;
672 ih = ih < 1 ? 30 : ih;
674 if (tinyMCE.isGecko) {
680 iframe.style.width = iw + "px";
682 iframe.style.height = ih + "px";
684 // Is it to small, make it bigger again
686 var tableBodyElm = tableElm.firstChild;
687 var minIframeWidth = tableBodyElm.scrollWidth;
688 if (inst.iframeElement.clientWidth < minIframeWidth) {
689 dx = minIframeWidth - inst.iframeElement.clientWidth;
691 inst.iframeElement.style.width = (iw + dx) + "px";
697 * Handles resizing events.
699 function TinyMCE_advanced_resizeEventHandler(e) {
700 var resizer = TinyMCE_advanced_resizer;
703 if (!resizer.resizing)
706 e = typeof(e) == "undefined" ? window.event : e;
708 var dx = e.screenX - resizer.downX;
709 var dy = e.screenY - resizer.downY;
710 var resizeBox = resizer.resizeBox;
711 var editorId = resizer.editorId;
717 w = resizer.width + dx;
718 h = resizer.height + dy;
723 if (resizer.horizontal)
724 resizeBox.style.width = w + "px";
726 resizeBox.style.height = h + "px";
730 TinyMCE_advanced_setResizing(e, editorId, false);
731 TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
734 if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
735 var expires = new Date();
736 expires.setTime(expires.getTime() + 3600000 * 24 * 30);
739 TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
740 TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
747 * Insert link template function.
749 function TinyMCE_advanced_getInsertLinkTemplate()
751 var template = new Array();
753 template['file'] = 'link.htm';
754 template['width'] = 330;
755 template['height'] = 170 + (tinyMCE.isMSIE ? 25 : 0);
757 // Language specific width and height addons
758 template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
759 template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
765 * Insert image template function.
767 function TinyMCE_advanced_getInsertImageTemplate() {
768 var template = new Array();
770 template['file'] = 'image.htm?src={$src}';
771 template['width'] = 340;
772 template['height'] = 250 + (tinyMCE.isMSIE ? 25 : 0);
774 // Language specific width and height addons
775 template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
776 template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
782 * Node change handler.
784 function TinyMCE_advanced_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
785 function selectByValue(select_elm, value, first_index) {
786 first_index = typeof(first_index) == "undefined" ? false : true;
789 for (var i=0; i<select_elm.options.length; i++) {
790 var ov = "" + select_elm.options[i].value;
792 if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
793 select_elm.selectedIndex = i;
798 select_elm.selectedIndex = i;
807 function getAttrib(elm, name) {
808 return elm.getAttribute(name) ? elm.getAttribute(name) : "";
818 var pathElm = document.getElementById(editor_id + "_path");
819 var inst = tinyMCE.getInstanceById(editor_id);
820 var doc = inst.getDoc();
824 var parentNode = node;
825 var path = new Array();
827 while (parentNode != null) {
828 if (parentNode.nodeName.toUpperCase() == "BODY") {
832 // Only append element nodes to path
833 if (parentNode.nodeType == 1) {
834 path[path.length] = parentNode;
837 parentNode = parentNode.parentNode;
842 for (var i=path.length-1; i>=0; i--) {
843 var nodeName = path[i].nodeName.toLowerCase();
846 if (nodeName == "b") {
850 if (nodeName == "i") {
854 if (nodeName == "span") {
855 var cn = tinyMCE.getAttrib(path[i], "class");
856 if (cn != "" && cn.indexOf('mceItem') == -1)
857 nodeData += "class: " + cn + " ";
859 var st = tinyMCE.getAttrib(path[i], "style");
861 st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st));
862 nodeData += "style: " + st + " ";
866 if (nodeName == "font") {
867 if (tinyMCE.getParam("convert_fonts_to_spans"))
870 var face = tinyMCE.getAttrib(path[i], "face");
872 nodeData += "font: " + face + " ";
874 var size = tinyMCE.getAttrib(path[i], "size");
876 nodeData += "size: " + size + " ";
878 var color = tinyMCE.getAttrib(path[i], "color");
880 nodeData += "color: " + color + " ";
883 if (getAttrib(path[i], 'id') != "") {
884 nodeData += "id: " + path[i].getAttribute('id') + " ";
887 var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
888 if (className != "" && className.indexOf('mceItem') == -1)
889 nodeData += "class: " + className + " ";
891 if (getAttrib(path[i], 'src') != "") {
892 var src = tinyMCE.getAttrib(path[i], "mce_src");
895 src = tinyMCE.getAttrib(path[i], "src");
897 nodeData += "src: " + src + " ";
900 if (getAttrib(path[i], 'href') != "") {
901 var href = tinyMCE.getAttrib(path[i], "mce_href");
904 href = tinyMCE.getAttrib(path[i], "href");
906 nodeData += "href: " + href + " ";
909 if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
911 nodeData = "src: " + path[i].getAttribute('title');
914 if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
916 nodeName += "#" + anchor;
920 if (getAttrib(path[i], 'name').indexOf("mce_") != 0) {
921 var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
922 if (className != "" && className.indexOf('mceItem') == -1) {
923 nodeName += "." + className;
927 var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');';
928 html += '<a title="' + nodeData + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" target="_self" class="mcePathItem">' + nodeName + '</a>';
935 pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' ';
939 tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonNormal');
940 tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonNormal');
941 tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonNormal');
942 tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonNormal');
943 tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonNormal');
944 tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonNormal');
945 tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonNormal');
946 tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonNormal');
947 tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonNormal');
948 tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonNormal');
949 tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonNormal');
950 tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonNormal');
951 tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonNormal');
952 tinyMCE.switchClassSticky(editor_id + '_link', 'mceButtonDisabled', true);
953 tinyMCE.switchClassSticky(editor_id + '_unlink', 'mceButtonDisabled', true);
954 tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonDisabled', true);
955 tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonNormal');
956 tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonNormal');
958 if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1)
959 tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonSelected');
962 var anchorLink = tinyMCE.getParentElement(node, "a", "href");
964 if (anchorLink || any_selection)
966 tinyMCE.switchClassSticky(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false);
967 tinyMCE.switchClassSticky(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false);
971 tinyMCE.switchClassSticky(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal', false);
973 if (undo_levels != -1)
975 tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonDisabled', true);
976 tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonDisabled', true);
979 // Within li, blockquote
980 if (tinyMCE.getParentElement(node, "li,blockquote"))
982 tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonNormal', false);
986 if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
988 tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonNormal', false);
992 if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
994 tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonNormal', false);
997 // Select class in select box
998 var selectElm = document.getElementById(editor_id + "_styleSelect");
1002 TinyMCE_advanced_setupCSSClasses(editor_id);
1010 if (classNode && classNode.className)
1012 for (var i=0; i<selectElm.options.length; i++)
1014 if (selectElm.options[i].value == classNode.className)
1022 } while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
1024 selectElm.selectedIndex = index;
1027 // Select formatblock
1028 var selectElm = document.getElementById(editor_id + "_formatSelect");
1030 var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
1033 selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
1035 selectByValue(selectElm, "");
1038 // Select fontselect
1039 var selectElm = document.getElementById(editor_id + "_fontNameSelect");
1041 if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) {
1042 var face = inst.queryCommandValue('FontName');
1044 face = face == null || face == "" ? "" : face;
1046 selectByValue(selectElm, face, face != "");
1048 var elm = tinyMCE.getParentElement(node, "font", "face");
1051 var family = tinyMCE.getAttrib(elm, "face");
1054 family = '' + elm.style.fontFamily;
1056 if (!selectByValue(selectElm, family, family != ""))
1057 selectByValue(selectElm, "");
1059 selectByValue(selectElm, "");
1064 var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
1066 if (!tinyMCE.isSafari && !tinyMCE.isOpera) {
1067 var size = inst.queryCommandValue('FontSize');
1068 selectByValue(selectElm, size == null || size == "" ? "0" : size);
1070 var elm = tinyMCE.getParentElement(node, "font", "size");
1072 var size = tinyMCE.getAttrib(elm, "size");
1075 var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px');
1077 size = '' + elm.style.fontSize;
1079 for (var i=0; i<sizes.length; i++) {
1080 if (('' + sizes[i]) == size) {
1087 if (!selectByValue(selectElm, size))
1088 selectByValue(selectElm, "");
1090 selectByValue(selectElm, "0");
1094 // Handle align attributes
1098 if (!alignNode.getAttribute || !alignNode.getAttribute('align')) {
1102 switch (alignNode.getAttribute('align').toLowerCase()) {
1104 tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonSelected');
1109 tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonSelected');
1115 tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonSelected');
1120 tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonSelected');
1124 } while (!breakOut && (alignNode = alignNode.parentNode) != null);
1126 // Div justification
1127 var div = tinyMCE.getParentElement(node, "div");
1128 if (div && div.style.textAlign == "center")
1129 tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonSelected');
1132 if (!setup_content) {
1133 // , "JustifyLeft", "_justifyleft", "JustifyCenter", "justifycenter", "JustifyRight", "justifyright", "JustifyFull", "justifyfull", "InsertUnorderedList", "bullist", "InsertOrderedList", "numlist", "InsertUnorderedList", "bullist", "Outdent", "outdent", "Indent", "indent", "subscript", "sub"
1134 var ar = new Array("Bold", "_bold", "Italic", "_italic", "Strikethrough", "_strikethrough", "superscript", "_sup", "subscript", "_sub");
1135 for (var i=0; i<ar.length; i+=2) {
1136 if (inst.queryCommandState(ar[i]))
1137 tinyMCE.switchClassSticky(editor_id + ar[i+1], 'mceButtonSelected');
1140 if (inst.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A")) {
1141 tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonSelected');
1147 switch (node.nodeName) {
1150 tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonSelected');
1155 tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonSelected');
1159 tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonSelected');
1163 tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonSelected');
1167 tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonSelected');
1171 tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonSelected');
1175 tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonSelected');
1179 if (getAttrib(node, 'name').indexOf('mce_') != 0) {
1180 tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonSelected');
1184 } while ((node = node.parentNode) != null);
1187 // This function auto imports CSS classes into the class selection droplist
1188 function TinyMCE_advanced_setupCSSClasses(editor_id) {
1189 if (!TinyMCE_advanced_autoImportCSSClasses) {
1193 var selectElm = document.getElementById(editor_id + '_styleSelect');
1195 if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
1196 var csses = tinyMCE.getCSSClasses(editor_id);
1197 if (csses && selectElm) {
1198 for (var i=0; i<csses.length; i++) {
1199 selectElm.options[selectElm.length] = new Option(csses[i], csses[i]);
1203 // Only do this once
1204 if (csses != null && csses.length > 0) {
1205 selectElm.setAttribute('cssImported', 'true');