Author: vmolotkov
Date: 2007-11-19 12:05:18 -0500 (Mon, 19 Nov 2007)
New Revision: 4092
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/templates/org/richfaces/htmlListShuttle.jspx
Log:
listShuttle 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-19
16:47:05 UTC (rev 4091)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-19
17:05:18 UTC (rev 4092)
@@ -0,0 +1,101 @@
+if(!window.Richfaces) window.Richfaces = {};
+
+
+Richfaces.ListShuttle = {
+ initialize: function(listParams, controlIds) {
+ this.targetList = new ListBase(listParams[1]);
+ this.sourceList = new OrderingList(listParams[0]);
+
+ this.controlList = null;
+ this.initControlList(controlIds);
+ },
+
+ initControlList : function(ids) {
+ for (var i = 0; i < ids.length; i++) {
+ var id = ids[i];
+ var node = document.getElementById(containerId + id[0]);
+ var disNode = document.getElementById(containerId + id[1]);
+ if (node && disNode) {
+ Shuttle.addClickListener(node,
Richfaces.ListShuttle.HANDLERS[id[0]].bindAsEventListener(this));
+ this.controlList[i] = new Control(node, disNode, false, false, id[0]);
+ }
+ }
+ this.controlListManager();
+ },
+
+ 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();
+ }
+ },
+
+ controlsProcessing : function(disabledControls) {
+ 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();
+ }
+ }
+ },
+
+ /*addItems : function(component, items) {
+ var componentItems = list.shuttleItems;
+
+ for (var item in items) {
+ var newItem = Object.clone(item);
+ collection.push(newItem);
+ }
+ },
+
+ removeItems : function(component, items) {
+ var componentItems = component.shuttleItems;
+ var componentSelectedItems = component.selectedItems;
+
+ for (var item in items) {
+ targetCollection.remove(item);
+ }
+ }*/
+
+ moveItems : function(sourceComponent, targetComponent, items) {
+ for (var item in items) {
+ moveItem(sourceComponent, targetComponent, item);
+ }
+ },
+
+ moveItem : function(sourceComponent, targetComponent, item) {
+ addItem(targetComponent, item);
+ removeItem(sourceComponent, item);
+ },
+
+ removeItem : function(component, item) {
+ var items = component.shuttleItems;
+ var selectedItems = component.selectedItems;
+ 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);
+ },
+
+}
+
+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; },
+ removeAll: function (e) { this.moveItems(this.targetList, this.sourceList,
this.targetList.shuttleItems); return false; }
+};
\ No newline at end of file
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-11-19
16:47:05 UTC (rev 4091)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-11-19
17:05:18 UTC (rev 4092)
@@ -108,11 +108,12 @@
document.body.className = "body";
function init() {
var cotrolsIdPrefix = [['up', 'disup'], ['down',
'disdown'], ['last', 'dislast'],
['first','disfirst']];
- var sourceList = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper', cotrolsIdPrefix, '#{cId}sortLabel', function()
{#{component.attributes['onorderchanged']}});
- var targetList = new Shuttle('#{cId}', '#{cId}tlInternal_tab',
'#{cId}tlInternal_header_tab', '#{cId}tlFocusKeeper',
'#{cId}tlValueKeeper', cotrolsIdPrefix, '#{cId}tlSortLabel', function()
{#{component.attributes['onorderchanged']}});
+ var listShuttle = new ListShuttle([['#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper', cotrolsIdPrefix, '#{cId}sortLabel', function()
{#{component.attributes['onorderchanged']}}],
+ ['#{cId}', '#{cId}tlInternal_tab',
'#{cId}tlInternal_header_tab', '#{cId}tlFocusKeeper',
'#{cId}tlValueKeeper', cotrolsIdPrefix, '#{cId}tlSortLabel', function()
{#{component.attributes['onorderchanged']}}]]);
var sourceLayoutManager = new LayoutManager('#{cId}internal_header_tab',
'#{cId}internal_tab');
- var sourceLayoutManager = new LayoutManager('#{cId}tlInternal_header_tab',
'#{cId}tlInternal_tab');
+ var targetLayoutManager = new LayoutManager('#{cId}tlInternal_header_tab',
'#{cId}tlInternal_tab');
layoutManager.widthSynchronization();
+ targetLayoutManager.widthSynchronization();
}
//setTimeout(init, 0);
</script>