2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fck_select.js
14
* Scripts for the fck_select.html page.
17
* Frederico Caldeira Knabben (fredck@fckeditor.net)
20
function Select( combo )
22
var iIndex = combo.selectedIndex ;
24
oListText.selectedIndex = iIndex ;
25
oListValue.selectedIndex = iIndex ;
27
var oTxtText = document.getElementById( "txtText" ) ;
28
var oTxtValue = document.getElementById( "txtValue" ) ;
30
oTxtText.value = oListText.value ;
31
oTxtValue.value = oListValue.value ;
36
var oTxtText = document.getElementById( "txtText" ) ;
37
var oTxtValue = document.getElementById( "txtValue" ) ;
39
AddComboOption( oListText, oTxtText.value, oTxtText.value ) ;
40
AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ;
42
oListText.selectedIndex = oListText.options.length - 1 ;
43
oListValue.selectedIndex = oListValue.options.length - 1 ;
46
oTxtValue.value = '' ;
53
var iIndex = oListText.selectedIndex ;
55
if ( iIndex < 0 ) return ;
57
var oTxtText = document.getElementById( "txtText" ) ;
58
var oTxtValue = document.getElementById( "txtValue" ) ;
60
oListText.options[ iIndex ].innerHTML = oTxtText.value ;
61
oListText.options[ iIndex ].value = oTxtText.value ;
63
oListValue.options[ iIndex ].innerHTML = oTxtValue.value ;
64
oListValue.options[ iIndex ].value = oTxtValue.value ;
67
oTxtValue.value = '' ;
72
function Move( steps )
74
ChangeOptionPosition( oListText, steps ) ;
75
ChangeOptionPosition( oListValue, steps ) ;
80
RemoveSelectedOptions( oListText ) ;
81
RemoveSelectedOptions( oListValue ) ;
84
function SetSelectedValue()
86
var iIndex = oListValue.selectedIndex ;
87
if ( iIndex < 0 ) return ;
89
var oTxtValue = document.getElementById( "txtSelValue" ) ;
91
oTxtValue.value = oListValue.options[ iIndex ].value ;
94
// Moves the selected option by a number of steps (also negative)
95
function ChangeOptionPosition( combo, steps )
97
var iActualIndex = combo.selectedIndex ;
99
if ( iActualIndex < 0 )
102
var iFinalIndex = iActualIndex + steps ;
104
if ( iFinalIndex < 0 )
107
if ( iFinalIndex > ( combo.options.lenght - 1 ) )
108
iFinalIndex = combo.options.lenght - 1 ;
110
if ( iActualIndex == iFinalIndex )
113
var oOption = combo.options[ iActualIndex ] ;
114
var sText = oOption.innerHTML ;
115
var sValue = oOption.value ;
117
combo.remove( iActualIndex ) ;
119
oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ;
121
oOption.selected = true ;
124
// Remove all selected options from a SELECT object
125
function RemoveSelectedOptions(combo)
127
// Save the selected index
128
var iSelectedIndex = combo.selectedIndex ;
130
var oOptions = combo.options ;
132
// Remove all selected options
133
for ( var i = oOptions.length - 1 ; i >= 0 ; i-- )
135
if (oOptions[i].selected) combo.remove(i) ;
138
// Reset the selection based on the original selected index
139
if ( combo.options.length > 0 )
141
if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ;
142
combo.selectedIndex = iSelectedIndex ;
146
// Add a new option to a SELECT object (combo or list)
147
function AddComboOption( combo, optionText, optionValue, documentObject, index )
151
if ( documentObject )
152
oOption = documentObject.createElement("OPTION") ;
154
oOption = document.createElement("OPTION") ;
157
combo.options.add( oOption, index ) ;
159
combo.options.add( oOption ) ;
161
oOption.innerHTML = optionText.length > 0 ? optionText : ' ' ;
162
oOption.value = optionValue ;
b'\\ No newline at end of file'
2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2008 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
* Scripts for the fck_select.html page.
24
function Select( combo )
26
var iIndex = combo.selectedIndex ;
28
oListText.selectedIndex = iIndex ;
29
oListValue.selectedIndex = iIndex ;
31
var oTxtText = document.getElementById( "txtText" ) ;
32
var oTxtValue = document.getElementById( "txtValue" ) ;
34
oTxtText.value = oListText.value ;
35
oTxtValue.value = oListValue.value ;
40
var oTxtText = document.getElementById( "txtText" ) ;
41
var oTxtValue = document.getElementById( "txtValue" ) ;
43
AddComboOption( oListText, oTxtText.value, oTxtText.value ) ;
44
AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ;
46
oListText.selectedIndex = oListText.options.length - 1 ;
47
oListValue.selectedIndex = oListValue.options.length - 1 ;
50
oTxtValue.value = '' ;
57
var iIndex = oListText.selectedIndex ;
59
if ( iIndex < 0 ) return ;
61
var oTxtText = document.getElementById( "txtText" ) ;
62
var oTxtValue = document.getElementById( "txtValue" ) ;
64
oListText.options[ iIndex ].innerHTML = HTMLEncode( oTxtText.value ) ;
65
oListText.options[ iIndex ].value = oTxtText.value ;
67
oListValue.options[ iIndex ].innerHTML = HTMLEncode( oTxtValue.value ) ;
68
oListValue.options[ iIndex ].value = oTxtValue.value ;
71
oTxtValue.value = '' ;
76
function Move( steps )
78
ChangeOptionPosition( oListText, steps ) ;
79
ChangeOptionPosition( oListValue, steps ) ;
84
RemoveSelectedOptions( oListText ) ;
85
RemoveSelectedOptions( oListValue ) ;
88
function SetSelectedValue()
90
var iIndex = oListValue.selectedIndex ;
91
if ( iIndex < 0 ) return ;
93
var oTxtValue = document.getElementById( "txtSelValue" ) ;
95
oTxtValue.value = oListValue.options[ iIndex ].value ;
98
// Moves the selected option by a number of steps (also negative)
99
function ChangeOptionPosition( combo, steps )
101
var iActualIndex = combo.selectedIndex ;
103
if ( iActualIndex < 0 )
106
var iFinalIndex = iActualIndex + steps ;
108
if ( iFinalIndex < 0 )
111
if ( iFinalIndex > ( combo.options.length - 1 ) )
112
iFinalIndex = combo.options.length - 1 ;
114
if ( iActualIndex == iFinalIndex )
117
var oOption = combo.options[ iActualIndex ] ;
118
var sText = HTMLDecode( oOption.innerHTML ) ;
119
var sValue = oOption.value ;
121
combo.remove( iActualIndex ) ;
123
oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ;
125
oOption.selected = true ;
128
// Remove all selected options from a SELECT object
129
function RemoveSelectedOptions(combo)
131
// Save the selected index
132
var iSelectedIndex = combo.selectedIndex ;
134
var oOptions = combo.options ;
136
// Remove all selected options
137
for ( var i = oOptions.length - 1 ; i >= 0 ; i-- )
139
if (oOptions[i].selected) combo.remove(i) ;
142
// Reset the selection based on the original selected index
143
if ( combo.options.length > 0 )
145
if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ;
146
combo.selectedIndex = iSelectedIndex ;
150
// Add a new option to a SELECT object (combo or list)
151
function AddComboOption( combo, optionText, optionValue, documentObject, index )
155
if ( documentObject )
156
oOption = documentObject.createElement("OPTION") ;
158
oOption = document.createElement("OPTION") ;
161
combo.options.add( oOption, index ) ;
163
combo.options.add( oOption ) ;
165
oOption.innerHTML = optionText.length > 0 ? HTMLEncode( optionText ) : ' ' ;
166
oOption.value = optionValue ;
171
function HTMLEncode( text )
176
text = text.replace( /&/g, '&' ) ;
177
text = text.replace( /</g, '<' ) ;
178
text = text.replace( />/g, '>' ) ;
184
function HTMLDecode( text )
189
text = text.replace( />/g, '>' ) ;
190
text = text.replace( /</g, '<' ) ;
191
text = text.replace( /&/g, '&' ) ;