Author: vmolotkov
Date: 2007-11-22 09:29:37 -0500 (Thu, 22 Nov 2007)
New Revision: 4182
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
Log:
refactoring of .js files
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-22
14:09:02 UTC (rev 4181)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-22
14:29:37 UTC (rev 4182)
@@ -325,7 +325,7 @@
focusListener : function(e) {
e = e || window.event;
- this.focusKeeper.focusused = false;
+ this.focusKeeper.focused = false;
this.shuttleTable.className = Richfaces.ListBase.ORDERING_LIST_CLASSES.normal;
},
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-22
14:09:02 UTC (rev 4181)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-22
14:29:37 UTC (rev 4182)
@@ -1,598 +1,183 @@
if(!window.Richfaces) window.Richfaces = {};
-Richfaces.disableSelectionText = function(target) {
- target.onselectstart = function(e) {
- e = window.event||e;
- if (e.srcElement) {
- if (e.srcElement.tagName) {
- var tagName = e.srcElement.tagName.toUpperCase();
-
- if (tagName != "INPUT" && tagName != "TEXTAREA" /* any
items more? */) {
- return false;
- }
- }
- }
- }
-
-}
-Richfaces.OrderingList = Class.create();
-
-Richfaces.OrderingList.prototype.initialize = function(containerId, contentTableId,
headerTableId, focusKeeperId, valueKeeperId,
- ids, onclickControlId, onorderchanged) {
- this.container = document.getElementById(containerId);
- this.shuttleTable = document.getElementById(contentTableId);
- this.shuttleTbody = this.shuttleTable.tBodies[0];
-
- this.items = null;
- this.selectedItems = new Array();
- this.retrieveShuttleItems(containerId);
-
- this.shuttle = null;
- this.sortOrder = Richfaces.OrderingList.ASC;
-
- this.activeItem = null;
-
- this.onorderchanged = onorderchanged;
-
- this.focusKeeper = document.getElementById(focusKeeperId);
- this.focusKeeper.focused = false;
-
- this.valueKeeper = document.getElementById(valueKeeperId);
-
- this.shuttleTop = null;
-
- this.isShuttleEnabled = true;
- this.controlList = new Array();
-
- var obj = this;
- this.focusKeeper.onkeydown = function(e) {
- obj.onkeydownHandler(window.event || e);
- }
- this.init(containerId, contentTableId, headerTableId, ids, onclickControlId);
- Richfaces.disableSelectionText(this.container);
-}
-
-Richfaces.OrderingList.ASC = "acs";
-Richfaces.OrderingList.DESC = "desc";
-
-Richfaces.OrderingList.CONTROL_SET = ["A", "INPUT",
"TEXTAREA", "SELECT", "BUTTON"];
-
-Richfaces.OrderingList.ORDERING_LIST_CLASSES = {
- normal : "ol_internal_tab rich-ordering-list-items",
- disabled : "ol_internal_tab rich-ordering-list-disabled",
- active : "ol_internal_tab rich-ordering-list-active"
-}
-
-Richfaces.OrderingList.ACTIVITY_MARKER = "a";
-Richfaces.OrderingList.SELECTION_MARKER = "s";
-Richfaces.OrderingList.ITEM_SEPARATOR = ",";
-
-Richfaces.OrderingList.HANDLERS = {
- first: function (e) { this.moveSelectedItems("first", e);return false; },
- last: function (e) { this.moveSelectedItems("last", e);return false; },
- up: function (e) { this.moveSelectedItems("up", e);return false; },
- down: function (e) { this.moveSelectedItems("down", e);return false; }
-};
-
-Richfaces.OrderingList.prototype.init = function(containerId, contentTableId,
headerTableId, ids, onclickControlId) {
- var obj = this;
- this.setFocus();
- Richfaces.OrderingList.addEventListener(this.focusKeeper, "blur", function (e)
{obj.focusListener(e);});
- 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) {
- Richfaces.OrderingList.addClickListener(node,
Richfaces.OrderingList.HANDLERS[id[0]].bindAsEventListener(this));
- this.controlList[i] = new Control(node, disNode, false, false, id[0]);
- }
- }
- this.controlListManager();
- document.getElementById(contentTableId).onclick = function(e)
{obj.onclickHandler(window.event || e);};
- this.shuttleTop = LayoutManager.getElemXY(this.shuttleTable).top;
-}
-
-Richfaces.OrderingList.prototype.isListActive = function() {
- if ((this.activeItem != null || this.selectedItems.length != 0) &&
this.focusKeeper.focused) {
- return true;
- }
- return false;
-}
-
-Richfaces.OrderingList.prototype.controlListManager = function() {
- this.selectedItems.sort(this.compareByRowIndex);
- var control;
- //FIXME
- if ((this.shuttleItems.length <= 1) || (this.selectedItems.length == 0)) {
- this.controlsProcessing(["first", "last", "down",
"up"]);
- } else if (this.selectedItems[0].rowIndex == 0) {
- this.controlsProcessing(["first", "up"]);
- } else if (this.selectedItems[this.selectedItems.length - 1].rowIndex ==
(this.shuttleItems.length - 1)) {
- this.controlsProcessing(["down", "last"]);
- } else {
- this.controlsProcessing();
- }
-}
-
-Richfaces.OrderingList.prototype.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();
- }
- }
-}
-
-Richfaces.OrderingList.prototype.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;
- }
- }
-}
-
-Richfaces.OrderingList.prototype.sort = function() {
- if (this.sortOrder == Richfaces.OrderingList.ASC) {
- this.shuttleItems.sort(this.compareByLabel);
- this.sortOrder = Richfaces.OrderingList.DESC;
- } else {
- this.shuttleItems.reverse();
- this.sortOrder = Richfaces.OrderingList.ASC;
- }
- this.rebuild();
-}
-
-Richfaces.OrderingList.prototype.moveSelectedItems = function(action, event) {
- event = window.event||event;
- var rows = this.shuttleTbody.rows;
- var item;
- if (this.selectedItems.length > 0) {
- this.selectedItems.sort(this.compareByRowIndex);
+Richfaces.OrderingList = Class.create({
+ CLASSDEF: {
+ name: 'Richfaces.OrderingList',
+ parent: Richfaces.ListBase
+ },
+
+ initialize: function(containerId, contentTableId, headerTableId, focusKeeperId,
valueKeeperId,
+ ids, onclickControlId, onorderchanged) {
+ Richfaces.OrderingList.parentClass.constructor().call(this, containerId,
contentTableId, headerTableId, focusKeeperId, valueKeeperId, onclickControlId);
+ this.onorderchanged = onorderchanged;
+ this.controlList = new Array();
- if ((action == 'up') &&
this.getExtremeItem("first").previousSibling) {
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, item.previousSibling);
+ this.initControlList(containerId, ids);
+ },
+
+ initControlList : function(containerId, 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) {
+ node.observe('click',
Richfaces.OrderingList.HANDLERS[id[0]].bindAsEventListener(this));
+ this.controlList[i] = new Control(node, disNode, false, false, id[0]);
}
- } else if ((action == 'down') &&
this.getExtremeItem("last").nextSibling) {
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item.nextSibling, item);
- }
- } else if (action == 'first') {
- var incr = this.selectedItems[0].rowIndex;
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, rows[item.rowIndex - incr]);
- }
- } else if (action == 'last') {
- var length = this.shuttleItems.length;
- var incr = length - this.selectedItems[this.selectedItems.length - 1].rowIndex;
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- if (item.rowIndex + incr > length - 1) {
- item.parentNode.insertBefore(item, null);
- } else {
- item.parentNode.insertBefore(item, rows[item.rowIndex + incr]);
- }
- }
}
-
- this.shuttleItems = new Array();
- for (var i = 0; i < rows.length; i++) {
- this.shuttleItems.push(rows[i].item);
- }
- if (action != null)
- this.autoScrolling(action, event);
-
this.controlListManager();
- this.saveState();
- this.onorderchanged();
- }
-}
-
-Richfaces.OrderingList.prototype.getExtremeItem = function(position) {
- 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;
- }
+ controlListManager : function() {
+ this.selectedItems.sort(this.compareByRowIndex);
+ var control;
+ //FIXME
+ if ((this.shuttleItems.length <= 1) || (this.selectedItems.length == 0)) {
+ this.controlsProcessing(["first", "last", "down",
"up"]);
+ } else if (this.selectedItems[0].rowIndex == 0) {
+ this.controlsProcessing(["first", "up"]);
+ } else if (this.selectedItems[this.selectedItems.length - 1].rowIndex ==
(this.shuttleItems.length - 1)) {
+ this.controlsProcessing(["down", "last"]);
} else {
- if (currentItem.rowIndex > extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
+ this.controlsProcessing();
}
- }
- return extremeItem;
-}
-
-Richfaces.OrderingList.prototype.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 &&
Richfaces.OrderingList.CONTROL_SET.indexOf(activeElem.tagName) != -1) {
- return;
- }
-
- while (activeElem.tagName.toLowerCase() != "tr") {
- activeElem = activeElem.parentNode;
- if (!activeElem.tagName) {
- return; //for IE
+ 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();
+ }
}
- }
+ },
- return activeElem;
-}
-
-Richfaces.OrderingList.prototype.onclickHandler = function(event) {
- var activeElem = this.getEventTargetRow(event);
- if (activeElem != null) {
-
- if (event.ctrlKey) {
- this.addSelectedItem(activeElem);
- this.activeItem = activeElem;
- } else if (event.shiftKey) {
- this.selectItemGroup(activeElem);
- } else {
- this.selectionItem(activeElem);
- this.activeItem = activeElem;
- }
-
- if (this.getSelectItemByNode(this.activeItem)._selected) {
- Richfaces.SelectItems.doActive(this.activeItem);
- } else {
- Richfaces.SelectItems.doNormal(this.activeItem);
- }
- this.saveState();
+ onclickHandler : function(event) {
+ Richfaces.OrderingList.parentClass.method("onclickHandler").call(this,
event);
this.controlListManager();
- this.setFocus();
- }
-}
-
-Richfaces.OrderingList.prototype.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';
- if (event.ctrlKey) {
- this.moveSelectedItems(action, event);
- } else {
- this.moveActiveItem(action, event);
- }
- break;
- case 40 : //down arrow
- action = 'down';
- if (event.ctrlKey) {
- this.moveSelectedItems(action ,event);
- } else {
- this.moveActiveItem(action, event);
- }
- break;
- case 65 : // Ctrl + A
- if (event.ctrlKey) {
- this.selectAll();
- Richfaces.OrderingList.stopPropogation(event);
- }
- Richfaces.SelectItems.doActive(this.activeItem);
- this.saveState();
- break;
- case 32 : this.invertSelection(event); this.saveState(); break; //blank
- }
- //if (action != null)
- // this.autoScrolling(action, event);
-}
-
-Richfaces.OrderingList.stopPropogation = function(event) {
- if (event.stopPropagation) {
- event.preventDefault();
- event.stopPropagation();
- } else {
- event.cancelBubble = true;
- event.returnValue = false;
- }
-}
-
-Richfaces.OrderingList.prototype.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);
- }
-}
-
-Richfaces.OrderingList.prototype.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();
-}
-
-Richfaces.OrderingList.prototype.changeActiveItems = function(newItem, item) {
- var shuttleItem = this.getSelectItemByNode(item);
- var newShuttleItem = this.getSelectItemByNode(newItem);
+ moveActiveItem : function(action, event) {
+ Richfaces.OrderingList.parentClass.method("moveActiveItem").call(this
,action, event);
+ this.controlListManager();
+ },
- this.resetMarked();
+ moveSelectedItems : function(action, event) {
+ event = window.event||event;
+ var rows = this.shuttleTbody.rows;
+ var item;
+ if (this.selectedItems.length > 0) {
+ this.selectedItems.sort(this.compareByRowIndex);
+
+ if ((action == 'up') &&
this.getExtremeItem("first").previousSibling) {
+ for (var i = 0; i < this.selectedItems.length; i++) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item, item.previousSibling);
+ }
+ } else if ((action == 'down') &&
this.getExtremeItem("last").nextSibling) {
+ for (var i = this.selectedItems.length - 1; i > -1; i--) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item.nextSibling, item);
+ }
+ } else if (action == 'first') {
+ var incr = this.selectedItems[0].rowIndex;
+ for (var i = 0; i < this.selectedItems.length; i++) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item, rows[item.rowIndex - incr]);
+ }
+ } else if (action == 'last') {
+ var length = this.shuttleItems.length;
+ var incr = length - this.selectedItems[this.selectedItems.length - 1].rowIndex;
+ for (var i = this.selectedItems.length - 1; i > -1; i--) {
+ item = this.selectedItems[i];
+ if (item.rowIndex + incr > length - 1) {
+ item.parentNode.insertBefore(item, null);
+ } else {
+ item.parentNode.insertBefore(item, rows[item.rowIndex + incr]);
+ }
+ }
+ }
+
+ this.shuttleItems = new Array();
+ for (var i = 0; i < rows.length; i++) {
+ this.shuttleItems.push(rows[i].item);
+ }
+ if (action != null)
+ this.autoScrolling(action, event);
+
+ this.onorderchanged();
+ this.controlListManager();
+ this.saveState();
+ }
+ },
- Richfaces.SelectItems.doActive(newItem);
- newItem._selected = true;
- this.activeItem = newItem;
- this.selectedItems.push(newItem);
-}
+ 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';
+ if (event.ctrlKey) {
+ this.moveSelectedItems(action, event);
+ } else {
+ this.moveActiveItem(action, event);
+ }
+ break;
+ case 40 : //down arrow
+ action = 'down';
+ if (event.ctrlKey) {
+ this.moveSelectedItems(action ,event);
+ } else {
+ this.moveActiveItem(action, event);
+ }
+ break;
+ case 65 : // Ctrl + A
+ if (event.ctrlKey) {
+ this.selectAll();
+ Event.stop(event);
+ }
+ Richfaces.SelectItems.doActive(this.activeItem);
+ this.saveState();
+ break;
+ case 32 : this.invertSelection(event); this.saveState(); break; //blank
+ }
+ },
-Richfaces.OrderingList.prototype.selectAll = function() {
- var startIndex = 0;
- var endIndex = this.shuttleItems.length - 1;
- this.selectItemRange(startIndex, endIndex);
-}
-
-/**
- * Click handler
- */
-Richfaces.OrderingList.prototype.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;
+ toString : function() {
+ var result = new Array();
+ for (var i = 0; i < this.shuttleItems.length; i++) {
+ var item = this.shuttleItems[i];
+ result.push(item._id);
+ if (item._selected) {
+ result.push(Richfaces.OrderingList.SELECTION_MARKER);
+ }
+ if (this.activeItem && (this.activeItem.rowIndex == item._node.rowIndex)) {
+ result.push(Richfaces.OrderingList.ACTIVITY_MARKER);
+ }
+ if (i != (this.shuttleItems.length - 1)) {
+ result.push(Richfaces.OrderingList.ITEM_SEPARATOR);
+ }
}
- }
-}
-
-/**
- * CTRL+Click handler
- */
-Richfaces.OrderingList.prototype.addSelectedItem = function(activeItem) {
- var markedItem = this.getSelectItemByNode(activeItem);
- var markedShuttleItem = activeItem;
+ return result.join("");
+ },
- 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
- */
-Richfaces.OrderingList.prototype.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);
-}
-
-Richfaces.OrderingList.prototype.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;
- }
-}
-
-Richfaces.OrderingList.prototype.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;
-}
-
-Richfaces.OrderingList.prototype.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;
+ saveState : function() {
+ if (this.activeItem != null || (this.selectedItems.length > 0)) {
+ this.valueKeeper.value = this.toString();
}
}
- return null;
-}
-
-Richfaces.OrderingList.prototype.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;
- }
- }
- Richfaces.OrderingList.stopPropogation(event);
-}
-
-/*Shuttle.prototype.init = function() {
- this.shuttle = this.shuttleTbody;
- this.addList(this.shuttleItems);
- this.shuttleTable.appendChild(this.shuttle)
- this.container.appendChild(this.shuttleTable);
-}
-
-Shuttle.prototype.rebuild = function() {
- this.shuttle = document.createElement("tbody");
- for (var i = 0; i < this.shuttleItems.length; i++) {
- this.shuttle.appendChild(this.shuttleItems[i]._node);
- }
- this.shuttleTbody.parentNode.removeChild(this.shuttleTbody);
- this.shuttleTable.appendChild(this.shuttle);
- this.shuttleTbody = this.shuttleTable.tBodies[0];
-}
+});
-Shuttle.prototype.createShuttleItem = function(selectItem, elemContainer) {
- var tr = document.createElement("tr");
- elemContainer.appendChild(tr);
- tr.id = selectItem._id
- var className = null;
- if (selectItem._selected) {
- className = Shuttle.SELECTED_ITEM_CLASS;
- } else if (this.activeItem && (this.activeItem == selectItem)) {
- className = Shuttle.ACTIVE_ITEM_CLASS;
- } else {
- className = Shuttle.NORMAL_ITEM_CLASS;
- }
- tr.className = className;
-
- var obj = this;
- tr.onclick = function(e) {
- obj.onclickHandler(window.event || e);
- }
-
- var td = document.createElement("td");
- tr.appendChild(td);
- if (td.textContent == undefined) {
- td.innerText = selectItem._label;
- } else {
- td.textContent = selectItem._label;
- }
- selectItem._node = tr;
-}*/
+Richfaces.OrderingList.ACTIVITY_MARKER = "a";
+Richfaces.OrderingList.SELECTION_MARKER = "s";
+Richfaces.OrderingList.ITEM_SEPARATOR = ",";
-Richfaces.OrderingList.prototype.toString = function() {
- var result = new Array();
- for (var i = 0; i < this.shuttleItems.length; i++) {
- var item = this.shuttleItems[i];
- result.push(item._id);
- if (item._selected) {
- result.push(Richfaces.OrderingList.SELECTION_MARKER);
- }
- if (this.activeItem && (this.activeItem.rowIndex == item._node.rowIndex)) {
- result.push(Richfaces.OrderingList.ACTIVITY_MARKER);
- }
- if (i != (this.shuttleItems.length - 1)) {
- result.push(Richfaces.OrderingList.ITEM_SEPARATOR);
- }
- }
- return result.join("");
-}
-
-Richfaces.OrderingList.prototype.saveState = function() {
- if (this.activeItem != null || (this.selectedItems.length > 0)) {
- this.valueKeeper.value = this.toString();
- }
-}
-
-Richfaces.OrderingList.prototype.compareByLabel = function(obj1, obj2) {
- obj1 = obj1._label;
- obj2 = obj2._label;
- return Richfaces.OrderingList.compare(obj1, obj2);
-}
-
-Richfaces.OrderingList.prototype.compareByRowIndex = function(obj1, obj2) {
- obj1 = obj1.rowIndex;
- obj2 = obj2.rowIndex;
- return Richfaces.OrderingList.compare(obj1, obj2);
-}
-
-Richfaces.OrderingList.compare = function(obj1, obj2) {
- return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
-}
-
-Richfaces.OrderingList.prototype.setFocus = function() {
- this.focusKeeper.focus();
- this.focusKeeper.focused = true;
- if (this.isListActive()) {
- this.shuttleTable.className = Richfaces.OrderingList.ORDERING_LIST_CLASSES.active;
- }
-}
-
-Richfaces.OrderingList.prototype.focusListener = function(e) {
- e = e || window.event;
- this.focusKeeper.focusused = false;
- if (this.activeItem != null) {
- if (this.getSelectItemByNode(this.activeItem)._selected) {
- Richfaces.SelectItems.doSelect(this.activeItem);
- } else {
- Richfaces.SelectItems.doNormal(this.activeItem);
- }
- }
- this.shuttleTable.className = Richfaces.OrderingList.ORDERING_LIST_CLASSES.normal;
-}
-
-Richfaces.OrderingList.addEventListener = function(elem, event, func) {
- if (window.attachEvent) {
- elem.attachEvent("on" + event, func);
- } else {
- elem.addEventListener(event, func, false);
- }
-}
-
-Richfaces.OrderingList.addClickListener = function(elem, func) {
- Richfaces.OrderingList.addEventListener(elem, "click", func);
-}
-
+Richfaces.OrderingList.HANDLERS = {
+ first: function (e) { this.moveSelectedItems("first", e);return false; },
+ last: function (e) { this.moveSelectedItems("last", e);return false; },
+ up: function (e) { this.moveSelectedItems("up", e);return false; },
+ down: function (e) { this.moveSelectedItems("down", e);return false; }
+};
\ No newline at end of file