JBoss Rich Faces SVN: r4644 - in branches/3.1.x/samples/richfaces-demo/src/main: webapp/richfaces/calendar and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2007-12-10 06:05:30 -0500 (Mon, 10 Dec 2007)
New Revision: 4644
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml
branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml
Log:
http://jira.jboss.com/jira/browse/RF-1561
Calendar Time fields addition.
Modified: branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
===================================================================
--- branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java 2007-12-09 22:52:58 UTC (rev 4643)
+++ branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java 2007-12-10 11:05:30 UTC (rev 4644)
@@ -43,7 +43,7 @@
locale = Locale.US;
popup = true;
- pattern = "MMM d, yyyy";
+ pattern = "MMM d, yyyy, HH:mm";
}
public void selectLocale(ValueChangeEvent event) {
Modified: branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml
===================================================================
--- branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml 2007-12-09 22:52:58 UTC (rev 4643)
+++ branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml 2007-12-10 11:05:30 UTC (rev 4644)
@@ -40,12 +40,12 @@
<h:outputText value="Select Date Pattern:"/>
<h:selectOneMenu value="#{calendarBean.pattern}">
<a4j:support event="onchange" reRender="calendar"/>
- <f:selectItem itemLabel="d/M/yy" itemValue="d/M/yy"/>
- <f:selectItem itemLabel="dd/M/yy" itemValue="dd/M/yy"/>
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm"/>
+ <f:selectItem itemLabel="dd/M/yy hh:mm a" itemValue="dd/M/yy hh:mm a"/>
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y"/>
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
</h:selectOneMenu>
-
+
</h:panelGrid>
</h:panelGrid>
Modified: branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml
===================================================================
--- branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml 2007-12-09 22:52:58 UTC (rev 4643)
+++ branches/3.1.x/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml 2007-12-10 11:05:30 UTC (rev 4644)
@@ -8,8 +8,8 @@
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
- <p>
- rich:calendar allows to select the date using monthly calendar elements on pages.
+ <p><b>
+ rich:calendar</b> allows to select the date using monthly calendar elements on pages.
It is possible to use the component in a popup and inline code. At a popup mode Calendar
is initially rendered as input for date and button on the right side to call a popup.
In case of an inline mode, the monthly calendar is located on a page initially.
@@ -23,6 +23,15 @@
</ui:include>
</div>
+ <p>
+ Calendar component allows to work with <b>time</b> also. You should just define
+ time in pattern ( for example "<i>d/M/yy HH:mm</i>" as it defined in this sample
+ by default)
+ </p>
+ <p>
+ After you choose some date - you'll be able to manage time for this date. Spinner will be called
+ after click on the time fields to edit them.
+ </p>
<p>
<b>locale</b> attribute is defined as a Locale. The default value is set to the Locale of the current page.
The name of the month and week days names depend of the Locale.
18 years, 5 months
JBoss Rich Faces SVN: r4643 - in branches/3.1.x/ui/orderingList/src/main: resources/org/richfaces/renderkit/html/css and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-09 17:52:58 -0500 (Sun, 09 Dec 2007)
New Revision: 4643
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
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
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1558
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-12-09 22:52:58 UTC (rev 4643)
@@ -296,7 +296,8 @@
}
writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + helper.getIdSuffix(), null); //FIXME:
+ String controlId = clientId + helper.getIdSuffix();
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); //FIXME:
writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
String style = null;
if (enabled) {
@@ -317,12 +318,15 @@
}
writer.startElement(HTML.a_ELEMENT, orderingList);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link", null); //FIXME:
writer.writeAttribute(HTML.HREF_ATTR, "#", null);
if (!helper.enable) {
writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-a-disabled", null);
} else {
writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection", null);
+ writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Control.onblur(this);", null);
+ writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Control.onfocus(this);", null);
}
writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;", null);
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-12-09 22:52:58 UTC (rev 4643)
@@ -122,10 +122,10 @@
ItemState state = getItemState(context, table, variables);
boolean active = state.isActive();
- if (active) {
- rowClassName.append(" rich-ordering-list-row-active");
- cellClassName.append(" rich-ordering-list-cell-active");
- }
+// if (active) {
+// rowClassName.append(" rich-ordering-list-row-active");
+// cellClassName.append(" rich-ordering-list-cell-active");
+// }
boolean selected = state.isSelected();
if (selected) {
@@ -170,8 +170,6 @@
writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
StringBuffer value = new StringBuffer();
- value.append(table.getRowKey());
-
if (selected) {
value.append('s');
}
@@ -180,6 +178,7 @@
value.append('a');
}
+ value.append(table.getRowKey());
value.append(':');
value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
@@ -217,20 +216,20 @@
Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
String substring = string.substring(0, idx);
- idx = substring.length() - 1;
+ idx = 0;
+ if (substring.charAt(idx) == 's') {
+ selection.add(value);
+ idx++;
+ }
+
if (substring.charAt(idx) == 'a') {
activeItem = value;
- idx--;
+ idx++;
}
- if (substring.charAt(idx) == 's') {
- selection.add(value);
- idx--;
- }
+ substring = substring.substring(idx);
- substring = substring.substring(0, idx + 1);
-
Object key = new Integer(substring);
map.put(key, value);
}
Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-12-09 22:52:58 UTC (rev 4643)
@@ -172,10 +172,8 @@
}
.rich-ordering-list-cell-selected {
- padding : 1px 2px;
+ padding : 2px 2px;
white-space: nowrap;
- border-top: 1px solid;
- border-bottom: 1px solid;
}
.rich-ordering-list-cell-active {
@@ -293,10 +291,6 @@
<u:style name="font-family" skin="generalFamilyFont" />
<u:style name="font-size" skin="generalSizeFont" />
</u:selector>
- <u:selector name=".rich-ordering-list-cell-selected">
- <u:style name="border-bottom-color" skin="tableBorderColor" />
- <u:style name="border-top-color" skin="tableBackgroundColor" />
- </u:selector>
<u:selector name=".rich-ordering-list-cell-selected, .rich-ordering-list-cell-selected *">
<u:style name="color" skin="generalTextColor"/>
Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js 2007-12-09 22:52:58 UTC (rev 4643)
@@ -4,6 +4,14 @@
return false;
}
+Control.onfocus = function(element) {
+ element.hasFocus = true;
+}
+
+Control.onblur = function(element) {
+ element.hasFocus = undefined;
+}
+
Control.prototype.initialize = function(eNode, dNode, isShown, isEnabled, action) {
this.disabledNode = dNode;
this.disabledNode.onselectstart = Control.eventStub;
@@ -50,8 +58,30 @@
Control.prototype.doDisable = function() {
this.isEnabled = false;
+
+ var nodes = this.enabledNode.select("a[id='" + this.enabledNode.id + "link']");
+
+ var newFocusNode = undefined;
+
+ if (nodes && nodes[0]) {
+ var link = nodes[0];
+ if (link.hasFocus) {
+ var disNodes = this.disabledNode.select("a[id='" + this.disabledNode.id + "link']");
+ if (disNodes && disNodes[0]) {
+ newFocusNode = disNodes[0];
+ }
+ }
+ }
+
this.doHideNode(this.enabledNode);
this.doShowNode(this.disabledNode);
+ if (newFocusNode && newFocusNode.focus) {
+ //For IE
+ newFocusNode.disabled = false;
+ newFocusNode.focus();
+ //For IE
+ newFocusNode.disabled = true;
+ }
}
Control.prototype.doHideNode = function(node) {
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-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-12-09 22:52:58 UTC (rev 4643)
@@ -32,27 +32,8 @@
Richfaces.ListBase.CONTROL_SET = ["A", "INPUT", "TEXTAREA", "SELECT", "OPTION", "BUTTON"];
Richfaces.ListBase.prototype = {
- CLASSES : {
- ROW : {
- ACTIVE : "rich-ordering-list-row-active",
- SELECTED : "rich-ordering-list-row-selected",
- ACTIVE_SELECTED : "rich-ordering-list-row-selected rich-ordering-list-row-active",
- DISABLED : "rich-ordering-list-row-disabled",
- NORMAL : "rich-ordering-list-row"
- },
- CELL : {
- ACTIVE : "rich-ordering-list-cell-active",
- SELECTED : "rich-ordering-list-cell-selected",
- ACTIVE_SELECTED : "rich-ordering-list-cell-selected rich-ordering-list-cell-active",
- DISABLED : "rich-ordering-list-cell-disabled",
- NORMAL : "rich-ordering-list-cell",
- BEGIN: " rich-ordering-list-cell-begin",
- END: " rich-ordering-list-cell-end"
- }
- },
-
initialize : function(containerId, contentTableId, headerTableId, focusKeeperId,
- onclickControlId) {
+ onclickControlId, controlClass) {
this.selectedItems = new Array();
//this.layoutManager = layoutManager;
@@ -64,13 +45,14 @@
//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.focusKeeper.observe("focus", function (e) {this.onfocusHandler(e);}.bindAsEventListener(this));
this.shuttleTbody = this.shuttleTable.tBodies[0];
this.activeItem = null;
this.items = null;
- this.retrieveShuttleItems(containerId);
+ this.retrieveShuttleItems(containerId, controlClass);
this.shuttle = null;
this.sortOrder = Richfaces.ListBase.ASC;
@@ -78,7 +60,7 @@
this.shuttleTable.observe("click", function(e) {this.onclickHandler(window.event || e)}.bindAsEventListener(this));
},
- retrieveShuttleItems : function(containerId) {
+ retrieveShuttleItems : function(containerId, controlClass) {
var rows = this.shuttleTbody.rows;
this.shuttleItems = new Array();
var id;
@@ -86,15 +68,14 @@
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, this.CLASSES)) ? true : false), row);
- if (Richfaces.SelectItems.isSelected(row, this.CLASSES)) {
+ var item = new controlClass(null, (id || i), row);
+ if (item.isSelected()) {
this.selectedItems.push(row);
}
- if (Richfaces.SelectItems.isActive(row, this.CLASSES)) {
+ if (item.isActive()) {
this.activeItem = row;
}
+ this.shuttleItems[i] = item;
}
},
@@ -144,6 +125,17 @@
return activeElem;
},
+ onfocusHandler: function (event) {
+ if (!this.activeItem && this.shuttleItems.length != 0) {
+ this.activeItem = this.shuttleItems[0]._node;
+
+ }
+
+ if (this.activeItem) {
+ this.activeItem.item.doActive();
+ }
+ },
+
onclickHandler : function(event) {
if (event.srcElement && (event.srcElement.tagName.toLowerCase() == "tbody")) {
return;
@@ -162,7 +154,6 @@
}
- Richfaces.SelectItems.doActive(this.activeItem, this.CLASSES);
this.setFocus();
this.saveState();
@@ -188,7 +179,7 @@
this.selectAll();
Event.stop(event);
}
- Richfaces.SelectItems.doActive(this.activeItem, this.CLASSES);
+ this.activeItem.item.doActive();
this.saveState();
break;
}
@@ -212,8 +203,8 @@
changeActiveItems : function(newItem, item) {
this.resetMarked();
- Richfaces.SelectItems.doSelect(newItem, this.CLASSES);
- Richfaces.SelectItems.doActive(newItem, this.CLASSES);
+ newItem.item.doSelect();
+ newItem.item.doActive();
this.activeItem = newItem;
this.selectedItems.push(newItem);
},
@@ -239,10 +230,10 @@
markedItem._selected = true;
this.selectedItems[0] = markedShuttleItem;
}*/
- if (Richfaces.SelectItems.isSelected(activeItem, this.CLASSES)) {
- Richfaces.SelectItems.doNormal(activeItem);
+ if (activeItem.item.isSelected()) {
+ activeItem.item.doNormal();
} else {
- Richfaces.SelectItems.doSelect(activeItem, this.CLASSES);
+ activeItem.item.doSelect();
this.selectedItems[0] = markedShuttleItem; //TODO: delete
}
//}
@@ -263,20 +254,20 @@
this.selectedItems.push(markedShuttleItem);
}*/
- if (Richfaces.SelectItems.isSelected(activeItem, this.CLASSES)) {
+ if (activeItem.item.isSelected()) {
this.selectedItems.remove(markedShuttleItem); //TODO :delete
- Richfaces.SelectItems.doNormal(activeItem, this.CLASSES);
+ activeItem.item.doNormal();
} else {
- Richfaces.SelectItems.doSelect(activeItem, this.CLASSES);
+ activeItem.item.doSelect();
this.selectedItems.push(markedShuttleItem); //TODO :delete
}
if ((this.activeItem != null) && (this.activeItem.rowIndex != activeItem.rowIndex)) {
//reset activity of an element
- if (Richfaces.SelectItems.isSelected(this.activeItem, this.CLASSES)) {
- Richfaces.SelectItems.doSelect(this.activeItem, this.CLASSES);
+ if (this.activeItem.item.isSelected()) {
+ this.activeItem.item.doSelect();
} else {
- Richfaces.SelectItems.doNormal(this.activeItem, this.CLASSES);
+ this.activeItem.item.doNormal();
}
}
@@ -311,7 +302,7 @@
selectItemRange : function(startIndex, endIndex) {
var rows = this.shuttleTbody.rows;
for (var i = startIndex; i <= endIndex; i++) {
- Richfaces.SelectItems.doSelect(rows[i], this.CLASSES);
+ rows[i].item.doSelect();
this.selectedItems.push(rows[i]);
//this.getSelectItemByNode(rows[i])._selected = true;
}
@@ -323,7 +314,7 @@
var rows = this.shuttleTbody.rows;
for (var i = 0; i < rows.length; i++) {
var shuttleItem = rows[i];
- Richfaces.SelectItems.doNormal(shuttleItem, this.CLASSES);
+ shuttleItem.item.doNormal();
//this.getSelectItemByNode(shuttleItem)._selected = false; //FIXME
}
this.selectedItems.length = 0;
@@ -379,10 +370,10 @@
//this.shuttleTable.className = Richfaces.ListBase.ORDERING_LIST_CLASSES.normal;
if (this.activeItem) {
- if (Richfaces.SelectItems.isSelected(this.activeItem, this.CLASSES)) {
- Richfaces.SelectItems.doSelect(this.activeItem, this.CLASSES);
+ if (this.activeItem.item.isSelected()) {
+ this.activeItem.item.doSelect();
} else {
- Richfaces.SelectItems.doNormal(this.activeItem, this.CLASSES);
+ this.activeItem.item.doNormal();
}
}
},
@@ -409,22 +400,9 @@
saveState : function() {
for (var i = 0; i < this.shuttleItems.length; i++) {
var item = this.shuttleItems[i];
- var value = item.input.value;
- var idx = value.indexOf(":");
- var state = value.substring(0, idx);
- state = state.replace(/[as]/g, "");
-
- //TODO optimization
- if (Richfaces.SelectItems.isSelected(item._node, this.CLASSES)) {
- state = state + "s";
- }
- if (this.activeItem && (this.activeItem.rowIndex == item._node.rowIndex)) {
- state = state + "a";
- }
-
- item.input.value = state + value.substring(idx);
- }
+ item.saveState();
+ }
}
}
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-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-12-09 22:52:58 UTC (rev 4643)
@@ -1,8 +1,29 @@
if(!window.Richfaces) window.Richfaces = {};
+Richfaces.OrderingListSelectItem = Class.create(Richfaces.SelectItem);
+Richfaces.OrderingListSelectItem.prototype.CLASSES = {
+ ROW : {
+ ACTIVE : "rich-ordering-list-row-active",
+ SELECTED : "rich-ordering-list-row-selected",
+ ACTIVE_SELECTED : "rich-ordering-list-row-selected rich-ordering-list-row-active",
+ DISABLED : "rich-ordering-list-row-disabled",
+ NORMAL : "rich-ordering-list-row"
+ },
+ CELL : {
+ ACTIVE : "rich-ordering-list-cell-active",
+ SELECTED : "rich-ordering-list-cell-selected",
+ ACTIVE_SELECTED : "rich-ordering-list-cell-selected rich-ordering-list-cell-active",
+ DISABLED : "rich-ordering-list-cell-disabled",
+ NORMAL : "rich-ordering-list-cell",
+ BEGIN: " rich-ordering-list-cell-begin",
+ END: " rich-ordering-list-cell-end"
+ }
+},
+
+
Richfaces.OrderingList = Class.create(Richfaces.ListBase, {
- initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId, ids, onclickControlId, onorderchanged) {
- $super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId);
+ initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId, ids, onclickControlId, onorderchanged, controlClass) {
+ $super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId, controlClass);
if (onorderchanged) {
this.container.observe("rich:onorderchanged", onorderchanged);
Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js 2007-12-09 22:52:58 UTC (rev 4643)
@@ -1,43 +1,67 @@
if(!window.Richfaces) var Richfaces = function(){};
+Richfaces.SelectItem = Class.create();
-Richfaces.SelectItems = {
+Richfaces.SelectItem.prototype = {
+ initialize : function(label, id, node) {
+ this._label = label;
+ this._node = node;
+ this._node.item = this;
+ this._id = id;
+
+ //TODO 2 optimize
+ this.input = $(node.id + "StateInput");
+
+ this.selected = /^s/.test(this.input.value);
+ this.active = /^s?a/.test(this.input.value);
+ },
- doActive : function(row, classes) {
+ doActive : function() {
+ var classes = this.CLASSES;
+ var row = this._node;
var newRowStyle = classes.ROW.ACTIVE;
var newCellStyle = classes.CELL.ACTIVE;
if (Element.hasClassName(row, classes.ROW.SELECTED)) {
newRowStyle = classes.ROW.ACTIVE_SELECTED;
newCellStyle = classes.CELL.ACTIVE_SELECTED;
}
- Richfaces.SelectItems.doChange(row, newRowStyle, newCellStyle,
+ this.doChange(row, newRowStyle, newCellStyle,
classes.CELL.BEGIN, classes.CELL.END);
+
+ this.active = true;
},
- doSelect : function(row, classes) {
- Richfaces.SelectItems
- .doChange(row,
+ doSelect : function() {
+ var row = this._node;
+ var classes = this.CLASSES;
+ this.doChange(row,
classes.ROW.SELECTED,
classes.CELL.SELECTED);
+
+ this.selected = true;
},
- doNormal : function(row, classes) {
- Richfaces.SelectItems
- .doChange(row,
+ doNormal : function() {
+ var row = this._node;
+ var classes = this.CLASSES;
+ this.doChange(row,
classes.ROW.NORMAL,
classes.CELL.NORMAL);
+
+ this.active = false;
+ this.selected = false;
},
- isSelected : function(row, classes) {
- return Richfaces.SelectItems.compareStates(row, classes.ROW.SELECTED);
+ isSelected : function() {
+ return this.selected;
},
- isActive : function(row, classes) {
- return Richfaces.SelectItems.compareStates(row, classes.ROW.ACTIVE);
+ isActive : function() {
+ return this.active;
},
doChange : function(row, classNameRow, classNameCell, classNameCellBegin, classNameCellEnd) {
- Richfaces.SelectItems.doChangeNode(row, classNameRow);
+ this.doChangeNode(row, classNameRow);
var cells = row.cells;
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
@@ -48,7 +72,7 @@
if (classNameCellBegin && 0 == i){
clazz += " " + classNameCellBegin;
}
- Richfaces.SelectItems.doChangeNode(cell, clazz);
+ this.doChangeNode(cell, clazz);
}
},
@@ -56,24 +80,17 @@
node.className = className;
},
- compareStates : function(row, className) {
- if (row.className.indexOf(className) != -1) {
- return true;
+ saveState: function() {
+ var regex = /^s?a?/;
+
+ if (this.selected && this.active) {
+ this.input.value = this.input.value.replace(regex, 'sa');
+ } else if (this.selected) {
+ this.input.value = this.input.value.replace(regex, 's');
+ } else if (this.active) {
+ this.input.value = this.input.value.replace(regex, 'a');
+ } else {
+ this.input.value = this.input.value.replace(regex, '');
}
- return false;
}
}
-
-Richfaces.SelectItem = Class.create();
-Richfaces.SelectItem.prototype = {
- initialize : function(label, id, selected, node) {
- this._label = label;
- this._node = node;
- this._node.item = this;
- this._id = id;
- this._selected = selected;
-
- //TODO 2 optimize
- this.input = $(node.id + "StateInput");
- }
-}
Modified: branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-12-09 22:52:44 UTC (rev 4642)
+++ branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-12-09 22:52:58 UTC (rev 4643)
@@ -88,7 +88,7 @@
var clientId = '#{cId}';
Event.onReady(function() {
var cotrolsIdPrefix = [['up', 'disup'], ['down', 'disdown'], ['last', 'dislast'], ['first','disfirst']];
- var shuttle = new Richfaces.OrderingList('#{cId}', '#{cId}internal_tab', '#{cId}internal_header_tab', '#{cId}focusKeeper', cotrolsIdPrefix, '#{cId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")});
+ var shuttle = new Richfaces.OrderingList('#{cId}', '#{cId}internal_tab', '#{cId}internal_header_tab', '#{cId}focusKeeper', cotrolsIdPrefix, '#{cId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}, Richfaces.OrderingListSelectItem);
var layoutManager = new LayoutManager('#{clientId}internal_header_tab', '#{clientId}internal_tab');
layoutManager.widthSynchronization();
});
18 years, 5 months
JBoss Rich Faces SVN: r4642 - in branches/3.1.x/ui/listShuttle/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-09 17:52:44 -0500 (Sun, 09 Dec 2007)
New Revision: 4642
Modified:
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1558
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-12-08 16:47:40 UTC (rev 4641)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-12-09 22:52:44 UTC (rev 4642)
@@ -131,15 +131,15 @@
ItemState itemState = getItemState(context, table, variables);
boolean active = itemState.isActive();
- if (active) {
- if (source) {
- rowClassName.append(" rich-shuttle-source-row-active");
- cellClassName.append(" rich-shuttle-source-cell-active");
- } else {
- rowClassName.append(" rich-shuttle-target-row-active");
- cellClassName.append(" rich-shuttle-target-cell-active");
- }
- }
+// if (active) {
+// if (source) {
+// rowClassName.append(" rich-shuttle-source-row-active");
+// cellClassName.append(" rich-shuttle-source-cell-active");
+// } else {
+// rowClassName.append(" rich-shuttle-target-row-active");
+// cellClassName.append(" rich-shuttle-target-cell-active");
+// }
+// }
boolean selected = itemState.isSelected();
selectionState.addState(selected);
@@ -181,8 +181,6 @@
writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
StringBuffer value = new StringBuffer();
- value.append(table.getRowKey());
-
if (selected) {
value.append('s');
}
@@ -191,6 +189,7 @@
value.append('a');
}
+ value.append(table.getRowKey());
value.append(':');
value.append(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
@@ -311,27 +310,27 @@
Object value = converter.getAsObject(context, listShuttle, string.substring(idx + 1));
String substring = string.substring(0, idx);
+ idx = 0;
boolean target = false;
- if (substring.charAt(0) == 't') {
- target = true;
- }
boolean selected = false;
- idx = substring.length() - 1;
-
+ if (substring.charAt(idx) == 's') {
+ (facadeSource ? sourceSelection : targetSelection).add(value);
+ idx++;
+ }
+
if (substring.charAt(idx) == 'a') {
activeItem = value;
- idx--;
+ idx++;
}
- if (substring.charAt(idx) == 's') {
- (facadeSource ? sourceSelection : targetSelection).add(value);
- idx--;
+ if (substring.charAt(idx) == 't') {
+ target = true;
+ idx++;
}
-
- substring = substring.substring(target ? 1 : 0, idx + 1);
+ substring = substring.substring(idx);
Object key = new ListShuttleRowKey(new Integer(substring), target, facadeSource);
map.put(key, value);
Modified: branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-12-08 16:47:40 UTC (rev 4641)
+++ branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-12-09 22:52:44 UTC (rev 4642)
@@ -3,8 +3,10 @@
Richfaces.ListShuttle = Class.create();
Richfaces.ListShuttle.Source = Class.create(Richfaces.ListBase);
+Richfaces.ListShuttle.Target = Class.create(Richfaces.OrderingList);
-Richfaces.ListShuttle.Source.prototype.CLASSES = {
+Richfaces.ListShuttle.Source.SelectItem = Class.create(Richfaces.SelectItem);
+Richfaces.ListShuttle.Source.SelectItem.prototype.CLASSES = {
ROW : {
ACTIVE : "rich-shuttle-source-row-active",
SELECTED : "rich-shuttle-source-row-selected",
@@ -21,11 +23,10 @@
BEGIN: " rich-shuttle-source-cell-begin",
END: " rich-shuttle-source-cell-end"
}
-};
+}
-Richfaces.ListShuttle.Target = Class.create(Richfaces.OrderingList);
-
-Richfaces.ListShuttle.Target.prototype.CLASSES = {
+Richfaces.ListShuttle.Target.SelectItem = Class.create(Richfaces.SelectItem);
+Richfaces.ListShuttle.Target.SelectItem.prototype.CLASSES = {
ROW : {
ACTIVE : "rich-shuttle-target-row-active",
SELECTED : "rich-shuttle-target-row-selected",
@@ -42,7 +43,7 @@
BEGIN: " rich-shuttle-target-cell-begin",
END: " rich-shuttle-target-cell-end"
}
-};
+}
Richfaces.ListShuttle.prototype = {
initialize: function(targetList, sourceList, clientId, controlIds, switchByClick, sourceLayoutManager, targetLayoutManager) {
@@ -152,7 +153,7 @@
addItem : function(component, item) {
//var newItem = Object.clone(item);
- Richfaces.SelectItems.doNormal(item._node, component.CLASSES);
+ item.doNormal();
component.shuttleTbody.insertBefore(item._node, null);
component.shuttleItems.push(item);
},
Modified: branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-08 16:47:40 UTC (rev 4641)
+++ branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-09 22:52:44 UTC (rev 4642)
@@ -183,8 +183,8 @@
var sourceLayoutManager = new LayoutManager('#{clientId}internal_header_tab', '#{clientId}internal_tab');
var targetLayoutManager = new LayoutManager('#{clientId}tlInternal_header_tab', '#{clientId}tlInternal_tab');
- var listShuttle = new Richfaces.ListShuttle(new Richfaces.ListShuttle.Target('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}),
- new Richfaces.ListShuttle.Source('#{clientId}', '#{clientId}internal_tab', '#{clientId}internal_header_tab', '#{clientId}focusKeeper'),
+ var listShuttle = new Richfaces.ListShuttle(new Richfaces.ListShuttle.Target('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}, Richfaces.ListShuttle.Target.SelectItem),
+ new Richfaces.ListShuttle.Source('#{clientId}', '#{clientId}internal_tab', '#{clientId}internal_header_tab', '#{clientId}focusKeeper', undefined, Richfaces.ListShuttle.Source.SelectItem),
"#{clientId}", listShuttleCotrolsIdPrefix, "#{switchByClick}", sourceLayoutManager, targetLayoutManager);
var sourceLayoutManager = new LayoutManager('#{clientId}internal_header_tab', '#{clientId}internal_tab');
var targetLayoutManager = new LayoutManager('#{clientId}tlInternal_header_tab', '#{clientId}tlInternal_tab');
18 years, 5 months
JBoss Rich Faces SVN: r4641 - in branches/3.1.x/ui/dropdown-menu/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-12-08 11:47:40 -0500 (Sat, 08 Dec 2007)
New Revision: 4641
Modified:
branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
branches/3.1.x/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1566
Adaptation to Prototype 1.6
Modified: branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-12-08 16:47:34 UTC (rev 4640)
+++ branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-12-08 16:47:40 UTC (rev 4641)
@@ -91,6 +91,7 @@
menuOptions.addEventHandler("onexpand");
menuOptions.addEventHandler("onitemselect");
menuOptions.addEventHandler("ongroupactivate");
+ menuOptions.addOption("disabled");
function.addParameter(menuOptions);
function.appendScript(buffer);
Modified: branches/3.1.x/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- branches/3.1.x/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-12-08 16:47:34 UTC (rev 4640)
+++ branches/3.1.x/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-12-08 16:47:40 UTC (rev 4641)
@@ -19,8 +19,8 @@
</jsp:scriptlet>
<div id="#{clientId}" style=""
class="#{component.attributes['styleClass']} dr-menu-label dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect"
- onmouseover="this.className='dr-menu-label dr-menu-label-select rich-ddmenu-label rich-ddmenu-label-select' ; #{component.attributes['onmouseover']}"
- onmouseout="this.className='dr-menu-label dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect'; #{component.attributes['onmouseout']}"
+ onmouseover="#{component.attributes['onmouseover']}"
+ onmouseout="#{component.attributes['onmouseout']}"
onmousemove="#{component.attributes['onmousemove']}">
<jsp:scriptlet>
<![CDATA[ } else { ]]>
18 years, 5 months
JBoss Rich Faces SVN: r4640 - in branches/3.1.x/ui/menu-components/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-12-08 11:47:34 -0500 (Sat, 08 Dec 2007)
New Revision: 4640
Modified:
branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
branches/3.1.x/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1566
Adaptation to Prototype 1.6
Modified: branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2007-12-08 16:00:20 UTC (rev 4639)
+++ branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2007-12-08 16:47:34 UTC (rev 4640)
@@ -82,17 +82,19 @@
String itemId = null;
int flcloseonclick = 1;
int flagGroup = 0;
+ boolean disabled = false;
if (kid instanceof UIMenuItem) {
UIMenuItem menuItem = (UIMenuItem) kid;
itemId = kid.getClientId(context);
- if (menuItem.isDisabled()) {
+ disabled = menuItem.isDisabled();
+ if (disabled) {
flcloseonclick = 0;
}
} else if (kid instanceof UIMenuGroup) {
UIMenuGroup menuGroup = (UIMenuGroup) kid;
itemId = "ref" + kid.getClientId(context);
flcloseonclick = 0;
- if (menuGroup.isDisabled()) {
+ if ((disabled = menuGroup.isDisabled())) {
flagGroup = 2;
} else {
flagGroup = 1;
@@ -101,13 +103,16 @@
if (itemId != null) {
JSFunction function = new JSFunction(".addItem");
function.addParameter(itemId);
- function.addParameter(new Integer(flcloseonclick));
-
ScriptOptions options = new ScriptOptions(kid);
options.addEventHandler("onmouseout");
options.addEventHandler("onmouseover");
+ options.addOption("closeOnClick", new Integer(flcloseonclick));
options.addOption("flagGroup", new Integer(flagGroup));
options.addOption("selectClass");
+ options.addOption("style");
+ options.addOption("selectStyle");
+ options.addOption("iconClass");
+ options.addOption("disabled", Boolean.valueOf(disabled));
function.addParameter(options);
return function.toScript();
}
Modified: branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-12-08 16:00:20 UTC (rev 4639)
+++ branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-12-08 16:47:34 UTC (rev 4640)
@@ -1,4 +1,3 @@
-
if(!window.RichFaces) window.RichFaces = {};
if(!RichFaces.Menu) RichFaces.Menu = {};
@@ -342,13 +341,25 @@
var win = RichFaces.Menu.getWindowDimensions();
var bodyHeight = body.height;
var bodyWidth = body.width;
+
var clientX = this.event.clientX;
var clientY = this.event.clientY;
-
- var top = Event.pointerY(this.event);
- var left = Event.pointerX(this.event);
+
+ var e = this.event;
+ var x = Event.pointerX(e);
+ var y = Event.pointerY(e);
+ var elementDim = Richfaces.Position.getOffsetDimensions(this.layer);
+
+ var offsets = Position.cumulativeOffset(this.layer);
+
+ offsets[0] -= this.layer.offsetLeft || 0;
+ offsets[1] -= this.layer.offsetTop || 0;
+
+ var toolTipX = x - offsets[0];
+ var toolTipY = y - offsets[1];
+
var layerdim = Element.getDimensions(this.layer);
- var layerLeft = left;
+ var layerLeft = toolTipX;
if (clientX + layerdim.width > win.width) {
layerLeft -= (layerdim.width - RichFaces.Menu.Layers.shadowWidth - RichFaces.Menu.Layers.CornerRadius);
@@ -367,7 +378,7 @@
layerLeft = 0;
}
*/
- var layerTop = top;
+ var layerTop = toolTipY;
/*if (layertop + layerdim.height > bodyHeight) {
layertop = bodyHeight - layerdim.height;
}
@@ -709,9 +720,8 @@
function(e){
RichFaces.Menu.MouseIn=true;
RichFaces.Menu.Layers.clearLMTO();
- if (this.highlightParent) {
- var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-select rich-ddmenu-label rich-ddmenu-label-select';
+ if (this.shouldHighlightParent() && !this.isWithin(e)) {
+ this.highlightLabel();
}
Event.stop(e);
@@ -723,9 +733,8 @@
if (!RichFaces.Menu.selectOpen) {
RichFaces.Menu.Layers.setLMTO(this.hideDelay);
}
- if (this.highlightParent) {
- var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect';
+ if (this.shouldHighlightParent() && !this.isWithin(e)) {
+ this.unHighlightLabel();
}
Event.stop(e);
}.bindAsEventListener(this);
@@ -799,17 +808,61 @@
A4J.AJAX.AddListener(listener);
} */
},
+
+ getLabel : function() {
+ return RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
+ },
+
+ highlightLabel: function() {
+ var label1 = $(this.getLabel());
+ RichFaces.Menu.Items.replaceClasses(label1,
+ ['dr-menu-label-unselect', 'rich-ddmenu-label-unselect'],
+ ['dr-menu-label-select','rich-ddmenu-label-select']);
+ },
+
+ unHighlightLabel: function() {
+ var label1 = $(this.getLabel());
+ RichFaces.Menu.Items.replaceClasses(label1,
+ ['dr-menu-label-select','rich-ddmenu-label-select'],
+ ['dr-menu-label-unselect', 'rich-ddmenu-label-unselect']);
+ },
+
+ shouldHighlightParent : function() {
+ var result = this.highlightParent;
+ var parent = null;
+ if (result && (parent = this.getParentLayer())) {
+ result &= parent.shouldHighlightParent();
+ }
+ return result;
+ },
+
+ getParentLayer: function() {
+ return this.level > 0 ? RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[this.id])] : null;
+ },
+
+ isWithin : function(event){
+ var within = true;
+ var targetElement = event.relatedTarget;
+ var srcElement = event.target;
+ var layer = $(this.id);
+ if (targetElement) {
+ within = $(targetElement).descendantOf(layer);
+ }
+
+ within &= $(srcElement).descendantOf(layer);
+
+ return within;
+ },
-
-
openSelect: function(event){
RichFaces.Menu.selectOpen = true;
var ClickInputb = this.ClickInput.bindAsEventListener(this);
Event.observe(Event.element(event), "click", this.ClickInput);
},
+
+
-
closeSelect: function(event){
RichFaces.Menu.selectOpen = false;
var ClickInputb = this.ClickInput.bindAsEventListener(this);
@@ -893,104 +946,11 @@
},
//addItem: function(itemId, hoverClass, plainClass, hoverStyle, plainStyle){
- addItem: function(itemId, flag_close_onclick, options) {
+ addItem: function(itemId, options) {
var dis = this;
- var item = {
- highLightGroup: function(light) {
- if (light) {
- Element.removeClassName(this.id,"dr-menu-item-enabled");
- Element.addClassName(this.id,"dr-menu-item-hover");
- Element.addClassName(this.id,"rich-menu-group-hover");
- if (this.options.selectClass) Element.addClassName(this.id, this.options.selectClass);
-
- Element.addClassName(this.id+":icon","rich-menu-item-icon-selected");
- Element.addClassName(this.id+":anchor","rich-menu-item-label");
- } else if (!this.mouseOver) {
- Element.removeClassName(this.id,"dr-menu-item-hover");
- Element.removeClassName(this.id,"rich-menu-group-hover");
- Element.addClassName(this.id,"dr-menu-item-enabled");
- if (this.options.selectClass) Element.removeClassName(this.id, this.options.selectClass);
-
- Element.removeClassName(this.id+":icon","rich-menu-item-icon-selected");
- Element.removeClassName(this.id+":anchor","rich-menu-item-label");
- }
- }
- };
- item.id = itemId;
- item.obj = $(itemId);
- item.menu = this;
- item.options = options || {};
- item.mouseOver = false;
- if (item.options.onmouseover && item.options.onmouseover != ""){
- item.eventOnMouseOver = new Function("event",item.options.onmouseover).bindAsEventListener(item);
- }
- if (item.options.onmouseout && item.options.onmouseout != ""){
- item.eventOnMouseOut = new Function("event",item.options.onmouseout).bindAsEventListener(item);
- }
+ var item = new RichFaces.Menu.Item(itemId, this, options || {});
+ //item.menu = this;
this.items[itemId] = item;
-
- var onmouseover =
- function(e){
- this.menu.closeMinors(this.id);
- if (this.options.flagGroup == 1) {
- this.mouseOver = true;
- this.highLightGroup(true);
- }
- if (this.eventOnMouseOver) {
- var reltg = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
- while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOver();
- }
- }.bindAsEventListener(item);
-
- var onmouseout =
- function(e){
- if (this.options.flagGroup == 1) {
- this.mouseOver = false;
- this.highLightGroup(false);
- }
- if (this.eventOnMouseOut) {
- var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
- while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOut();
- }
- }.bindAsEventListener(item);
-
- var onmouseclick =
- function(e){
- var menuLayer = item.menu;
- while (menuLayer.level > 0) {
- menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
- }
- if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
- RichFaces.Menu.Layers.shutdown();
- }.bindAsEventListener(item);
-
- var binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseover",
- onmouseover);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseout",
- onmouseout);
- this.bindings.push(binding);
- binding.refresh();
- if (flag_close_onclick==1){
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "click",
- onmouseclick);
- this.bindings.push(binding);
- binding.refresh();
- }
-
return this;
},
hideMe: function(e){
@@ -1019,7 +979,12 @@
if (!e) {
e = window.event;
}
+
RichFaces.Menu.Layers.showDropDownLayer(this.id, topLevel, e,this.delay);
+ if (options.disabled == false && !RichFaces.Menu.isWithin(e, $(topLevel))) {
+ this.highlightLabel();
+ }
+
}.bindAsEventListener(this);
if(!onEvt){
@@ -1036,6 +1001,9 @@
function(e){
RichFaces.Menu.Layers.setLMTO(this.hideDelay);
RichFaces.Menu.Layers.clearPopUpTO();
+ if (options.disabled == false && !RichFaces.Menu.isWithin(e, $(topLevel))) {
+ this.unHighlightLabel();
+ }
}.bindAsEventListener(this);
// var item = $(topLevel);
@@ -1136,84 +1104,208 @@
return false;
}
};
-if(!RichFaces.Menu.Item) RichFaces.Menu.Item = {};
+RichFaces.Menu.Items = {
+ classNames: ['dr-menu-item-enabled', 'rich-menu-item-enabled'],
+ hoverClassNames : ['dr-menu-item-hover', 'rich-menu-item-hover'],
+ iconClassNames : [],
+ hoverIconClassNames: ['dr-menu-icon-selected', 'rich-menu-item-icon-selected'],
+ labelClassNames: [],
+ hoverLabelClassNames: ['rich-menu-item-label-selected'],
+
+ replaceClasses: function(element, toRemove, toAdd) {
+ var e = $(element);
+ $A(toRemove).each(function(className) {e.removeClassName(className)});
+ $A(toAdd).each(function(className) {e.addClassName(className)});
+ },
+
+ onmouseover: function(item) {
+ var element = item.getElement();
+ var icon = item.getIcon();
+ var labl = item.getLabel();
-/**
- *
- */
-RichFaces.Menu.Item.Onclick = function(evt, item, action, params, target) {
- var form = Event.findElement(evt, 'form');
+ var hoverClass = item.getHoverClasses();
+ var iconHoverClass = item.getIconHoverClasses();
+ var labelHoverClass = item.getLabelHoverClasses();
+
+ var inlineStyle = item.getInlineStyle();
+ var hoverStyle = item.getHoverStyle();
+ element.style.cssText = inlineStyle.concat(hoverStyle);
+
+ this.replaceClasses(element, this.classNames, this.hoverClassNames.concat(hoverClass));
+ this.replaceClasses(icon, this.iconClassNames, this.hoverIconClassNames.concat(iconHoverClass));
+ this.replaceClasses(labl, this.labelClassNames, this.hoverLabelClassNames.concat(labelHoverClass));
+ },
+ onmouseout : function(item) {
+ var element = item.getElement();
+ var icon = item.getIcon();
+ var labl = item.getLabel();
- /*if(!form || typeof(form) == 'undefined' || !form.nodeName || form.nodeName.toLowerCase() != 'form'){
- form = document.createElement('form');
- form.setAttribute('method', 'post');
- form.setAttribute('enctype', 'application/x-www-form-urlencoded');
- form.action = action;
- document.body.appendChild(form);
- }*/
- var objectsCreated = new Array();
- var oldValues = new Object();
- RichFaces.Menu.Item._createOrInitHiddenInput(item + ":submit", item + ":submit", objectsCreated, oldValues, form);
+ var hoverClass = item.getHoverClasses();
+ var iconHoverClass = item.getIconHoverClasses();
+ var labelHoverClass = item.getLabelHoverClasses();
+
+ var inlineStyle = item.getInlineStyle();
+ element.style.cssText = inlineStyle;
+
+ this.replaceClasses(element, this.hoverClassNames.concat(hoverClass), this.classNames);
+ this.replaceClasses(icon, this.hoverIconClassNames.concat(iconHoverClass), this.iconClassNames);
+ this.replaceClasses(labl, this.hoverLabelClassNames.concat(labelHoverClass), this.labelClassNames);
+ }
+
+};
+RichFaces.Menu.isWithin = function (event, element) {
+ var within = false;
+ Event.extend(event);
+ var targetElement = event.relatedTarget;
+ var srcElement = Event.element(event);
- if (params) {
+ if (targetElement) {
+ within = targetElement == element ||
+ $(targetElement).descendantOf(element);
+ }
+
+ return within;
+};
- for (var param in params) {
- var paramName = param;
- var paramValue = params[paramName];
- if (typeof(paramValue) != 'function') {
- if (paramValue) {
- paramValue = String(paramValue);
- }
- RichFaces.Menu.Item._createOrInitHiddenInput(paramName, paramValue, objectsCreated, oldValues, form);
+RichFaces.Menu.Item = Class.create({
+ initialize: function(id, menu, options) {
+ this.options = options;
+ this.id = id;
+ this.menu = menu;
+ this.mouseOver = false;
+
+
+
+ var binding;
+
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "mouseover",
+ this.onmouseover.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
+
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "mouseout",
+ this.onmouseout.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
- }
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "click",
+ this.onclick.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
+ },
+
+
+ onclick: function(e){
+ if (this.options.closeOnClick == 1) {
+ var menuLayer = this.menu;
+ while (menuLayer.level > 0) {
+ menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
}
+ if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
+ RichFaces.Menu.Layers.shutdown();
}
+ RichFaces.Menu.Items.onmouseout(this);
+ },
+ getElement: function() {
+ return $(this.id);
+ },
+ getIcon: function() {
+ return $(this.id + ":icon");
+ },
+ getLabel: function() {
+ return $(this.id + ":anchor");
+ },
+ getInlineStyle: function() {
+ return this.options.style || "";
+ },
+ getHoverStyle: function() {
+ return this.options.selectStyle || "";
+ },
+ getHoverClasses: function() {
+ return $A(this.options.selectClass).compact();
+ },
+ getIconHoverClasses : function() {
+ return $A(this.options.iconHoverClass).compact();
+ },
+ getLabelHoverClasses : function() {
+ return $A(this.options.labelHoverClass).compact();
+ },
+
+ isDisabled : function() {
+ //console.log(this.id + (this.options.disabled));
+ return this.options.disabled || false;
+ },
+ onmouseover : function(event) {
+ var element = this.getElement();
+
+ if (this.options.onmouseover) {
+ if (this.options.onmouseover.call(element, event) == false) {
+ Event.stop(event);
+ return;
+ };
+ }
+ if (RichFaces.Menu.isWithin(event, element)) {
+ return;
+ }
+ this.menu.closeMinors(this.id);
+ if (this.isDisabled()) {
+ return;
+ }
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = true;
+ this.highLightGroup(true);
+ }
+ RichFaces.Menu.Items.onmouseover(this);
+ },
+ onmouseout : function(event) {
+ Event.extend(event);
+ //window.status = $(event.relatedTarget).inspect();
+ if (this.options.onmouseout) {
+ if (this.options.onmouseover.call(element, event) == false) {
+ Event.stop(event);
+ return;
+ };
+ }
+ var element = this.getElement();
+ if (RichFaces.Menu.isWithin(event, element)) {
+ return;
+ }
+ if (this.isDisabled()) {
+ return;
+ }
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = false;
+ this.highLightGroup(false);
+ }
+ RichFaces.Menu.Items.onmouseout(this);
+ },
+ highLightGroup: function(light) {
+ if (light) {
+ Element.removeClassName(this.id,"dr-menu-item-enabled");
+ Element.addClassName(this.id,"dr-menu-item-hover");
+ Element.addClassName(this.id,"rich-menu-group-hover");
+ if (this.options.selectClass) {
+ Element.addClassName(this.id, this.options.selectClass);
+ }
- var l = objectsCreated.length;
-
- for (var i = 0; i < l; i++) {
- var kid = objectsCreated[i];
- form.appendChild(kid);
- }
-
- var targ = form.target;
-
- if (target) {
- form.target = target;
- }
-
- form.submit();
-
- form.target = targ;
-
- for (var j = 0; j < l; j++) {
- var kid = objectsCreated[j];
- if (form && kid) {
- form.removeChild(kid);
- }
- }
-
- for (var key in oldValues) {
- var value = oldValues[key];
- if (typeof(value) != 'function') {
- ($(key) || form[key]).value = value;
- }
- }
+ Element.addClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.addClassName(this.id+":anchor","rich-menu-item-label");
+ } else if (!this.mouseOver) {
+ Element.removeClassName(this.id,"dr-menu-item-hover");
+ Element.removeClassName(this.id,"rich-menu-group-hover");
+ Element.addClassName(this.id,"dr-menu-item-enabled");
+ if (this.options.selectClass) {
+ Element.removeClassName(this.id, this.options.selectClass);
+ }
+ Element.removeClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.removeClassName(this.id+":anchor","rich-menu-item-label");
+ }
}
-
-RichFaces.Menu.Item._createOrInitHiddenInput = function(name, value, list, oldValues, form) {
- var hiddenObj = $(name) || form[name];
-
- if (!hiddenObj) {
- hiddenObj = document.createElement('input');
- hiddenObj.setAttribute('type', 'hidden');
- hiddenObj.setAttribute('name', name);
- hiddenObj.setAttribute('id', name);
- list.push(hiddenObj);
- } else {
- oldValues[name] = hiddenObj.value;
- }
- hiddenObj.value = value;
-}
-
+
+});
Modified: branches/3.1.x/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-12-08 16:00:20 UTC (rev 4639)
+++ branches/3.1.x/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-12-08 16:47:34 UTC (rev 4640)
@@ -46,16 +46,8 @@
<div id="#{clientId}"
class="dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled #{component.attributes['styleClass']}"
- onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled #{component.attributes['styleClass']}';
- #{onmouseoutInlineStyles}
- $('#{clientId}:icon').className='dr-menu-icon rich-menu-item-icon #{component.attributes['iconClass']}';
- $('#{clientId}:anchor').className='rich-menu-item-label';"
- onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-item rich-menu-item-hover #{component.attributes['styleClass']} #{component.attributes['selectClass']}';
- #{onmouseoverInlineStyles}
- $('#{clientId}:icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected #{component.attributes['iconClass']}';
- $('#{clientId}:anchor').className='rich-menu-item-label rich-menu-item-label-selected';"
style="#{component.attributes['style']}"
- onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled #{component.attributes['styleClass']}'; #{component.attributes['onselect']}; #{onclick}">
+ onclick="#{component.attributes['onselect']}; #{onclick}">
<f:call name="utils.encodeAttributes">
<f:parameter value="onmousedown,onmouseup,onmousemove" />
</f:call>
18 years, 5 months