You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ha...@apache.org on 2008/07/25 05:42:15 UTC

svn commit: r679655 - /myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js

Author: hazems
Date: Thu Jul 24 20:42:14 2008
New Revision: 679655

URL: http://svn.apache.org/viewvc?rev=679655&view=rev
Log:
https://issues.apache.org/jira/browse/TOMAHAWK-1308

Adding (remove/add) all feature to <t:selectManyPickList .../>

Modified:
    myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js?rev=679655&r1=679654&r2=679655&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/picklist/resource/picklist.js Thu Jul 24 20:42:14 2008
@@ -22,6 +22,26 @@
  * @version $Revision$ $Date$
  */
  
+// moves all the items to the selected list
+function myfaces_picklist_addAllToSelected(availableListId, selectedListId, hiddenId)
+{
+	var availableList = document.getElementById(availableListId);
+    var selectedList = document.getElementById(selectedListId);
+
+	myfaces_picklist_moveAll(availableList, selectedList, hiddenId);
+	myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
+// removes all the items from the selected list
+function myfaces_picklist_removeAllFromSelected(availableListId, selectedListId, hiddenId)
+{
+    var availableList = document.getElementById(availableListId);
+    var selectedList = document.getElementById(selectedListId);
+
+	myfaces_picklist_moveAll(selectedList, availableList, hiddenId);
+	myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
 // moves an item to the selected list
 function myfaces_picklist_addToSelected(availableListId, selectedListId, hiddenId)
 {
@@ -56,7 +76,17 @@
 			fromList.options[i] = null;
 		}
 	}
+}
 
+function myfaces_picklist_moveAll(fromList, toList, hiddenId) {
+
+	// Decremental loop, so the index is not affected in the moves
+	for (var i = fromList.options.length - 1; i >= 0; i--) {
+		var tLen = toList.options.length;
+		toList.options[tLen] = new Option(fromList.options[i].text);
+		toList.options[tLen].value = fromList.options[i].value;
+		fromList.options[i] = null;
+	}
 }
 
 // Selection - invoked on submit