diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-07-20 13:58:10 +0200 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-07-20 13:58:10 +0200 |
commit | 88ec776178b62d21ac6e218946800b2d0c2b0b78 (patch) | |
tree | 32373be01cb84e71cfa698f78ac56d6d400632bc /ui/jquery.ui.tabs.js | |
parent | 4be0942af0d0a73541148899fbb2e0c406795c79 (diff) | |
parent | 5debdb08d7702e9c04b4efa883c68d350576d710 (diff) | |
download | jquery-ui-88ec776178b62d21ac6e218946800b2d0c2b0b78.tar.gz jquery-ui-88ec776178b62d21ac6e218946800b2d0c2b0b78.zip |
Merge remote branch 'origin/master'
Diffstat (limited to 'ui/jquery.ui.tabs.js')
-rw-r--r-- | ui/jquery.ui.tabs.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 2d258d1d2..5555b95f5 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -413,6 +413,16 @@ $.widget("ui.tabs", { }, + _getIndex: function(index) { + // meta-function to give users option to provide a href string instead of a numerical index. + // also sanitizes numerical indexes to valid values. + if (typeof index == 'string') { + index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); + } + + return index; + }, + destroy: function() { var o = this.options; @@ -512,6 +522,7 @@ $.widget("ui.tabs", { }, remove: function(index) { + index = this._getIndex(index); var o = this.options, $li = this.lis.eq(index).remove(), $panel = this.panels.eq(index).remove(); @@ -532,6 +543,7 @@ $.widget("ui.tabs", { }, enable: function(index) { + index = this._getIndex(index); var o = this.options; if ($.inArray(index, o.disabled) == -1) { return; @@ -546,6 +558,7 @@ $.widget("ui.tabs", { }, disable: function(index) { + index = this._getIndex(index); var self = this, o = this.options; if (index != o.selected) { // cannot disable already selected tab this.lis.eq(index).addClass('ui-state-disabled'); @@ -561,21 +574,20 @@ $.widget("ui.tabs", { }, select: function(index) { - if (typeof index == 'string') { - index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); - } - else if (index === null) { // usage of null is deprecated, TODO remove in next release - index = -1; - } - if (index == -1 && this.options.collapsible) { - index = this.options.selected; + index = this._getIndex(index); + if (index == -1) { + if (this.options.collapsible && this.options.selected != -1) { + index = this.options.selected; + } else { + return this; + } } - this.anchors.eq(index).trigger(this.options.event + '.tabs'); return this; }, load: function(index) { + index = this._getIndex(index); var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs'); this.abort(); |