/[drupal]/contributions/modules/ui/javascript/ui.tabs.js
ViewVC logotype

Diff of /contributions/modules/ui/javascript/ui.tabs.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Sun Sep 2 20:21:42 2007 UTC revision 1.2, Mon Sep 17 03:42:34 2007 UTC
# Line 1  Line 1 
1  /* jQuery UI Tabs (Tabs 3)  /*
2   *   * Tabs 3 - New Wave Tabs
3     *
4     * Copyright (c) 2007 Klaus Hartl (stilbuero.de)
5     * Dual licensed under the MIT (MIT-LICENSE.txt)
6     * and GPL (GPL-LICENSE.txt) licenses.
7   */   */
8    
9  (function($) {  (function($) {
10    
11          // if the UI scope is not availalable, add it      // if the UI scope is not availalable, add it
12          $.ui = $.ui || {};      $.ui = $.ui || {};
13    
14        // tabs initialization
15      $.fn.tabs = function(initial, options) {      $.fn.tabs = function(initial, options) {
16          if (initial && initial.constructor == Object) {          if (initial && initial.constructor == Object) { // shift arguments
17              options = initial;              options = initial;
18              initial = null;              initial = null;
19          }          }
20          options = options || {};          options = options || {};
21    
22          // first get initial tab from options          initial = initial && initial.constructor == Number && --initial || 0;
23          initial = initial && initial.constructor == Number && --initial || 0;  
24            return this.each(function() {
25          return this.each(function() {              new $.ui.tabs(this, $.extend(options, { initial: initial }));
26                  new $.ui.tabs(this, $.extend(options, { initial: initial }));          });
         });  
27      };      };
28    
29      // create chainable tabs methods      // other chainable tabs methods
30      $.each(['add', 'remove'], function(i, method) {      $.each(['Add', 'Remove', 'Enable', 'Disable', 'Click', 'Load'], function(i, method) {
31          $.fn[method + 'Tab'] = function() {          $.fn['tabs' + method] = function() {
32              var args = arguments;              var args = arguments;
33              return this.each(function() {              return this.each(function() {
34                  this.jQueryTabs[method].apply(this.jQueryTabs, args);                  var instance = $.ui.tabs.getInstance(this);
35                    instance[method.toLowerCase()].apply(instance, args);
36              });              });
37          };          };
38      });      });
39        $.fn.tabsSelected = function() {
40      /*$.fn.addTab = function(url, text, position) { // TODO callback?          var selected = -1;
41          var args = arguments;          if (this[0]) {
42          return this.each(function() {              var instance = $.ui.tabs.getInstance(this[0]),
43              this.jQueryTabs.add.apply(this.jQueryTabs, args);                  $lis = $('li', this);
44          });              selected = $lis.index( $lis.filter('.' + instance.options.selectedClass)[0] );
45      };          }
46            return selected >= 0 ? ++selected : -1;
     $.fn.removeTab = function(position) {  
         var args = arguments;  
         return this.each(function() {  
             this.jQueryTabs.remove.apply(this.jQueryTabs, args);  
         });  
     };*/  
   
     $.fn.enableTab = function(position) {  
         return this.each(function() {  
   
         });  
     };  
   
     $.fn.disableTab = function(position) {  
         return this.each(function() {  
   
         });  
     };  
   
     $.fn.showTab = function(position) {  
         return this.each(function() {  
   
         });  
     };  
   
     $.fn.reloadTab = function(position, url) {  
         // frequently requested: if url is passed reload tab with that url  
         return this.each(function() {  
   
         });  
     };  
   
     $.fn.activeTab = function() {  
         // returns number or element?  
47      };      };
48    
49        // tabs class
50      $.ui.tabs = function(el, options) {      $.ui.tabs = function(el, options) {
51    
52          this.source = el;          this.source = el;
53    
54          this.options = $.extend({          this.options = $.extend({
55    
56                // basic setup
57              initial: 0,              initial: 0,
58              /*disabled: null,*/              event: 'click',
59                disabled: [],
60              // TODO bookmarkable: $.ajaxHistory ? true : false,              // TODO bookmarkable: $.ajaxHistory ? true : false,
61                unselected: false,
62                unselect: options.unselected ? true : false,
63    
64                // Ajax
65              spinner: 'Loading…',              spinner: 'Loading…',
66              hashPrefix: 'tab-',              cache: false,
67                idPrefix: 'tab-',
68    
69                // animations
70              /*fxFade: null,              /*fxFade: null,
71              fxSlide: null,              fxSlide: null,
72              fxShow: null,              fxShow: null,
# Line 91  Line 74 
74              fxSpeed: 'normal',              fxSpeed: 'normal',
75              /*fxShowSpeed: null,              /*fxShowSpeed: null,
76              fxHideSpeed: null,*/              fxHideSpeed: null,*/
77              click: null,  
78              show: null,              // callbacks
79              navClass: 'tabs-nav',              add: function() {},
80              selectedClass: 'tabs-selected',              remove: function() {},
81              disabledClass: 'tabs-disabled',              enable: function() {},
82              containerClass: 'tabs-container',              disable: function() {},
83              hideClass: 'tabs-hide',              click: function() {},
84              loadingClass: 'tabs-loading'              hide: function() {},
85          }, options);              show: function() {},
86                load: function() {},
87          this.tabify();  
88                // CSS classes
89                navClass: 'ui-tabs-nav',
90                selectedClass: 'ui-tabs-selected',
91                disabledClass: 'ui-tabs-disabled',
92                containerClass: 'ui-tabs-container',
93                hideClass: 'ui-tabs-hide',
94                loadingClass: 'ui-tabs-loading'
95    
96            }, options);
97    
98            this.tabify(true);
99    
100            // save instance for later
101            var uuid = 'tabs' + $.ui.tabs.prototype.count++;
102            $.ui.tabs.instances[uuid] = this;
103            $.data(el, 'tabsUUID', uuid);
104    
105      };      };
106    
107      $.extend($.ui.tabs.prototype, {      // static
108          tabify: function() {      $.ui.tabs.instances = {};
109        $.ui.tabs.getInstance = function(el) {
110            return $.ui.tabs.instances[$.data(el, 'tabsUUID')];
111        };
112    
113        // instance methods
114        $.extend($.ui.tabs.prototype, {
115            count: 0,
116            tabify: function(init) {
117    
118              this.$tabs = $('a:first-child', this.source);              this.$tabs = $('a:first-child', this.source);
119              this.$containers = $([]);              this.$containers = $([]);
120    
121              var instance = this;              var self = this, o = this.options;
             var $source = $(this.source), options = this.options;  
122    
123              this.$tabs.each(function(i, a) {              this.$tabs.each(function(i, a) {
124                      if (a.hash) { // inline tab                  // inline tab
125                          instance.$containers = instance.$containers.add(a.hash); // jQuery's add() does not work somehow                  if (a.hash && a.hash.replace('#', '')) { // safari 2 reports '#' for an empty hash
126                      } else { // remote tab                      self.$containers = self.$containers.add(a.hash);
127                          // TODO create and add container                  }
128                      }                  // remote tab
129                  });                  else {
130                        $.data(a, 'href', a.href);
131                  // Try to retrieve initial tab from fragment identifier in url if present,                      var id = a.title && a.title.replace(/\s/g, '_') || o.idPrefix + (self.count + 1) + '-' + (i + 1);
132              // otherwise try to find selected class attribute on <li>.                      a.href = '#' + id;
133                  this.$tabs.each(function(i, a) {                      self.$containers = self.$containers.add(
134                  if (location.hash) {                          $('#' + id)[0] || $('<div id="' + id + '" class="' + o.containerClass + '"></div>')
135                      if (a.hash == location.hash) {                              .insertAfter( self.$containers[i - 1] || self.source )
136                          options.initial = i;                      );
137                          // prevent page scroll to fragment                  }
138                          //if (($.browser.msie || $.browser.opera) && !options.remote) {              });
139                          if ($.browser.msie || $.browser.opera) {  
140                              var $toShow = $(location.hash);              if (init) {
141                              var toShowId = toShow.attr('id');  
142                              $toShow.attr('id', '');                  // Try to retrieve initial tab from fragment identifier in url if present,
143                              setTimeout(function() {                  // otherwise try to find selected class attribute on <li>.
144                                  $toShow.attr('id', toShowId); // restore id                  this.$tabs.each(function(i, a) {
145                              }, 500);                      if (location.hash) {
146                            if (a.hash == location.hash) {
147                                o.initial = i;
148                                // prevent page scroll to fragment
149                                //if (($.browser.msie || $.browser.opera) && !o.remote) {
150                                if ($.browser.msie || $.browser.opera) {
151                                    var $toShow = $(location.hash), toShowId = $toShow.attr('id');
152                                    $toShow.attr('id', '');
153                                    setTimeout(function() {
154                                        $toShow.attr('id', toShowId); // restore id
155                                    }, 500);
156                                }
157                                scrollTo(0, 0);
158                                return false; // break
159                          }                          }
160                          scrollTo(0, 0);                      } else if ( $(a).parents('li:eq(0)').is('li.' + o.selectedClass) ) {
161                            o.initial = i;
162                          return false; // break                          return false; // break
163                      }                      }
164                  } else if ( $(a).parents('li:eq(0)').is('li.' + options.selectedClass) ) {                  });
165                      options.initial = i;  
166                      return false; // break                  // attach necessary classes for styling if not present
167                  }                  $(this.source).is('.' + o.navClass) || $(this.source).addClass(o.navClass);
168                  });                  this.$containers.each(function() {
169                        var $this = $(this);
170              // attach necessary classes for styling if not present                      $this.is('.' + o.containerClass) || $this.addClass(o.containerClass);
171              $source.is('.' + options.navClass) || $source.addClass(options.navClass);                  });
172              this.$containers.each(function() {  
173                  var $this = $(this);                  // highlight tab
174                  $this.is('.' + options.containerClass) || $this.addClass(options.containerClass);                  var $lis = $('li', this.source);
175              });                  this.$containers.addClass(o.hideClass);
176                    $lis.removeClass(o.selectedClass);
177              // highlight tab accordingly                  if (!o.unselected) {
178              this.$containers.filter(':eq(' + options.initial + ')').show().end().not(':eq(' + options.initial + ')').addClass(options.hideClass);                      this.$containers.slice(o.initial, o.initial + 1).show();
179              $('li', $source).removeClass(options.selectedClass).eq(options.initial).addClass(options.selectedClass); // eventually need to remove classes in case hash takes precedence over class                      $lis.slice(o.initial, o.initial + 1).addClass(o.selectedClass);
180                    }
181              // trigger load of initial tab  
182              // TODO                  // load if remote tab
183              //tabs.eq(options.initial).trigger('loadRemoteTab').end();                  if ($.data(this.$tabs[o.initial], 'href')) {
184                        this.load(o.initial + 1, $.data(this.$tabs[o.initial], 'href'));
185                  // setup animations                      if (o.cache) {
186              var showAnim = {}, hideAnim = {}, showSpeed = options.fxShowSpeed || options.fxSpeed, hideSpeed = options.fxHideSpeed || options.fxSpeed;                          $.removeData(this.$tabs[o.initial], 'href'); // if loaded once do not load them again
187              if (options.fxSlide || options.fxFade) {                      }
188                  if (options.fxSlide) {                  }
189    
190                    // disabled tabs
191                    for (var i = 0, position; position = o.disabled[i]; i++) {
192                        this.disable(position);
193                    }
194    
195                }
196    
197                // setup animations
198                var showAnim = {}, showSpeed = o.fxShowSpeed || o.fxSpeed,
199                    hideAnim = {}, hideSpeed = o.fxHideSpeed || o.fxSpeed;
200                if (o.fxSlide || o.fxFade) {
201                    if (o.fxSlide) {
202                      showAnim['height'] = 'show';                      showAnim['height'] = 'show';
203                      hideAnim['height'] = 'hide';                      hideAnim['height'] = 'hide';
204                  }                  }
205                  if (options.fxFade) {                  if (o.fxFade) {
206                      showAnim['opacity'] = 'show';                      showAnim['opacity'] = 'show';
207                      hideAnim['opacity'] = 'hide';                      hideAnim['opacity'] = 'hide';
208                  }                  }
209              } else {              } else {
210                  if (options.fxShow) {                  if (o.fxShow) {
211                      showAnim = options.fxShow;                      showAnim = o.fxShow;
212                  } else { // use some kind of animation to prevent browser scrolling to the tab                  } else { // use some kind of animation to prevent browser scrolling to the tab
213                      showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox                      showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
214                      showSpeed = 1; // as little as 1 is sufficient                      showSpeed = 1; // as little as 1 is sufficient
215                  }                  }
216                  if (options.fxHide) {                  if (o.fxHide) {
217                      hideAnim = options.fxHide;                      hideAnim = o.fxHide;
218                  } else { // use some kind of animation to prevent browser scrolling to the tab                  } else { // use some kind of animation to prevent browser scrolling to the tab
219                      hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox                      hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
220                      hideSpeed = 1; // as little as 1 is sufficient                      hideSpeed = 1; // as little as 1 is sufficient
221                  }                  }
222              }              }
   
                 var $containers = this.$containers;  
   
   
                 // attach click event  
             this.$tabs.bind('click', function(e) {  
223    
224                  //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click              // reset some styles to maintain print style sheets etc.
225                  var clicked = this, $li = $(this).parents('li:eq(0)'), $show = $(this.hash), $hide = $containers.filter(':visible');              var resetCSS = { display: '', overflow: '', height: '' };
226                if (!$.browser.msie) { // not in IE to prevent ClearType font issue
227                    resetCSS['opacity'] = '';
228                }
229    
230                // Hide a tab, animation prevents browser scrolling to fragment,
231                // $show is optional.
232                function hideTab(clicked, $hide, $show) {
233                    $hide.animate(hideAnim, hideSpeed, function() { //
234                        $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
235                        if ($.browser.msie) {
236                            $hide[0].style.filter = '';
237                        }
238                        o.hide(clicked, $hide[0], $show && $show[0] || null);
239                        if ($show) {
240                            showTab(clicked, $show, $hide);
241                        }
242                    });
243                }
244    
245                // Show a tab, animation prevents browser scrolling to fragment,
246                // $hide is optional
247                function showTab(clicked, $show, $hide) {
248                    if (!(o.fxSlide || o.fxFade || o.fxShow)) {
249                        $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab containers
250                    }
251                    $show.animate(showAnim, showSpeed, function() {
252                        $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
253                        if ($.browser.msie) {
254                            $show[0].style.filter = '';
255                        }
256                        o.show(clicked, $show[0], $hide && $hide[0] || null);
257                    });
258                }
259    
260                  // if animation is still running, tab is selected or disabled or onClick callback returns false stop here              // switch a tab
261                  // check if onClick returns false last so that it is not executed for a disabled tab              function switchTab(clicked, $hide, $show) {
262                  if ($source['locked'] || $li.is('.' + options.selectedClass, '.' + options.disabledClass)                  /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
263                      || typeof onClick == 'function' && onClick(this, $show[0], $hide[0]) === false) {                      $.ajaxHistory.update(clicked.hash);
264                    }*/
265                    $(clicked).parents('li:eq(0)').addClass(o.selectedClass)
266                        .siblings().removeClass(o.selectedClass);
267                    hideTab(clicked, $hide, $show);
268                }
269    
270                // tab click handler
271                function tabClick(e) {
272    
273                    //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
274                    var $li = $(this).parents('li:eq(0)'),
275                        $hide = self.$containers.filter(':visible'),
276                        $show = $(this.hash);
277    
278                    // If tab is already selected and not unselectable or tab disabled or click callback returns false stop here.
279                    // Check if click handler returns false last so that it is not executed for a disabled tab!
280                    if (($li.is('.' + o.selectedClass) && !o.unselect) || $li.is('.' + o.disabledClass)
281                        || o.click(this, $show[0], $hide[0]) === false) {
282                      this.blur();                      this.blur();
283                      return false;                      return false;
284                  }                  }
285    
286                    // if tab may be closed
287                    if (o.unselect) {
288                        if ($li.is('.' + o.selectedClass)) {
289                            $li.removeClass(o.selectedClass);
290                            self.$containers.stop();
291                            hideTab(this, $hide);
292                            this.blur();
293                            return false;
294                        } else if (!$hide.length) {
295                            $li.addClass(o.selectedClass);
296                            self.$containers.stop();
297                            showTab(this, $show);
298                            this.blur();
299                            return false;
300                        }
301                    }
302    
303                  $source['locked'] = true;                  // stop possibly running animations
304                    self.$containers.stop();
305    
306                  // show new tab                  // show new tab
307                  if ($show.size()) {                  if ($show.length) {
308    
309                      // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled                      // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
310                      if ($.browser.msie && options.bookmarkable) {                      /*if ($.browser.msie && o.bookmarkable) {
311                          var showId = this.hash.replace('#', '');                          var showId = this.hash.replace('#', '');
312                          $show.attr('id', '');                          $show.attr('id', '');
313                          setTimeout(function() {                          setTimeout(function() {
314                              $show.attr('id', showId); // restore id                              $show.attr('id', showId); // restore id
315                          }, 0);                          }, 0);
316                      }                      }*/
   
                     var resetCSS = { display: '', overflow: '', height: '' };  
                     if (!$.browser.msie) { // not in IE to prevent ClearType font issue  
                         resetCSS['opacity'] = '';  
                     }  
317    
318                      // switch tab, animation prevents browser scrolling to the fragment                      if ($.data(this, 'href')) { // remote tab
319                      function switchTab() {                          var a = this;
320                          /*if (options.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click                          self.load(self.$tabs.index(this) + 1, $.data(this, 'href'), function() {
321                              $.ajaxHistory.update(clicked.hash);                              switchTab(a, $hide, $show);
                         }*/  
                         $hide.animate(hideAnim, hideSpeed, function() { //  
                             $(clicked).parents('li:eq(0)').addClass(options.selectedClass).siblings().removeClass(options.selectedClass);  
                             $hide.addClass(options.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.  
                             if (typeof onHide == 'function') {  
                                 onHide(clicked, $show[0], $hide[0]);  
                             }  
                             if (!(options.fxSlide || options.fxFade || options.fxShow)) {  
                                 $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab containers  
                             }  
                             $show.animate(showAnim, showSpeed, function() {  
                                 $show.removeClass(options.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.  
                                 if ($.browser.msie) {  
                                     $hide[0].style.filter = '';  
                                     $show[0].style.filter = '';  
                                 }  
                                 if (typeof onShow == 'function') {  
                                     onShow(clicked, $show[0], $hide[0]);  
                                 }  
                                 $source['locked'] = null;  
                             });  
322                          });                          });
323                            if (o.cache) {
324                                $.removeData(this, 'href'); // if loaded once do not load them again
325                            }
326                        } else {
327                            switchTab(this, $hide, $show);
328                      }                      }
                     switchTab();  
329    
330                      /*if (!options.remote) {                      // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
331                          switchTab();                      /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
332                      } else {                      var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
333                          $(clicked).trigger('loadRemoteTab', [switchTab]);                      setTimeout(function() {
334                      }*/                          scrollTo(scrollX, scrollY);
335                        }, 0);*/
336    
337                  } else {                  } else {
338                      alert('There is no such container.');                      throw 'jQuery UI Tabs: Mismatching fragment identifier.';
339                  }                  }
340    
                 // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash  
                 var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;  
                 var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;  
                 setTimeout(function() {  
                     scrollTo(scrollX, scrollY);  
                 }, 0);  
   
341                  this.blur(); // prevent IE from keeping other link focussed when using the back button                  this.blur(); // prevent IE from keeping other link focussed when using the back button
342    
343                  //return options.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE                  //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
344                  return false;                  return false;
345    
346              });              }
347    
348                  // TODO attach instance as expando?              // attach click event, avoid duplicates from former tabifying
349                  this.source['jQueryTabs'] = this;              this.$tabs.unbind(o.event, tabClick).bind(o.event, tabClick);
350    
351          },          },
352          add: function(url, text, position) { // TODO callback          add: function(url, text, position) {
353              if (url && text) {              if (url && text) {
354                  position = position || this.$tabs.length + 1;                  var o = this.options;
355                  if (position > this.$tabs.length) {                  position = position || this.$tabs.length; // append by default
356                    if (position >= this.$tabs.length) {
357                      var method = 'insertAfter';                      var method = 'insertAfter';
358                      position = this.$tabs.length - 1;                      position = this.$tabs.length;
359                  } else {                  } else {
360                      var method = 'insertBefore';                      var method = 'insertBefore';
                     --position;  
361                  }                  }
362                  $('<div id="' + url.replace('#', '') + '"></div>')[method](this.$containers[position])                  if (url.indexOf('#') == 0) { // ajax container is created by tabify automatically
363                  $('<li><a href="' + url + '"><span>' + text + '</span></a></li>')[method](this.$tabs.eq(position).parents('li:eq(0)'));                      var $container = $(url);
364                  this.$tabs.unbind('click'); // TODO specify function                      // try to find an existing element before creating a new one
365                        ($container.length && $container || $('<div id="' + url.replace('#', '') + '" class="' + o.containerClass + ' ' + o.hideClass + '"></div>'))
366                            [method](this.$containers[position - 1]);
367                    }
368                    $('<li><a href="' + url + '"><span>' + text + '</span></a></li>')
369                        [method](this.$tabs.slice(position - 1, position).parents('li:eq(0)'));
370                  this.tabify();                  this.tabify();
371                    o.add(this.$tabs[position - 1], this.$containers[position - 1]); // callback
372              } else {              } else {
373                  alert('jQuery UI Tabs: Not enough arguments to add tab.'); // TODO use throw?                  throw 'jQuery UI Tabs: Not enough arguments to add tab.';
374              }              }
375          },          },
376          remove: function(position) { // TODO callback          remove: function(position) {
377              if (position && position.constructor == Number) {              if (position && position.constructor == Number) {
378                  --position;                  var $removedTab = this.$tabs.slice(position - 1, position).parents('li:eq(0)').remove();
379                  this.$tabs.unbind('click'); // TODO specify function                  var $removedContainer = this.$containers.slice(position - 1, position).remove();
                 this.$tabs.eq(position).parents('li:eq(0)').remove();  
                 this.$containers.eq(position).remove();  
380                  this.tabify();                  this.tabify();
381                    this.options.remove($removedTab[0], $removedContainer[0]); // callback
382              }              }
383          },          },
384          enable: function(position) { // TODO callback          enable: function(position) {
385                var $li = this.$tabs.slice(position - 1, position).parents('li:eq(0)'), o = this.options;
386                $li.removeClass(o.disabledClass);
387                if ($.browser.safari) { // fix disappearing tab after enabling in Safari... TODO check Safari 3
388                    $li.animate({ opacity: 1 }, 1, function() {
389                        $li.css({ opacity: '' });
390                    });
391                }
392                o.enable(this.$tabs[position - 1], this.$containers[position - 1]); // callback
393          },          },
394          disable: function(position) { // TODO callback          disable: function(position) {
395                var $li = this.$tabs.slice(position - 1, position).parents('li:eq(0)'), o = this.options;
396                if ($.browser.safari) { // fix opacity of tab after disabling in Safari... TODO check Safari 3
397                    $li.animate({ opacity: 0 }, 1, function() {
398                       $li.css({ opacity: '' });
399                    });
400                }
401                $li.addClass(this.options.disabledClass);
402                o.disable(this.$tabs[position - 1], this.$containers[position - 1]); // callback
403          },          },
404          show: function(position) { // TODO callback          click: function(position) {
405                this.$tabs.slice(position - 1, position).trigger('click');
406          },          },
407          reload: function(position, url) { // TODO callback          load: function(position, url, callback) {
408                var self = this,
409                    o = this.options,
410                    $a = this.$tabs.slice(position - 1, position).addClass(o.loadingClass),
411                    $span = $('span', $a),
412                    text = $span.html();
413    
414                // shift arguments
415                if (url && url.constructor == Function) {
416                    callback = url;
417                }
418    
419                // set new URL
420                if (url) {
421                    $.data($a[0], 'href', url);
422                }
423    
424                // load
425                if (o.spinner) {
426                    $span.html('<em>' + o.spinner + '</em>');
427                }
428                setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
429                    $($a[0].hash).load(url, function() {
430                        if (o.spinner) {
431                            $span.html(text);
432                        }
433                        $a.removeClass(o.loadingClass);
434                        // This callback is required because the switch has to take place after loading
435                        // has completed.
436                        if (callback && callback.constructor == Function) {
437                            callback();
438                        }
439                        o.load(self.$tabs[position - 1], self.$containers[position - 1]); // callback
440                    });
441                }, 0);
442          }          }
443      });      });
   
   
 })(jQuery);  
444    
445    })(jQuery);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2