[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fck_select.js 22 * Scripts for the fck_select.html page. 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 function Select( combo ) 29 { 30 var iIndex = combo.selectedIndex ; 31 32 oListText.selectedIndex = iIndex ; 33 oListValue.selectedIndex = iIndex ; 34 35 var oTxtText = document.getElementById( "txtText" ) ; 36 var oTxtValue = document.getElementById( "txtValue" ) ; 37 38 oTxtText.value = oListText.value ; 39 oTxtValue.value = oListValue.value ; 40 } 41 42 function Add() 43 { 44 var oTxtText = document.getElementById( "txtText" ) ; 45 var oTxtValue = document.getElementById( "txtValue" ) ; 46 47 AddComboOption( oListText, oTxtText.value, oTxtText.value ) ; 48 AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ; 49 50 oListText.selectedIndex = oListText.options.length - 1 ; 51 oListValue.selectedIndex = oListValue.options.length - 1 ; 52 53 oTxtText.value = '' ; 54 oTxtValue.value = '' ; 55 56 oTxtText.focus() ; 57 } 58 59 function Modify() 60 { 61 var iIndex = oListText.selectedIndex ; 62 63 if ( iIndex < 0 ) return ; 64 65 var oTxtText = document.getElementById( "txtText" ) ; 66 var oTxtValue = document.getElementById( "txtValue" ) ; 67 68 oListText.options[ iIndex ].innerHTML = oTxtText.value ; 69 oListText.options[ iIndex ].value = oTxtText.value ; 70 71 oListValue.options[ iIndex ].innerHTML = oTxtValue.value ; 72 oListValue.options[ iIndex ].value = oTxtValue.value ; 73 74 oTxtText.value = '' ; 75 oTxtValue.value = '' ; 76 77 oTxtText.focus() ; 78 } 79 80 function Move( steps ) 81 { 82 ChangeOptionPosition( oListText, steps ) ; 83 ChangeOptionPosition( oListValue, steps ) ; 84 } 85 86 function Delete() 87 { 88 RemoveSelectedOptions( oListText ) ; 89 RemoveSelectedOptions( oListValue ) ; 90 } 91 92 function SetSelectedValue() 93 { 94 var iIndex = oListValue.selectedIndex ; 95 if ( iIndex < 0 ) return ; 96 97 var oTxtValue = document.getElementById( "txtSelValue" ) ; 98 99 oTxtValue.value = oListValue.options[ iIndex ].value ; 100 } 101 102 // Moves the selected option by a number of steps (also negative) 103 function ChangeOptionPosition( combo, steps ) 104 { 105 var iActualIndex = combo.selectedIndex ; 106 107 if ( iActualIndex < 0 ) 108 return ; 109 110 var iFinalIndex = iActualIndex + steps ; 111 112 if ( iFinalIndex < 0 ) 113 iFinalIndex = 0 ; 114 115 if ( iFinalIndex > ( combo.options.length - 1 ) ) 116 iFinalIndex = combo.options.length - 1 ; 117 118 if ( iActualIndex == iFinalIndex ) 119 return ; 120 121 var oOption = combo.options[ iActualIndex ] ; 122 var sText = oOption.innerHTML ; 123 var sValue = oOption.value ; 124 125 combo.remove( iActualIndex ) ; 126 127 oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ; 128 129 oOption.selected = true ; 130 } 131 132 // Remove all selected options from a SELECT object 133 function RemoveSelectedOptions(combo) 134 { 135 // Save the selected index 136 var iSelectedIndex = combo.selectedIndex ; 137 138 var oOptions = combo.options ; 139 140 // Remove all selected options 141 for ( var i = oOptions.length - 1 ; i >= 0 ; i-- ) 142 { 143 if (oOptions[i].selected) combo.remove(i) ; 144 } 145 146 // Reset the selection based on the original selected index 147 if ( combo.options.length > 0 ) 148 { 149 if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ; 150 combo.selectedIndex = iSelectedIndex ; 151 } 152 } 153 154 // Add a new option to a SELECT object (combo or list) 155 function AddComboOption( combo, optionText, optionValue, documentObject, index ) 156 { 157 var oOption ; 158 159 if ( documentObject ) 160 oOption = documentObject.createElement("OPTION") ; 161 else 162 oOption = document.createElement("OPTION") ; 163 164 if ( index != null ) 165 combo.options.add( oOption, index ) ; 166 else 167 combo.options.add( oOption ) ; 168 169 oOption.innerHTML = optionText.length > 0 ? optionText : ' ' ; 170 oOption.value = optionValue ; 171 172 return oOption ; 173 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |