[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/fckeditor/editor/dialog/fck_select/ -> fck_select.js (source)

   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: fck_select.js
  14   *     Scripts for the fck_select.html page.
  15   * 
  16   * File Authors:
  17   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  18   */
  19  
  20  function Select( combo )
  21  {
  22      var iIndex = combo.selectedIndex ;
  23  
  24      oListText.selectedIndex        = iIndex ;
  25      oListValue.selectedIndex    = iIndex ;
  26  
  27      var oTxtText    = document.getElementById( "txtText" ) ;
  28      var oTxtValue    = document.getElementById( "txtValue" ) ;
  29  
  30      oTxtText.value    = oListText.value ;
  31      oTxtValue.value    = oListValue.value ;
  32  }
  33  
  34  function Add()
  35  {
  36      var oTxtText    = document.getElementById( "txtText" ) ;
  37      var oTxtValue    = document.getElementById( "txtValue" ) ;
  38  
  39      AddComboOption( oListText, oTxtText.value, oTxtText.value ) ;
  40      AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ;
  41  
  42      oListText.selectedIndex = oListText.options.length - 1 ;
  43      oListValue.selectedIndex = oListValue.options.length - 1 ;
  44  
  45      oTxtText.value    = '' ;
  46      oTxtValue.value    = '' ;
  47  
  48      oTxtText.focus() ;
  49  }
  50  
  51  function Modify()
  52  {
  53      var iIndex = oListText.selectedIndex ;
  54  
  55      if ( iIndex < 0 ) return ;
  56  
  57      var oTxtText    = document.getElementById( "txtText" ) ;
  58      var oTxtValue    = document.getElementById( "txtValue" ) ;
  59  
  60      oListText.options[ iIndex ].innerHTML    = oTxtText.value ;
  61      oListText.options[ iIndex ].value        = oTxtText.value ;
  62  
  63      oListValue.options[ iIndex ].innerHTML    = oTxtValue.value ;
  64      oListValue.options[ iIndex ].value        = oTxtValue.value ;
  65  
  66      oTxtText.value    = '' ;
  67      oTxtValue.value    = '' ;
  68  
  69      oTxtText.focus() ;
  70  }
  71  
  72  function Move( steps )
  73  {
  74      ChangeOptionPosition( oListText, steps ) ;
  75      ChangeOptionPosition( oListValue, steps ) ;
  76  }
  77  
  78  function Delete()
  79  {
  80      RemoveSelectedOptions( oListText ) ;
  81      RemoveSelectedOptions( oListValue ) ;
  82  }
  83  
  84  function SetSelectedValue()
  85  {
  86      var iIndex = oListValue.selectedIndex ;
  87      if ( iIndex < 0 ) return ;
  88  
  89      var oTxtValue = document.getElementById( "txtSelValue" ) ;
  90  
  91      oTxtValue.value = oListValue.options[ iIndex ].value ;
  92  }
  93  
  94  // Moves the selected option by a number of steps (also negative)
  95  function ChangeOptionPosition( combo, steps )
  96  {
  97      var iActualIndex = combo.selectedIndex ;
  98  
  99      if ( iActualIndex < 0 )
 100          return ;
 101  
 102      var iFinalIndex = iActualIndex + steps ;
 103  
 104      if ( iFinalIndex < 0 )
 105          iFinalIndex = 0 ;
 106  
 107      if ( iFinalIndex > ( combo.options.length - 1 ) )
 108          iFinalIndex = combo.options.length - 1 ;
 109  
 110      if ( iActualIndex == iFinalIndex )
 111          return ;
 112  
 113      var oOption = combo.options[ iActualIndex ] ;
 114      var sText    = oOption.innerHTML ;
 115      var sValue    = oOption.value ;
 116  
 117      combo.remove( iActualIndex ) ;
 118  
 119      oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ;
 120  
 121      oOption.selected = true ;
 122  }
 123  
 124  // Remove all selected options from a SELECT object
 125  function RemoveSelectedOptions(combo)
 126  {
 127      // Save the selected index
 128      var iSelectedIndex = combo.selectedIndex ;
 129  
 130      var oOptions = combo.options ;
 131  
 132      // Remove all selected options
 133      for ( var i = oOptions.length - 1 ; i >= 0 ; i-- )
 134      {
 135          if (oOptions[i].selected) combo.remove(i) ;
 136      }
 137  
 138      // Reset the selection based on the original selected index
 139      if ( combo.options.length > 0 )
 140      {
 141          if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ;
 142          combo.selectedIndex = iSelectedIndex ;
 143      }
 144  }
 145  
 146  // Add a new option to a SELECT object (combo or list)
 147  function AddComboOption( combo, optionText, optionValue, documentObject, index )
 148  {
 149      var oOption ;
 150  
 151      if ( documentObject )
 152          oOption = documentObject.createElement("OPTION") ;
 153      else
 154          oOption = document.createElement("OPTION") ;
 155  
 156      if ( index != null )
 157          combo.options.add( oOption, index ) ;
 158      else
 159          combo.options.add( oOption ) ;
 160  
 161      oOption.innerHTML = optionText.length > 0 ? optionText : '&nbsp;' ;
 162      oOption.value     = optionValue ;
 163  
 164      return oOption ;
 165  }


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics