Changeset 4128
- Timestamp:
- 12/12/07 23:33:05 (1 year ago)
- Files:
-
- 1 modified
-
trunk/ui/current/ui.tabs.js (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/current/ui.tabs.js
r3983 r4128 127 127 tabify: function(init) { 128 128 129 this.$tabs = $('a:first-child', this.source); 129 this.$lis = $('li:has(a[href])', this.source); 130 this.$tabs = $('a[href]', this.source); 130 131 this.$panels = $([]); 131 132 … … 192 193 o.initial = parseInt($.cookie( $.ui.tabs.INSTANCE_KEY + $.data(self.source) )) || 0; 193 194 return false; // break 194 } else if ( $(a).parent('li').hasClass(o.selectedClass) ) {195 } else if ( self.$lis.eq(i).hasClass(o.selectedClass) ) { 195 196 o.initial = i; 196 197 return false; // break 197 198 } 198 199 }); 199 var n = this.$ tabs.length;200 while ( this.$tabs.eq(o.initial).parent('li').hasClass(o.disabledClass) && n) {201 o.initial = ++o.initial < this.$ tabs.length ? o.initial : 0;200 var n = this.$lis.length; 201 while (this.$lis.eq(o.initial).hasClass(o.disabledClass) && n) { 202 o.initial = ++o.initial < this.$lis.length ? o.initial : 0; 202 203 n--; 203 204 } … … 207 208 208 209 // highlight selected tab 209 var $lis = this.$tabs.parent('li');210 210 this.$panels.addClass(o.hideClass); 211 $lis.removeClass(o.selectedClass);211 this.$lis.removeClass(o.selectedClass); 212 212 if (!o.unselected) { 213 213 this.$panels.eq(o.initial).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before 214 $lis.eq(o.initial).addClass(o.selectedClass);214 this.$lis.eq(o.initial).addClass(o.selectedClass); 215 215 } 216 216 … … 287 287 288 288 // switch a tab 289 function switchTab(clicked, $ hide, $show) {289 function switchTab(clicked, $li, $hide, $show) { 290 290 /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click 291 291 $.ajaxHistory.update(clicked.hash); 292 292 }*/ 293 $ (clicked).parents('li:eq(0)').addClass(o.selectedClass)293 $li.addClass(o.selectedClass) 294 294 .siblings().removeClass(o.selectedClass); 295 295 hideTab(clicked, $hide, $show); … … 300 300 301 301 //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click 302 var $li = $(this).parent ('li'),302 var $li = $(this).parents('li:eq(0)'), 303 303 $hide = self.$panels.filter(':visible'), 304 304 $show = $(this.hash); … … 359 359 var a = this; 360 360 self.load(self.$tabs.index(this) + 1, $.data(this, 'href'), function() { 361 switchTab(a, $ hide, $show);361 switchTab(a, $li, $hide, $show); 362 362 }); 363 363 } else { 364 switchTab(this, $ hide, $show);364 switchTab(this, $li, $hide, $show); 365 365 } 366 366 … … 397 397 $panel = $panel.length && $panel 398 398 || $(o.panelTemplate).attr('id', id).addClass(o.panelClass).addClass(o.hideClass); 399 if (position >= this.$ tabs.length) {399 if (position >= this.$lis.length) { 400 400 $li.appendTo(this.source); 401 401 $panel.appendTo(this.source.parentNode); 402 402 } else { 403 $li.insertBefore(this.$ tabs.eq(position - 1).parent('li'));403 $li.insertBefore(this.$lis[position - 1]); 404 404 $panel.insertBefore(this.$panels[position - 1]); 405 405 } … … 422 422 remove: function(position) { 423 423 if (position && position.constructor == Number) { 424 var o = this.options, $li = this.$ tabs.eq(position - 1).parent('li').remove(),424 var o = this.options, $li = this.$lis.eq(position - 1).remove(), 425 425 $panel = this.$panels.eq(position - 1).remove(); 426 426 … … 435 435 }, 436 436 enable: function(position) { 437 var o = this.options, $li = this.$ tabs.eq(position - 1).parent('li');437 var o = this.options, $li = this.$lis.eq(position - 1); 438 438 $li.removeClass(o.disabledClass); 439 439 if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2... … … 447 447 disable: function(position) { 448 448 var o = this.options; 449 this.$ tabs.eq(position - 1).parent('li').addClass(o.disabledClass);449 this.$lis.eq(position - 1).addClass(o.disabledClass); 450 450 o.disable(this.$tabs[position - 1], this.$panels[position - 1]); // callback 451 451 },
