[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2006 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: fcktoolbarstylecombo.js 14 * FCKToolbarPanelButton Class: Handles the Fonts combo selector. 15 * 16 * File Authors: 17 * Frederico Caldeira Knabben (fredck@fckeditor.net) 18 */ 19 20 var FCKToolbarStyleCombo = function( tooltip, style ) 21 { 22 this.CommandName = 'Style' ; 23 this.Label = this.GetLabel() ; 24 this.Tooltip = tooltip ? tooltip : this.Label ; 25 this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; 26 } 27 28 // Inherit from FCKToolbarSpecialCombo. 29 FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ; 30 31 32 FCKToolbarStyleCombo.prototype.GetLabel = function() 33 { 34 return FCKLang.Style ; 35 } 36 37 FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo ) 38 { 39 var oTargetDoc = targetSpecialCombo._Panel.Document ; 40 41 // Add the Editor Area CSS to the Styles panel so the style classes are previewed correctly. 42 var aCSSs = FCKConfig.EditorAreaCSS ; 43 for ( var i = 0 ; i < aCSSs.length ; i++ ) 44 FCKTools.AppendStyleSheet( oTargetDoc, aCSSs[i] ) ; 45 46 oTargetDoc.body.className += ' ForceBaseFont' ; 47 48 // For some reason Gecko is blocking inside the "RefreshVisibleItems" function. 49 if ( ! FCKBrowserInfo.IsGecko ) 50 targetSpecialCombo.OnBeforeClick = this.RefreshVisibleItems ; 51 52 // Add the styles to the special combo. 53 var aCommandStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Styles ; 54 for ( var s in aCommandStyles ) 55 { 56 var oStyle = aCommandStyles[s] ; 57 var oItem ; 58 59 if ( oStyle.IsObjectElement ) 60 oItem = targetSpecialCombo.AddItem( s, s ) ; 61 else 62 oItem = targetSpecialCombo.AddItem( s, oStyle.GetOpenerTag() + s + oStyle.GetCloserTag() ) ; 63 64 oItem.Style = oStyle ; 65 } 66 } 67 68 FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo ) 69 { 70 // Clear the actual selection. 71 targetSpecialCombo.DeselectAll() ; 72 73 // Get the active styles. 74 var aStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetActiveStyles() ; 75 76 if ( aStyles.length > 0 ) 77 { 78 // Select the active styles in the combo. 79 for ( var i = 0 ; i < aStyles.length ; i++ ) 80 targetSpecialCombo.SelectItem( aStyles[i].Name ) ; 81 82 // Set the combo label to the first style in the collection. 83 targetSpecialCombo.SetLabelById( aStyles[0].Name ) ; 84 } 85 else 86 targetSpecialCombo.SetLabel('') ; 87 } 88 89 FCKToolbarStyleCombo.prototype.RefreshVisibleItems = function( targetSpecialCombo ) 90 { 91 if ( FCKSelection.GetType() == 'Control' ) 92 var sTagName = FCKSelection.GetSelectedElement().tagName ; 93 94 for ( var i in targetSpecialCombo.Items ) 95 { 96 var oItem = targetSpecialCombo.Items[i] ; 97 if ( ( sTagName && oItem.Style.Element == sTagName ) || ( ! sTagName && ! oItem.Style.IsObjectElement ) ) 98 oItem.style.display = '' ; 99 else 100 oItem.style.display = 'none' ; // For some reason Gecko is blocking here. 101 } 102 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |