[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2004 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 * File Name: fcktoolbarcombo.js 12 * FCKToolbarCombo Class: represents a combo in the toolbar. 13 * 14 * Version: 2.0 RC3 15 * Modified: 2004-11-10 17:14:48 16 * 17 * File Authors: 18 * Frederico Caldeira Knabben (fredck@fckeditor.net) 19 */ 20 21 var FCKToolbarCombo = function( commandName, label, itemsValues, itemsNames, tooltip, style, firstIsBlank, itemsSeparator, sourceView ) 22 { 23 this.Command = FCKCommands.GetCommand( commandName ) ; 24 25 this.Label = label ? label : commandName ; 26 this.Tooltip = tooltip ? tooltip : ( label ? label : commandName) ; 27 this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; 28 this.SourceView = sourceView ? true : false ; 29 this.State = FCK_UNKNOWN ; 30 31 this.ItemsValues = itemsValues ; 32 this.ItemsNames = itemsNames ? itemsNames : itemsValues ; 33 this.ItemsSeparator = itemsSeparator ? itemsSeparator : ';' ; 34 35 this.FirstIsBlank = firstIsBlank != null ? firstIsBlank : true ; 36 } 37 38 FCKToolbarCombo.prototype.CreateInstance = function( parentToolbar ) 39 { 40 /* 41 <td class="TB_Combo_Disabled" unselectable="on"> 42 <table class="ButtonType_IconText" cellspacing="0" cellpadding="0" border="0"> 43 <tr> 44 <td class="TB_Text" unselectable="on">Style</td> 45 <td><select title="Style"><option>Style 1</option><option>Style 2</option></select></td> 46 </tr> 47 </table> 48 </td> 49 */ 50 this.DOMDiv = document.createElement( 'div' ) ; 51 this.DOMDiv.className = 'TB_Combo_Off' ; 52 53 // Gets the correct CSS class to use for the specified style (param). 54 var sClass ; 55 switch ( this.Style ) 56 { 57 case FCK_TOOLBARITEM_ONLYICON : 58 sClass = 'TB_ButtonType_Icon' ; 59 break ; 60 case FCK_TOOLBARITEM_ONLYTEXT : 61 sClass = 'TB_ButtonType_Text' ; 62 break ; 63 case FCK_TOOLBARITEM_ICONTEXT : 64 sClass = '' ; 65 break ; 66 } 67 68 this.DOMDiv.innerHTML = 69 '<table class="' + sClass + '" cellspacing="0" cellpadding="0" border="0" unselectable="on">' + 70 '<tr>' + 71 '<td class="TB_Text" unselectable="on" nowrap>' + this.Label + '</td>' + 72 '<td unselectable="on"><select title="' + this.Tooltip + '"></select></td>' + 73 '</tr>' + 74 '</table>' ; 75 76 // Gets the SELECT element. 77 this.SelectElement = this.DOMDiv.firstChild.firstChild.firstChild.childNodes.item(1).firstChild ; 78 79 this.SelectElement.FCKToolbarCombo = this ; 80 81 this.SelectElement.onchange = function() 82 { 83 this.FCKToolbarCombo.Command.Execute( this.value ) ; 84 return false ; 85 } 86 87 var oCell = parentToolbar.DOMRow.insertCell(-1) ; 88 oCell.appendChild( this.DOMDiv ) ; 89 90 // Loads all combo items. 91 this.RefreshItems() ; 92 93 // Sets its initial state (probably disabled). 94 this.RefreshState() ; 95 } 96 97 FCKToolbarCombo.prototype.RefreshItems = function() 98 { 99 // Create the empty arrays of items to add (names and values) 100 var aNames = FCKTools.GetResultingArray( this.ItemsNames, this.ItemsSeparator ) ; 101 var aValues = FCKTools.GetResultingArray( this.ItemsValues, this.ItemsSeparator ) ; 102 103 // Clean up the combo. 104 FCKTools.RemoveAllSelectOptions( this.SelectElement ) ; 105 106 // Verifies if the first item in the combo must be blank. 107 if ( this.FirstIsBlank ) 108 FCKTools.AddSelectOption( document, this.SelectElement, '', '' ) ; 109 110 // Add all items to the combo. 111 for ( var i = 0 ; i < aValues.length ; i++ ) 112 { 113 FCKTools.AddSelectOption( document, this.SelectElement, aNames[i], aValues[i] ) ; 114 } 115 } 116 117 FCKToolbarCombo.prototype.RefreshState = function() 118 { 119 // Gets the actual state. 120 var eState ; 121 122 if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView ) 123 { 124 eState = FCK_TRISTATE_DISABLED ; 125 126 // Cleans the actual selection. 127 this.SelectElement.value = '' ; 128 } 129 else 130 { 131 var sValue = this.Command.GetState() ; 132 133 // Sets the combo value. 134 FCKTools.SelectNoCase( this.SelectElement, sValue ? sValue : '', '' ) ; 135 136 // Gets the actual state. 137 eState = sValue == null ? FCK_TRISTATE_DISABLED : FCK_TRISTATE_ON ; 138 } 139 140 // If there are no state changes then do nothing and return. 141 if ( eState == this.State ) return ; 142 143 // Sets the actual state. 144 this.State = eState ; 145 146 // Updates the graphical state. 147 this.DOMDiv.className = ( eState == FCK_TRISTATE_ON ? 'TB_Combo_Off' : 'TB_Combo_Disabled' ) ; 148 this.SelectElement.disabled = ( eState == FCK_TRISTATE_DISABLED ) ; 149 } 150
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 |