Author: vmolotkov
Date: 2007-11-22 15:19:10 -0500 (Thu, 22 Nov 2007)
New Revision: 4211
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
Log:
copy/remove functionality
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-22
18:58:38 UTC (rev 4210)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-22
20:19:10 UTC (rev 4211)
@@ -70,29 +70,38 @@
}*/
moveItems : function(sourceComponent, targetComponent, items) {
- for (var item in items) {
- moveItem(sourceComponent, targetComponent, item);
- }
+ if (items.length > 0) {
+ var length = items.length;
+ for (var i = 0; items.length > 0;) {
+ var item = items[i];
+ this.moveItem(sourceComponent, targetComponent, item);
+ }
+ }
},
moveItem : function(sourceComponent, targetComponent, item) {
- addItem(targetComponent, item);
- removeItem(sourceComponent, item);
+ if (!(item instanceof Richfaces.SelectItem)) {
+ item = sourceComponent.getSelectItemByNode(item);
+ }
+ this.addItem(targetComponent, item);
+ this.removeItem(sourceComponent, item);
},
removeItem : function(component, item) {
var items = component.shuttleItems;
var selectedItems = component.selectedItems;
+ selectedItems.remove(item._node);
items.remove(item);
- selectedItems.remove(item);
if (item == component.activeItem) {
component.activeItem == null;
}
},
addItem : function(component, item) {
- var newItem = Object.clone(item);
- component.shuttleItems.push(newItem);
+ //var newItem = Object.clone(item);
+ Richfaces.SelectItems.doNormal(item._node);
+ component.shuttleTbody.insertBefore(item._node, null);
+ component.shuttleItems.push(item);
},
}
@@ -100,6 +109,6 @@
Richfaces.ListShuttle.HANDLERS = {
copy: function (e) { this.moveItem(this.sourceList, this.targetList,
this.sourceList.selectedItems); return false; },
copyAll: function (e) { this.moveItems(this.sourceList, this.targetList,
this.sourceList.shuttleItems); return false; },
- remove: function (e) { this.moveItem(this.targetList, this.sourceList,
this.targetList.selectedItems); return false; },
+ remove: function (e) { this.moveItems(this.targetList, this.sourceList,
this.targetList.selectedItems); return false; },
removeAll: function (e) { this.moveItems(this.targetList, this.sourceList,
this.targetList.shuttleItems); return false; }
};
\ No newline at end of file
Show replies by date