[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2005 Frederico Caldeira Knabben 4 * 5 * Licensed under the terms of the GNU Lesser General Public License: 6 * http://www.opensource.org/licenses/lgpl-license.php 7 * 8 * For further information visit: 9 * http://www.fckeditor.net/ 10 * 11 * "Support Open Source software. What about a donation today?" 12 * 13 * File Name: fckstylecommand.js 14 * FCKStyleCommand Class: represents the "Style" command. 15 * 16 * File Authors: 17 * Frederico Caldeira Knabben (fredck@fckeditor.net) 18 */ 19 20 var FCKStyleCommand = function() 21 { 22 this.Name = 'Style' ; 23 24 // Load the Styles defined in the XML file. 25 this.StylesLoader = new FCKStylesLoader() ; 26 this.StylesLoader.Load( FCKConfig.StylesXmlPath ) ; 27 this.Styles = this.StylesLoader.Styles ; 28 } 29 30 FCKStyleCommand.prototype.Execute = function( styleName, styleComboItem ) 31 { 32 FCKUndo.SaveUndoStep() ; 33 34 if ( styleComboItem.Selected ) 35 styleComboItem.Style.RemoveFromSelection() ; 36 else 37 styleComboItem.Style.ApplyToSelection() ; 38 39 FCKUndo.SaveUndoStep() ; 40 41 FCK.Focus() ; 42 43 FCK.Events.FireEvent( "OnSelectionChange" ) ; 44 } 45 46 FCKStyleCommand.prototype.GetState = function() 47 { 48 var oSelection = FCK.EditorDocument.selection ; 49 50 if ( FCKSelection.GetType() == 'Control' ) 51 { 52 var e = FCKSelection.GetSelectedElement() ; 53 if ( e ) 54 return this.StylesLoader.StyleGroups[ e.tagName ] ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; 55 } 56 57 return FCK_TRISTATE_OFF ; 58 } 59 60 FCKStyleCommand.prototype.GetActiveStyles = function() 61 { 62 var aActiveStyles = new Array() ; 63 64 if ( FCKSelection.GetType() == 'Control' ) 65 this._CheckStyle( FCKSelection.GetSelectedElement(), aActiveStyles, false ) ; 66 else 67 this._CheckStyle( FCKSelection.GetParentElement(), aActiveStyles, true ) ; 68 69 return aActiveStyles ; 70 } 71 72 FCKStyleCommand.prototype._CheckStyle = function( element, targetArray, checkParent ) 73 { 74 if ( ! element ) 75 return ; 76 77 if ( element.nodeType == 1 ) 78 { 79 var aStyleGroup = this.StylesLoader.StyleGroups[ element.tagName ] ; 80 if ( aStyleGroup ) 81 { 82 for ( var i = 0 ; i < aStyleGroup.length ; i++ ) 83 { 84 if ( aStyleGroup[i].IsEqual( element ) ) 85 targetArray[ targetArray.length ] = aStyleGroup[i] ; 86 } 87 } 88 } 89 90 if ( checkParent ) 91 this._CheckStyle( element.parentNode, targetArray, checkParent ) ; 92 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |