r1476 - branches/experimental/tabbable
Author: scott.gonzalez
Date: Fri Jan 2 08:39:29 2009
New Revision: 1476
Modified:
branches/experimental/tabbable/ui.core.js
Log:
Tabbable: Refactored implementation a bit.
Modified: branches/experimental/tabbable/ui.core.js
==============================================================================
--- branches/experimental/tabbable/ui.core.js (original)
+++ branches/experimental/tabbable/ui.core.js Fri Jan 2 08:39:29 2009
@@ -1,25 +1,23 @@
(function($) {
-// temporary hack to proxy $.attr
-// everything should be contained in here eventually
-var attr = $.attr;
-$.attr = function(elem, name, value) {
- if (/tabindex/i.test(name) && value === undefined) {
- return getTabIndex(elem);
+var attr = $.attr,
+ normalizedTabindex = ($.browser.msie && parseInt($.browser.version, 10) <
8
+ ? 'tabIndex'
+ : 'tabindex');
+
+$.attr = function(elem, key, value) {
+ if (/tabindex/i.test(key)) {
+ if (value !== undefined) {
+ // TODO: set tabindex
+ } else {
+ var attribute = elem.getAttributeNode(normalizedTabindex);
+ return attribute && attribute.specified && attribute.value || undefined;
+ }
}
return attr.apply(this, arguments);
};
-var normalizedTabindex = ($.browser.msie && parseInt($.browser.version,
10) < 8
- ? 'tabIndex'
- : 'tabindex');
-
-function getTabIndex(element) {
- var attr = element.getAttributeNode(normalizedTabindex);
- return attr && attr.specified && attr.value || undefined;
-}
-
$.extend($.expr[':'], {
focusable: function(element) {
var nodeName = element.nodeName.toLowerCase(),
@@ -41,15 +39,14 @@
var element = this[0];
if (element) {
- //if (!isNaN(getTabIndex(element))) {
- $(element).attr('tabIndex', -1);
- //}
+ // TODO: force tabindex if there is none
+// $(element).attr('tabIndex', -1);
setTimeout(function() {
element.focus();
- }, time || // sometimes a higher timeout is needed, to allow
screenreader to update the outputbuffer
- 1);
+ }, time || 1);
}
+
return this;
};