cvs: pear /HTML_QuickForm_advmultiselect advmultiselect.php

From: Date: Sat, 08 Apr 2006 10:39:54 +0000
Subject: cvs: pear /HTML_QuickForm_advmultiselect advmultiselect.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39489@lists.php.net to get a copy of this message
farell Sat Apr 8 10:39:54 2006 UTC Modified files: /pear/HTML_QuickForm_advmultiselect advmultiselect.php Log: implement 'toggle' button for a dual select boxes. feature already exists for a single select box (with checkboxes) http://cvs.php.net/viewcvs.cgi/pear/HTML_QuickForm_advmultiselect/advmultiselect.php?r1=1.9&r2=1.10&diff_format=u Index: pear/HTML_QuickForm_advmultiselect/advmultiselect.php diff -u pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.9 pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.10 --- pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.9 Wed Nov 30 22:03:21 2005 +++ pear/HTML_QuickForm_advmultiselect/advmultiselect.php Sat Apr 8 10:39:54 2006 @@ -19,7 +19,7 @@ * @author Laurent Laville <pear@laurent-laville.org> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 -* @version CVS: $Id: advmultiselect.php,v 1.9 2005/11/30 22:03:21 farell Exp $ +* @version CVS: $Id: advmultiselect.php,v 1.10 2006/04/08 10:39:54 farell Exp $ * @link http://pear.php.net/package/HTML_QuickForm_advmultiselect */ @@ -721,7 +721,11 @@ $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); $strHtmlNone = "<input$attrStrNone />". PHP_EOL; - $strHtmlToggle = ''; + // build the toggle button with all its attributes + $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'toggle'); return false;"); + $this->_toggleButtonAttributes = array_merge($this->_toggleButtonAttributes, $attributes); + $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); + $strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; // build the move up button with all its attributes $attributes = array('onclick' => "{$this->_jsPrefix}moveUp(this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "']); return false;"); @@ -832,7 +836,7 @@ $js .= " /* begin javascript for HTML_QuickForm_advmultiselect */ function {$jsfuncName}(selectLeft, selectRight, selectHidden, action) { - if (action == 'add' || action == 'all') { + if (action == 'add' || action == 'all' || action == 'toggle') { menuFrom = selectLeft; menuTo = selectRight; } else { @@ -844,19 +848,31 @@ return; } + maxTo = menuTo.length; + // Add items to the 'TO' list. for (i=0; i < menuFrom.length; i++) { - if (action == 'all' || action == 'none' || menuFrom.options[i].selected == true ) { + if (action == 'all' || action == 'none' || action == 'toggle' || menuFrom.options[i].selected == true ) { menuTo.options[menuTo.length]= new Option(menuFrom.options[i].text, menuFrom.options[i].value); } } // Remove items from the 'FROM' list. for (i=(menuFrom.length - 1); i>=0; i--){ - if (action == 'all' || action == 'none' || menuFrom.options[i].selected == true) { + if (action == 'all' || action == 'none' || action == 'toggle' || menuFrom.options[i].selected == true) { menuFrom.options[i] = null; } } + + // Add items to the 'FROM' list for toggle function + if (action == 'toggle') { + for (i=0; i < maxTo; i++) { + menuFrom.options[menuFrom.length]= new Option(menuTo.options[i].text, menuTo.options[i].value); + } + for (i=(maxTo - 1); i>=0; i--) { + menuTo.options[i] = null; + } + } "; if ($this->_sort === false) { $js .= "

« previous php.pear.cvs (#39489) next »