Author: sergeyhalipov
Date: 2007-06-26 15:22:29 -0400 (Tue, 26 Jun 2007)
New Revision: 1332
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/richfaces/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-46
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-06-26
18:32:56 UTC (rev 1331)
+++
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-06-26
19:22:29 UTC (rev 1332)
@@ -161,6 +161,9 @@
ModalPanel.panels.push(this);
+
+ this.eventFirstOnfocus = this.firstOnfocus.bindAsEventListener(this);
+ this.eventLastOnfocus = this.lastOnfocus.bindAsEventListener(this);
},
destroy: function() {
@@ -259,8 +262,110 @@
}
},
+ firstOnfocus: function(event) {
+ var firstHref = $(this.markerId.id + "FirstHref");
+ if (firstHref) {
+ firstHref.focus();
+ }
+ },
+
+ lastOnfocus: function(event) {
+ var lastHref = $(this.markerId.id + "LastHref");
+ if (lastHref) {
+ lastHref.focus();
+ }
+ },
+
+ isInModalPanel: function(input) {
+ var element = $(input);
+ if (!element)
+ return false;
+ while (element && element.tagName && element.tagName.toLowerCase !=
"body") {
+ if (element == this.cdiv)
+ return true;
+ element = element.parentNode;
+ }
+ return false;
+ },
+
+ processTabindexes: function(inputs, tabindex) {
+ if (!inputs || !tabindex || !inputs.length)
+ return tabindex;
+ for (var i = 0; i < inputs.length; i++) {
+ if (!this.isInModalPanel(inputs[i])) {
+ if (!this.firstOutside)
+ this.firstOutside = inputs[i];
+ this.lastOutside = inputs[i];
+ if (inputs[i].tabIndex) {
+ inputs[i].prevTabIndex = inputs[i].tabIndex;
+ inputs[i].tabIndex = tabindex;
+ }
+ if (inputs[i].accesskey) {
+ inputs[i].prevAccesskey = inputs[i].accesskey;
+ inputs[i].accesskey = undefined;
+ }
+ tabindex--;
+ }
+ }
+ return tabindex;
+ },
+
+ restoreTabindexes: function(inputs) {
+ if (!inputs || !inputs.length)
+ return;
+ for (var i = 0; i < inputs.length; i++) {
+ if (!this.isInModalPanel(inputs[i])) {
+ if (inputs[i].prevTabIndex)
+ inputs[i].tabIndex = inputs[i].prevTabIndex;
+ if (inputs[i].prevAccesskey)
+ inputs[i].accesskey = inputs[i].prevAccesskey;
+ }
+ }
+ },
+
+ preventFocus: function() {
+ var tabindex = 32768;
+ var inputs = document.getElementsByTagName("input");
+ tabindex = this.processTabindexes(inputs, tabindex);
+ var selects = document.getElementsByTagName("select");
+ tabindex = this.processTabindexes(selects, tabindex);
+ var buttons = document.getElementsByTagName("button");
+ tabindex = this.processTabindexes(buttons, tabindex);
+ var hrefs = document.getElementsByTagName("a");
+ tabindex = this.processTabindexes(hrefs, tabindex);
+
+ if (this.firstOutside) {
+ Event.observe(this.firstOutside, "focus", this.eventFirstOnfocus);
+ }
+ if (this.lastOutside) {
+ Event.observe(this.lastOutside, "focus", this.eventLastOnfocus);
+ }
+ if (RichFaces.navigatorType() != "MSIE")
+ this.lastOnfocus();
+ },
+
+ restoreFocus: function() {
+ var inputs = document.getElementsByTagName("input");
+ this.restoreTabindexes(inputs);
+ var selects = document.getElementsByTagName("select");
+ this.restoreTabindexes(selects);
+ var buttons = document.getElementsByTagName("button");
+ this.restoreTabindexes(buttons);
+ var hrefs = document.getElementsByTagName("a");
+ this.restoreTabindexes(hrefs);
+
+ if (this.firstOutside) {
+ Event.stopObserving(this.firstOutside, "focus", this.eventFirstOnfocus);
+ this.firstOutside = null;
+ }
+ if (this.lastOutside) {
+ Event.stopObserving(this.lastOutside, "focus", this.eventLastOnfocus);
+ this.lastOutside = null;
+ }
+ },
+
show: function(opts) {
- //this.disableDocumentFocusElements();
+ this.preventFocus();
if (!this.floatedToBody) {
this.parent = this.id.parentNode;
@@ -427,9 +532,9 @@
},
hide: function(opts) {
- //this.enableDocumentFocusElements();
+ this.restoreFocus();
- this.traverseSelects(true);
+ this.traverseSelects(true);
if (this.div.style.removeExpression) {
this.div.style.removeExpression("width");
Modified:
trunk/richfaces/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
---
trunk/richfaces/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-06-26
18:32:56 UTC (rev 1331)
+++
trunk/richfaces/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-06-26
19:22:29 UTC (rev 1332)
@@ -72,8 +72,10 @@
</div>
<div style="position: absolute; overflow: hidden; z-index: 2;"
- class="dr-mpnl-pnl" id="#{clientId}ContentDiv">
- <table style="height: 100%; width: 100%;" border="0"
cellpadding="0" cellspacing="0">
+ class="dr-mpnl-pnl" id="#{clientId}ContentDiv">
+
+ <table style="height: 100%; width: 100%;" border="0"
cellpadding="0" cellspacing="0">
+ <a href="#" style="position: absolute; left: -32000"
id="#{clientId}FirstHref" >_</a>
<jsp:scriptlet>
<![CDATA[if(component.getFacet("header")!=null &&
component.getFacet("header").isRendered()) {]]>
</jsp:scriptlet>
@@ -99,17 +101,17 @@
</jsp:scriptlet>
<tr>
<td class="dr-mpnl-pnl-b rich-mpnl-body"
valign="top">
- <vcp:body>
- <f:call name="renderChildren" />
- </vcp:body>
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ <f:clientid var="clientId"/>
+ <a href="#" style="position: absolute; left:
-32001" id="#{clientId}LastHref" >_</a>
</td>
</tr>
</table>
</div>
</div>
- <f:clientid var="clientId"/>
-
<script type="text/javascript">
new ModalPanel('#{clientId}',
{