Changeset 3952
- Timestamp:
- 11/27/07 22:08:49 (9 months ago)
- Location:
- trunk/ui/current
- Files:
-
- 2 modified
-
tests/tabs.html (modified) (2 diffs)
-
ui.tabs.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/current/tests/tabs.html
r3930 r3952 77 77 }); 78 78 </script> 79 80 <style type="text/css" media="screen, projection">81 /* Not required for Tabs, just to make this demo look better... */82 h1 {83 margin: 1em 0 1.5em;84 font-size: 18px;85 }86 h2 {87 margin: 2em 0 1.5em;88 font-size: 16px;89 }90 p {91 margin: 0;92 }93 pre, pre+p, p+p {94 margin: 1em 0 0;95 }96 code {97 font-family: "Courier New", Courier, monospace;98 }99 </style>100 79 </head> 101 80 <body> 102 <h1><a href="http://ui.jquery.com">jQuery UI</a> Tabs </h1>81 <h1><a href="http://ui.jquery.com">jQuery UI</a> Tabs tests</h1> 103 82 104 83 <h2>Simple Tabs</h2> … … 391 370 </div> 392 371 393 <h2>Tested with</h2>394 395 <ul>396 <li>Firefox 2.0</li>397 <li>Firefox 1.5</li>398 <li>Opera 9.20</li>399 <li>Safari 2.0.4</li>400 <li><abbr title="Internet Explorer">IE</abbr> 7</li>401 <li><abbr title="Internet Explorer">IE</abbr> 6</li>402 </ul>403 404 372 </body> 405 373 </html> -
trunk/ui/current/ui.tabs.js
r3935 r3952 157 157 158 158 // attach necessary classes for styling if not present 159 $(this.source). is('.' +o.navClass) || $(this.source).addClass(o.navClass);159 $(this.source).hasClass(o.navClass) || $(this.source).addClass(o.navClass); 160 160 this.$panels.each(function() { 161 161 var $this = $(this); 162 $this. is('.' +o.panelClass) || $this.addClass(o.panelClass);162 $this.hasClass(o.panelClass) || $this.addClass(o.panelClass); 163 163 }); 164 164 … … 193 193 o.initial = parseInt($.cookie(self.uuid)) || 0; 194 194 return false; // break 195 } else if ( $(a).parent('li'). is('.' +o.selectedClass) ) {195 } else if ( $(a).parent('li').hasClass(o.selectedClass) ) { 196 196 o.initial = i; 197 197 return false; // break … … 199 199 }); 200 200 var n = this.$tabs.length; 201 while ( this.$tabs.eq(o.initial).parent('li'). is('.' +o.disabledClass) && n) {201 while ( this.$tabs.eq(o.initial).parent('li').hasClass(o.disabledClass) && n) { 202 202 o.initial = ++o.initial < this.$tabs.length ? o.initial : 0; 203 203 n--; … … 307 307 // If tab is already selected and not unselectable or tab disabled or click callback returns false stop here. 308 308 // Check if click handler returns false last so that it is not executed for a disabled tab! 309 if (($li. is('.' + o.selectedClass) && !o.unselect) || $li.is('.' +o.disabledClass)309 if (($li.hasClass(o.selectedClass) && !o.unselect) || $li.hasClass(o.disabledClass) 310 310 || o.click(this, $show[0], $hide[0]) === false) { 311 311 this.blur(); … … 319 319 // if tab may be closed 320 320 if (o.unselect) { 321 if ($li. is('.' +o.selectedClass)) {321 if ($li.hasClass(o.selectedClass)) { 322 322 $li.removeClass(o.selectedClass); 323 323 self.$panels.stop(); … … 387 387 add: function(url, text, position) { 388 388 if (url && text) { 389 var o = this.options;390 position = position || this.$tabs.length; // append by default391 392 var$li = $(o.tabTemplate.replace(/#\{href\}/, url).replace(/#\{text\}/, text));389 position = position || this.$tabs.length; // append by default 390 391 var o = this.options, 392 $li = $(o.tabTemplate.replace(/#\{href\}/, url).replace(/#\{text\}/, text)); 393 393 394 394 if (url.indexOf('#') == 0) { … … 400 400 // try to find an existing element before creating a new one 401 401 var $panel = $('#' + id); 402 $panel = $panel.length && $panel || $(o.panelTemplate).attr('id', id).addClass(o.panelClass).addClass(o.hideClass); 402 $panel = $panel.length && $panel 403 || $(o.panelTemplate).attr('id', id).addClass(o.panelClass).addClass(o.hideClass); 403 404 if (position >= this.$tabs.length) { 404 405 $li.appendTo(this.source); 405 406 $panel.appendTo(this.source.parentNode); 406 407 } else { 407 $li.insertBefore(this.$tabs. slice(position - 1, position).parent('li'));408 $li.insertBefore(this.$tabs.eq(position - 1).parent('li')); 408 409 $panel.insertBefore(this.$panels[position - 1]); 409 410 } … … 426 427 remove: function(position) { 427 428 if (position && position.constructor == Number) { 428 var $li = this.$tabs.slice(position - 1, position).parent('li').remove(), 429 $panel = this.$panels.slice(position - 1, position).remove(), 430 o = this.options; 429 var o = this.options, $li = this.$tabs.eq(position - 1).parent('li').remove(), 430 $panel = this.$panels.eq(position - 1).remove(); 431 431 432 432 // If selected tab was removed focus tab to the right or 433 433 // tab to the left if last tab was removed. 434 if ($li. is('.' +o.selectedClass) && this.$tabs.length > 1) {434 if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1) { 435 435 this.click(position + (position < this.$tabs.length ? 1 : -1)); 436 436 } … … 440 440 }, 441 441 enable: function(position) { 442 var $li = this.$tabs.slice(position - 1, position).parent('li'), o = this.options;442 var o = this.options, $li = this.$tabs.eq(position - 1).parent('li'); 443 443 $li.removeClass(o.disabledClass); 444 444 if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2... … … 452 452 disable: function(position) { 453 453 var o = this.options; 454 this.$tabs. slice(position - 1, position).parent('li').addClass(o.disabledClass);454 this.$tabs.eq(position - 1).parent('li').addClass(o.disabledClass); 455 455 o.disable(this.$tabs[position - 1], this.$panels[position - 1]); // callback 456 456 }, 457 457 click: function(position) { 458 this.$tabs. slice(position - 1, position).trigger(this.options.event);458 this.$tabs.eq(position - 1).trigger(this.options.event); 459 459 }, 460 460 load: function(position, url, callback) { 461 461 var self = this, o = this.options, 462 $a = this.$tabs. slice(position - 1, position), a = $a[0], $span = $('span', a);462 $a = this.$tabs.eq(position - 1), a = $a[0], $span = $('span', a); 463 463 464 464 // shift arguments … … 517 517 }, 518 518 href: function(position, href) { 519 $.data(this.$tabs. slice(position - 1, position)[0], 'href', href);519 $.data(this.$tabs.eq(position - 1)[0], 'href', href); 520 520 } 521 521 });
