You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/02/09 09:08:07 UTC
svn commit: r620086 - in /myfaces/tobago/branches/tobago-1.0.x: ./
theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Author: bommel
Date: Sat Feb 9 00:07:47 2008
New Revision: 620086
URL: http://svn.apache.org/viewvc?rev=620086&view=rev
Log:
Merged revisions 619947-619962 via svnmerge from
https://svn.apache.org/repos/asf/myfaces/tobago/trunk
........
r619947 | idus | 2008-02-08 18:19:27 +0100 (Fr, 08 Feb 2008) | 1 line
TOBAGO-615: made sure field with lowest tab index receives focus if no other field explicitly requests focus
........
r619962 | idus | 2008-02-08 19:04:21 +0100 (Fr, 08 Feb 2008) | 1 line
TOBAGO-615: take fields with implicit tab index 0 into account for automatic focus
........
Modified:
myfaces/tobago/branches/tobago-1.0.x/ (props changed)
myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Feb 9 00:07:47 2008
@@ -1 +1 @@
-/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133
+/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133,619947-619962
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=620086&r1=620085&r2=620086&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Sat Feb 9 00:07:47 2008
@@ -1008,7 +1008,6 @@
*/
setFocus: function() {
var focusElement = this.element(this.focusId);
-
if (focusElement) {
try { // focus() on not visible elements breaks IE
focusElement.focus();
@@ -1016,21 +1015,43 @@
LOG.warn("Exception when setting focus on : \"" + this.focusId + "\"");
}
} else if (typeof this.focusId == "undefined") {
+ var lowestTabIndex = 32768; // HTML max tab index value + 1
+ var candidate = null;
+ var candidateWithTabIndexZero = null;
foriLoop: for (var i = 0 ; i < document.forms.length ; i++) {
var form = document.forms[i];
if (form != null){
for (var j = 0 ; j < form.elements.length ; j++) {
var element = form.elements[j];
if (element != null) {
- if (!element.disabled && !element.readOnly && this.isFocusType(element.type)){
- try { // focus() on not visible elements breaks IE
- element.focus();
- break foriLoop;
- } catch(ex) { }
+ if (!element.disabled && !element.readOnly
+ && this.isFocusType(element.type)) {
+ if (lowestTabIndex > element.tabIndex && element.tabIndex > 0) {
+ lowestTabIndex = element.tabIndex;
+ candidate = element;
+ if (lowestTabIndex == 1) {
+ // optimization: stop on first field with lowest possible tab index 1
+ break foriLoop;
+ }
+ }
+ if (candidateWithTabIndexZero == null && element.tabIndex == 0) {
+ candidateWithTabIndexZero = element;
+ }
}
}
}
}
+ }
+ if (candidate != null) {
+ try {
+ // focus() on not visible elements breaks IE
+ candidate.focus();
+ } catch(ex) { }
+ } else if (candidateWithTabIndexZero != null) {
+ try {
+ // focus() on not visible elements breaks IE
+ candidateWithTabIndexZero.focus();
+ } catch(ex) { }
}
} else if (this.focusId.length > 0) {
LOG.warn("Cannot find component to set focus : \"" + this.focusId + "\"");