Author: vmolotkov
Date: 2007-11-22 16:12:54 -0500 (Thu, 22 Nov 2007)
New Revision: 4212
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
Log:
controls disable/enable
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
20:19:10 UTC (rev 4211)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-22
21:12:54 UTC (rev 4212)
@@ -4,9 +4,11 @@
Richfaces.ListShuttle.prototype = {
initialize: function(targetList, sourceList, clientId, controlIds) {
- //this.targetList = Richfaces.ListBase.apply(Richfaces.ListBase.constructor(),
listParams[1]);
- //this.sourceList = Richfaces.OrderingList.apply(Richfaces.OrderingList.constructor(),
listParams[0]);
+ $(targetList.shuttleTable.id).observe("click", function(e)
{this.onclickHandler(window.event || e, targetList)}.bindAsEventListener(this));
+ $(sourceList.shuttleTable.id).observe("click", function(e)
{this.onclickHandler(window.event || e, sourceList)}.bindAsEventListener(this));
+
+
this.targetList = targetList;
this.sourceList = sourceList;
@@ -28,25 +30,36 @@
},
controlListManager : function() {
- if (this.sourceList.shuttleItems.length < 1) {
- this.controlsProcessing(["copyAll"]);
- } else if (this.targetList.shuttleItems.length < 1) {
- this.controlsProcessing(["removeAll"]);
- } else if (this.sourceList.selectedItems.length < 1) {
- this.controlsProcessing(["copy"]);
- } else if (this.targetList.selectedItems.length < 1) {
- this.controlsProcessing(["remove"]);
- } else {
- this.controlsProcessing();
- }
+ //this.controlsProcessing();
+ this.controlsProcessing(["copy", "copyAll", "removeAll"
,"remove"], "enable");
+ if (this.sourceList.shuttleItems.length < 1)
+ this.controlsProcessing(["copy", "copyAll"],
"disable");
+ if (this.sourceList.selectedItems.length < 1)
+ this.controlsProcessing(["copy"] , "disable");
+ if (this.targetList.shuttleItems.length < 1)
+ this.controlsProcessing(["removeAll" ,"remove"],
"disable");
+ if (this.targetList.selectedItems.length < 1) {
+ this.controlsProcessing(["remove"], "disable");
+ }
},
- controlsProcessing : function(disabledControls) {
+ onclickHandler : function(event, component) {
+ component.onclickHandler(event);
+ this.controlListManager();
+ Event.stop(event);
+ },
+
+ controlsProcessing : function(disabledControls , action) {
for (var i = 0; i < this.controlList.length; i++) {
control = this.controlList[i];
if (control != null) {
- if (disabledControls != null && disabledControls.indexOf(control.action) !=
-1) control.doDisable();
- else control.doEnable();
+ if (disabledControls != null && disabledControls.indexOf(control.action) !=
-1) {
+ if (action == "disable") {
+ control.doDisable();
+ } else {
+ control.doEnable();
+ }
+ }
}
}
},
@@ -76,6 +89,7 @@
var item = items[i];
this.moveItem(sourceComponent, targetComponent, item);
}
+ this.controlListManager();
}
},
@@ -89,8 +103,7 @@
removeItem : function(component, item) {
var items = component.shuttleItems;
- var selectedItems = component.selectedItems;
- selectedItems.remove(item._node);
+ component.selectedItems.remove(item._node);
items.remove(item);
if (item == component.activeItem) {
component.activeItem == null;
@@ -107,7 +120,7 @@
}
Richfaces.ListShuttle.HANDLERS = {
- copy: function (e) { this.moveItem(this.sourceList, this.targetList,
this.sourceList.selectedItems); return false; },
+ copy: function (e) { this.moveItems(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.moveItems(this.targetList, this.sourceList,
this.targetList.selectedItems); return false; },
removeAll: function (e) { this.moveItems(this.targetList, this.sourceList,
this.targetList.shuttleItems); return false; }