r3148 committed - selectable dev: implemented setting tabindex 0 on current focus, -1 on...

r3148 committed - selectable dev: implemented setting tabindex 0 on current focus, -1 on...


Revision: 3148
Author: paul.bakaus
Date: Thu Aug 27 07:12:19 2009
Log: selectable dev: implemented setting tabindex 0 on current focus, -1 on
non-focussed items
http://code.google.com/p/jquery-ui/source/detail?r=3148
Modified:
/branches/dev/selectable/demos/selectable/draggable.html
/branches/dev/selectable/demos/selectable/serialize.html
/branches/dev/selectable/ui/ui.selectable.js
=======================================
--- /branches/dev/selectable/demos/selectable/draggable.html    Wed Aug 26
03:38:27 2009
+++ /branches/dev/selectable/demos/selectable/draggable.html    Thu Aug 27
07:12:19 2009
@@ -132,7 +132,7 @@
<body>
<div class="demo">
-<div id="selectable" tabindex='1' class="ui-helper-clearfix">
+<div id="selectable" tabindex="1" class="ui-helper-clearfix">
    <img src='images/1.jpg' />
    <img src='images/2.jpg' />
    <img src='images/3.jpg' />
=======================================
--- /branches/dev/selectable/demos/selectable/serialize.html    Wed Aug 26
03:38:27 2009
+++ /branches/dev/selectable/demos/selectable/serialize.html    Thu Aug 27
07:12:19 2009
@@ -87,7 +87,7 @@
    <button class="selectnext">Select Next</button>

-<ol id="selectable" tabindex='1'>
+<ol id="selectable" tabindex="1">
    <li class="ui-widget-content">Item 1</li>
    <li class="ui-widget-content">Item 2</li>
    <li class="ui-widget-content">Item 3</li>
=======================================
--- /branches/dev/selectable/ui/ui.selectable.js    Wed Aug 26 03:25:48 2009
+++ /branches/dev/selectable/ui/ui.selectable.js    Thu Aug 27 07:12:19 2009
@@ -21,7 +21,7 @@
            this.element.addClass("ui-selectable ui-widget");
            //Set the currentFocus to the first item
-            this.currentFocus = this.items.eq(0);
+            this.currentFocus = this.items.eq(0).attr('tabindex', 0);
            //Refresh item positions
            this.refresh(1);
@@ -490,8 +490,8 @@
        _select: function(event, item) {
            //Set the current selection to the previous/next item
-            this.previousFocus = this.currentFocus;
-            this.currentFocus = $(item);
+            this.previousFocus = this.currentFocus.attr('tabindex', -1);
+            this.currentFocus = $(item).attr('tabindex', 0);
            this.previousFocus.removeClass('ui-state-focus');
            this.currentFocus.addClass('ui-state-focus');
@@ -512,8 +512,8 @@
            if (!item.length) return;
            //Set the current selection to the previous/next item
-            this.previousFocus = this.currentFocus;
-            this.currentFocus = item;
+            this.previousFocus = this.currentFocus.attr('tabindex', -1);
+            this.currentFocus = item.attr('tabindex', 0);
            this.previousFocus.removeClass('ui-state-focus');
            this.currentFocus.addClass('ui-state-focus');
@@ -537,12 +537,17 @@
        refresh: function(fromInside) {
-            var o = this.options;
+            var o = this.options, self = this;
            this.items = $(o.filter, this.element);
            this.items.addClass('ui-state-default');
            this.items.each(function() {
+
                var $this = $(this);
                var pos = $this.offset();
+
+                if(self.currentFocus && self.currentFocus[0] != this)
+                    $this.attr('tabindex', -1);
+
                $.data(this, "selectable-item", {
                    left: pos.left,
                    top: pos.top,
@@ -582,8 +587,8 @@
            var newlySelected = [], self = this;
            item.each(function(i) {
                if(i == 0) { //Setting the focus on the first item in the list
-                    self.previousFocus = self.currentFocus;
-                    self.currentFocus = $(this);
+                    self.previousFocus = self.currentFocus.attr('tabindex', -1);
+                    self.currentFocus = $(this).attr('tabindex', 0);
                    self.previousFocus.removeClass('ui-state-focus');
                    self.currentFocus.addClass('ui-state-focus');
                }