--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>jQuery UI Tabs Test Suite</title>
+
+ <link type="text/css" href="../../../themes/base/jquery.ui.tabs.css" rel="stylesheet" />
+
+ <script type="text/javascript" src="../../../jquery-1.5.1.js"></script>
+ <script type="text/javascript" src="../../../external/jquery.cookie.js"></script>
+ <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
+ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
+ <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
+
+ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
+ <script type="text/javascript" src="../../../external/qunit.js"></script>
+ <script type="text/javascript" src="../../jquery.simulate.js"></script>
+ <script type="text/javascript" src="../testsuite.js"></script>
+
+ <script type="text/javascript" src="tabs_core.js"></script>
+ <script type="text/javascript" src="tabs_defaults_deprecated.js"></script>
+ <script type="text/javascript" src="tabs_events.js"></script>
+ <script type="text/javascript" src="tabs_methods.js"></script>
+ <script type="text/javascript" src="tabs_options.js"></script>
+ <script type="text/javascript" src="tabs_tickets.js"></script>
+ <script type="text/javascript" src="tabs_deprecated.js"></script>
+
+ <script type="text/javascript">
+ // disable this stale testsuite for testswarm only
+ var url = window.location.search;
+ url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
+ if ( url && url.indexOf("http") == 0 ) {
+ // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
+ QUnit.init();
+ test("tabs", function() { ok(true, "disabled tabs testsuite"); });
+ }
+ </script>
+ <script type="text/javascript" src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Tabs Test Suite (deprecated)</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests">
+</ol>
+
+<div id="qunit-fixture">
+
+ <div id="tabs1">
+ <ul>
+ <li><a href="#fragment-1"><span>1</span></a></li>
+ <li><a href="#fragment-2"><span>2</span></a></li>
+ <li><a href="#fragment-3"><span>3</span></a></li>
+ </ul>
+ <div id="fragment-1"></div>
+ <div id="fragment-2"></div>
+ <div id="fragment-3"></div>
+ </div>
+ <div id="tabs2">
+ <ul>
+ <li><a href="#colon:test"><span>1</span></a></li>
+ <li><a href="#inline-style"><span>2</span></a></li>
+ <li><a href="data/test.html#test"><span>3</span></a></li>
+ <li><a href="data/test.html" title="∫ßáö Սե"><span>4</span></a></li>
+ </ul>
+ <div id="colon:test"></div>
+ <div style="height: 300px;" id="inline-style"></div>
+ </div>
+ <div id="tabs3">
+ <div>
+ <ul id="tabs3-list">
+ <li><a href="#tabs3-1">1</a></li>
+ </ul>
+ </div>
+ </div>
+ <div id="tabs4">
+ <ul id="tabs4-list">
+ <li><a href="#tabs4-1">1</a></li>
+ </ul>
+ <ol>
+ <li><a href="#tabs4-1">1</a></li>
+ </ol>
+ </div>
+ <div id="tabs4a">
+ <ol id="tabs4a-list">
+ <li><a href="#tabs4a-1">1</a></li>
+ </ol>
+ <ul>
+ <li><a href="#tabs4a-1">1</a></li>
+ </ul>
+ </div>
+ <div id="tabs5">
+ <div>
+ <ul id="tabs5-list"></ul>
+ </div>
+ </div>
+ <div id="tabs6">
+ <ul id="tabs6-list">
+ <li><a href="#tabs6-1">1</a>
+ <ul>
+ <li><a href="#item6-3">3</a></li>
+ <li><a href="#item6-4">4</a></li>
+ </ul>
+ </li>
+ <li><a href="#tabs6-2">2</a></li>
+ </ul>
+ <div id="tabs6-1"></div>
+ <div id="tabs6-2"></div>
+ </div>
+ <div id="tabs7">
+ <ul id="tabs7-list">
+ <li><a href="#tabs7-1">1</a></li>
+ <li><a href="#tabs7-2">2</a></li>
+ </ul>
+ <div id="tabs7-2"></div>
+ <div id="tabs7-1"></div>
+ </div>
+ </div>
+</body>
+</html>
$.widget( "ui.tabs", {
options: {
add: null,
- ajaxOptions: null,
- cache: false,
+ beforeload: null,
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
collapsible: false,
disable: null,
$( li ).toggleClass( "ui-state-disabled", $.inArray( i, o.disabled ) != -1 );
}
- // reset cache if switching from cached to not cached
- if ( o.cache === false ) {
- this.anchors.removeData( "cache.tabs" );
- }
-
// remove all handlers before, tabify may run on existing tabs after add or option change
this.lis.add( this.anchors ).unbind( ".tabs" );
this.href = href;
}
var $this = $( this ).unbind( ".tabs" );
- $.each( [ "href", "load", "cache" ], function( i, prefix ) {
+ $.each( [ "href", "load" ], function( i, prefix ) {
$this.removeData( prefix + ".tabs" );
});
});
var self = this,
o = this.options,
a = this.anchors.eq( index )[ 0 ],
- url = $.data( a, "load.tabs" );
+ url = $.data( a, "load.tabs" ),
+ eventData = self._ui( self.anchors[ index ], self.panels[ index ] );
this.abort();
- // not remote or from cache
- if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
+ // not remote
+ if ( !url ) {
this.element.dequeue( "tabs" );
return;
}
- // load remote from here on
- this.lis.eq( index ).addClass( "ui-state-processing" );
-
- if ( o.spinner ) {
- var span = $( "span", a );
- span.data( "label.tabs", span.html() ).html( o.spinner );
- }
-
- this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
+ this.xhr = $.ajax({
url: url,
- success: function( r, s ) {
- self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
-
- // take care of tab labels
- self._cleanup();
+ beforeSend: function( jqXHR, settings ) {
+ return self._trigger( "beforeload", null,
+ $.extend( { jqXHR: jqXHR, settings: settings }, eventData ) );
+ }
+ });
- if ( o.cache ) {
- $.data( a, "cache.tabs", true );
- }
+ if ( this.xhr ) {
+ // load remote from here on
+ this.lis.eq( index ).addClass( "ui-state-processing" );
- self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
- try {
- o.ajaxOptions.success( r, s );
- }
- catch ( e ) {}
- },
- error: function( xhr, s, e ) {
- // take care of tab labels
- self._cleanup();
-
- self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
- 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)
- o.ajaxOptions.error( xhr, s, index, a );
- }
- catch ( e ) {}
+ if ( o.spinner ) {
+ var span = $( "span", a );
+ span.data( "label.tabs", span.html() ).html( o.spinner );
}
- } ) );
+
+ this.xhr
+ .success( function( response ) {
+ self.element.find( self._sanitizeSelector( a.hash ) ).html( response );
+ })
+ .complete( function( jqXHR, status ) {
+ // take care of tab labels
+ self._cleanup();
+
+ self._trigger( "load", null, eventData );
+ });
+ }
// last, so that load event is fired before show...
self.element.dequeue( "tabs" );
},
url: function( index, url ) {
- this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
+ this.anchors.eq( index ).data( "load.tabs", url );
return this;
},
version: "@VERSION"
});
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+
+ // ajaxOptions and cache options
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ ajaxOptions: null,
+ cache: false
+ });
+
+ var _create = prototype._create,
+ _setOption = prototype._setOption,
+ _destroy = prototype._destroy,
+ oldurl = prototype._url;
+
+ $.extend( prototype, {
+ _create: function() {
+ _create.call( this );
+
+ var self = this;
+
+ this.element.bind( "tabsbeforeload", function( event, ui ) {
+ // tab is already cached
+ if ( $.data( ui.tab, "cache.tabs" ) ) {
+ event.preventDefault();
+ return;
+ }
+
+ $.extend( ui.settings, self.options.ajaxOptions, {
+ error: function( xhr, s, e ) {
+ 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)
+ self.options.ajaxOptions.error( xhr, s, ui.index, ui.tab );
+ }
+ catch ( e ) {}
+ }
+ });
+
+ ui.jqXHR.success( function() {
+ if ( self.options.cache ) {
+ $.data( ui.tab, "cache.tabs", true );
+ }
+ });
+ });
+ },
+
+ _setOption: function( key, value ) {
+ // reset cache if switching from cached to not cached
+ if ( key === "cache" && value === false ) {
+ this.anchors.removeData( "cache.tabs" );
+ }
+ _setOption.apply( this, arguments );
+ },
+
+ _destroy: function() {
+ this.anchors.removeData( "cache.tabs" );
+ _destroy.call( this );
+ },
+
+ url: function( index, url ){
+ this.anchors.eq( index ).removeData( "cache.tabs" );
+ oldurl.apply( this, arguments );
+ }
+ });
+ }( jQuery, jQuery.ui.tabs.prototype ) );
+}
+
})( jQuery );