+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * FCKToolbarPanelButton Class: Handles the Fonts combo selector.\r
- */\r
-\r
-var FCKToolbarStyleCombo = function( tooltip, style )\r
-{\r
- if ( tooltip === false )\r
- return ;\r
-\r
- this.CommandName = 'Style' ;\r
- this.Label = this.GetLabel() ;\r
- this.Tooltip = tooltip ? tooltip : this.Label ;\r
- this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ;\r
-\r
- this.DefaultLabel = FCKConfig.DefaultStyleLabel || '' ;\r
-}\r
-\r
-// Inherit from FCKToolbarSpecialCombo.\r
-FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ;\r
-\r
-FCKToolbarStyleCombo.prototype.GetLabel = function()\r
-{\r
- return FCKLang.Style ;\r
-}\r
-\r
-FCKToolbarStyleCombo.prototype.GetStyles = function()\r
-{\r
- var styles = {} ;\r
- var allStyles = FCK.ToolbarSet.CurrentInstance.Styles.GetStyles() ;\r
-\r
- for ( var styleName in allStyles )\r
- {\r
- var style = allStyles[ styleName ] ;\r
- if ( !style.IsCore )\r
- styles[ styleName ] = style ;\r
- }\r
- return styles ;\r
-}\r
-\r
-FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo )\r
-{\r
- var targetDoc = targetSpecialCombo._Panel.Document ;\r
-\r
- // Add the Editor Area CSS to the panel so the style classes are previewed correctly.\r
- FCKTools.AppendStyleSheet( targetDoc, FCKConfig.ToolbarComboPreviewCSS ) ;\r
- FCKTools.AppendStyleString( targetDoc, FCKConfig.EditorAreaStyles ) ;\r
- targetDoc.body.className += ' ForceBaseFont' ;\r
-\r
- // Add ID and Class to the body.\r
- FCKConfig.ApplyBodyAttributes( targetDoc.body ) ;\r
-\r
- // Get the styles list.\r
- var styles = this.GetStyles() ;\r
-\r
- for ( var styleName in styles )\r
- {\r
- var style = styles[ styleName ] ;\r
-\r
- // Object type styles have no preview.\r
- var caption = style.GetType() == FCK_STYLE_OBJECT ?\r
- styleName :\r
- FCKToolbarStyleCombo_BuildPreview( style, style.Label || styleName ) ;\r
-\r
- var item = targetSpecialCombo.AddItem( styleName, caption ) ;\r
-\r
- item.Style = style ;\r
- }\r
-\r
- // We must prepare the list before showing it.\r
- targetSpecialCombo.OnBeforeClick = this.StyleCombo_OnBeforeClick ;\r
-}\r
-\r
-FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo )\r
-{\r
- var startElement = FCK.ToolbarSet.CurrentInstance.Selection.GetBoundaryParentElement( true ) ;\r
-\r
- if ( startElement )\r
- {\r
- var path = new FCKElementPath( startElement ) ;\r
- var elements = path.Elements ;\r
-\r
- for ( var e = 0 ; e < elements.length ; e++ )\r
- {\r
- for ( var i in targetSpecialCombo.Items )\r
- {\r
- var item = targetSpecialCombo.Items[i] ;\r
- var style = item.Style ;\r
-\r
- if ( style.CheckElementRemovable( elements[ e ], true ) )\r
- {\r
- targetSpecialCombo.SetLabel( style.Label || style.Name ) ;\r
- return ;\r
- }\r
- }\r
- }\r
- }\r
-\r
- targetSpecialCombo.SetLabel( this.DefaultLabel ) ;\r
-}\r
-\r
-FCKToolbarStyleCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo )\r
-{\r
- // Two things are done here:\r
- // - In a control selection, get the element name, so we'll display styles\r
- // for that element only.\r
- // - Select the styles that are active for the current selection.\r
-\r
- // Clear the current selection.\r
- targetSpecialCombo.DeselectAll() ;\r
-\r
- var startElement ;\r
- var path ;\r
- var tagName ;\r
-\r
- var selection = FCK.ToolbarSet.CurrentInstance.Selection ;\r
-\r
- if ( selection.GetType() == 'Control' )\r
- {\r
- startElement = selection.GetSelectedElement() ;\r
- tagName = startElement.nodeName.toLowerCase() ;\r
- }\r
- else\r
- {\r
- startElement = selection.GetBoundaryParentElement( true ) ;\r
- path = new FCKElementPath( startElement ) ;\r
- }\r
-\r
- for ( var i in targetSpecialCombo.Items )\r
- {\r
- var item = targetSpecialCombo.Items[i] ;\r
- var style = item.Style ;\r
-\r
- if ( ( tagName && style.Element == tagName ) || ( !tagName && style.GetType() != FCK_STYLE_OBJECT ) )\r
- {\r
- item.style.display = '' ;\r
-\r
- if ( ( path && style.CheckActive( path ) ) || ( !path && style.CheckElementRemovable( startElement, true ) ) )\r
- targetSpecialCombo.SelectItem( style.Name ) ;\r
- }\r
- else\r
- item.style.display = 'none' ;\r
- }\r
-}\r
-\r
-function FCKToolbarStyleCombo_BuildPreview( style, caption )\r
-{\r
- var styleType = style.GetType() ;\r
- var html = [] ;\r
-\r
- if ( styleType == FCK_STYLE_BLOCK )\r
- html.push( '<div class="BaseFont">' ) ;\r
-\r
- var elementName = style.Element ;\r
-\r
- // Avoid <bdo> in the preview.\r
- if ( elementName == 'bdo' )\r
- elementName = 'span' ;\r
-\r
- html = [ '<', elementName ] ;\r
-\r
- // Assign all defined attributes.\r
- var attribs = style._StyleDesc.Attributes ;\r
- if ( attribs )\r
- {\r
- for ( var att in attribs )\r
- {\r
- html.push( ' ', att, '="', style.GetFinalAttributeValue( att ), '"' ) ;\r
- }\r
- }\r
-\r
- // Assign the style attribute.\r
- if ( style._GetStyleText().length > 0 )\r
- html.push( ' style="', style.GetFinalStyleValue(), '"' ) ;\r
-\r
- html.push( '>', caption, '</', elementName, '>' ) ;\r
-\r
- if ( styleType == FCK_STYLE_BLOCK )\r
- html.push( '</div>' ) ;\r
-\r
- return html.join( '' ) ;\r
-}\r