diff options
author | Klaus Hartl <klaus.hartl@googlemail.com> | 2009-02-05 19:02:47 +0000 |
---|---|---|
committer | Klaus Hartl <klaus.hartl@googlemail.com> | 2009-02-05 19:02:47 +0000 |
commit | 8aee174cdb1846688b7c720c50ea6c715db5f0f3 (patch) | |
tree | 60d0fe10155c178a2796b9ab8aabbb2c6d128544 /ui/ui.tabs.js | |
parent | dd3636c97afe68ab931dfa2c5a8d2a1f60cbee2e (diff) | |
download | jquery-ui-8aee174cdb1846688b7c720c50ea6c715db5f0f3.tar.gz jquery-ui-8aee174cdb1846688b7c720c50ea6c715db5f0f3.zip |
Tabs: Added tests for select method while at the same time implemented consistent handling of possible values to pass, addresses #4051
Diffstat (limited to 'ui/ui.tabs.js')
-rw-r--r-- | ui/ui.tabs.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ui/ui.tabs.js b/ui/ui.tabs.js index 7d077b173..b80e51759 100644 --- a/ui/ui.tabs.js +++ b/ui/ui.tabs.js @@ -21,8 +21,9 @@ $.widget("ui.tabs", { }, _setData: function(key, value) { - if ((/^selected/).test(key)) + if (key == 'selected') this.select(value); + else { this.options[key] = value; if (key == 'deselectable') @@ -311,7 +312,7 @@ $.widget("ui.tabs", { if (o.cookie) self._cookie(o.selected, o.cookie); // stop possibly running animations - self.$panels.stop(); + self.$panels.stop(false, true); // show new tab if ($show.length) { @@ -474,19 +475,23 @@ $.widget("ui.tabs", { select: function(index) { if (typeof index == 'string') index = this.$tabs.index(this.$tabs.filter('[href$=' + index + ']')); + + else if (index === null) + index = -1; + + if (index == -1 && this.options.collapsible) + index = this.options.selected; + this.$tabs.eq(index).trigger(this.options.event + '.tabs'); }, load: function(index, callback) { // callback is for internal usage only - + callback = callback || function() {}; + var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0], bypassCache = callback == undefined, url = $a.data('load.tabs'); - callback = callback || function() {}; - - // no remote or from cache - just finish with callback - // TODO in any case: insert cancel running load here..! - + // not remote or from cache - just finish with callback if (!url || !bypassCache && $.data(a, 'cache.tabs')) { callback(); return; |