Author: vmolotkov
Date: 2007-11-08 10:35:22 -0500 (Thu, 08 Nov 2007)
New Revision: 3826
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
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:
rowId generation, initialization of active and selected items
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-08
14:51:30 UTC (rev 3825)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-08
15:35:22 UTC (rev 3826)
@@ -37,7 +37,6 @@
public void encodeOrderingListStructure(FacesContext context, UIOrderingList
orderingList)
throws IOException {
-
ResponseWriter writer = context.getResponseWriter();
//encodeCaption(context, orderingList);
encodeHeader(context, orderingList);
@@ -112,9 +111,9 @@
ResponseWriter writer = context.getResponseWriter();
UIDataAdaptor table = holder.getTable();
-
+ String clientId = holder.getTable().getClientId(context);
writer.startElement(HTML.TR_ELEMENT, table);
-
+ writer.writeAttribute("id", clientId, null);
List<UIComponent> children = table.getChildren();
for (UIComponent component : children) {
if (component instanceof UIColumn && component.isRendered()) {
Modified:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js 2007-11-08
14:51:30 UTC (rev 3825)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js 2007-11-08
15:35:22 UTC (rev 3826)
@@ -27,12 +27,13 @@
for (var i = 0; i < contentCells.length; i++) {
width = contentCells[i].offsetWidth - LayoutManager.STYLE_CONTENTTD_BORDER -
LayoutManager.STYLE_CONTENTTD_PADDING;
if (i == contentCells.length - 1) {
- width = width + LayoutManager.SCROLL_WIDTH;
+ width = width + LayoutManager.SCROLL_WIDTH + "px";
headerCells[i].firstChild.style.width = width;
headerCells[i].style.width = width;
} else {
+ width = width + "px";
headerCells[i].firstChild.style.width = width;
- headerCells[i].style.width = width;
+ headerCells[i].style.width = width;
}
}
this.headerTable.style.width = this.contentTable.offsetWidth +
LayoutManager.SCROLL_WIDTH;
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-08
14:51:30 UTC (rev 3825)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-08
15:35:22 UTC (rev 3826)
@@ -1,14 +1,15 @@
+if (LayoutManager.isIE()) {
+Array.prototype.indexOf = function(obj) {
+ for(var i=0; i < this.length; i++) {
+ if(this[i]==obj) {
+ return i;
+ }
+ }
+ return -1;
+}
+}
+
Array.prototype.remove = function(object) {
- if (!this.indexOf) {
- this.indexOf = function(obj){
- for(var i=0; i < this.length; i++){
- if(this[i]==obj){
- return i;
- }
- }
- return -1;
- }
- }
var index = this.indexOf(object, 0, this.length);
if (index == 0) {
this.shift();
@@ -18,14 +19,14 @@
}
Shuttle = function(containerId, contentTableId, headerTableId, focusKeeperId,
valueKeeperId,
- upControlId, downControlId, firstControlId, lastControlId, onclickControlId,
ordering) {
+ upControlId, downControlId, firstControlId, lastControlId, onclickControlId) {
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(ordering);
+ this.retrieveShuttleItems(containerId);
this.shuttle = null;
this.sortOrder = Shuttle.ASC;
@@ -56,7 +57,9 @@
Shuttle.ACTIVE_SUBITEM_CLASS = "rich-ordering-list-cell-active";
Shuttle.DISABLED_SUBITEM_CLASS = "rich-ordering-list-cell-disabled";
+Shuttle.CONTROL_SET = ["A", "INPUT", "TEXTAREA",
"SELECT", "BUTTON"];
+
Shuttle.ACTIVITY_MARKER = "a";
Shuttle.SELECTION_MARKER = "s";
Shuttle.ITEM_SEPARATOR = ",";
@@ -72,13 +75,21 @@
this.shuttleTop = LayoutManager.getElemXY(this.shuttleTable).top;
}
-Shuttle.prototype.retrieveShuttleItems = function(ordering) {
+Shuttle.prototype.retrieveShuttleItems = function(containerId) {
var rows = this.shuttleTbody.rows;
this.shuttleItems = new Array();
- var obj = this;
+ var id;
+
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
- this.shuttleItems[i] = new SelectItem(null, ordering ? ordering[i] : i, false, row);
+ id = row.id.split(containerId + ":")[1];
+ 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.ACTIVE_ITEM_CLASS) {
+ this.activeItem = row;
+ }
}
}
@@ -177,7 +188,8 @@
Shuttle.prototype.getEventTargetRow = function(event) {
var activeElem;
if (event.rangeParent) {
- activeElem = event.rangeParent.parentNode;
+ //activeElem = event.rangeParent.parentNode;
+ activeElem = event.target;
} else {
activeElem = event.srcElement;
}
@@ -186,6 +198,10 @@
return;
}
+ if (activeElem.tagName && Shuttle.CONTROL_SET.indexOf(activeElem.tagName) != -1)
{
+ return;
+ }
+
while (activeElem.tagName.toLowerCase() != "tr") {
activeElem = activeElem.parentNode;
if (!activeElem.tagName) {
@@ -198,21 +214,21 @@
Shuttle.prototype.onclickHandler = function(event) {
var activeElem = this.getEventTargetRow(event);
- if (activeElem == null) {
- return;
+ 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;
+ }
+ this.activeItem.className = Shuttle.ACTIVE_ITEM_CLASS;
+ this.saveState();
+ Shuttle.setFocus(this.focusKeeper.id);
}
-
- if (event.ctrlKey) {
- this.addSelectedItem(activeElem);
- this.activeItem = activeElem;
- } else if (event.shiftKey) {
- this.selectItemGroup(activeElem);
- } else {
- this.selectionItem(activeElem);
- this.activeItem = activeElem;
- }
- this.activeItem.className = Shuttle.ACTIVE_ITEM_CLASS;
- this.saveState();
}
Shuttle.prototype.onkeydownHandler = function(event) {
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-08
14:51:30 UTC (rev 3825)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-08
15:35:22 UTC (rev 3826)
@@ -12,12 +12,12 @@
<h:styles>css/orderingList.xcss</h:styles>
<h:scripts>
- scripts/SelectItem.js,scripts/OrderingList.js,scripts/LayoutManager.js
+ scripts/SelectItem.js,scripts/LayoutManager.js,scripts/OrderingList.js
</h:scripts>
<f:clientId var="clientId"/>
- <div id="#{clientId}"
onclick="Shuttle.setFocus('#{clientId}focusKeeper')"
x:passThruWithExclusions="id,onclick">
- <input id="#{clientId}focusKeeper" type="button"
value="" style="position: absolute; left: -32767;"
name="focusKeeper"/>
+ <div id="#{clientId}" x:passThruWithExclusions="id">
+ <input id="#{clientId}focusKeeper" type="button"
value="" style="position: absolute; left: -32767px;"
name="focusKeeper"/>
<input id="#{clientId}valueKeeper" type="hidden"
name="#{clientId}" value="#{component.submittedValueAsString}"/>
<table id="#{clientId}table" cellpadding="0"
cellspacing="0" class="ol_body">
@@ -52,19 +52,19 @@
<f:clientId var="cId"/>
<script type="text/javascript">
var clientId = '#{cId}';
- /*if (window.attachEvent) {
+ if (window.attachEvent) {
window.attachEvent("onload", init);
} else {
window.addEventListener("load", init, false);
- }*/
+ }
document.body.onselectstart = function() {return false;};
document.body.className = "body";
+ var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper','#{cId}up', '#{cId}down',
'#{cId}first', '#{cId}last', '#{cId}sortLabel');
function init() {
- var shuttle = new Shuttle('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper','#{cId}up', '#{cId}down',
'#{cId}first', '#{cId}last', '#{cId}sortLabel',
#{component.elementsOrder});
var layoutManager = new LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
layoutManager.widthSynchronization();
}
- setTimeout(init, 0);
+ //setTimeout(init, 0);
</script>
</f:root>
\ No newline at end of file