You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by id...@apache.org on 2008/02/08 18:19:37 UTC
svn commit: r619947 -
/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Author: idus
Date: Fri Feb 8 09:19:27 2008
New Revision: 619947
URL: http://svn.apache.org/viewvc?rev=619947&view=rev
Log:
TOBAGO-615: made sure field with lowest tab index receives focus if no other field explicitly requests focus
Modified:
myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=619947&r1=619946&r2=619947&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Fri Feb 8 09:19:27 2008
@@ -1022,21 +1022,33 @@
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;
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) {
+ lowestTabIndex = element.tabIndex;
+ candidate = element;
+ if (lowestTabIndex == 1) {
+ break foriLoop;
+ }
+ }
}
}
}
}
+ }
+ if (candidate != null) {
+ try {
+ // focus() on not visible elements breaks IE
+ candidate.focus();
+ } catch(ex) { }
}
} else if (this.focusId.length > 0) {
LOG.warn("Cannot find component to set focus : \"" + this.focusId + "\"");