2008-06-04 02:34:33 +00:00
|
|
|
/*
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Tabs @VERSION
|
2008-06-04 02:34:33 +00:00
|
|
|
*
|
2012-03-19 13:25:07 +00:00
|
|
|
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
|
2010-07-09 13:01:04 +00:00
|
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
* http://jquery.org/license
|
2008-06-04 02:34:33 +00:00
|
|
|
*
|
|
|
|
* http://docs.jquery.com/UI/Tabs
|
|
|
|
*
|
|
|
|
* Depends:
|
2009-09-17 10:39:12 +00:00
|
|
|
* jquery.ui.core.js
|
2009-12-22 19:51:24 +00:00
|
|
|
* jquery.ui.widget.js
|
2008-06-04 02:34:33 +00:00
|
|
|
*/
|
2010-07-13 13:57:58 +00:00
|
|
|
(function( $, undefined ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2010-03-04 02:36:43 +00:00
|
|
|
var tabId = 0,
|
|
|
|
listId = 0;
|
2009-10-17 01:27:02 +00:00
|
|
|
|
2010-05-18 00:48:07 +00:00
|
|
|
function getNextTabId() {
|
|
|
|
return ++tabId;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNextListId() {
|
|
|
|
return ++listId;
|
|
|
|
}
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
$.widget( "ui.tabs", {
|
2010-01-07 03:19:50 +00:00
|
|
|
options: {
|
|
|
|
add: null,
|
|
|
|
ajaxOptions: null,
|
|
|
|
cache: false,
|
|
|
|
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
|
|
|
|
collapsible: false,
|
|
|
|
disable: null,
|
|
|
|
disabled: [],
|
|
|
|
enable: null,
|
2010-07-28 15:28:14 +00:00
|
|
|
event: "click",
|
2010-01-07 03:19:50 +00:00
|
|
|
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
|
2010-07-28 15:28:14 +00:00
|
|
|
idPrefix: "ui-tabs-",
|
2010-01-07 03:19:50 +00:00
|
|
|
load: null,
|
2010-07-28 15:28:14 +00:00
|
|
|
panelTemplate: "<div></div>",
|
2010-01-07 03:19:50 +00:00
|
|
|
remove: null,
|
|
|
|
select: null,
|
|
|
|
show: null,
|
2010-07-28 15:28:14 +00:00
|
|
|
spinner: "<em>Loading…</em>",
|
|
|
|
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
|
2010-01-07 03:19:50 +00:00
|
|
|
},
|
2010-07-28 15:28:14 +00:00
|
|
|
|
2010-01-15 18:58:20 +00:00
|
|
|
_create: function() {
|
2010-07-28 15:28:14 +00:00
|
|
|
this._tabify( true );
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_setOption: function( key, value ) {
|
|
|
|
if ( key == "selected" ) {
|
|
|
|
if (this.options.collapsible && value == this.options.selected ) {
|
2009-02-22 11:54:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
this.select( value );
|
|
|
|
} else {
|
|
|
|
this.options[ key ] = value;
|
2008-08-16 07:34:55 +00:00
|
|
|
this._tabify();
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_tabId: function( a ) {
|
2010-09-03 15:35:10 +00:00
|
|
|
return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
|
2010-05-18 00:48:07 +00:00
|
|
|
this.options.idPrefix + getNextTabId();
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_sanitizeSelector: function( hash ) {
|
|
|
|
// we need this because an id may contain a ":"
|
|
|
|
return hash.replace( /:/g, "\\:" );
|
2008-10-02 14:20:35 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2008-10-02 14:20:35 +00:00
|
|
|
_cookie: function() {
|
2010-07-28 15:28:14 +00:00
|
|
|
var cookie = this.cookie ||
|
|
|
|
( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
|
|
|
|
return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
|
2008-10-02 14:20:35 +00:00
|
|
|
},
|
2009-01-31 00:45:14 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_ui: function( tab, panel ) {
|
2009-01-26 11:34:28 +00:00
|
|
|
return {
|
|
|
|
tab: tab,
|
|
|
|
panel: panel,
|
2010-07-28 15:28:14 +00:00
|
|
|
index: this.anchors.index( tab )
|
2009-01-26 11:34:28 +00:00
|
|
|
};
|
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2009-02-18 21:44:34 +00:00
|
|
|
_cleanup: function() {
|
|
|
|
// restore all former loading tabs labels
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.filter( ".ui-state-processing" )
|
|
|
|
.removeClass( "ui-state-processing" )
|
|
|
|
.find( "span:data(label.tabs)" )
|
2009-02-18 21:44:34 +00:00
|
|
|
.each(function() {
|
2010-07-28 15:28:14 +00:00
|
|
|
var el = $( this );
|
|
|
|
el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
|
2009-02-18 21:44:34 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_tabify: function( init ) {
|
|
|
|
var self = this,
|
|
|
|
o = this.options,
|
|
|
|
fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
|
2009-01-22 13:10:18 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.list = this.element.find( "ol,ul" ).eq( 0 );
|
2010-08-12 03:06:41 +00:00
|
|
|
this.lis = $( " > li:has(a[href])", this.list );
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors = this.lis.map(function() {
|
|
|
|
return $( "a", this )[ 0 ];
|
|
|
|
});
|
|
|
|
this.panels = $( [] );
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.each(function( i, a ) {
|
|
|
|
var href = $( a ).attr( "href" );
|
2009-02-19 20:19:13 +00:00
|
|
|
// For dynamically created HTML that contains a hash as href IE < 8 expands
|
|
|
|
// such href to the full page url with hash and then misinterprets tab as ajax.
|
|
|
|
// Same consideration applies for an added tab with a fragment identifier
|
|
|
|
// since a[href=#fragment-identifier] does unexpectedly not match.
|
|
|
|
// Thus normalize href attribute...
|
2010-07-28 15:28:14 +00:00
|
|
|
var hrefBase = href.split( "#" )[ 0 ],
|
|
|
|
baseEl;
|
|
|
|
if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
|
|
|
|
( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
|
2009-02-19 20:19:13 +00:00
|
|
|
href = a.hash;
|
|
|
|
a.href = href;
|
|
|
|
}
|
2009-02-22 17:40:16 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// inline tab
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( fragmentId.test( href ) ) {
|
2010-12-07 21:27:56 +00:00
|
|
|
self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
|
2008-06-04 02:34:33 +00:00
|
|
|
// remote tab
|
2010-07-28 15:28:14 +00:00
|
|
|
// prevent loading the page itself if href is just "#"
|
2010-09-03 17:35:05 +00:00
|
|
|
} else if ( href && href !== "#" ) {
|
2010-07-28 15:28:14 +00:00
|
|
|
// required for restore on destroy
|
|
|
|
$.data( a, "href.tabs", href );
|
2009-01-22 13:10:18 +00:00
|
|
|
|
2009-01-20 12:57:32 +00:00
|
|
|
// TODO until #3808 is fixed strip fragment identifier from url
|
|
|
|
// (IE fails to load from such url)
|
2010-07-28 15:28:14 +00:00
|
|
|
$.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
|
|
|
|
|
|
|
|
var id = self._tabId( a );
|
|
|
|
a.href = "#" + id;
|
2010-12-07 21:27:56 +00:00
|
|
|
var $panel = self.element.find( "#" + id );
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( !$panel.length ) {
|
|
|
|
$panel = $( o.panelTemplate )
|
|
|
|
.attr( "id", id )
|
|
|
|
.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
|
|
|
|
.insertAfter( self.panels[ i - 1 ] || self.list );
|
|
|
|
$panel.data( "destroy.tabs", true );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
self.panels = self.panels.add( $panel );
|
2008-06-04 02:34:33 +00:00
|
|
|
// invalid tab href
|
2010-07-28 15:28:14 +00:00
|
|
|
} else {
|
|
|
|
o.disabled.push( i );
|
2009-02-19 20:19:13 +00:00
|
|
|
}
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-08-15 14:43:44 +00:00
|
|
|
// initialization from scratch
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( init ) {
|
2008-12-22 11:44:30 +00:00
|
|
|
// attach necessary classes for styling
|
2010-07-28 15:28:14 +00:00
|
|
|
this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
|
|
|
|
this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
|
|
|
|
this.lis.addClass( "ui-state-default ui-corner-top" );
|
|
|
|
this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// Selected tab
|
|
|
|
// use "selected" option or try to retrieve:
|
|
|
|
// 1. from fragment identifier in url
|
|
|
|
// 2. from cookie
|
|
|
|
// 3. from selected class attribute on <li>
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.selected === undefined ) {
|
|
|
|
if ( location.hash ) {
|
|
|
|
this.anchors.each(function( i, a ) {
|
|
|
|
if ( a.hash == location.hash ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
o.selected = i;
|
2010-07-28 15:28:14 +00:00
|
|
|
return false;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( typeof o.selected !== "number" && o.cookie ) {
|
|
|
|
o.selected = parseInt( self._cookie(), 10 );
|
2009-02-22 11:54:00 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
|
|
|
|
o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
|
2009-02-22 11:54:00 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
o.selected = o.selected || ( this.lis.length ? 0 : -1 );
|
|
|
|
} else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
|
2009-01-25 23:42:56 +00:00
|
|
|
o.selected = -1;
|
2009-02-22 11:54:00 +00:00
|
|
|
}
|
2009-01-25 23:42:56 +00:00
|
|
|
|
2009-02-22 11:54:00 +00:00
|
|
|
// sanity check - default to first tab...
|
2010-07-28 15:28:14 +00:00
|
|
|
o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
|
|
|
|
? o.selected
|
|
|
|
: 0;
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// Take disabling tabs via class attribute from HTML
|
|
|
|
// into account and update option properly.
|
|
|
|
// A selected tab cannot become disabled.
|
2010-07-28 15:28:14 +00:00
|
|
|
o.disabled = $.unique( o.disabled.concat(
|
|
|
|
$.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
|
|
|
|
return self.lis.index( n );
|
|
|
|
})
|
|
|
|
) ).sort();
|
|
|
|
|
|
|
|
if ( $.inArray( o.selected, o.disabled ) != -1 ) {
|
|
|
|
o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// highlight selected tab
|
2010-07-28 15:28:14 +00:00
|
|
|
this.panels.addClass( "ui-tabs-hide" );
|
|
|
|
this.lis.removeClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
// check for length avoids error when initializing empty list
|
|
|
|
if ( o.selected >= 0 && this.anchors.length ) {
|
2010-12-07 21:27:56 +00:00
|
|
|
self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// seems to be expected behavior that the show callback is fired
|
2010-07-28 15:28:14 +00:00
|
|
|
self.element.queue( "tabs", function() {
|
|
|
|
self._trigger( "show", null,
|
2011-01-16 21:19:58 +00:00
|
|
|
self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
|
2009-02-25 22:09:45 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
|
|
|
|
this.load( o.selected );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2009-01-19 20:40:51 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// clean up to avoid memory leaks in certain versions of IE 6
|
2010-07-28 15:28:14 +00:00
|
|
|
// TODO: namespace this event
|
|
|
|
$( window ).bind( "unload", function() {
|
|
|
|
self.lis.add( self.anchors ).unbind( ".tabs" );
|
2009-02-25 22:15:49 +00:00
|
|
|
self.lis = self.anchors = self.panels = null;
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
2008-08-15 14:43:44 +00:00
|
|
|
// update selected after add/remove
|
2010-07-28 15:28:14 +00:00
|
|
|
} else {
|
|
|
|
o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
|
2009-02-13 23:05:16 +00:00
|
|
|
}
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2009-02-02 20:15:06 +00:00
|
|
|
// update collapsible
|
2010-07-28 15:28:14 +00:00
|
|
|
// TODO: use .toggleClass()
|
|
|
|
this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2008-09-09 09:28:03 +00:00
|
|
|
// set or update cookie after init and add/remove respectively
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cookie ) {
|
|
|
|
this._cookie( o.selected, o.cookie );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// disable tabs
|
2010-07-28 15:28:14 +00:00
|
|
|
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
|
|
|
|
$( li )[ $.inArray( i, o.disabled ) != -1 &&
|
|
|
|
// TODO: use .toggleClass()
|
|
|
|
!$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// reset cache if switching from cached to not cached
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cache === false ) {
|
|
|
|
this.anchors.removeData( "cache.tabs" );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-13 23:05:16 +00:00
|
|
|
// remove all handlers before, tabify may run on existing tabs after add or option change
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.add( this.anchors ).unbind( ".tabs" );
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.event !== "mouseover" ) {
|
|
|
|
var addState = function( state, el ) {
|
|
|
|
if ( el.is( ":not(.ui-state-disabled)" ) ) {
|
|
|
|
el.addClass( "ui-state-" + state );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2009-02-13 23:05:16 +00:00
|
|
|
};
|
2010-07-28 15:28:14 +00:00
|
|
|
var removeState = function( state, el ) {
|
|
|
|
el.removeClass( "ui-state-" + state );
|
2009-02-22 18:54:29 +00:00
|
|
|
};
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.bind( "mouseover.tabs" , function() {
|
|
|
|
addState( "hover", $( this ) );
|
2009-02-22 18:54:29 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.bind( "mouseout.tabs", function() {
|
|
|
|
removeState( "hover", $( this ) );
|
2009-02-22 18:54:29 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.bind( "focus.tabs", function() {
|
|
|
|
addState( "focus", $( this ).closest( "li" ) );
|
2009-02-13 23:05:16 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.bind( "blur.tabs", function() {
|
|
|
|
removeState( "focus", $( this ).closest( "li" ) );
|
2009-02-13 23:05:16 +00:00
|
|
|
});
|
|
|
|
}
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// set up animations
|
2008-11-05 10:59:55 +00:00
|
|
|
var hideFx, showFx;
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.fx ) {
|
|
|
|
if ( $.isArray( o.fx ) ) {
|
|
|
|
hideFx = o.fx[ 0 ];
|
|
|
|
showFx = o.fx[ 1 ];
|
|
|
|
} else {
|
2009-02-22 14:00:11 +00:00
|
|
|
hideFx = showFx = o.fx;
|
|
|
|
}
|
2008-11-05 10:59:55 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-05 10:59:55 +00:00
|
|
|
// Reset certain styles left over from animation
|
|
|
|
// and prevent IE's ClearType bug...
|
2010-07-28 15:28:14 +00:00
|
|
|
function resetStyle( $el, fx ) {
|
|
|
|
$el.css( "display", "" );
|
|
|
|
if ( !$.support.opacity && fx.opacity ) {
|
|
|
|
$el[ 0 ].style.removeAttribute( "filter" );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2008-11-05 10:59:55 +00:00
|
|
|
|
|
|
|
// Show a tab...
|
2010-07-28 15:28:14 +00:00
|
|
|
var showTab = showFx
|
|
|
|
? function( clicked, $show ) {
|
|
|
|
$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
$show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
|
|
|
|
.animate( showFx, showFx.duration || "normal", function() {
|
|
|
|
resetStyle( $show, showFx );
|
|
|
|
self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
|
2009-01-21 21:05:07 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
}
|
|
|
|
: function( clicked, $show ) {
|
|
|
|
$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
$show.removeClass( "ui-tabs-hide" );
|
|
|
|
self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
|
2008-11-05 10:59:55 +00:00
|
|
|
};
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-05 10:59:55 +00:00
|
|
|
// Hide a tab, $show is optional...
|
2010-07-28 15:28:14 +00:00
|
|
|
var hideTab = hideFx
|
|
|
|
? function( clicked, $hide ) {
|
|
|
|
$hide.animate( hideFx, hideFx.duration || "normal", function() {
|
|
|
|
self.lis.removeClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
$hide.addClass( "ui-tabs-hide" );
|
|
|
|
resetStyle( $hide, hideFx );
|
|
|
|
self.element.dequeue( "tabs" );
|
2008-11-05 10:59:55 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
}
|
|
|
|
: function( clicked, $hide, $show ) {
|
|
|
|
self.lis.removeClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
$hide.addClass( "ui-tabs-hide" );
|
|
|
|
self.element.dequeue( "tabs" );
|
2008-11-05 10:59:55 +00:00
|
|
|
};
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// attach tab event handler, unbind to avoid duplicates from former tabifying...
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.bind( o.event + ".tabs", function() {
|
|
|
|
var el = this,
|
|
|
|
$li = $(el).closest( "li" ),
|
|
|
|
$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
|
2010-12-07 21:27:56 +00:00
|
|
|
$show = self.element.find( self._sanitizeSelector( el.hash ) );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-02 20:15:06 +00:00
|
|
|
// If tab is already selected and not collapsible or tab disabled or
|
2008-06-04 02:34:33 +00:00
|
|
|
// or is already loading or click callback returns false stop here.
|
|
|
|
// Check if click handler returns false last so that it is not executed
|
|
|
|
// for a disabled or loading tab!
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
|
|
|
|
$li.hasClass( "ui-state-disabled" ) ||
|
|
|
|
$li.hasClass( "ui-state-processing" ) ||
|
2010-09-07 17:20:41 +00:00
|
|
|
self.panels.filter( ":animated" ).length ||
|
2010-07-28 15:28:14 +00:00
|
|
|
self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
this.blur();
|
|
|
|
return false;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
o.selected = self.anchors.index( this );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-18 21:44:34 +00:00
|
|
|
self.abort();
|
|
|
|
|
2009-02-22 11:54:00 +00:00
|
|
|
// if tab may be closed
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.collapsible ) {
|
|
|
|
if ( $li.hasClass( "ui-tabs-selected" ) ) {
|
2009-01-25 23:42:56 +00:00
|
|
|
o.selected = -1;
|
2009-02-22 17:40:16 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cookie ) {
|
|
|
|
self._cookie( o.selected, o.cookie );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2009-02-22 17:40:16 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
self.element.queue( "tabs", function() {
|
|
|
|
hideTab( el, $hide );
|
|
|
|
}).dequeue( "tabs" );
|
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
this.blur();
|
|
|
|
return false;
|
2010-07-28 15:28:14 +00:00
|
|
|
} else if ( !$hide.length ) {
|
|
|
|
if ( o.cookie ) {
|
|
|
|
self._cookie( o.selected, o.cookie );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
|
|
|
|
self.element.queue( "tabs", function() {
|
|
|
|
showTab( el, $show );
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
2009-02-25 22:09:45 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
|
|
|
|
self.load( self.anchors.index( this ) );
|
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
this.blur();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cookie ) {
|
|
|
|
self._cookie( o.selected, o.cookie );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// show new tab
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( $show.length ) {
|
|
|
|
if ( $hide.length ) {
|
|
|
|
self.element.queue( "tabs", function() {
|
|
|
|
hideTab( el, $hide );
|
2009-02-25 22:09:45 +00:00
|
|
|
});
|
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
self.element.queue( "tabs", function() {
|
|
|
|
showTab( el, $show );
|
2009-02-25 22:09:45 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
|
|
|
|
self.load( self.anchors.index( this ) );
|
|
|
|
} else {
|
|
|
|
throw "jQuery UI Tabs: Mismatching fragment identifier.";
|
2009-02-18 21:44:34 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// Prevent IE from keeping other link focussed when using the back button
|
2008-11-05 10:59:55 +00:00
|
|
|
// and remove dotted border from clicked link. This is controlled via CSS
|
|
|
|
// in modern browsers; blur() removes focus from address bar in Firefox
|
|
|
|
// which can become a usability and annoying problem with tabs('rotate').
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( $.browser.msie ) {
|
2009-02-22 14:00:11 +00:00
|
|
|
this.blur();
|
|
|
|
}
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
2009-01-19 20:40:51 +00:00
|
|
|
|
2009-01-31 01:16:59 +00:00
|
|
|
// disable click in any case
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.bind( "click.tabs", function(){
|
|
|
|
return false;
|
|
|
|
});
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2009-01-31 00:45:14 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
_getIndex: function( index ) {
|
2010-07-16 16:37:54 +00:00
|
|
|
// meta-function to give users option to provide a href string instead of a numerical index.
|
|
|
|
// also sanitizes numerical indexes to valid values.
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( typeof index == "string" ) {
|
2012-03-22 17:17:17 +00:00
|
|
|
index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
|
2010-07-16 16:37:54 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
|
2010-07-16 16:37:54 +00:00
|
|
|
return index;
|
|
|
|
},
|
|
|
|
|
2009-01-26 11:34:28 +00:00
|
|
|
destroy: function() {
|
|
|
|
var o = this.options;
|
|
|
|
|
2009-03-01 14:32:29 +00:00
|
|
|
this.abort();
|
2009-01-26 11:34:28 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.element
|
|
|
|
.unbind( ".tabs" )
|
|
|
|
.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
|
|
|
|
.removeData( "tabs" );
|
|
|
|
|
|
|
|
this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
|
2009-01-26 11:34:28 +00:00
|
|
|
|
2009-02-25 22:15:49 +00:00
|
|
|
this.anchors.each(function() {
|
2010-07-28 15:28:14 +00:00
|
|
|
var href = $.data( this, "href.tabs" );
|
|
|
|
if ( href ) {
|
2009-01-26 11:34:28 +00:00
|
|
|
this.href = href;
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
var $this = $( this ).unbind( ".tabs" );
|
|
|
|
$.each( [ "href", "load", "cache" ], function( i, prefix ) {
|
|
|
|
$this.removeData( prefix + ".tabs" );
|
2009-01-26 11:34:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
|
|
|
|
if ( $.data( this, "destroy.tabs" ) ) {
|
|
|
|
$( this ).remove();
|
|
|
|
} else {
|
|
|
|
$( this ).removeClass([
|
|
|
|
"ui-state-default",
|
|
|
|
"ui-corner-top",
|
|
|
|
"ui-tabs-selected",
|
|
|
|
"ui-state-active",
|
|
|
|
"ui-state-hover",
|
|
|
|
"ui-state-focus",
|
|
|
|
"ui-state-disabled",
|
|
|
|
"ui-tabs-panel",
|
|
|
|
"ui-widget-content",
|
|
|
|
"ui-corner-bottom",
|
|
|
|
"ui-tabs-hide"
|
|
|
|
].join( " " ) );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2009-01-26 11:34:28 +00:00
|
|
|
});
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cookie ) {
|
|
|
|
this._cookie( null, o.cookie );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2009-04-15 02:33:28 +00:00
|
|
|
|
|
|
|
return this;
|
2009-01-26 11:34:28 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
add: function( url, label, index ) {
|
|
|
|
if ( index === undefined ) {
|
|
|
|
index = this.anchors.length;
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
var self = this,
|
|
|
|
o = this.options,
|
|
|
|
$li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
|
|
|
|
id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
|
2009-02-22 17:40:16 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
$li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// try to find an existing element before creating a new one
|
2010-12-07 21:27:56 +00:00
|
|
|
var $panel = self.element.find( "#" + id );
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( !$panel.length ) {
|
|
|
|
$panel = $( o.panelTemplate )
|
|
|
|
.attr( "id", id )
|
|
|
|
.data( "destroy.tabs", true );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
$panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
|
|
|
|
|
|
|
|
if ( index >= this.lis.length ) {
|
|
|
|
$li.appendTo( this.list );
|
|
|
|
$panel.appendTo( this.list[ 0 ].parentNode );
|
|
|
|
} else {
|
|
|
|
$li.insertBefore( this.lis[ index ] );
|
|
|
|
$panel.insertBefore( this.panels[ index ] );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
o.disabled = $.map( o.disabled, function( n, i ) {
|
|
|
|
return n >= index ? ++n : n;
|
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-08-16 07:34:55 +00:00
|
|
|
this._tabify();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( this.anchors.length == 1 ) {
|
2009-12-31 13:43:54 +00:00
|
|
|
o.selected = 0;
|
2010-07-28 15:28:14 +00:00
|
|
|
$li.addClass( "ui-tabs-selected ui-state-active" );
|
|
|
|
$panel.removeClass( "ui-tabs-hide" );
|
|
|
|
this.element.queue( "tabs", function() {
|
|
|
|
self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
|
2009-02-25 22:09:45 +00:00
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
|
|
|
|
this.load( 0 );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
remove: function( index ) {
|
|
|
|
index = this._getIndex( index );
|
|
|
|
var o = this.options,
|
|
|
|
$li = this.lis.eq( index ).remove(),
|
|
|
|
$panel = this.panels.eq( index ).remove();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// If selected tab was removed focus tab to the right or
|
|
|
|
// in case the last tab was removed the tab to the left.
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
|
|
|
|
this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
o.disabled = $.map(
|
|
|
|
$.grep( o.disabled, function(n, i) {
|
|
|
|
return n != index;
|
|
|
|
}),
|
|
|
|
function( n, i ) {
|
|
|
|
return n >= index ? --n : n;
|
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-08-16 07:34:55 +00:00
|
|
|
this._tabify();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
enable: function( index ) {
|
|
|
|
index = this._getIndex( index );
|
2008-06-04 02:34:33 +00:00
|
|
|
var o = this.options;
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( $.inArray( index, o.disabled ) == -1 ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
return;
|
2009-02-22 14:00:11 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.eq( index ).removeClass( "ui-state-disabled" );
|
|
|
|
o.disabled = $.grep( o.disabled, function( n, i ) {
|
|
|
|
return n != index;
|
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
disable: function( index ) {
|
|
|
|
index = this._getIndex( index );
|
2008-06-04 02:34:33 +00:00
|
|
|
var self = this, o = this.options;
|
2010-07-28 15:28:14 +00:00
|
|
|
// cannot disable already selected tab
|
|
|
|
if ( index != o.selected ) {
|
|
|
|
this.lis.eq( index ).addClass( "ui-state-disabled" );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
o.disabled.push( index );
|
2008-06-04 02:34:33 +00:00
|
|
|
o.disabled.sort();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2009-04-15 02:33:28 +00:00
|
|
|
|
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
select: function( index ) {
|
|
|
|
index = this._getIndex( index );
|
|
|
|
if ( index == -1 ) {
|
|
|
|
if ( this.options.collapsible && this.options.selected != -1 ) {
|
2010-07-17 22:50:47 +00:00
|
|
|
index = this.options.selected;
|
|
|
|
} else {
|
|
|
|
return this;
|
|
|
|
}
|
2009-02-22 11:54:00 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-08-10 22:16:44 +00:00
|
|
|
load: function( index ) {
|
2010-07-28 15:28:14 +00:00
|
|
|
index = this._getIndex( index );
|
|
|
|
var self = this,
|
|
|
|
o = this.options,
|
|
|
|
a = this.anchors.eq( index )[ 0 ],
|
|
|
|
url = $.data( a, "load.tabs" );
|
2009-02-18 21:44:34 +00:00
|
|
|
|
|
|
|
this.abort();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-25 22:09:45 +00:00
|
|
|
// not remote or from cache
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
|
|
|
|
this.element.dequeue( "tabs" );
|
2008-06-04 02:34:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
// load remote from here on
|
2010-07-28 15:28:14 +00:00
|
|
|
this.lis.eq( index ).addClass( "ui-state-processing" );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.spinner ) {
|
|
|
|
var span = $( "span", a );
|
|
|
|
span.data( "label.tabs", span.html() ).html( o.spinner );
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
|
2008-06-04 02:34:33 +00:00
|
|
|
url: url,
|
2010-07-28 15:28:14 +00:00
|
|
|
success: function( r, s ) {
|
2010-12-07 21:27:56 +00:00
|
|
|
self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-18 21:44:34 +00:00
|
|
|
// take care of tab labels
|
|
|
|
self._cleanup();
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( o.cache ) {
|
|
|
|
$.data( a, "cache.tabs", true );
|
2009-02-18 21:44:34 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
|
2008-10-02 14:20:35 +00:00
|
|
|
try {
|
2010-07-28 15:28:14 +00:00
|
|
|
o.ajaxOptions.success( r, s );
|
2008-10-02 14:20:35 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
catch ( e ) {}
|
2010-02-24 18:43:33 +00:00
|
|
|
},
|
2010-07-28 15:28:14 +00:00
|
|
|
error: function( xhr, s, e ) {
|
2010-02-24 18:43:33 +00:00
|
|
|
// take care of tab labels
|
|
|
|
self._cleanup();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
|
2010-02-24 18:43:33 +00:00
|
|
|
try {
|
|
|
|
// Passing index avoid a race condition when this method is
|
|
|
|
// called after the user has selected another tab.
|
|
|
|
// Pass the anchor that initiated this request allows
|
|
|
|
// loadError to manipulate the tab content panel via $(a.hash)
|
2010-07-28 15:28:14 +00:00
|
|
|
o.ajaxOptions.error( xhr, s, index, a );
|
2010-02-24 18:43:33 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
catch ( e ) {}
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
} ) );
|
2009-04-15 02:33:28 +00:00
|
|
|
|
2010-02-24 18:43:33 +00:00
|
|
|
// last, so that load event is fired before show...
|
2010-07-28 15:28:14 +00:00
|
|
|
self.element.dequeue( "tabs" );
|
2010-02-24 18:43:33 +00:00
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2009-02-18 21:44:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
abort: function() {
|
|
|
|
// stop possibly running animations
|
2010-07-28 15:28:14 +00:00
|
|
|
this.element.queue( [] );
|
|
|
|
this.panels.stop( false, true );
|
2009-02-18 21:44:34 +00:00
|
|
|
|
2009-06-12 08:36:03 +00:00
|
|
|
// "tabs" queue must not contain more than two elements,
|
|
|
|
// which are the callbacks for the latest clicked tab...
|
2010-07-28 15:28:14 +00:00
|
|
|
this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
|
2009-06-12 08:36:03 +00:00
|
|
|
|
2009-02-18 21:44:34 +00:00
|
|
|
// terminate pending requests from other tabs
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( this.xhr ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
this.xhr.abort();
|
2009-02-18 21:44:34 +00:00
|
|
|
delete this.xhr;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2009-02-18 21:44:34 +00:00
|
|
|
|
|
|
|
// take care of tab labels
|
|
|
|
this._cleanup();
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-21 04:48:06 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
url: function( index, url ) {
|
|
|
|
this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2009-01-31 00:45:14 +00:00
|
|
|
|
2009-01-26 11:34:28 +00:00
|
|
|
length: function() {
|
2009-02-25 22:15:49 +00:00
|
|
|
return this.anchors.length;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
$.extend( $.ui.tabs, {
|
|
|
|
version: "@VERSION"
|
2008-10-08 10:09:55 +00:00
|
|
|
});
|
2008-06-04 02:34:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Tabs Extensions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rotate
|
|
|
|
*/
|
2010-07-28 15:28:14 +00:00
|
|
|
$.extend( $.ui.tabs.prototype, {
|
2008-06-04 02:34:33 +00:00
|
|
|
rotation: null,
|
2010-07-28 15:28:14 +00:00
|
|
|
rotate: function( ms, continuing ) {
|
|
|
|
var self = this,
|
|
|
|
o = this.options;
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
var rotate = self._rotate || ( self._rotate = function( e ) {
|
|
|
|
clearTimeout( self.rotation );
|
2009-01-24 17:20:46 +00:00
|
|
|
self.rotation = setTimeout(function() {
|
2009-03-01 15:27:40 +00:00
|
|
|
var t = o.selected;
|
|
|
|
self.select( ++t < self.anchors.length ? t : 0 );
|
2010-07-28 15:28:14 +00:00
|
|
|
}, ms );
|
2009-03-01 15:27:40 +00:00
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( e ) {
|
2009-03-01 15:27:40 +00:00
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
});
|
2010-07-28 15:28:14 +00:00
|
|
|
|
|
|
|
var stop = self._unrotate || ( self._unrotate = !continuing
|
|
|
|
? function(e) {
|
2009-02-28 22:10:30 +00:00
|
|
|
if (e.clientX) { // in case of a true click
|
2009-03-01 15:27:40 +00:00
|
|
|
self.rotate(null);
|
2009-02-28 22:10:30 +00:00
|
|
|
}
|
2010-07-28 15:28:14 +00:00
|
|
|
}
|
|
|
|
: function( e ) {
|
2009-02-28 22:10:30 +00:00
|
|
|
rotate();
|
2009-03-01 15:27:40 +00:00
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-01-24 17:20:46 +00:00
|
|
|
// start rotation
|
2010-07-28 15:28:14 +00:00
|
|
|
if ( ms ) {
|
|
|
|
this.element.bind( "tabsshow", rotate );
|
|
|
|
this.anchors.bind( o.event + ".tabs", stop );
|
2009-01-24 17:20:46 +00:00
|
|
|
rotate();
|
|
|
|
// stop rotation
|
2010-07-28 15:28:14 +00:00
|
|
|
} else {
|
|
|
|
clearTimeout( self.rotation );
|
|
|
|
this.element.unbind( "tabsshow", rotate );
|
|
|
|
this.anchors.unbind( o.event + ".tabs", stop );
|
2009-03-01 15:27:40 +00:00
|
|
|
delete this._rotate;
|
|
|
|
delete this._unrotate;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
2009-04-15 02:33:28 +00:00
|
|
|
|
|
|
|
return this;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-07-28 15:28:14 +00:00
|
|
|
})( jQuery );
|