cvs: pear /HTML_QuickForm_advmultiselect advmultiselect.php
[email protected] ("Laurent Laville")
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsfarell1209231420@cvsserver> |
farell Sat Apr 26 17:37:00 2008 UTC
Modified files:
/pear/HTML_QuickForm_advmultiselect advmultiselect.php
Log:
- introduce TIP to make double-select-box XHTML compliant even with an empty list
see also qfamsHandler.js
- fix WC3 warning naming (XML notation) : replace
__ prefix by -f suffix (for source select list on left)
_ prefix by -t suffix (for target select list on right)
farell-20080426173700.txt
(text/plain, 9.4 KB)
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_advmultiselect/advmultiselect.php?r1=1.17&r2=1.18&diff_format=u Index: pear/HTML_QuickForm_advmultiselect/advmultiselect.php diff -u pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.17 pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.18 --- pear/HTML_QuickForm_advmultiselect/advmultiselect.php:1.17 Sat Apr 26 12:24:35 2008 +++ pear/HTML_QuickForm_advmultiselect/advmultiselect.php Sat Apr 26 17:37:00 2008 @@ -36,7 +36,7 @@ * @author Laurent Laville <[email protected]> * @copyright 2005-2008 Laurent Laville * @license http://www.opensource.org/licenses/bsd-license.php BSD - * @version CVS: $Id: advmultiselect.php,v 1.17 2008/04/26 12:24:35 farell Exp $ + * @version CVS: $Id: advmultiselect.php,v 1.18 2008/04/26 17:37:00 farell Exp $ * @link http://pear.php.net/package/HTML_QuickForm_advmultiselect * @since File available since Release 0.4.0 */ @@ -546,6 +546,8 @@ $selectId = $this->getName(); $selectName = $this->getName() . '[]'; + $selectNameFrom = $this->getName() . '-f[]'; + $selectNameTo = $this->getName() . '-t[]'; $selected_count = 0; // placeholder {unselected} existence determines if we will render @@ -637,12 +639,12 @@ // set name of Select From Box $this->_attributesUnselected - = array('id' => '__' . $selectId, - 'name' => '__' . $selectName, + = array('id' => $selectId . '-f', + 'name' => $selectNameFrom, 'ondblclick' => $jsName . "('{$selectId}', ". - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'add', '{$this->_sort}')"); $this->_attributesUnselected @@ -651,12 +653,12 @@ // set name of Select To Box $this->_attributesSelected - = array('id' => '_' . $selectId, - 'name' => '_' . $selectName, + = array('id' => $selectId . '-t', + 'name' => $selectNameTo, 'ondblclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], ". + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], ". "this.form.elements['" . $selectName . "'], " . "'remove', '{$this->_sort}')"); $this->_attributesSelected @@ -714,8 +716,15 @@ } // The 'unselected' multi-select which appears on the left + $unselected_count = count($arrHtmlUnselected); + + if ($unselected_count == 0) { + $this->_attributesUnselected['disabled'] = 'disabled'; + $this->_attributesUnselected + = array_merge($this->_attributes, $this->_attributesUnselected); + $attrUnselected = $this->_getAttrString($this->_attributesUnselected); + } $strHtmlUnselected = "<select$attrUnselected>". PHP_EOL; - $unselected_count = count($arrHtmlUnselected); if ($unselected_count > 0) { foreach ($arrHtmlUnselected as $data) { $strHtmlUnselected @@ -723,12 +732,21 @@ . '<option' . $this->_getAttrString($data['attr']) . '>' . $data['text'] . '</option>' . PHP_EOL; } + } else { + $strHtmlUnselected .= '<option value=""> </option>'; } $strHtmlUnselected .= '</select>'; // The 'selected' multi-select which appears on the right + $selected_count = count($arrHtmlSelected); + + if ($selected_count == 0) { + $this->_attributesSelected['disabled'] = 'disabled'; + $this->_attributesSelected + = array_merge($this->_attributes, $this->_attributesSelected); + $attrSelected = $this->_getAttrString($this->_attributesSelected); + } $strHtmlSelected = "<select$attrSelected>". PHP_EOL; - $selected_count = count($arrHtmlSelected); if ($selected_count > 0) { foreach ($arrHtmlSelected as $data) { $strHtmlSelected @@ -736,6 +754,8 @@ . '<option' . $this->_getAttrString($data['attr']) . '>' . $data['text'] . '</option>' . PHP_EOL; } + } else { + $strHtmlSelected .= '<option value=""> </option>'; } $strHtmlSelected .= '</select>'; @@ -755,8 +775,8 @@ $attributes = array('onclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'remove', '{$this->_sort}'); return false;"); $this->_removeButtonAttributes @@ -768,8 +788,8 @@ $attributes = array('onclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'add', '{$this->_sort}'); return false;"); $this->_addButtonAttributes @@ -781,8 +801,8 @@ $attributes = array('onclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'all', '{$this->_sort}'); return false;"); $this->_allButtonAttributes @@ -794,8 +814,8 @@ $attributes = array('onclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'none', '{$this->_sort}'); return false;"); $this->_noneButtonAttributes @@ -807,8 +827,8 @@ $attributes = array('onclick' => $jsName . "('{$selectId}', " . - "this.form.elements['__" . $selectName . "'], " . - "this.form.elements['_" . $selectName . "'], " . + "this.form.elements['" . $selectNameFrom . "'], " . + "this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "'], " . "'toggle', '{$this->_sort}'); return false;"); $this->_toggleButtonAttributes @@ -819,7 +839,7 @@ // build the move up button with all its attributes $attributes = array('onclick' => "{$this->_jsPrefix}MoveUp" . - "(this.form.elements['_" . $selectName . "'], " . + "(this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "']); " . "return false;"); $this->_upButtonAttributes @@ -830,7 +850,7 @@ // build the move down button with all its attributes $attributes = array('onclick' => "{$this->_jsPrefix}MoveDown" . - "(this.form.elements['_" . $selectName . "'], " . + "(this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['" . $selectName . "']); " . "return false;"); $this->_downButtonAttributes