[prev in list] [next in list] [prev in thread] [next in thread]
List: mono-patches
Subject: [Mono-patches] r70285 - trunk/mcs/class/System.Web/resources
From: "Igor Zalmanovich (igorz () mainsoft ! com)"
Date: 2006-12-31 15:22:15
Message-ID: 20061231152215.C82E19472C () mono-cvs ! ximian ! com
[Download RAW message or body]
Author: igorz
Date: 2006-12-31 10:22:15 -0500 (Sun, 31 Dec 2006)
New Revision: 70285
Modified:
trunk/mcs/class/System.Web/resources/ChangeLog
trunk/mcs/class/System.Web/resources/webform.js
Log:
2006-12-31 Igor Zelmanovich <igorz@mainsoft.com>
* webform.js: WebForm_AutoFocus support for not focusable elements
by setting focus on first focusable child.
Modified: trunk/mcs/class/System.Web/resources/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/resources/ChangeLog 2006-12-31 14:44:01 UTC (rev 70284)
+++ trunk/mcs/class/System.Web/resources/ChangeLog 2006-12-31 15:22:15 UTC (rev 70285)
@@ -1,5 +1,10 @@
2006-12-31 Igor Zelmanovich <igorz@mainsoft.com>
+ * webform.js: WebForm_AutoFocus support for not focusable elements
+ by setting focus on first focusable child.
+
+2006-12-31 Igor Zelmanovich <igorz@mainsoft.com>
+
* callback.js: fixed: support IE7, encodeURIComponent is used to
encode form.
Modified: trunk/mcs/class/System.Web/resources/webform.js
===================================================================
--- trunk/mcs/class/System.Web/resources/webform.js 2006-12-31 14:44:01 UTC (rev 70284)
+++ trunk/mcs/class/System.Web/resources/webform.js 2006-12-31 15:22:15 UTC (rev 70285)
@@ -33,11 +33,55 @@
var x = document.getElementById ? document.getElementById (id) :
((document.all) ? document.all [id] : null);
- if (typeof (x) != 'undefined') {
- x.focus();
+ if (x && (!WebForm_CanFocus(x))) {
+ x = WebForm_FindFirstFocusableChild(x);
}
+ if (x) { x.focus(); }
}
+function WebForm_CanFocus(element) {
+ if (!element || !(element.tagName) || element.disabled) {
+ return false;
+ }
+ if (element.type && element.type.toLowerCase() == "hidden") {
+ return false;
+ }
+ var tagName = element.tagName.toLowerCase();
+ return (tagName == "input" ||
+ tagName == "textarea" ||
+ tagName == "select" ||
+ tagName == "button" ||
+ tagName == "a");
+}
+
+function WebForm_FindFirstFocusableChild(element) {
+ if (!element || !(element.tagName)) {
+ return null;
+ }
+ var tagName = element.tagName.toLowerCase();
+ if (tagName == "undefined") {
+ return null;
+ }
+ var children = element.childNodes;
+ if (children) {
+ for (var i = 0; i < children.length; i++) {
+ try {
+ if (WebForm_CanFocus(children[i])) {
+ return children[i];
+ }
+ else {
+ var focused = WebForm_FindFirstFocusableChild(children[i]);
+ if (WebForm_CanFocus(focused)) {
+ return focused;
+ }
+ }
+ } catch (e) {
+ }
+ }
+ }
+ return null;
+}
+
function wasControlEnabled (id)
{
if (typeof (__enabledControlArray) == 'undefined')
_______________________________________________
Mono-patches maillist - Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic