Author: sergeyhalipov
Date: 2008-04-02 08:27:11 -0400 (Wed, 02 Apr 2008)
New Revision: 7572
Modified:
branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-2724
Modified:
branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-04-02
11:22:13 UTC (rev 7571)
+++
branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-04-02
12:27:11 UTC (rev 7572)
@@ -335,54 +335,51 @@
}
},
- processAllFocusElements: function(root) {
+ processAllFocusElements: function(root, callback) {
if (root.focus &&
// Many not visible elements have focus method, we is had to avoid processing them.
- /^a|input|select|button|textarea$/i.test(root.tagName) &&
+ /^(?:a|input|select|button|textarea)$/i.test(root.tagName) &&
!root.disabled && !/^hidden$/.test(root.type) &&
- !/^none$/.test(root.style.display)) {
- this.execute(root);
+ Element.visible(root)) {
+
+ callback.call(this, root);
} else {
- if (root.id && root.id==this.cdiv)
- this.inModalPanel = true;
- var child = root.firstChild;
- while (child) {
- this.processAllFocusElements(child);
- child = child.nextSibling;
+ if (root != this.id) {
+ var child = root.firstChild;
+ while (child) {
+ if (!child.style || Element.visible(child)) {
+ this.processAllFocusElements(child, callback);
+ }
+ child = child.nextSibling;
+ }
}
- if (root.id && root.id==this.cdiv)
- this.inModalPanel = false;
}
},
processTabindexes: function(input) {
- if (!this.inModalPanel) {
- if (!this.firstOutside)
- this.firstOutside = input;
- this.lastOutside = input;
- if (input.tabIndex) {
- input.prevTabIndex = input.tabIndex;
- }
- input.tabIndex = undefined;
- if (input.accesskey) {
- input.prevAccesskey = input.accesskey;
- }
- input.accesskey = undefined;
+ if (!this.firstOutside && !(/^select$/i.test(input.tagName) &&
ModalPanel.disableSelects)) {
+ this.firstOutside = input;
}
+ this.lastOutside = input;
+ if (input.tabIndex) {
+ input.prevTabIndex = input.tabIndex;
+ }
+ input.tabIndex = undefined;
+ if (input.accesskey) {
+ input.prevAccesskey = input.accesskey;
+ }
+ input.accesskey = undefined;
},
restoreTabindexes: function(input) {
- if (!this.inModalPanel) {
- if (input.prevTabIndex)
- input.tabIndex = input.prevTabIndex;
- if (input.prevAccesskey)
- input.accesskey = input.prevAccesskey;
- }
+ if (input.prevTabIndex)
+ input.tabIndex = input.prevTabIndex;
+ if (input.prevAccesskey)
+ input.accesskey = input.prevAccesskey;
},
preventFocus: function() {
- this.execute = this.processTabindexes;
- this.processAllFocusElements(document);
+ this.processAllFocusElements(document, this.processTabindexes);
if (this.firstOutside) {
Event.observe(this.firstOutside, "focus", this.eventFirstOnfocus);
@@ -393,8 +390,7 @@
},
restoreFocus: function() {
- this.execute = this.restoreTabindexes;
- this.processAllFocusElements(document);
+ this.processAllFocusElements(document, this.restoreTabindexes);
if (this.firstOutside) {
Event.stopObserving(this.firstOutside, "focus", this.eventFirstOnfocus);