+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * Scripts for the fck_select.html page.\r
- */\r
-\r
-function Select( combo )\r
-{\r
- var iIndex = combo.selectedIndex ;\r
-\r
- oListText.selectedIndex = iIndex ;\r
- oListValue.selectedIndex = iIndex ;\r
-\r
- var oTxtText = document.getElementById( "txtText" ) ;\r
- var oTxtValue = document.getElementById( "txtValue" ) ;\r
-\r
- oTxtText.value = oListText.value ;\r
- oTxtValue.value = oListValue.value ;\r
-}\r
-\r
-function Add()\r
-{\r
- var oTxtText = document.getElementById( "txtText" ) ;\r
- var oTxtValue = document.getElementById( "txtValue" ) ;\r
-\r
- AddComboOption( oListText, oTxtText.value, oTxtText.value ) ;\r
- AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ;\r
-\r
- oListText.selectedIndex = oListText.options.length - 1 ;\r
- oListValue.selectedIndex = oListValue.options.length - 1 ;\r
-\r
- oTxtText.value = '' ;\r
- oTxtValue.value = '' ;\r
-\r
- oTxtText.focus() ;\r
-}\r
-\r
-function Modify()\r
-{\r
- var iIndex = oListText.selectedIndex ;\r
-\r
- if ( iIndex < 0 ) return ;\r
-\r
- var oTxtText = document.getElementById( "txtText" ) ;\r
- var oTxtValue = document.getElementById( "txtValue" ) ;\r
-\r
- oListText.options[ iIndex ].innerHTML = HTMLEncode( oTxtText.value ) ;\r
- oListText.options[ iIndex ].value = oTxtText.value ;\r
-\r
- oListValue.options[ iIndex ].innerHTML = HTMLEncode( oTxtValue.value ) ;\r
- oListValue.options[ iIndex ].value = oTxtValue.value ;\r
-\r
- oTxtText.value = '' ;\r
- oTxtValue.value = '' ;\r
-\r
- oTxtText.focus() ;\r
-}\r
-\r
-function Move( steps )\r
-{\r
- ChangeOptionPosition( oListText, steps ) ;\r
- ChangeOptionPosition( oListValue, steps ) ;\r
-}\r
-\r
-function Delete()\r
-{\r
- RemoveSelectedOptions( oListText ) ;\r
- RemoveSelectedOptions( oListValue ) ;\r
-}\r
-\r
-function SetSelectedValue()\r
-{\r
- var iIndex = oListValue.selectedIndex ;\r
- if ( iIndex < 0 ) return ;\r
-\r
- var oTxtValue = document.getElementById( "txtSelValue" ) ;\r
-\r
- oTxtValue.value = oListValue.options[ iIndex ].value ;\r
-}\r
-\r
-// Moves the selected option by a number of steps (also negative)\r
-function ChangeOptionPosition( combo, steps )\r
-{\r
- var iActualIndex = combo.selectedIndex ;\r
-\r
- if ( iActualIndex < 0 )\r
- return ;\r
-\r
- var iFinalIndex = iActualIndex + steps ;\r
-\r
- if ( iFinalIndex < 0 )\r
- iFinalIndex = 0 ;\r
-\r
- if ( iFinalIndex > ( combo.options.length - 1 ) )\r
- iFinalIndex = combo.options.length - 1 ;\r
-\r
- if ( iActualIndex == iFinalIndex )\r
- return ;\r
-\r
- var oOption = combo.options[ iActualIndex ] ;\r
- var sText = HTMLDecode( oOption.innerHTML ) ;\r
- var sValue = oOption.value ;\r
-\r
- combo.remove( iActualIndex ) ;\r
-\r
- oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ;\r
-\r
- oOption.selected = true ;\r
-}\r
-\r
-// Remove all selected options from a SELECT object\r
-function RemoveSelectedOptions(combo)\r
-{\r
- // Save the selected index\r
- var iSelectedIndex = combo.selectedIndex ;\r
-\r
- var oOptions = combo.options ;\r
-\r
- // Remove all selected options\r
- for ( var i = oOptions.length - 1 ; i >= 0 ; i-- )\r
- {\r
- if (oOptions[i].selected) combo.remove(i) ;\r
- }\r
-\r
- // Reset the selection based on the original selected index\r
- if ( combo.options.length > 0 )\r
- {\r
- if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ;\r
- combo.selectedIndex = iSelectedIndex ;\r
- }\r
-}\r
-\r
-// Add a new option to a SELECT object (combo or list)\r
-function AddComboOption( combo, optionText, optionValue, documentObject, index )\r
-{\r
- var oOption ;\r
-\r
- if ( documentObject )\r
- oOption = documentObject.createElement("OPTION") ;\r
- else\r
- oOption = document.createElement("OPTION") ;\r
-\r
- if ( index != null )\r
- combo.options.add( oOption, index ) ;\r
- else\r
- combo.options.add( oOption ) ;\r
-\r
- oOption.innerHTML = optionText.length > 0 ? HTMLEncode( optionText ) : ' ' ;\r
- oOption.value = optionValue ;\r
-\r
- return oOption ;\r
-}\r
-\r
-function HTMLEncode( text )\r
-{\r
- if ( !text )\r
- return '' ;\r
-\r
- text = text.replace( /&/g, '&' ) ;\r
- text = text.replace( /</g, '<' ) ;\r
- text = text.replace( />/g, '>' ) ;\r
-\r
- return text ;\r
-}\r
-\r
-\r
-function HTMLDecode( text )\r
-{\r
- if ( !text )\r
- return '' ;\r
-\r
- text = text.replace( />/g, '>' ) ;\r
- text = text.replace( /</g, '<' ) ;\r
- text = text.replace( /&/g, '&' ) ;\r
-\r
- return text ;\r
-}\r