2005-08-23 01:33:52 +00:00
/* Import theme specific language pack */
tinyMCE . importThemeLanguagePack ( 'advanced' ) ;
// Variable declarations
var TinyMCE _advanced _autoImportCSSClasses = true ;
var TinyMCE _advanced _resizer = new Object ( ) ;
var TinyMCE _advanced _buttons = [
// Control id, button img, button title, command, user_interface, value
[ 'bold' , '{$lang_bold_img}' , '{$lang_bold_desc}' , 'Bold' ] ,
[ 'italic' , '{$lang_italic_img}' , '{$lang_italic_desc}' , 'Italic' ] ,
[ 'underline' , '{$lang_underline_img}' , '{$lang_underline_desc}' , 'Underline' ] ,
[ 'strikethrough' , 'strikethrough.gif' , '{$lang_striketrough_desc}' , 'Strikethrough' ] ,
[ 'justifyleft' , 'left.gif' , '{$lang_justifyleft_desc}' , 'JustifyLeft' ] ,
[ 'justifycenter' , 'center.gif' , '{$lang_justifycenter_desc}' , 'JustifyCenter' ] ,
[ 'justifyright' , 'right.gif' , '{$lang_justifyright_desc}' , 'JustifyRight' ] ,
[ 'justifyfull' , 'full.gif' , '{$lang_justifyfull_desc}' , 'JustifyFull' ] ,
[ 'bullist' , 'bullist.gif' , '{$lang_bullist_desc}' , 'InsertUnorderedList' ] ,
[ 'numlist' , 'numlist.gif' , '{$lang_numlist_desc}' , 'InsertOrderedList' ] ,
[ 'outdent' , 'outdent.gif' , '{$lang_outdent_desc}' , 'Outdent' ] ,
[ 'indent' , 'indent.gif' , '{$lang_indent_desc}' , 'Indent' ] ,
[ 'cut' , 'cut.gif' , '{$lang_cut_desc}' , 'Cut' ] ,
[ 'copy' , 'copy.gif' , '{$lang_copy_desc}' , 'Copy' ] ,
[ 'paste' , 'paste.gif' , '{$lang_paste_desc}' , 'Paste' ] ,
[ 'undo' , 'undo.gif' , '{$lang_undo_desc}' , 'Undo' ] ,
[ 'redo' , 'redo.gif' , '{$lang_redo_desc}' , 'Redo' ] ,
[ 'link' , 'link.gif' , '{$lang_link_desc}' , 'mceLink' , true ] ,
[ 'unlink' , 'unlink.gif' , '{$lang_unlink_desc}' , 'unlink' ] ,
[ 'image' , 'image.gif' , '{$lang_image_desc}' , 'mceImage' , true ] ,
[ 'cleanup' , 'cleanup.gif' , '{$lang_cleanup_desc}' , 'mceCleanup' ] ,
[ 'help' , 'help.gif' , '{$lang_help_desc}' , 'mceHelp' ] ,
[ 'code' , 'code.gif' , '{$lang_theme_code_desc}' , 'mceCodeEditor' ] ,
[ 'hr' , 'hr.gif' , '{$lang_theme_hr_desc}' , 'inserthorizontalrule' ] ,
[ 'removeformat' , 'removeformat.gif' , '{$lang_theme_removeformat_desc}' , 'removeformat' ] ,
[ 'sub' , 'sub.gif' , '{$lang_theme_sub_desc}' , 'subscript' ] ,
[ 'sup' , 'sup.gif' , '{$lang_theme_sup_desc}' , 'superscript' ] ,
[ 'forecolor' , 'forecolor.gif' , '{$lang_theme_forecolor_desc}' , 'mceForeColor' , true ] ,
[ 'backcolor' , 'backcolor.gif' , '{$lang_theme_backcolor_desc}' , 'mceBackColor' , true ] ,
[ 'charmap' , 'charmap.gif' , '{$lang_theme_charmap_desc}' , 'mceCharMap' ] ,
[ 'visualaid' , 'visualaid.gif' , '{$lang_theme_visualaid_desc}' , 'mceToggleVisualAid' ] ,
[ 'anchor' , 'anchor.gif' , '{$lang_theme_anchor_desc}' , 'mceInsertAnchor' ] ,
[ 'newdocument' , 'newdocument.gif' , '{$lang_newdocument_desc}' , 'mceNewDocument' ]
] ;
/ * *
* Returns HTML code for the specificed control .
* /
function TinyMCE _advanced _getControlHTML ( button _name )
{
var buttonTileMap = new Array ( 'anchor.gif' , 'backcolor.gif' , 'bullist.gif' , 'center.gif' ,
'charmap.gif' , 'cleanup.gif' , 'code.gif' , 'copy.gif' , 'custom_1.gif' ,
'cut.gif' , 'forecolor.gif' , 'full.gif' , 'help.gif' , 'hr.gif' ,
'image.gif' , 'indent.gif' , 'left.gif' , 'link.gif' , 'numlist.gif' ,
'outdent.gif' , 'paste.gif' , 'redo.gif' , 'removeformat.gif' ,
'right.gif' , 'strikethrough.gif' , 'sub.gif' , 'sup.gif' , 'undo.gif' ,
'unlink.gif' , 'visualaid.gif' ) ;
// Lookup button in button list
for ( var i = 0 ; i < TinyMCE _advanced _buttons . length ; i ++ )
{
var but = TinyMCE _advanced _buttons [ i ] ;
if ( but [ 0 ] == button _name )
{
// Check for it in tilemap
if ( tinyMCE . settings [ 'button_tile_map' ] )
{
for ( var x = 0 ; ! tinyMCE . isMSIE && x < buttonTileMap . length ; x ++ )
{
if ( buttonTileMap [ x ] == but [ 1 ] )
{
2005-09-26 06:52:30 +00:00
return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but [ 3 ] + '\', ' + ( but . length > 4 ? but [ 4 ] : false ) + ( but . length > 5 ? ', \'' + but [ 5 ] + '\'' : '' ) + ')" onmousedown="return false;"><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>' ;
2005-08-23 01:33:52 +00:00
}
}
}
// Old style
2005-09-26 06:52:30 +00:00
return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but [ 3 ] + '\', ' + ( but . length > 4 ? but [ 4 ] : false ) + ( but . length > 5 ? ', \'' + but [ 5 ] + '\'' : '' ) + ')" onmousedown="return false;"><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>' ;
2005-08-23 01:33:52 +00:00
}
}
// Custom controlls other than buttons
switch ( button _name )
{
case "formatselect" :
2005-09-26 06:52:30 +00:00
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">' ;
2005-08-23 01:33:52 +00:00
var formats = tinyMCE . getParam ( "theme_advanced_blockformats" , "p,address,pre,h1,h2,h3,h4,h5,h6" , true ) . split ( ',' ) ;
var lookup = [
[ 'p' , '{$lang_theme_paragraph}' ] ,
[ 'address' , '{$lang_theme_address}' ] ,
[ 'pre' , '{$lang_theme_pre}' ] ,
[ 'h1' , '{$lang_theme_h1}' ] ,
[ 'h2' , '{$lang_theme_h2}' ] ,
[ 'h3' , '{$lang_theme_h3}' ] ,
[ 'h4' , '{$lang_theme_h4}' ] ,
[ 'h5' , '{$lang_theme_h5}' ] ,
[ 'h6' , '{$lang_theme_h6}' ]
] ;
html += '<option value="">{$lang_theme_block}</option>' ;
// Build format select
for ( var i = 0 ; i < formats . length ; i ++ )
{
for ( var x = 0 ; x < lookup . length ; x ++ )
{
if ( formats [ i ] == lookup [ x ] [ 0 ] )
{
html += '<option value="<' + lookup [ x ] [ 0 ] + '>">' + lookup [ x ] [ 1 ] + '</option>' ;
}
}
}
html += '</select>' ;
//formatselect
return html ;
case "styleselect" :
//styleselect
2005-09-26 06:52:30 +00:00
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>' ;
2005-08-23 01:33:52 +00:00
case "fontselect" :
2005-09-26 06:52:30 +00:00
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>' ;
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' ;
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' ;
var fonts = tinyMCE . getParam ( "theme_advanced_fonts" , nFonts ) . split ( ';' ) ;
for ( var i = 0 ; i < fonts . length ; i ++ ) {
if ( fonts [ i ] != '' ) {
var parts = fonts [ i ] . split ( '=' ) ;
fontHTML += '<option value="' + parts [ 1 ] + '">' + parts [ 0 ] + '</option>' ;
}
}
fontHTML += '</select>' ;
return fontHTML ;
2005-08-23 01:33:52 +00:00
case "fontsizeselect" :
//fontsizeselect
2005-09-26 06:52:30 +00:00
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 " > \
< option value = "0" > { $lang _theme _font _size } < / o p t i o n > \
2005-08-23 01:33:52 +00:00
< option value = "1" > 1 ( 8 pt ) < / o p t i o n > \
< option value = "2" > 2 ( 10 pt ) < / o p t i o n > \
< option value = "3" > 3 ( 12 pt ) < / o p t i o n > \
< option value = "4" > 4 ( 14 pt ) < / o p t i o n > \
< option value = "5" > 5 ( 18 pt ) < / o p t i o n > \
< option value = "6" > 6 ( 24 pt ) < / o p t i o n > \
< option value = "7" > 7 ( 36 pt ) < / o p t i o n > \
< / s e l e c t > ' ;
case "|" :
case "separator" :
return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">' ;
case "spacer" :
return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />' ;
case "rowseparator" :
return '<br />' ;
}
return "" ;
}
/ * *
* Theme specific exec command handeling .
* /
function TinyMCE _advanced _execCommand ( editor _id , element , command , user _interface , value )
{
switch ( command )
{
case "mceForeColor" :
var template = new Array ( ) ;
2005-09-26 06:52:30 +00:00
var elm = tinyMCE . selectedInstance . getFocusElement ( ) ;
var inputColor = tinyMCE . getAttrib ( elm , "color" ) ;
if ( inputColor == '' )
inputColor = elm . style . color ;
2005-08-23 01:33:52 +00:00
if ( ! inputColor )
inputColor = "#000000" ;
template [ 'file' ] = 'color_picker.htm' ;
template [ 'width' ] = 220 ;
2005-09-26 06:52:30 +00:00
template [ 'height' ] = 190 ;
2005-08-23 01:33:52 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , inline : "yes" , command : "forecolor" , input _color : inputColor } ) ;
return true ;
case "mceBackColor" :
var template = new Array ( ) ;
2005-09-26 06:52:30 +00:00
var elm = tinyMCE . selectedInstance . getFocusElement ( ) ;
var inputColor = elm . style . backgroundColor ;
2005-08-23 01:33:52 +00:00
if ( ! inputColor )
inputColor = "#000000" ;
template [ 'file' ] = 'color_picker.htm' ;
2005-09-26 06:52:30 +00:00
template [ 'width' ] = 220 ;
template [ 'height' ] = 190 ;
template [ 'width' ] += tinyMCE . getLang ( 'lang_theme_advanced_backcolor_delta_width' , 0 ) ;
template [ 'height' ] += tinyMCE . getLang ( 'lang_theme_advanced_backcolor_delta_height' , 0 ) ;
2005-08-23 01:33:52 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , inline : "yes" , command : "HiliteColor" , input _color : inputColor } ) ;
//mceBackColor
return true ;
case "mceColorPicker" :
if ( user _interface ) {
var template = new Array ( ) ;
var inputColor = value [ 'document' ] . getElementById ( value [ 'element_id' ] ) . value ;
template [ 'file' ] = 'color_picker.htm' ;
template [ 'width' ] = 220 ;
2005-09-26 06:52:30 +00:00
template [ 'height' ] = 190 ;
template [ 'width' ] += tinyMCE . getLang ( 'lang_theme_advanced_colorpicker_delta_width' , 0 ) ;
template [ 'height' ] += tinyMCE . getLang ( 'lang_theme_advanced_colorpicker_delta_height' , 0 ) ;
2005-08-23 01:33:52 +00:00
2005-08-23 01:37:34 +00:00
if ( typeof ( value [ 'store_selection' ] ) == "undefined" )
value [ 'store_selection' ] = true ;
2005-08-23 01:33:52 +00:00
tinyMCE . lastColorPickerValue = value ;
2005-08-23 01:37:34 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , mce _store _selection : value [ 'store_selection' ] , inline : "yes" , command : "mceColorPicker" , input _color : inputColor } ) ;
2005-08-23 01:33:52 +00:00
} else {
var savedVal = tinyMCE . lastColorPickerValue ;
2005-08-23 01:37:34 +00:00
var elm = savedVal [ 'document' ] . getElementById ( savedVal [ 'element_id' ] ) ;
elm . value = value ;
eval ( 'elm.onchange();' ) ;
2005-08-23 01:33:52 +00:00
}
return true ;
case "mceCodeEditor" :
var template = new Array ( ) ;
template [ 'file' ] = 'source_editor.htm' ;
2005-09-26 06:52:30 +00:00
template [ 'width' ] = parseInt ( tinyMCE . getParam ( "theme_advanced_source_editor_width" , 500 ) ) ;
template [ 'height' ] = parseInt ( tinyMCE . getParam ( "theme_advanced_source_editor_height" , 400 ) ) ;
2005-08-23 01:33:52 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , resizable : "yes" , scrollbars : "no" , inline : "yes" } ) ;
//mceCodeEditor
return true ;
case "mceCharMap" :
var template = new Array ( ) ;
template [ 'file' ] = 'charmap.htm' ;
template [ 'width' ] = 550 ;
2005-09-26 06:52:30 +00:00
template [ 'height' ] = 250 ;
template [ 'width' ] += tinyMCE . getLang ( 'lang_theme_advanced_charmap_delta_width' , 0 ) ;
template [ 'height' ] += tinyMCE . getLang ( 'lang_theme_advanced_charmap_delta_height' , 0 ) ;
2005-08-23 01:33:52 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , inline : "yes" } ) ;
//mceCharMap
return true ;
case "mceInsertAnchor" :
var template = new Array ( ) ;
template [ 'file' ] = 'anchor.htm' ;
template [ 'width' ] = 320 ;
2005-09-26 06:52:30 +00:00
template [ 'height' ] = 90 ;
template [ 'width' ] += tinyMCE . getLang ( 'lang_theme_advanced_anchor_delta_width' , 0 ) ;
template [ 'height' ] += tinyMCE . getLang ( 'lang_theme_advanced_anchor_delta_height' , 0 ) ;
2005-08-23 01:33:52 +00:00
2005-08-23 01:37:34 +00:00
tinyMCE . openWindow ( template , { editor _id : editor _id , inline : "yes" } ) ;
2005-08-23 01:33:52 +00:00
return true ;
case "mceNewDocument" :
if ( confirm ( tinyMCE . getLang ( 'lang_newdocument' ) ) )
tinyMCE . execInstanceCommand ( editor _id , 'mceSetContent' , false , '' ) ;
return true ;
}
// Default behavior
return false ;
}
/ * *
* Editor instance template function .
* /
function TinyMCE _advanced _getEditorTemplate ( settings , editorId )
{
function removeFromArray ( in _array , remove _array )
{
var outArray = new Array ( ) ;
for ( var i = 0 ; i < in _array . length ; i ++ )
{
skip = false ;
for ( var j = 0 ; j < remove _array . length ; j ++ )
{
if ( in _array [ i ] == remove _array [ j ] )
{
skip = true ;
}
}
if ( ! skip )
{
outArray [ outArray . length ] = in _array [ i ] ;
}
}
return outArray ;
}
function addToArray ( in _array , add _array )
{
for ( var i = 0 ; i < add _array . length ; i ++ )
{
in _array [ in _array . length ] = add _array [ i ] ;
}
return in _array ;
}
var template = new Array ( ) ;
var deltaHeight = 0 ;
var resizing = tinyMCE . getParam ( "theme_advanced_resizing" , false ) ;
var path = tinyMCE . getParam ( "theme_advanced_path" , true ) ;
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" />' ;
var layoutManager = tinyMCE . getParam ( "theme_advanced_layout_manager" , "SimpleLayout" ) ;
// Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>' ;
if ( settings [ 'theme_advanced_styles' ] )
{
var stylesAr = settings [ 'theme_advanced_styles' ] . split ( ';' ) ;
for ( var i = 0 ; i < stylesAr . length ; i ++ )
{
var key , value ;
key = stylesAr [ i ] . split ( '=' ) [ 0 ] ;
value = stylesAr [ i ] . split ( '=' ) [ 1 ] ;
styleSelectHTML += '<option value="' + value + '">' + key + '</option>' ;
}
TinyMCE _advanced _autoImportCSSClasses = false ;
}
switch ( layoutManager )
{
case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
var toolbarHTML = "" ;
var toolbarLocation = tinyMCE . getParam ( "theme_advanced_toolbar_location" , "bottom" ) ;
var toolbarAlign = tinyMCE . getParam ( "theme_advanced_toolbar_align" , "center" ) ;
var pathLocation = tinyMCE . getParam ( "theme_advanced_path_location" , "none" ) ; // Compatiblity
var statusbarLocation = tinyMCE . getParam ( "theme_advanced_statusbar_location" , pathLocation ) ;
2005-08-23 01:37:34 +00:00
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"
} ;
// Render rows
for ( var i = 1 ; i < 100 ; i ++ ) {
var def = defVals [ "theme_advanced_buttons" + i ] ;
buttons = tinyMCE . getParam ( "theme_advanced_buttons" + i , def == null ? '' : def , true , ',' ) ;
if ( buttons . length == 0 )
break ;
buttons = removeFromArray ( buttons , tinyMCE . getParam ( "theme_advanced_disable" , "" , true , ',' ) ) ;
buttons = addToArray ( buttons , tinyMCE . getParam ( "theme_advanced_buttons" + i + "_add" , "" , true , ',' ) ) ;
buttons = addToArray ( tinyMCE . getParam ( "theme_advanced_buttons" + i + "_add_before" , "" , true , ',' ) , buttons ) ;
for ( var b = 0 ; b < buttons . length ; b ++ )
toolbarHTML += tinyMCE . getControlHTML ( buttons [ b ] ) ;
if ( buttons . length > 0 ) {
toolbarHTML += "<br />" ;
deltaHeight -= 23 ;
}
2005-08-23 01:33:52 +00:00
}
// Setup template html
2005-08-23 01:37:34 +00:00
template [ 'html' ] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>' ;
2005-08-23 01:33:52 +00:00
if ( toolbarLocation == "top" )
{
template [ 'html' ] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>' ;
}
if ( statusbarLocation == "top" )
{
template [ 'html' ] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>' ;
deltaHeight -= 23 ;
}
template [ 'html' ] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>' ;
if ( toolbarLocation == "bottom" )
{
template [ 'html' ] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>' ;
}
2005-08-23 01:37:34 +00:00
2005-08-23 01:33:52 +00:00
// External toolbar changes
if ( toolbarLocation == "external" )
{
var bod = document . body ;
var elm = document . createElement ( "div" ) ;
toolbarHTML = tinyMCE . replaceVars ( toolbarHTML , tinyMCE . settings ) ;
toolbarHTML = tinyMCE . replaceVars ( toolbarHTML , tinyMCELang ) ;
toolbarHTML = tinyMCE . replaceVar ( toolbarHTML , 'style_select_options' , styleSelectHTML ) ;
toolbarHTML = tinyMCE . replaceVar ( toolbarHTML , "editor_id" , editorId ) ;
2005-08-23 01:37:34 +00:00
toolbarHTML = tinyMCE . applyTemplate ( toolbarHTML ) ;
2005-08-23 01:33:52 +00:00
elm . className = "mceToolbarExternal" ;
2005-08-23 01:37:34 +00:00
elm . id = editorId + "_toolbar" ;
2005-08-23 01:33:52 +00:00
elm . innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">' + toolbarHTML + '</td></tr></table>' ;
bod . appendChild ( elm ) ;
2005-08-23 01:37:34 +00:00
// bod.style.marginTop = elm.offsetHeight + "px";
deltaHeight = 0 ;
tinyMCE . getInstanceById ( editorId ) . toolbarElement = elm ;
2005-08-23 01:33:52 +00:00
//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"];
}
else
{
2005-08-23 01:37:34 +00:00
tinyMCE . getInstanceById ( editorId ) . toolbarElement = null ;
2005-08-23 01:33:52 +00:00
}
if ( statusbarLocation == "bottom" )
{
template [ 'html' ] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>' ;
deltaHeight -= 23 ;
}
template [ 'html' ] += '</table>' ;
//"SimpleLayout"
break ;
case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
2005-08-23 01:37:34 +00:00
template [ 'html' ] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>' ;
2005-08-23 01:33:52 +00:00
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' ] += ' < tr > < td align = "center" class = "mceEditor_border" > \
< span id = "{$editor_id}" > < / s p a n > \
< / t d > < / t r > ' ;
}
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' ] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>' ;
deltaHeight -= 22 ;
}
else //Render normal Container:
{
var curContainer = tinyMCE . getParam ( "theme_advanced_container_" + containers [ i ] , "" , true , ',' ) ;
var curContainerHTML = "" ;
var curAlign = tinyMCE . getParam ( "theme_advanced_container_" + containers [ i ] + "_align" , defaultContainerAlign ) ;
var curCSS = tinyMCE . getParam ( "theme_advanced_container_" + containers [ i ] + "_class" , defaultContainerCSS ) ;
for ( var j = 0 ; j < curContainer . length ; j ++ )
{
curContainerHTML += tinyMCE . getControlHTML ( curContainer [ j ] ) ;
}
if ( curContainer . length > 0 )
{
curContainerHTML += "<br />" ;
deltaHeight -= 23 ;
}
template [ 'html' ] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>' ;
}
}
template [ 'html' ] += '</tbody></table>' ;
//RowLayout
break ;
case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java...
// Not implemented yet...
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 ;
default :
alert ( 'UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!' ) ;
//CustomLayout
break ;
}
template [ 'html' ] += '<div id="{$editor_id}_resize_box" class="mceResizeBox"></div>' ;
template [ 'html' ] = tinyMCE . replaceVar ( template [ 'html' ] , 'style_select_options' , styleSelectHTML ) ;
template [ 'delta_width' ] = 0 ;
template [ 'delta_height' ] = deltaHeight ;
return template ;
}
/ * *
* Starts / stops the editor resizing .
* /
function TinyMCE _advanced _setResizing ( e , editor _id , state ) {
e = typeof ( e ) == "undefined" ? window . event : e ;
var resizer = TinyMCE _advanced _resizer ;
var editorContainer = document . getElementById ( editor _id + '_parent' ) ;
var editorArea = document . getElementById ( editor _id + '_parent' ) . firstChild ;
var resizeBox = document . getElementById ( editor _id + '_resize_box' ) ;
var inst = tinyMCE . getInstanceById ( editor _id ) ;
if ( state ) {
// Place box over editor area
var width = editorArea . clientWidth ;
var height = editorArea . clientHeight ;
resizeBox . style . width = width + "px" ;
resizeBox . style . height = height + "px" ;
resizer . iframeWidth = inst . iframeElement . clientWidth ;
resizer . iframeHeight = inst . iframeElement . clientHeight ;
// Hide editor and show resize box
editorArea . style . display = "none" ;
resizeBox . style . display = "block" ;
// Add event handlers, only once
if ( ! resizer . eventHandlers ) {
if ( tinyMCE . isMSIE )
tinyMCE . addEvent ( document , "mousemove" , TinyMCE _advanced _resizeEventHandler ) ;
else
tinyMCE . addEvent ( window , "mousemove" , TinyMCE _advanced _resizeEventHandler ) ;
tinyMCE . addEvent ( document , "mouseup" , TinyMCE _advanced _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 ;
2005-08-23 01:37:34 +00:00
resizer . horizontal = tinyMCE . getParam ( "theme_advanced_resize_horizontal" , true ) ;
2005-08-23 01:33:52 +00:00
} else {
resizer . resizing = false ;
resizeBox . style . display = "none" ;
2005-08-23 01:37:34 +00:00
editorArea . style . display = tinyMCE . isMSIE ? "block" : "table" ;
tinyMCE . execCommand ( 'mceResetDesignMode' ) ;
}
}
function TinyMCE _advanced _initInstance ( inst ) {
2005-09-26 06:52:30 +00:00
if ( tinyMCE . getParam ( "theme_advanced_resizing" , false ) ) {
var w = TinyMCE _advanced _getCookie ( "TinyMCE_" + inst . editorId + "_width" ) ;
var h = TinyMCE _advanced _getCookie ( "TinyMCE_" + inst . editorId + "_height" ) ;
2005-08-23 01:37:34 +00:00
2005-09-26 06:52:30 +00:00
TinyMCE _advanced _resizeTo ( inst , w , h , tinyMCE . getParam ( "theme_advanced_resize_horizontal" , true ) ) ;
}
2005-08-23 01:37:34 +00:00
}
function TinyMCE _advanced _setCookie ( name , value , expires , path , domain , secure ) {
var curCookie = name + "=" + escape ( value ) +
( ( expires ) ? "; expires=" + expires . toGMTString ( ) : "" ) +
( ( path ) ? "; path=" + escape ( path ) : "" ) +
( ( domain ) ? "; domain=" + domain : "" ) +
( ( secure ) ? "; secure" : "" ) ;
document . cookie = curCookie ;
}
function TinyMCE _advanced _getCookie ( name ) {
var dc = document . cookie ;
var prefix = name + "=" ;
var begin = dc . indexOf ( "; " + prefix ) ;
if ( begin == - 1 ) {
begin = dc . indexOf ( prefix ) ;
if ( begin != 0 )
return null ;
} else
begin += 2 ;
var end = document . cookie . indexOf ( ";" , begin ) ;
if ( end == - 1 )
end = dc . length ;
return unescape ( dc . substring ( begin + prefix . length , end ) ) ;
}
function TinyMCE _advanced _resizeTo ( inst , w , h , set _w ) {
var editorContainer = document . getElementById ( inst . editorId + '_parent' ) ;
var tableElm = editorContainer . firstChild ;
var iframe = inst . iframeElement ;
if ( w == null || w == "null" ) {
set _w = false ;
w = 0 ;
}
if ( h == null || h == "null" )
return ;
w = parseInt ( w ) ;
h = parseInt ( h ) ;
if ( tinyMCE . isGecko ) {
w += 2 ;
h += 2 ;
}
var dx = w - tableElm . clientWidth ;
var dy = h - tableElm . clientHeight ;
if ( set _w )
tableElm . style . width = w + "px" ;
tableElm . style . height = h + "px" ;
iw = iframe . clientWidth + dx ;
ih = iframe . clientHeight + dy ;
if ( tinyMCE . isGecko ) {
iw -= 2 ;
ih -= 2 ;
}
if ( set _w )
iframe . style . width = iw + "px" ;
iframe . style . height = ih + "px" ;
// Is it to small, make it bigger again
if ( set _w ) {
var tableBodyElm = tableElm . firstChild ;
var minIframeWidth = tableBodyElm . scrollWidth ;
if ( inst . iframeElement . clientWidth < minIframeWidth ) {
dx = minIframeWidth - inst . iframeElement . clientWidth ;
inst . iframeElement . style . width = ( iw + dx ) + "px" ;
}
2005-08-23 01:33:52 +00:00
}
}
/ * *
* Handles resizing events .
* /
function TinyMCE _advanced _resizeEventHandler ( e ) {
var resizer = TinyMCE _advanced _resizer ;
// Do nothing
if ( ! resizer . resizing )
return ;
e = typeof ( e ) == "undefined" ? window . event : e ;
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" :
if ( resizer . horizontal )
resizeBox . style . width = ( resizer . width + dx ) + "px" ;
resizeBox . style . height = ( resizer . height + dy ) + "px" ;
break ;
case "mouseup" :
TinyMCE _advanced _setResizing ( e , editorId , false ) ;
2005-08-23 01:37:34 +00:00
TinyMCE _advanced _resizeTo ( tinyMCE . getInstanceById ( editorId ) , resizer . width + dx , resizer . height + dy , resizer . horizontal ) ;
2005-08-23 01:33:52 +00:00
2005-08-23 01:37:34 +00:00
// Expire in a month
var expires = new Date ( ) ;
expires . setTime ( expires . getTime ( ) + 3600000 * 24 * 30 ) ;
2005-08-23 01:33:52 +00:00
2005-08-23 01:37:34 +00:00
// Set the cookies
TinyMCE _advanced _setCookie ( "TinyMCE_" + editorId + "_width" , "" + ( resizer . horizontal ? resizer . width + dx : "" ) , expires ) ;
TinyMCE _advanced _setCookie ( "TinyMCE_" + editorId + "_height" , "" + ( resizer . height + dy ) , expires ) ;
2005-08-23 01:33:52 +00:00
break ;
}
}
/ * *
* Insert link template function .
* /
function TinyMCE _advanced _getInsertLinkTemplate ( )
{
var template = new Array ( ) ;
template [ 'file' ] = 'link.htm' ;
2005-09-26 06:52:30 +00:00
template [ 'width' ] = 330 ;
template [ 'height' ] = 170 ;
2005-08-23 01:33:52 +00:00
// 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 ) ;
return template ;
} ;
/ * *
* Insert image template function .
* /
function TinyMCE _advanced _getInsertImageTemplate ( )
{
var template = new Array ( ) ;
template [ 'file' ] = 'image.htm?src={$src}' ;
template [ 'width' ] = 340 ;
2005-09-26 06:52:30 +00:00
template [ 'height' ] = 245 ;
2005-08-23 01:33:52 +00:00
// 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 ) ;
return template ;
} ;
/ * *
* Node change handler .
* /
function TinyMCE _advanced _handleNodeChange ( editor _id , node , undo _index ,
undo _levels , visual _aid , any _selection )
{
function selectByValue ( select _elm , value )
{
if ( select _elm )
{
for ( var i = 0 ; i < select _elm . options . length ; i ++ )
{
if ( select _elm . options [ i ] . value == value )
{
select _elm . selectedIndex = i ;
return true ;
}
}
}
return false ;
} ;
function getAttrib ( elm , name )
{
return elm . getAttribute ( name ) ? elm . getAttribute ( name ) : "" ;
} ;
// No node provided
if ( node == null )
{
return ;
}
// Update path
var pathElm = document . getElementById ( editor _id + "_path" ) ;
if ( pathElm )
{
// Get node path
var parentNode = node ;
var path = new Array ( ) ;
while ( parentNode )
{
if ( parentNode . nodeName . toLowerCase ( ) == "body" )
{
break ;
}
// Only append element nodes to path
if ( parentNode . nodeType == 1 )
{
path [ path . length ] = parentNode ;
}
parentNode = parentNode . parentNode ;
}
// Setup HTML
var html = "" ;
for ( var i = path . length - 1 ; i >= 0 ; i -- )
{
var nodeName = path [ i ] . nodeName . toLowerCase ( ) ;
var nodeData = "" ;
if ( nodeName == "b" )
{
nodeName = "strong" ;
}
if ( nodeName == "i" )
{
nodeName = "em" ;
}
if ( getAttrib ( path [ i ] , 'id' ) != "" )
{
nodeData += "id: " + path [ i ] . getAttribute ( 'id' ) + " " ;
}
2005-09-26 06:52:30 +00:00
var className = tinyMCE . getVisualAidClass ( tinyMCE . getAttrib ( path [ i ] , "class" ) , false ) ;
2005-08-23 01:37:34 +00:00
if ( className != "" && className . indexOf ( 'mceItem' ) == - 1 )
2005-08-23 01:33:52 +00:00
nodeData += "class: " + className + " " ;
if ( getAttrib ( path [ i ] , 'src' ) != "" )
{
nodeData += "src: " + path [ i ] . getAttribute ( 'src' ) + " " ;
}
if ( getAttrib ( path [ i ] , 'href' ) != "" )
{
nodeData += "href: " + path [ i ] . getAttribute ( 'href' ) + " " ;
}
2005-08-23 01:37:34 +00:00
if ( nodeName == "img" && tinyMCE . getAttrib ( path [ i ] , "class" ) . indexOf ( 'mceItemFlash' ) != - 1 )
2005-08-23 01:33:52 +00:00
{
nodeName = "flash" ;
nodeData = "" ;
}
2005-08-23 01:37:34 +00:00
if ( nodeName == "a" && ( anchor = tinyMCE . getAttrib ( path [ i ] , "name" ) ) != "" )
{
nodeName = "a" ;
nodeName += "#" + anchor ;
nodeData = "" ;
}
2005-08-23 01:33:52 +00:00
if ( getAttrib ( path [ i ] , 'name' ) . indexOf ( "mce_" ) != 0 )
{
2005-09-26 06:52:30 +00:00
var className = tinyMCE . getVisualAidClass ( tinyMCE . getAttrib ( path [ i ] , "class" ) , false ) ;
2005-08-23 01:37:34 +00:00
if ( className != "" && className . indexOf ( 'mceItem' ) == - 1 )
2005-08-23 01:33:52 +00:00
nodeName += "." + className ;
}
if ( tinyMCE . isMSIE )
{
html += '<a title="' + nodeData + '" href="javascript:void(0);" onmousedown="tinyMCE.execInstanceCommand(\'' + editor _id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');return false;" class="mcePathItem">' + nodeName + '</a>' ;
}
else
{
html += '<a title="' + nodeData + '" href="javascript:tinyMCE.execInstanceCommand(\'' + editor _id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');" class="mcePathItem">' + nodeName + '</a>' ;
}
if ( i > 0 )
{
html += " » " ;
}
}
2005-08-23 01:37:34 +00:00
pathElm . innerHTML = tinyMCE . getLang ( 'lang_theme_path' ) + ": " + html + ' ' ;
2005-08-23 01:33:52 +00:00
}
// Reset old states
tinyMCE . switchClassSticky ( editor _id + '_justifyleft' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_justifyright' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_justifycenter' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_justifyfull' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_bold' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_italic' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_underline' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_strikethrough' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_bullist' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_numlist' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_sub' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_sup' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_anchor' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_link' , 'mceButtonDisabled' , true ) ;
tinyMCE . switchClassSticky ( editor _id + '_unlink' , 'mceButtonDisabled' , true ) ;
tinyMCE . switchClassSticky ( editor _id + '_outdent' , 'mceButtonDisabled' , true ) ;
2005-08-23 01:37:34 +00:00
tinyMCE . switchClassSticky ( editor _id + '_image' , 'mceButtonNormal' ) ;
tinyMCE . switchClassSticky ( editor _id + '_hr' , 'mceButtonNormal' ) ;
2005-08-23 01:33:52 +00:00
2005-09-26 06:52:30 +00:00
if ( node . nodeName == "A" && tinyMCE . getAttrib ( node , "class" ) . indexOf ( 'mceItemAnchor' ) != - 1 )
2005-08-23 01:33:52 +00:00
tinyMCE . switchClassSticky ( editor _id + '_anchor' , 'mceButtonSelected' ) ;
// Get link
var anchorLink = tinyMCE . getParentElement ( node , "a" , "href" ) ;
2005-08-23 01:37:34 +00:00
2005-08-23 01:33:52 +00:00
if ( anchorLink || any _selection )
{
tinyMCE . switchClassSticky ( editor _id + '_link' , anchorLink ? 'mceButtonSelected' : 'mceButtonNormal' , false ) ;
tinyMCE . switchClassSticky ( editor _id + '_unlink' , anchorLink ? 'mceButtonSelected' : 'mceButtonNormal' , false ) ;
}
// Handle visual aid
tinyMCE . switchClassSticky ( editor _id + '_visualaid' , visual _aid ? 'mceButtonSelected' : 'mceButtonNormal' , false ) ;
if ( undo _levels != - 1 )
{
tinyMCE . switchClassSticky ( editor _id + '_undo' , 'mceButtonDisabled' , true ) ;
tinyMCE . switchClassSticky ( editor _id + '_redo' , 'mceButtonDisabled' , true ) ;
}
// Within li, blockquote
if ( tinyMCE . getParentElement ( node , "li,blockquote" ) )
{
tinyMCE . switchClassSticky ( editor _id + '_outdent' , 'mceButtonNormal' , false ) ;
}
// Has redo levels
if ( undo _index != - 1 && ( undo _index < undo _levels - 1 && undo _levels > 0 ) )
{
tinyMCE . switchClassSticky ( editor _id + '_redo' , 'mceButtonNormal' , false ) ;
}
// Has undo levels
if ( undo _index != - 1 && ( undo _index > 0 && undo _levels > 0 ) )
{
tinyMCE . switchClassSticky ( editor _id + '_undo' , 'mceButtonNormal' , false ) ;
}
// Select class in select box
var selectElm = document . getElementById ( editor _id + "_styleSelect" ) ;
if ( selectElm )
{
TinyMCE _advanced _setupCSSClasses ( editor _id ) ;
classNode = node ;
breakOut = false ;
var index = 0 ;
do
{
if ( classNode && classNode . className )
{
for ( var i = 0 ; i < selectElm . options . length ; i ++ )
{
if ( selectElm . options [ i ] . value == classNode . className )
{
index = i ;
breakOut = true ;
break ;
}
}
}
} while ( ! breakOut && classNode != null && ( classNode = classNode . parentNode ) ) ;
selectElm . selectedIndex = index ;
}
// Select formatblock
var selectElm = document . getElementById ( editor _id + "_formatSelect" ) ;
if ( selectElm )
{
var elm = tinyMCE . getParentElement ( node , "p,div,h1,h2,h3,h4,h5,h6,pre,address" ) ;
if ( elm )
{
selectByValue ( selectElm , "<" + elm . nodeName . toLowerCase ( ) + ">" ) ;
}
else
{
selectByValue ( selectElm , "" ) ;
}
}
// Select fontselect
var selectElm = document . getElementById ( editor _id + "_fontNameSelect" ) ;
2005-09-26 06:52:30 +00:00
if ( selectElm ) {
var elm = tinyMCE . getParentElement ( node ) ;
if ( elm ) {
var family = tinyMCE . getAttrib ( elm , "face" ) ;
if ( family == '' )
family = '' + elm . style . fontFamily ;
if ( ! selectByValue ( selectElm , family ) )
selectByValue ( selectElm , "" ) ;
} else
2005-08-23 01:33:52 +00:00
selectByValue ( selectElm , "" ) ;
}
// Select fontsize
var selectElm = document . getElementById ( editor _id + "_fontSizeSelect" ) ;
2005-09-26 06:52:30 +00:00
if ( selectElm ) {
var elm = tinyMCE . getParentElement ( node ) ;
2005-08-23 01:33:52 +00:00
2005-09-26 06:52:30 +00:00
if ( elm ) {
var size = tinyMCE . getAttrib ( elm , "size" ) ;
if ( size == '' ) {
var sizes = new Array ( '' , '8px' , '10px' , '12px' , '14px' , '18px' , '24px' , '36px' ) ;
size = '' + elm . style . fontSize ;
for ( var i = 0 ; i < sizes . length ; i ++ ) {
if ( ( '' + sizes [ i ] ) == size ) {
size = i ;
break ;
}
}
}
if ( ! selectByValue ( selectElm , size ) )
selectByValue ( selectElm , "" ) ;
} else
2005-08-23 01:33:52 +00:00
selectByValue ( selectElm , "0" ) ;
}
// Handle align attributes
alignNode = node ;
breakOut = false ;
do
{
if ( ! alignNode . getAttribute || ! alignNode . getAttribute ( 'align' ) )
{
continue ;
}
switch ( alignNode . getAttribute ( 'align' ) . toLowerCase ( ) )
{
case "left" :
tinyMCE . switchClassSticky ( editor _id + '_justifyleft' , 'mceButtonSelected' ) ;
breakOut = true ;
break ;
case "right" :
tinyMCE . switchClassSticky ( editor _id + '_justifyright' , 'mceButtonSelected' ) ;
breakOut = true ;
break ;
case "middle" :
case "center" :
tinyMCE . switchClassSticky ( editor _id + '_justifycenter' , 'mceButtonSelected' ) ;
breakOut = true ;
break ;
case "justify" :
tinyMCE . switchClassSticky ( editor _id + '_justifyfull' , 'mceButtonSelected' ) ;
breakOut = true ;
break ;
}
} while ( ! breakOut && ( alignNode = alignNode . parentNode ) ) ;
2005-08-23 01:37:34 +00:00
// Div justification
var div = tinyMCE . getParentElement ( node , "div" ) ;
if ( div && div . style . textAlign == "center" )
tinyMCE . switchClassSticky ( editor _id + '_justifycenter' , 'mceButtonSelected' ) ;
2005-08-23 01:33:52 +00:00
// Do special text
if ( tinyMCE . isGecko && node . nodeType == 3 )
{
var inst = tinyMCE . getInstanceById ( editor _id ) ;
var doc = inst . getDoc ( ) ;
if ( doc . queryCommandState ( "Bold" ) )
{
tinyMCE . switchClassSticky ( editor _id + '_bold' , 'mceButtonSelected' ) ;
}
if ( doc . queryCommandState ( "Italic" ) )
{
tinyMCE . switchClassSticky ( editor _id + '_italic' , 'mceButtonSelected' ) ;
}
if ( doc . queryCommandState ( "Underline" ) &&
( node . parentNode == null || node . parentNode . nodeName != "A" ) )
{
tinyMCE . switchClassSticky ( editor _id + '_underline' , 'mceButtonSelected' ) ;
}
if ( doc . queryCommandState ( "Strikethrough" ) )
{
tinyMCE . switchClassSticky ( editor _id + '_strikethrough' , 'mceButtonSelected' ) ;
}
}
// Handle elements
do
{
switch ( node . nodeName . toLowerCase ( ) )
{
case "b" :
case "strong" :
tinyMCE . switchClassSticky ( editor _id + '_bold' , 'mceButtonSelected' ) ;
break ;
case "i" :
case "em" :
tinyMCE . switchClassSticky ( editor _id + '_italic' , 'mceButtonSelected' ) ;
break ;
case "u" :
tinyMCE . switchClassSticky ( editor _id + '_underline' , 'mceButtonSelected' ) ;
break ;
case "strike" :
tinyMCE . switchClassSticky ( editor _id + '_strikethrough' , 'mceButtonSelected' ) ;
break ;
case "ul" :
tinyMCE . switchClassSticky ( editor _id + '_bullist' , 'mceButtonSelected' ) ;
break ;
case "ol" :
tinyMCE . switchClassSticky ( editor _id + '_numlist' , 'mceButtonSelected' ) ;
break ;
case "sub" :
tinyMCE . switchClassSticky ( editor _id + '_sub' , 'mceButtonSelected' ) ;
break ;
case "sup" :
tinyMCE . switchClassSticky ( editor _id + '_sup' , 'mceButtonSelected' ) ;
break ;
case "hr" :
tinyMCE . switchClassSticky ( editor _id + '_hr' , 'mceButtonSelected' ) ;
break ;
case "img" :
if ( getAttrib ( node , 'name' ) . indexOf ( 'mce_' ) != 0 )
{
tinyMCE . switchClassSticky ( editor _id + '_image' , 'mceButtonSelected' ) ;
}
break ;
}
} while ( ( node = node . parentNode ) ) ;
} ;
// This function auto imports CSS classes into the class selection droplist
function TinyMCE _advanced _setupCSSClasses ( editor _id )
{
if ( ! TinyMCE _advanced _autoImportCSSClasses )
{
return ;
}
var selectElm = document . getElementById ( editor _id + '_styleSelect' ) ;
if ( selectElm && selectElm . getAttribute ( 'cssImported' ) != 'true' )
{
var csses = tinyMCE . getCSSClasses ( editor _id ) ;
if ( csses && selectElm )
{
for ( var i = 0 ; i < csses . length ; i ++ )
{
selectElm . options [ selectElm . length ] = new Option ( csses [ i ] , csses [ i ] ) ;
}
}
// Only do this once
if ( csses != null && csses . length > 0 )
{
selectElm . setAttribute ( 'cssImported' , 'true' ) ;
}
}
} ;