Author: vmolotkov
Date: 2007-11-22 11:57:55 -0500 (Thu, 22 Nov 2007)
New Revision: 4195
Removed:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
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
Deleted:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-22
16:53:38 UTC (rev 4194)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-22
16:57:55 UTC (rev 4195)
@@ -1,313 +0,0 @@
-if(!window.Richfaces) window.Richfaces = {};
-
-Richfaces.ListBase = Class.create();
-
-Richfaces.ListBase.compare = function(obj1, obj2) {
- return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
-}
-
-Richfaces.ListBase.prototype = {
- initialize : function(containerId, contentTableId, headerTableId, focusKeeperId,
valueKeeperId,
- onclickControlId) {
- this.container = $(containerId);
- this.shuttleTable = $(contentTableId);
- this.valueKeeper = $(valueKeeperId);
- this.focusKeeper = $(focusKeeperId);
- this.focusKeeper.focused = false;
- this.setFocus();
- this.focusKeeper.observe("keydown", (function(e)
{this.onkeydownHandler(window.event || e)}).bindAsEventListener(this));
- this.focusKeeper.observe("blur", function (e)
{this.focusListener(e);}.bindAsEventListener(this));
-
- this.shuttleTbody = this.shuttleTable.tBodies[0];
-
- this.items = null;
- this.selectedItems = new Array();
- this.retrieveShuttleItems(containerId);
-
- this.shuttle = null;
- this.sortOrder = Shuttle.ASC;
-
- this.activeItem = null;
-
- this.onorderchanged = onorderchanged;
-
- this.shuttleTop = LayoutManager.getElemXY(this.shuttleTable).top;
-
- $(contentTableId).observe("click", function(e)
{this.onclickHandler(window.event || e)}.bindAsEventListener(this));
- },
-
- retrieveShuttleItems : function(containerId) {
- var rows = this.shuttleTbody.rows;
- this.shuttleItems = new Array();
- var id;
-
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- id = row.id.split(containerId + ":")[1];
- this.shuttleItems[i]
- = new Richfaces.SelectItem(null, (id || i),
- ((Richfaces.SelectItems.isSelected(row)) ? true : false), row);
- if (Richfaces.SelectItems.isSelected(row)) {
- this.selectedItems.push(row);
- }
- if (Richfaces.SelectItems.isActive(row)) {
- this.activeItem = row;
- }
- }
- },
-
- getExtremeItem : function(position) { //FIXME
- var extremeItem = this.selectedItems[0];
- var currentItem;
-
- for (var i = 1; i < this.selectedItems.length; i++) {
- currentItem = this.selectedItems[i];
- if (position == "first") {
- if (currentItem.rowIndex < extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- } else {
- if (currentItem.rowIndex > extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- }
- }
- return extremeItem;
- },
-
- getEventTargetRow : function(event) {
- var activeElem;
- if (event.rangeParent) {
- //activeElem = event.rangeParent.parentNode;
- activeElem = event.target;
- } else {
- activeElem = event.srcElement;
- }
-
- if (activeElem == null) {
- return;
- }
-
- if (activeElem.tagName && Shuttle.CONTROL_SET.indexOf(activeElem.tagName) !=
-1) {
- return;
- }
-
- while (activeElem.tagName.toLowerCase() != "tr") {
- activeElem = activeElem.parentNode;
- if (!activeElem.tagName) {
- return; //for IE
- }
- }
-
- return activeElem;
- },
-
- onkeydownHandler : function(event) {
- var action = null;
- switch (event.keyCode) {
- case 34 : action = 'last'; this.moveSelectedItems(action ,event); break;
//page down
- case 33 : action = 'first'; this.moveSelectedItems(action, event); break;
//page up
- case 38 : //up arrow
- action = 'up';
- this.moveActiveItem(action, event);
- break;
- case 40 : //down arrow
- action = 'down';
- this.moveActiveItem(action, event);
- break;
- case 65 : // Ctrl + A
- if (event.ctrlKey) {
- this.selectAll();
- Shuttle.stopPropogation(event);
- }
- Richfaces.SelectItems.doActive(this.activeItem);
- this.saveState();
- break;
- case 32 : this.invertSelection(event); this.saveState(); break; //blank
- }
- },
-
- invertSelection : function(event) {
- var eventItem = this.activeItem;
- var eventShuttleItem = this.getSelectItemByNode(eventItem);
- if (eventShuttleItem._selected) {
- eventShuttleItem._selected = false;
- this.selectedItems.remove(eventShuttleItem);
- } else {
- eventShuttleItem._selected = true;
- this.selectedItems.push(eventShuttleItem);
- }
- },
-
- moveActiveItem : function(action, event) {
- var item = this.activeItem;
- var rows = this.shuttleTbody.rows;
- if ((action == 'up') && (item.rowIndex > 0)) {
- this.changeActiveItems(rows[item.rowIndex - 1], item);
- } else if ((action == 'down') && (item.rowIndex <
this.shuttleItems.length - 1)) {
- this.changeActiveItems(rows[item.rowIndex + 1], item);
- }
-
- this.saveState();
- this.autoScrolling(action, event);
- this.controlListManager();
- },
-
- changeActiveItems : function(newItem, item) {
- var shuttleItem = this.getSelectItemByNode(item);
- var newShuttleItem = this.getSelectItemByNode(newItem);
-
- this.resetMarked();
-
- Richfaces.SelectItems.doActive(newItem);
- newItem._selected = true;
- this.activeItem = newItem;
- this.selectedItems.push(newItem);
- },
-
- selectAll : function() {
- var startIndex = 0;
- var endIndex = this.shuttleItems.length - 1;
- this.selectItemRange(startIndex, endIndex);
- },
-
- /**
- * Click handler
- */
- selectionItem : function(activeItem) {
- var markedItem = this.getSelectItemByNode(activeItem);
- var markedShuttleItem = activeItem;
-
- if (markedItem != null) {
- this.resetMarked();
- if (markedItem._selected) {
- markedItem._selected = false;
- } else {
- markedItem._selected = true;
- this.selectedItems[0] = markedShuttleItem;
- }
- }
- },
-
- /**
- * CTRL+Click handler
- */
- addSelectedItem : function(activeItem) {
- var markedItem = this.getSelectItemByNode(activeItem);
- var markedShuttleItem = activeItem;
-
- if (markedItem._selected) {
- this.selectedItems.remove(markedShuttleItem);
- markedItem._selected = false;
- } else {
- markedItem._selected = true;
- this.selectedItems.push(markedShuttleItem);
- }
-
- Richfaces.SelectItems.doSelect(this.activeItem);
-
- if (this.activeItem && !this.getSelectItemByNode(this.activeItem)._selected) {
- Richfaces.SelectItems.doNormal(this.activeItem);
- }
- },
-
- /**
- * Shift+Click handler
- */
- selectItemGroup : function(currentItem) {
- //FIXME
- var activeItemIndex = this.activeItem.rowIndex;
- var startIndex;
- var endIndex;
-
- if (currentItem.rowIndex > activeItemIndex) {
- startIndex = activeItemIndex;
- endIndex = currentItem.rowIndex;
- } else {
- startIndex = currentItem.rowIndex;
- endIndex = activeItemIndex;
- }
-
- this.resetMarked();
-
- this.selectItemRange(startIndex, endIndex);
- },
-
- selectItemRange : function(startIndex, endIndex) {
- var rows = this.shuttleTbody.rows;
- for (var i = startIndex; i <= endIndex; i++) {
- Richfaces.SelectItems.doSelect(rows[i]);
- this.selectedItems.push(rows[i]);
- this.getSelectItemByNode(rows[i])._selected = true;
- }
- },
-
- resetMarked : function() {
- var rows = this.shuttleTbody.rows;
- for (var i = 0; i < rows.length; i++) {
- var shuttleItem = rows[i];
- Richfaces.SelectItems.doNormal(shuttleItem);
- this.getSelectItemByNode(shuttleItem)._selected = false; //FIXME
- }
- this.selectedItems.length = 0;
- },
-
- getSelectItemByNode : function(selectItemNode) {
- for (var i = 0; i < this.shuttleItems.length; i++) {
- var item = this.shuttleItems[i];
- if (selectItemNode.rowIndex == item._node.rowIndex) {
- return item;
- }
- }
- return null;
- },
-
- autoScrolling : function(action, event) {
- this.selectedItems.sort(this.compareByRowIndex);
- var increment;
- var scrollTop = this.shuttleTable.parentNode.scrollTop;
- if (action == 'up' || action == 'first') {
- var targetItemTop = LayoutManager.getElemXY(this.selectedItems[0]).top;
- increment = (targetItemTop - scrollTop) - this.shuttleTop;
- if (increment < 0) {
- this.shuttleTable.parentNode.scrollTop += increment;
- }
- } else if (action == 'down' || action == 'last') {
- var item = this.selectedItems[this.selectedItems.length - 1];
- targetItemBottom =
LayoutManager.getElemXY(this.selectedItems[this.selectedItems.length - 1]).top +
item.offsetHeight;
- var increment = (targetItemBottom - scrollTop) - (this.shuttleTop +
this.shuttleTable.parentNode.offsetHeight - LayoutManager.SCROLL_WIDTH);
- if (increment > 0) {
- this.shuttleTable.parentNode.scrollTop += increment;
- }
- }
- Event.stop(event);
- },
-
- setFocus : function() {
- this.focusKeeper.focus();
- this.focusKeeper.focused = true;
- if (this.isListActive()) {
- this.shuttleTable.className = Shuttle.ORDERING_LIST_CLASSES.active;
- }
- },
-
- focusListener : function(e) {
- e = e || window.event;
- this.focusKeeper.focusused = false;
- this.shuttleTable.className = Shuttle.ORDERING_LIST_CLASSES.normal;
- },
-
- compareByLabel : function(obj1, obj2) {
- obj1 = obj1._label;
- obj2 = obj2._label;
- return Richfaces.ListBase.compare(obj1, obj2);
- },
-
- compareByRowIndex : function(obj1, obj2) {
- obj1 = obj1.rowIndex;
- obj2 = obj2.rowIndex;
- return Richfaces.ListBase.compare(obj1, obj2);
- }
-}
-
-
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
16:53:38 UTC (rev 4194)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-22
16:57:55 UTC (rev 4195)
@@ -3,19 +3,22 @@
Richfaces.ListShuttle = Class.create();
Richfaces.ListShuttle.prototype = {
- initialize: function(listParams, controlIds) {
- this.targetList = Richfaces.ListBase.apply(Richfaces.ListBase.constructor(),
listParams[1]);
- this.sourceList = Richfaces.OrderingList.apply(this, listParams[0]);
+ 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]);
- this.controlList = null;
+ this.targetList = targetList;
+ this.sourceList = sourceList;
+
+ this.controlList = new Array();
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]);
+ var node = document.getElementById(clientId + id[0]);
+ var disNode = document.getElementById(clientId + 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]);
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-22
16:53:38 UTC (rev 4194)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-11-22
16:57:55 UTC (rev 4195)
@@ -13,11 +13,12 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
+ scripts/extend.js,
scripts/SelectItem.js,
scripts/LayoutManager.js
scripts/Control.js,
+ scripts/ListBase.js,
scripts/OrderingList.js,
- scripts/ListBase.js,
scripts/ListShuttle.js
</h:scripts>
@@ -110,11 +111,12 @@
document.body.className = "body";
function init() {
var cotrolsIdPrefix = [['up', 'disup'], ['down',
'disdown'], ['last', 'dislast'],
['first','disfirst']];
- var listShuttle = new Richfaces.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 listShuttle = new Richfaces.ListShuttle(new
Richfaces.OrderingList('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper', cotrolsIdPrefix, '#{cId}sortLabel', function()
{#{component.attributes['onorderchanged']}}),
+ new Richfaces.ListBase('#{cId}', '#{cId}tlInternal_tab',
'#{cId}tlInternal_header_tab', '#{cId}tlFocusKeeper',
'#{cId}tlValueKeeper', cotrolsIdPrefix, '#{cId}tlSortLabel', function()
{#{component.attributes['onorderchanged']}}),
+ "#{cId}", cotrolsIdPrefix);
var sourceLayoutManager = new LayoutManager('#{cId}internal_header_tab',
'#{cId}internal_tab');
var targetLayoutManager = new LayoutManager('#{cId}tlInternal_header_tab',
'#{cId}tlInternal_tab');
- layoutManager.widthSynchronization();
+ sourceLayoutManager.widthSynchronization();
targetLayoutManager.widthSynchronization();
}
//setTimeout(init, 0);