Author: sergeyhalipov
Date: 2008-04-04 07:39:15 -0400 (Fri, 04 Apr 2008)
New Revision: 7601
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-2964
http://jira.jboss.com/jira/browse/RF-2492
http://jira.jboss.com/jira/browse/RF-2353
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-04-04
11:03:55 UTC (rev 7600)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-04-04
11:39:15 UTC (rev 7601)
@@ -69,6 +69,7 @@
}
ModalPanel.panels = new Array();
+ModalPanel.activePanels = new Array();
ModalPanel.Context = Class.create();
ModalPanel.Context.prototype = {
@@ -259,60 +260,31 @@
for (var i = 0; i < selects.length; i++) {
var elt = selects[i];
- if (this.selectBehavior && "hide" == this.selectBehavior) {
- if (enable) {
- if (elt._mdwCount) {
- elt._mdwCount -= 1;
-
- if (elt._mdwCount == 0) {
- if (elt._mdwHidden) {
- Element.setStyle(elt, { "visibility" : elt._mdwHidden });
- elt._mdwHidden = undefined;
- } else {
- Element.setStyle(elt, { "visibility" : "" });
- }
-
- elt._mdwCount = undefined;
- }
+ if (enable) {
+ if (0 == ModalPanel.activePanels.length) {
+ if (elt._mdwDisabledSet) {
+ elt.disabled = elt._mdwDisabled;
+ elt._mdwDisabledSet = undefined;
}
- } else {
- if (elt._mdwCount) {
- elt._mdwCount += 1;
- } else {
- if (elt.style.visibility && "" != elt.style.visibility) {
- elt._mdwHidden = elt.style.visibility;
- }
- Element.setStyle(elt, { "visibility" : "hidden" });
-
- elt._mdwCount = 1;
+ if (elt._mdwHiddenSet) {
+ Element.setStyle(elt, { "visibility" : elt._mdwHidden });
+ elt._mdwHiddenSet = undefined;
}
}
} else {
- if (enable) {
- if (elt._mdwCount) {
- elt._mdwCount -= 1;
-
- if (elt._mdwCount == 0) {
- if (elt._mdwDisabled) {
- elt._mdwDisabled = undefined;
- } else {
- elt.disabled = false;
- }
-
- elt._mdwCount = undefined;
+ if (ModalPanel.activePanels.length > 0) {
+ if (this.selectBehavior && "hide" == this.selectBehavior) {
+ if (!elt._mdwHiddenSet) {
+ elt._mdwHidden = elt.style.visibility;
+ elt._mdwHiddenSet = true;
}
- }
- } else {
- if (elt._mdwCount) {
- elt._mdwCount += 1;
+ Element.setStyle(elt, { "visibility" : "hidden" });
} else {
- if (elt.disabled) {
- elt._mdwDisabled = true;
- } else {
- elt.disabled = true;
+ if (!elt._mdwDisabledSet) {
+ elt._mdwDisabled = elt.disabled;
+ elt._mdwDisabledSet = true;
}
-
- elt._mdwCount = 1;
+ elt.disabled = true;
}
}
}
@@ -341,14 +313,14 @@
firstOnfocus: function(event) {
var e = $(this.firstHref)
- if (e) {
+ if (e && (ModalPanel.activePanels.last() == this)) {
e.focus();
}
},
lastOnfocus: function(event) {
var e = $(this.lastHref);
- if (e) {
+ if (e && (ModalPanel.activePanels.last() == this)) {
e.focus();
}
},
@@ -379,21 +351,25 @@
this.firstOutside = input;
}
this.lastOutside = input;
- if (input.tabIndex) {
+ if (input.tabIndex && !input.prevTabIndex) {
input.prevTabIndex = input.tabIndex;
}
input.tabIndex = undefined;
- if (input.accesskey) {
+ if (input.accesskey && !input.prevAccesskey) {
input.prevAccesskey = input.accesskey;
}
input.accesskey = undefined;
},
restoreTabindexes: function(input) {
- if (input.prevTabIndex)
+ if (input.prevTabIndex) {
input.tabIndex = input.prevTabIndex;
- if (input.prevAccesskey)
+ input.prevTabIndex = undefined;
+ }
+ if (input.prevAccesskey) {
input.accesskey = input.prevAccesskey;
+ input.prevAccesskey = undefined;
+ }
},
preventFocus: function() {
@@ -507,7 +483,8 @@
// eIframe.allowTransparency = true;
//}
-
+ ModalPanel.activePanels = ModalPanel.activePanels.without(this);
+ ModalPanel.activePanels.push(this);
this.traverseSelects();
//this.shape.init(eCdiv, this.options);
@@ -644,6 +621,9 @@
if (this.invokeEvent("beforehide",event,null,element)) {
this.restoreFocus();
+
+ ModalPanel.activePanels = ModalPanel.activePanels.without(this);
+
this.traverseSelects(true);
var eDiv = $(this.div);
@@ -693,6 +673,10 @@
if (this.options.autosized) {
window.clearInterval(this.observerSize);
}
+
+ if (ModalPanel.activePanels.length > 0) {
+ ModalPanel.activePanels.last().preventFocus();
+ }
}
},