cvs: pear /HTML_QuickForm_advmultiselect qfamsHandler.js

[email protected] ("Laurent Laville")
Newsgroups php.pear.cvs
Message-ID <cvsfarell1209231358@cvsserver>
farell		Sat Apr 26 17:35:58 2008 UTC

  Modified files:              
    /pear/HTML_QuickForm_advmultiselect	qfamsHandler.js 
  Log:
  - introduce TIP to make double-select-box XHTML compliant even with an empty list
    see also advmultiselect.php to prepare stage
  
  - 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) 
  
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_advmultiselect/qfamsHandler.js?r1=1.4&r2=1.5&diff_format=u
Index: pear/HTML_QuickForm_advmultiselect/qfamsHandler.js
diff -u pear/HTML_QuickForm_advmultiselect/qfamsHandler.js:1.4 pear/HTML_QuickForm_advmultiselect/qfamsHandler.js:1.5
--- pear/HTML_QuickForm_advmultiselect/qfamsHandler.js:1.4	Sat Apr 26 13:24:09 2008
+++ pear/HTML_QuickForm_advmultiselect/qfamsHandler.js	Sat Apr 26 17:35:58 2008
@@ -6,7 +6,7 @@
  * @author     Laurent Laville <[email protected]>
  * @copyright  2007-2008 Laurent Laville
  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
- * @version    CVS: $Id: qfamsHandler.js,v 1.4 2008/04/26 13:24:09 farell Exp $
+ * @version    CVS: $Id: qfamsHandler.js,v 1.5 2008/04/26 17:35:58 farell Exp $
  * @since      File available since Release 1.3.0
  */
 
@@ -24,7 +24,7 @@
 {
     if (window.qfamsName) {
         for (var e = 0; e < window.qfamsName.length; e++) {
-            var div    = document.getElementById('qfams_' + window.qfamsName[e]);
+            var div = document.getElementById('qfams_' + window.qfamsName[e]);
             if (div !== null) {
                 var inputs = div.getElementsByTagName('input');
                 for (var i = 0; i < inputs.length; i++) {
@@ -167,6 +167,12 @@
         return;
     }
 
+    // check if target list is empty and remove fake empty option (tip to be XHTML compliant)
+    if (target.length > 0 && target.options[0].value == "") {
+        target.removeAttribute("disabled");
+        target.options[0] = null;
+    }
+
     var maxTo = target.length;
 
     // Add items to the 'TO' list.
@@ -195,12 +201,12 @@
 
     // updates unselected item count
     var c = document.getElementById(qfamsName + '_unselected');
-    var s = document.getElementById('__' + qfamsName);
+    var s = document.getElementById(qfamsName + '-f');
     qfamsUpdateCounter(c, s.length);
 
     // updates selected item count
     var c = document.getElementById(qfamsName + '_selected');
-    var s = document.getElementById('_' + qfamsName);
+    var s = document.getElementById(qfamsName + '-t');
     qfamsUpdateCounter(c, s.length);
 
     // Sort list if required
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.