Author: vmolotkov
Date: 2008-07-09 13:44:07 -0400 (Wed, 09 Jul 2008)
New Revision: 9496
Modified:
trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
Log:
RF-3190
Modified:
trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
---
trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-07-09
17:24:04 UTC (rev 9495)
+++
trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-07-09
17:44:07 UTC (rev 9496)
@@ -54,9 +54,21 @@
this.events = events;
+ this.isFocused = false;
+ this.wasMouseDown = false;
+ this.skipBlurEvent = false;
+
this.targetLayoutManager = targetList.layoutManager;
this.sourceLayoutManager = sourceList.layoutManager;
+ //for focus\blur custom events
+ this.container.observe("focus", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+ this.container.observe("keypress", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+ this.container.observe("keydown", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+ this.container.observe("mousedown", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+ this.container.observe("click", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+ this.container.observe("blur", function (e)
{this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
+
if (switchByClick == "true") {
this.targetList.shuttleTable.observe("click", function(e)
{this.moveItemByClick(window.event||e, this.targetList,
this.sourceList)}.bindAsEventListener(this));
this.sourceList.shuttleTable.observe("click", function(e)
{this.moveItemByClick(window.event||e, this.sourceList,
this.targetList)}.bindAsEventListener(this));
@@ -248,8 +260,70 @@
remove : function() {
this.container.fire("rich:onremoveclick", {sourceItems:
this.sourceList.shuttleItems, targetItems: this.targetList.shuttleItems, selection:
this.targetList.getSelection()});
this.moveItems(this.targetList, this.sourceList, this.targetList.selectedItems);
+ },
+
+ focusOrBlurHandlerLS : function(e) {
+ var componentID = e.target.id;
+ if (e.type == "keydown") {
+ var code = e.which;
+ this.skipBlurEvent = false;
+ this.wasKeyDown = true;
+ if (Event.KEY_TAB == code) {
+ if (e.shiftKey) {
+ if ((componentID == this.sourceList.focusKeeper.id) && this.isFocused) {
+ //blur:shift+tab keys were pressed
+ this.fireOnblurEvent();
+ } else {
+ this.skipBlurEvent = true;
+ }
+ } else {
+ if ((componentID == this.targetList.focusKeeper.id) && this.isFocused) {
+ //blur:tab key was pressed
+ this.fireOnblurEvent();
+
+ } else {
+ this.skipBlurEvent = true;
+ }
+ }
+ }
+ } else if (e.type == "mousedown") {
+ this.skipBlurEvent = false;
+ this.wasMouseDown = true;
+ if (!this.isFocused) {
+ this.fireOnfocusEvent();
+ }
+ } else if (e.type == "click") {
+ this.wasMouseDown = false;
+ } else if (e.type == "keypress") {
+ this.wasKeyDown = false;
+ } else if (e.type == "focus") {
+ if (componentID == this.sourceList.focusKeeper.id && !this.wasMouseDown
&& !this.isFocused) {
+ //focus:tab key was pressed
+ this.fireOnfocusEvent();
+ } else if (componentID == this.targetList.focusKeeper.id && !this.wasMouseDown
&& !this.isFocused) {
+ //focus:shift+tab keys were pressed
+ this.fireOnfocusEvent();
+ }
+ } else if (e.type == "blur") {
+ //onblur event
+ if (!this.wasMouseDown && !this.wasKeyDown && this.isFocused
&& !this.skipBlurEvent) {
+ //blur:click component outside
+ this.fireOnblurEvent();
+ }
+ }
+ },
+
+ fireOnfocusEvent : function() {
+ //LOG.warn("fireOnfocusEvent|");
+ this.isFocused = true;
+ this.container.fire("rich:onfocus", {});
+ },
+
+ fireOnblurEvent : function() {
+ //LOG.warn("fireOnblurEvent|");
+ this.isFocused = false;
+ this.container.fire("rich:onblur", {});
}
-
};
Richfaces.ListShuttle.HANDLERS = {
Show replies by date