Author: nbelaevski
Date: 2008-06-28 07:40:01 -0400 (Sat, 28 Jun 2008)
New Revision: 9287
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-3739
http://jira.jboss.com/jira/browse/RF-3825
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-06-28
09:26:51 UTC (rev 9286)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-06-28
11:40:01 UTC (rev 9287)
@@ -187,7 +187,9 @@
ModalPanel.panels = ModalPanel.panels.without(this);
- this.traverseSelects(true);
+ this.enableSelects();
+
+ ModalPanel.activePanels = ModalPanel.activePanels.without(this);
this.parent = null;
this.firstOutside = null;
@@ -238,55 +240,124 @@
//iframeBodyStyle.opacity = "0.5";
//iframeBodyStyle.zIndex = "99";
},
+
+ enableSelect: function(elt) {
+ if (elt._mdwProcessed) {
+ elt._mdwProcessed = undefined;
- traverseSelects: function(enable) {
+ if (elt._mdwDisabled) {
+ elt.disabled = false;
+ elt._mdwDisabled = undefined;
+ }
+
+ if (typeof elt._mdwHidden != "undefined") {
+ elt.style.visibility = elt._mdwHidden;
+ elt._mdwHidden = undefined;
+ }
+ }
+ },
+
+ disableSelect: function(elt) {
+ if (!elt._mdwProcessed) {
+ elt._mdwProcessed = true;
+
+ if ("hide" == this.selectBehavior) {
+ if (elt.style.visibility != "hidden") {
+ elt._mdwHidden = elt.style.visibility;
+ elt.style.visibility = "hidden";
+ }
+ } else {
+ if (!elt.disabled) {
+ elt.disabled = true;
+ elt._mdwDisabled = true;
+ }
+ }
+ }
+ },
+
+ enableInnerSelects: function() {
+ if (ModalPanel.disableSelects) {
+ var selects = this.id.getElementsByTagName("SELECT");
+ for (var k = 0; k < selects.length; k++) {
+ this.enableSelect(selects[k]);
+ }
+ }
+ },
+
+ disableInnerSelects: function() {
+ if (ModalPanel.disableSelects) {
+ var selects = this.id.getElementsByTagName("SELECT");
+ for (var k = 0; k < selects.length; k++) {
+ this.disableSelect(selects[k]);
+ }
+ }
+ },
+
+ enableSelects: function() {
if (!ModalPanel.disableSelects) {
return ;
}
- var children = document.body.childNodes;
- for (var k = 0; k < children.length; k++) {
- var child = children[k];
- if (child != this.id && child.getElementsByTagName) {
-
+ var lastPanel = ModalPanel.activePanels[ModalPanel.activePanels.length - 1];
+ var newLastPanel = ModalPanel.activePanels[ModalPanel.activePanels.length - 2];
+
+ if (newLastPanel) {
+ if (lastPanel == this) {
+ //we've just closed top panel, re-enable next panel if any
+ newLastPanel.enableInnerSelects();
+ }
+ } else {
+ var children = document.body.childNodes;
+ for (var k = 0; k < children.length; k++) {
+ var child = children[k];
+
+ if (!child.getElementsByTagName) {
+ continue;
+ }
+
var selects = child.getElementsByTagName("SELECT");
for (var i = 0; i < selects.length; i++) {
- var elt = selects[i];
-
- if (enable) {
- if (0 == ModalPanel.activePanels.length) {
- if (elt._mdwDisabledSet) {
- elt.disabled = elt._mdwDisabled;
- elt._mdwDisabledSet = undefined;
- }
- if (elt._mdwHiddenSet) {
- Element.setStyle(elt, { "visibility" : elt._mdwHidden });
- elt._mdwHiddenSet = undefined;
- }
- }
- } else {
- if (ModalPanel.activePanels.length > 0) {
- if ("hide" == this.selectBehavior) {
- if (!elt._mdwHiddenSet) {
- elt._mdwHidden = elt.style.visibility;
- elt._mdwHiddenSet = true;
- }
- Element.setStyle(elt, { "visibility" : "hidden" });
- } else {
- if (!elt._mdwDisabledSet) {
- elt._mdwDisabled = elt.disabled;
- elt._mdwDisabledSet = true;
- }
- elt.disabled = true;
- }
- }
- }
+ this.enableSelect(selects[i]);
}
}
}
},
+ disableOuterSelects: function() {
+ if (!ModalPanel.disableSelects) {
+ return ;
+ }
+
+ var lastPanel = ModalPanel.activePanels.last();
+
+ if (lastPanel) {
+ //we need to disable only the last opened panel
+ lastPanel.disableInnerSelects();
+ this.enableInnerSelects();
+ } else {
+ //disable all outer
+ var children = document.body.childNodes;
+ for (var k = 0; k < children.length; k++) {
+ var child = children[k];
+
+ if (child == this.id) {
+ continue;
+ }
+
+ if (!child.getElementsByTagName) {
+ continue;
+ }
+
+ var selects = child.getElementsByTagName("SELECT");
+
+ for (var i = 0; i < selects.length; i++) {
+ this.disableSelect(selects[i]);
+ }
+ }
+ }
+ },
+
setLeft: function(pos) {
var eCdiv = $(this.cdiv);
if (eCdiv.mpUseExpr) {
@@ -391,8 +462,9 @@
},
show: function(event, opts) {
- var element = this.id;
- if(this.invokeEvent("beforeshow",event,null,element)) {
+ if(!this.shown && this.invokeEvent("beforeshow",event,null,element))
{
+ var element = this.id;
+
this.preventFocus();
if (!this.floatedToBody) {
@@ -471,9 +543,9 @@
// eIframe.allowTransparency = true;
//}
+ this.disableOuterSelects();
ModalPanel.activePanels = ModalPanel.activePanels.without(this);
ModalPanel.activePanels.push(this);
- this.traverseSelects();
//this.shape.init(eCdiv, this.options);
@@ -600,13 +672,13 @@
},
hide: function(event, opts) {
- if (this.invokeEvent("beforehide",event,null,element)) {
+ if (this.shown && this.invokeEvent("beforehide",event,null,element))
{
this.restoreFocus();
+ this.enableSelects();
+
ModalPanel.activePanels = ModalPanel.activePanels.without(this);
- this.traverseSelects(true);
-
var eDiv = $(this.div);
var eCdiv = $(this.cdiv);