2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* FCKStyleCommand Class: represents the "Style" command.
24
var FCKStyleCommand = function()
28
// Load the Styles defined in the XML file.
29
this.StylesLoader = new FCKStylesLoader() ;
30
this.StylesLoader.Load( FCKConfig.StylesXmlPath ) ;
31
this.Styles = this.StylesLoader.Styles ;
34
FCKStyleCommand.prototype.Execute = function( styleName, styleComboItem )
36
FCKUndo.SaveUndoStep() ;
38
if ( styleComboItem.Selected )
39
styleComboItem.Style.RemoveFromSelection() ;
41
styleComboItem.Style.ApplyToSelection() ;
43
FCKUndo.SaveUndoStep() ;
47
FCK.Events.FireEvent( "OnSelectionChange" ) ;
50
FCKStyleCommand.prototype.GetState = function()
52
if ( !FCK.EditorDocument )
53
return FCK_TRISTATE_DISABLED ;
55
var oSelection = FCK.EditorDocument.selection ;
57
if ( FCKSelection.GetType() == 'Control' )
59
var e = FCKSelection.GetSelectedElement() ;
61
return this.StylesLoader.StyleGroups[ e.tagName ] ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;
64
return FCK_TRISTATE_OFF ;
67
FCKStyleCommand.prototype.GetActiveStyles = function()
69
var aActiveStyles = new Array() ;
71
if ( FCKSelection.GetType() == 'Control' )
72
this._CheckStyle( FCKSelection.GetSelectedElement(), aActiveStyles, false ) ;
74
this._CheckStyle( FCKSelection.GetParentElement(), aActiveStyles, true ) ;
76
return aActiveStyles ;
79
FCKStyleCommand.prototype._CheckStyle = function( element, targetArray, checkParent )
84
if ( element.nodeType == 1 )
86
var aStyleGroup = this.StylesLoader.StyleGroups[ element.tagName ] ;
89
for ( var i = 0 ; i < aStyleGroup.length ; i++ )
91
if ( aStyleGroup[i].IsEqual( element ) )
92
targetArray[ targetArray.length ] = aStyleGroup[i] ;
98
this._CheckStyle( element.parentNode, targetArray, checkParent ) ;
b'\\ No newline at end of file'