Author: vmolotkov
Date: 2007-11-09 17:16:36 -0500 (Fri, 09 Nov 2007)
New Revision: 3888
Added:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
control list manager was added
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-09
20:59:54 UTC (rev 3887)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-09
22:16:36 UTC (rev 3888)
@@ -63,13 +63,13 @@
private final static String ATTRIBUTE_CAPTION_LABEL = "captionLabel";
- private final static String CONTROL_ID_UP = "_up";
+ private final static String CONTROL_ID_UP = "up";
- private final static String CONTROL_ID_DOWN = "_down";
+ private final static String CONTROL_ID_DOWN = "down";
- private final static String CONTROL_ID_TOP = "_top";
+ private final static String CONTROL_ID_TOP = "first";
- private final static String CONTROL_ID_BOTTOM = "_bottom";
+ private final static String CONTROL_ID_BOTTOM = "last";
protected static abstract class ControlsHelper {
private String name;
Modified:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-09
20:59:54 UTC (rev 3887)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-09
22:16:36 UTC (rev 3888)
@@ -120,6 +120,13 @@
.ol_internal_tab tr.ol_normal {
}
+.ol_control_shown {
+ visibility: hidden;
+}
+.ol_control_shown {
+ visibity: visible;
+}
+
.body {
-moz-user-select: none;
}
Added:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js 2007-11-09
22:16:36 UTC (rev 3888)
@@ -0,0 +1,55 @@
+Control = function(eNode, dNode, isShown, isEnabled, action) {
+ this.disabledNode = dNode;
+ this.enabledNode = eNode
+ this.isShown = isShown;
+ this.isEnabled = isEnabled;
+ this.action = action;
+ this.isEnabled ? this.doEnable() : this.doDisable();
+ this.isShown ? this.doShow() : this.doHide();
+}
+
+Control.CLASSES = {
+ first : {hidden : "ol_control_hidden", shown : "ol_control_shown",
disabled : "", enabled : ""},
+ down : {hidden : "ol_control_hidden", shown : "ol_control_shown",
disabled : "", enabled : ""},
+ up : {hidden : "ol_control_hidden", shown : "ol_control_shown",
disabled : "", enabled : ""},
+ last : {hidden : "ol_control_hidden", shown : "ol_control_shown",
disabled : "", enabled : ""}
+};
+
+Control.prototype.doShow = function() {
+ this.isShown = true;
+ if (this.isEnabled) {
+ this.doHideNode(this.disabledNode);
+ this.doShowNode(this.enabledNode);
+ } else {
+ this.doHideNode(this.enabledNode);
+ this.doShowNode(this.disabledNode);
+ }
+}
+
+Control.prototype.doHide = function() {
+ this.isShown = false;
+ this.doHideNode(this.disabledNode);
+ this.doHideNode(this.enabledNode);
+}
+
+Control.prototype.doEnable = function() {
+ this.isEnabled = true;
+ this.doHideNode(this.disabledNode);
+ this.doShowNode(this.enabledNode);
+}
+
+Control.prototype.doDisable = function() {
+ this.isEnabled = false;
+ this.doHideNode(this.enabledNode);
+ this.doShowNode(this.disabledNode);
+}
+
+Control.prototype.doHideNode = function(node) {
+ node.className = Control.CLASSES[this.action].hidden;
+}
+
+Control.prototype.doShowNode = function(node) {
+ node.className = Control.CLASSES[this.action].shown;
+}
+
+
Modified:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-09
20:59:54 UTC (rev 3887)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-09
22:16:36 UTC (rev 3888)
@@ -19,7 +19,7 @@
}
Shuttle = function(containerId, contentTableId, headerTableId, focusKeeperId,
valueKeeperId,
- upControlIdPr, downControlIdPr, firstControlIdPr, lastControlIdPr,
onclickControlId) {
+ controlsId, onclickControlId) {
this.container = document.getElementById(containerId);
this.shuttleTable = document.getElementById(contentTableId);
this.shuttleTbody = this.shuttleTable.tBodies[0];
@@ -37,11 +37,15 @@
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(contentTableId, headerTableId, containerId + upControlIdPr, containerId +
downControlIdPr, containerId + firstControlIdPr, containerId + lastControlIdPr,
onclickControlId, focusKeeperId);
+ this.init(containerId, contentTableId, headerTableId, controlsId, onclickControlId,
focusKeeperId);
}
Shuttle.ASC = "acs";
@@ -64,29 +68,60 @@
Shuttle.SELECTION_MARKER = "s";
Shuttle.ITEM_SEPARATOR = ",";
-Shuttle.prototype.init = function(contentTableId, headerTableId, upControlId,
downControlId, firstControlId, lastControlId, onclickControlId, focusKeeperId) {
+Shuttle.prototype.init = function(containerId, contentTableId, headerTableId, ids,
onclickControlId, focusKeeperId) {
var obj = this;
Shuttle.setFocus(focusKeeperId);
- var upControl = document.getElementById(upControlId);
- var downControl = document.getElementById(downControlId);
- var topControl = document.getElementById(firstControlId);
- var bottomControl = document.getElementById(lastControlId);
- if (upControl) {
- Shuttle.addClickListener(upControl, function(e) {obj.moveSelectedItems('up',
e);return false;});
+ 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, function(e) {obj.moveSelectedItems(id[0], e);return
false;});
+ this.controlList[i] = new Control(node, disNode, false, false, id[0]);
+ }
}
- if (downControl) {
- Shuttle.addClickListener(downControl, function(e)
{obj.moveSelectedItems('down', e);return false;});
- }
- if (topControl) {
- Shuttle.addClickListener(topControl, function(e)
{obj.moveSelectedItems('first', e);return false;});
- }
- if (bottomControl) {
- Shuttle.addClickListener(bottomControl, function(e)
{obj.moveSelectedItems('last', e);return false;});
- }
+ this.controlListManager();
document.getElementById(contentTableId).onclick = function(e)
{obj.onclickHandler(window.event || e);};
this.shuttleTop = LayoutManager.getElemXY(this.shuttleTable).top;
}
+Shuttle.prototype.controlListManager = function() {
+ this.selectedItems.sort(this.compareByRowIndex);
+ var control;
+ //FIXME
+ if (this.selectedItems.length <= 1) {
+ for (var i = 0; i < this.controlList; i++) {
+ control = this.controlList[i];
+ this.controlList[i].doDisable();
+ }
+ } else if (this.selectedItems[0].rowIndex == 0) {
+ this.getControlByAction("first").doDisable();
+ this.getControlByAction("up").doDisable();
+ this.getControlByAction("down").doEnable();
+ this.getControlByAction("last").doEnable();
+ } else if (this.selectedItems[this.selectedItems.length - 1].rowIndex ==
(this.shuttleItems.length - 1)) {
+ this.getControlByAction("down").doDisable();
+ this.getControlByAction("last").doDisable();
+ this.getControlByAction("first").doEnable();
+ this.getControlByAction("up").doEnable();
+ } else {
+ for (var i = 0; i < this.controlList; i++) {
+ control = this.controlList[i];
+ this.controlList[i].doEnable();
+ }
+ }
+}
+
+Shuttle.prototype.getControlByAction = function(action) {
+ for (var i = 0; i < this.controlList.length; i++) {
+ var control = this.controlList[i];
+ if (control.action == action) {
+ return control;
+ }
+ }
+ return null;
+}
+
Shuttle.prototype.retrieveShuttleItems = function(containerId) {
var rows = this.shuttleTbody.rows;
this.shuttleItems = new Array();
@@ -98,7 +133,9 @@
this.shuttleItems[i] = new SelectItem(null, (id || i),
((row.className == Shuttle.SELECTED_ITEM_CLASS) ? true : false),
row);
- this.selectedItems.push(row);
+ if (row.className == Shuttle.SELECTED_ITEM_CLASS) {
+ this.selectedItems.push(row);
+ }
if (row.className == Shuttle.ACTIVE_ITEM_CLASS) {
this.activeItem = row;
}
@@ -176,6 +213,7 @@
}
if (action != null)
this.autoScrolling(action, event);
+ this.controlListManager();
this.saveState();
}
}
@@ -313,6 +351,7 @@
this.saveState();
this.autoScrolling(action, event);
+ this.controlListManager();
}
Shuttle.prototype.changeActiveItems = function(newItem, item) {
@@ -487,6 +526,10 @@
selectItem._node = tr;
}*/
+Shuttle.prototype.isTopControlEnabled = function() {
+
+}
+
Shuttle.prototype.toString = function() {
var result = new Array();
for (var i = 0; i < this.shuttleItems.length; i++) {
Modified:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-09
20:59:54 UTC (rev 3887)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-09
22:16:36 UTC (rev 3888)
@@ -13,7 +13,8 @@
<h:scripts>
scripts/SelectItem.js,
- scripts/LayoutManager.js
+ scripts/LayoutManager.js
+ scripts/Control.js,
scripts/OrderingList.js,
</h:scripts>
@@ -51,11 +52,15 @@
</td>
<td class="ol_button_layout">
<f:call name="encodeControlsFacets"/>
+ <f:clientId var="clientId"/>
+ <a id="#{clientId}disFirst"
href="#">disabledTop</a><br/>
+ <a id="#{clientId}disUp"
href="#">disUp</a><br/>
+ <a id="#{clientId}disDown"
href="#">disDown</a><br/>
+ <a id="#{clientId}disLast" href="#">disBottom</a>
</td>
</tr>
</tbody>
</table>
- <f:clientId var="clientId"/>
<a id="#{clientId}sortLabel" href="#">Header</a>
</div>
@@ -70,7 +75,8 @@
document.body.onselectstart = function() {return false;};
document.body.className = "body";
function init() {
- var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper','_up', '_down', '_top',
'_bottom', '#{cId}sortLabel');
+ var cotrolsIdPrefix = [['up', 'disUp'], ['down',
'disDown'], ['last', 'disLast'],
['first','disFirst']];
+ var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper', cotrolsIdPrefix, '#{cId}sortLabel');
var layoutManager = new LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
layoutManager.widthSynchronization();
}