aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md17
-rw-r--r--tests/unit/tabs/spinner.gifbin1387 -> 0 bytes
-rw-r--r--tests/unit/tabs/tabs.html1
-rw-r--r--tests/unit/tabs/tabs_core.js28
-rw-r--r--tests/unit/tabs/tabs_deprecated.html1
-rw-r--r--tests/unit/tabs/tabs_deprecated.js202
-rw-r--r--tests/unit/tabs/tabs_events.js92
-rw-r--r--tests/unit/tabs/tabs_methods.js17
-rw-r--r--tests/unit/tabs/tabs_options.js83
-rw-r--r--tests/unit/tabs/tabs_tickets.js37
-rw-r--r--ui/jquery.ui.mouse.js12
-rw-r--r--ui/jquery.ui.tabs.js120
12 files changed, 399 insertions, 211 deletions
diff --git a/README.md b/README.md
index 5c7d79a13..9a0d7c5c5 100644
--- a/README.md
+++ b/README.md
@@ -7,3 +7,20 @@ If you want to use jQuery UI, go to [jqueryui.com](http://jqueryui.com) to get s
If you are interested in helping developing jQuery UI, you are in the right place.
To discuss development with team members and the community, visit the [Developing jQuery UI Forum](http://forum.jquery.com/developing-jquery-ui).
+
+For commiters
+---
+When looking at pull requests, first check for [proper commit messages](http://wiki.jqueryui.com/w/page/12137724/Bug-Fixing-Guide).
+
+Unless everything is fine and you can merge directly via GitHub's interface, fetch the remote first:
+
+ git remote add [username] [his-fork.git] -f
+
+If you want just one commit and edit the commit message:
+
+ git cherry-pick -e [sha-of-commit]
+
+If it should go to the stable brach, cherry-pick it to stable:
+
+ git checkout 1-8-stable
+ git cherry-pick -x [sha-of-commit]
diff --git a/tests/unit/tabs/spinner.gif b/tests/unit/tabs/spinner.gif
deleted file mode 100644
index 822747576..000000000
--- a/tests/unit/tabs/spinner.gif
+++ /dev/null
Binary files differ
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html
index 565a0b427..34ec28bc4 100644
--- a/tests/unit/tabs/tabs.html
+++ b/tests/unit/tabs/tabs.html
@@ -24,7 +24,6 @@
<script src="tabs_events.js"></script>
<script src="tabs_methods.js"></script>
<script src="tabs_options.js"></script>
- <script src="tabs_tickets.js"></script>
<script>
function tabs_state( tabs ) {
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index c9b16e3a8..98cb617ec 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -63,4 +63,32 @@ test( "accessibility", function() {
// TODO: add tests
});
+test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() {
+ expect( 1 );
+
+ var element = $( "#tabs2" ).tabs({
+ active: 2,
+ beforeLoad: function( event, ui ) {
+ event.preventDefault();
+ ok( /test.html$/.test( ui.ajaxSettings.url ), "should ignore fragment identifier" );
+ }
+ });
+});
+
+test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function() {
+ expect( 2 );
+
+ var element = $( "<div><ul><li><a href='#tab'>Tab</a></li></ul><div id='tab'></div></div>" );
+ element.appendTo( "#main" );
+ element.tabs({
+ beforeLoad: function( event, ui ) {
+ event.preventDefault();
+ ok( false, 'should not be an ajax tab');
+ }
+ });
+
+ equals( element.find( ".ui-tabs-nav a" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
+ tabs_state( element, 1 );
+});
+
}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html
index e71fea3d4..89d08f4d0 100644
--- a/tests/unit/tabs/tabs_deprecated.html
+++ b/tests/unit/tabs/tabs_deprecated.html
@@ -22,7 +22,6 @@
<script src="tabs_events.js"></script>
<script src="tabs_methods.js"></script>
<script src="tabs_options.js"></script>
- <script src="tabs_tickets.js"></script>
<script src="tabs_deprecated.js"></script>
<script>
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 90c43037c..49999670f 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -1,6 +1,6 @@
(function( $ ) {
-module("tabs (deprecated): core");
+module( "tabs (deprecated): core" );
test( "panel ids", function() {
expect( 2 );
@@ -20,91 +20,149 @@ test( "panel ids", function() {
element.tabs( "option", "active", 2 );
});
-module("tabs (deprecated): options");
+module( "tabs (deprecated): options" );
-test('ajaxOptions', function() {
- ok(false, "missing test - untested code is broken code.");
-});
+asyncTest( "ajaxOptions", function() {
+ expect( 1 );
-test('cache', function() {
- ok(false, "missing test - untested code is broken code.");
+ var element = $( "#tabs2" ).tabs({
+ ajaxOptions: {
+ converters: {
+ "text html": function() {
+ return "test";
+ }
+ }
+ }
+ });
+ element.one( "tabsload", function( event, ui ) {
+ equals( ui.panel.html(), "test" );
+ start();
+ });
+ element.tabs( "option", "active", 2 );
});
-test('idPrefix', function() {
- ok(false, "missing test - untested code is broken code.");
-});
+asyncTest( "cache", function() {
+ expect( 5 );
-test('tabTemplate', function() {
- ok(false, "missing test - untested code is broken code.");
+ var element = $( "#tabs2" ).tabs({
+ cache: true
+ });
+ element.one( "tabsshow", function( event, ui ) {
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ ok( true, "tabsload" );
+
+ setTimeout(function() {
+ element.tabs( "option", "active", 0 );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+
+ element.one( "tabsshow", function( event, ui ) {
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ ok( false, "should be cached" );
+ });
+ element.tabs( "option", "active", 2 );
+ start();
+ }, 1 );
+ });
+ element.tabs( "option", "active", 2 );
+ tabs_state( element, 0, 0, 1, 0, 0 );
});
-test('panelTemplate', function() {
- ok(false, "missing test - untested code is broken code.");
+test( "idPrefix", function() {
+ expect( 1 );
+
+ $( "#tabs2" )
+ .one( "tabsbeforeload", function( event, ui ) {
+ ok( /^testing-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" );
+ event.preventDefault();
+ })
+ .tabs({
+ idPrefix: "testing-",
+ active: 2
+ });
});
-test('cookie', function() {
- expect(6);
+test( "tabTemplate + panelTemplate", function() {
+ // defaults are tested in the add method test
+ expect( 11 );
+
+ var element = $( "#tabs2" ).tabs({
+ tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
+ panelTemplate: "<div class='customPanel'></div>"
+ });
+ element.one( "tabsadd", function( event, ui ) {
+ var anchor = $( ui.tab );
+ equal( ui.index, 5, "ui.index" );
+ equal( anchor.text(), "New", "ui.tab" );
+ equal( anchor.attr( "href" ), "http://example.com/#new", "tab href" );
+ ok( anchor.parent().hasClass( "customTab" ), "tab custom class" );
+ equal( ui.panel.id, "new", "ui.panel" );
+ ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
+ });
+ element.tabs( "add", "#new", "New" );
+ var tab = element.find( ".ui-tabs-nav li" ).last(),
+ anchor = tab.find( "a" );
+ equals( tab.text(), "New", "label" );
+ ok( tab.hasClass( "customTab" ), "tab custom class" );
+ equals( anchor.attr( "href" ), "http://example.com/#new", "href" );
+ equals( anchor.attr( "aria-controls" ), "new", "aria-controls" );
+ ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" );
+});
- el = $('#tabs1');
- var cookieName = 'tabs_test', cookieObj = { name: cookieName };
- $.cookie(cookieName, null); // blank state
- var cookie = function() {
- return parseInt($.cookie(cookieName), 10);
- };
+test( "cookie", function() {
+ expect( 6 );
- el.tabs({ cookie: cookieObj });
- equals(cookie(), 0, 'initial cookie value');
+ var element = $( "#tabs1" ),
+ cookieName = "tabs_test",
+ cookieObj = { name: cookieName };
+ $.cookie( cookieName, null );
+ function cookie() {
+ return parseInt( $.cookie( cookieName ), 10 );
+ }
- el.tabs('destroy');
- el.tabs({ active: 1, cookie: cookieObj });
- equals(cookie(), 1, 'initial cookie value, from active property');
+ element.tabs({ cookie: cookieObj });
+ equals( cookie(), 0, "initial cookie value" );
- el.tabs('option', 'active', 2);
- equals(cookie(), 2, 'cookie value updated after activating');
+ element.tabs( "destroy" );
+ element.tabs({ active: 1, cookie: cookieObj });
+ equals( cookie(), 1, "initial cookie value, from active property" );
- el.tabs('destroy');
- $.cookie(cookieName, 1);
- el.tabs({ cookie: cookieObj });
- equals(cookie(), 1, 'initial cookie value, from existing cookie');
+ element.tabs( "option", "active", 2 );
+ equals( cookie(), 2, "cookie value updated after activating" );
- el.tabs('destroy');
- el.tabs({ cookie: cookieObj, collapsible: true });
- el.tabs('option', 'active', false);
- equals(cookie(), -1, 'cookie value for all tabs unselected');
+ element.tabs( "destroy" );
+ $.cookie( cookieName, 1 );
+ element.tabs({ cookie: cookieObj });
+ equals( cookie(), 1, "initial cookie value, from existing cookie" );
- el.tabs('destroy');
- ok($.cookie(cookieName) === null, 'erase cookie after destroy');
+ element.tabs( "destroy" );
+ element.tabs({ cookie: cookieObj, collapsible: true });
+ element.tabs( "option", "active", false );
+ equals( cookie(), -1, "cookie value for all tabs unselected" );
+ element.tabs( "destroy" );
+ ok( $.cookie( cookieName ) === null, "erase cookie after destroy" );
});
+asyncTest( "spinner", function() {
+ expect( 2 );
-test('spinner', function() {
- expect(4);
- stop();
-
- el = $('#tabs2');
-
- el.tabs({
- selected: 2,
- load: function() {
- // spinner: default spinner
- setTimeout(function() {
- equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
- equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
- el.tabs('destroy');
- el.tabs({
- selected: 2,
- spinner: '<img src="spinner.gif" alt="">',
- load: function() {
- // spinner: image
- equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
- equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
- start();
- }
- });
- }, 1);
- }
+ var element = $( "#tabs2" ).tabs();
+
+ element.one( "tabsbeforeload", function( event, ui ) {
+ equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ // wait until after the load finishes before checking for the spinner to be removed
+ setTimeout(function() {
+ equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" );
+ start();
+ }, 1 );
});
+ element.tabs( "option", "active", 2 );
});
test( "selected", function() {
@@ -405,4 +463,18 @@ test( "url", function() {
element.tabs( "option", "active", 3 );
});
+asyncTest( "abort", function() {
+ expect( 1 );
+
+ var element = $( "#tabs2" ).tabs();
+ element.one( "tabsbeforeload", function( event, ui ) {
+ ui.jqXHR.error(function( jqXHR, status ) {
+ equals( status, "abort", "aborted" );
+ start();
+ });
+ });
+ element.tabs( "option", "active", 2 );
+ element.tabs( "abort" );
+});
+
}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js
index 28925a2b9..2fabaafca 100644
--- a/tests/unit/tabs/tabs_events.js
+++ b/tests/unit/tabs/tabs_events.js
@@ -138,15 +138,32 @@ test( "activate", function() {
});
test( "beforeLoad", function() {
- expect( 21 );
+ expect( 32 );
var tab, panelId, panel,
- element = $( "#tabs2" ).tabs();
+ element = $( "#tabs2" );
+
+ // init
+ element.one( "tabsbeforeload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
- // TODO: init
-// element.one( "tabsbeforeload", function( event, ui ) {
-// });
-// element.tabs({ active: 2 });
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ ok( "abort" in ui.jqXHR, "jqXHR" );
+ ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.html(), "", "panel html" );
+ event.preventDefault();
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ });
+ element.tabs({ active: 2 });
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ equals( panel.html(), "", "panel html after" );
+ element.tabs( "destroy" );
// .option()
element.one( "tabsbeforeload", function( event, ui ) {
@@ -165,6 +182,7 @@ test( "beforeLoad", function() {
event.preventDefault();
tabs_state( element, 1, 0, 0, 0, 0 );
});
+ element.tabs();
element.tabs( "option", "active", 2 );
tabs_state( element, 0, 0, 1, 0, 0 );
equals( panel.html(), "", "panel html after" );
@@ -191,8 +209,66 @@ test( "beforeLoad", function() {
equals( panel.html(), "<p>testing</p>", "panel html after" );
});
-test( "load", function() {
- ok( false, "missing test - untested code is broken code." );
+asyncTest( "load", function() {
+ expect( 21 );
+
+ var tab, panelId, panel,
+ element = $( "#tabs2" );
+
+ // init
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ tabsload1();
+ });
+ element.tabs({ active: 2 });
+
+ function tabsload1() {
+ // .option()
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ tabsload2();
+ });
+ element.tabs( "option", "active", 3 );
+ }
+
+ function tabsload2() {
+ // click, change panel content
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ equals( event.originalEvent.type, "click", "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 0, 1 );
+ start();
+ });
+ element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
+ }
});
}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index a6e60a4b3..221b0d39d 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -2,19 +2,10 @@
module( "tabs: methods" );
-test('destroy', function() {
- expect(6);
-
- el = $('#tabs1').tabs({ collapsible: true });
- $('li:eq(2)', el).simulate('mouseover').find('a').focus();
- el.tabs('destroy');
-
- ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)'), 'remove classes from container');
- ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' );
- ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom)'), 'remove classes to panel' );
- ok( $('li:eq(0)', el).is(':not(.ui-tabs-active, .ui-state-active, .ui-corner-top)'), 'remove classes from active li');
- ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li');
- ok( $('li:eq(2)', el).is(':not(.ui-state-hover, .ui-state-focus)'), 'remove classes from mouseovered or focused li');
+test( "destroy", function() {
+ domEqual( "#tabs1", function() {
+ $( "#tabs1" ).tabs().tabs( "destroy" );
+ });
});
test( "enable", function() {
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index 691186276..8d61c47ef 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -133,28 +133,81 @@ test( "{ collapsible: true }", function() {
tabs_state( element, 0, 0, 0 );
});
-test('disabled', function() {
- expect(4);
+test( "disabled", function() {
+ expect( 10 );
- el = $('#tabs1').tabs();
- same(el.tabs('option', 'disabled'), false, "should not disable any tab by default");
+ // fully enabled by default
+ var element = $( "#tabs1" ).tabs();
+ tabs_disabled( element, false );
+
+ // disable single tab
+ element.tabs( "option", "disabled", [ 1 ] );
+ tabs_disabled( element, [ 1 ] );
- el.tabs('option', 'disabled', [ 1 ]);
- same(el.tabs('option', 'disabled'), [ 1 ], "should set property"); // everything else is being tested in methods module...
+ // disabled active tab
+ element.tabs( "option", "disabled", [ 0, 1 ] );
+ tabs_disabled( element, [ 0, 1 ] );
- el.tabs('option', 'disabled', [ 0, 1 ]);
- same(el.tabs('option', 'disabled'), [ 0, 1 ], "should disable given tabs, even selected one"); // ...
+ // disable all tabs
+ element.tabs( "option", "disabled", [ 0, 1, 2 ] );
+ tabs_disabled( element, true );
- el.tabs('option', 'disabled', [ ]);
- same(el.tabs('option', 'disabled'), false, "should not disable any tab"); // ...
+ // enable all tabs
+ element.tabs( "option", "disabled", [] );
+ tabs_disabled( element, false );
});
-test('event', function() {
- ok(false, "missing test - untested code is broken code.");
+test( "{ event: null }", function() {
+ expect( 5 );
+
+ var element = $( "#tabs1" ).tabs({
+ event: null
+ });
+ tabs_state( element, 1, 0, 0 );
+
+ element.tabs( "option", "active", 1 );
+ equal( element.tabs( "option", "active" ), 1 );
+ tabs_state( element, 0, 1, 0 );
+
+ // ensure default click handler isn't bound
+ element.find( ".ui-tabs-nav a" ).eq( 2 ).click();
+ equal( element.tabs( "option", "active" ), 1 );
+ tabs_state( element, 0, 1, 0 );
});
-test('fx', function() {
- ok(false, "missing test - untested code is broken code.");
+test( "{ event: custom }", function() {
+ expect( 11 );
+
+ var element = $( "#tabs1" ).tabs({
+ event: "custom1 custom2"
+ });
+ tabs_state( element, 1, 0, 0 );
+
+ element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
+ equal( element.tabs( "option", "active" ), 1 );
+ tabs_state( element, 0, 1, 0 );
+
+ // ensure default click handler isn't bound
+ element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "click" );
+ equal( element.tabs( "option", "active" ), 1 );
+ tabs_state( element, 0, 1, 0 );
+
+ element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "custom2" );
+ equal( element.tabs( "option", "active" ), 2 );
+ tabs_state( element, 0, 0, 1 );
+
+ element.tabs( "option", "event", "custom3" );
+
+ // ensure old event handlers are unbound
+ element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
+ equal( element.tabs( "option", "active" ), 2 );
+ tabs_state( element, 0, 0, 1 );
+
+ element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom3" );
+ equal( element.tabs( "option", "active" ), 1 );
+ tabs_state( element, 0, 1, 0 );
});
-})(jQuery);
+// TODO: add animation tests
+
+}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_tickets.js b/tests/unit/tabs/tabs_tickets.js
deleted file mode 100644
index d7a59cb5b..000000000
--- a/tests/unit/tabs/tabs_tickets.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * tabs_tickets.js
- */
-(function($) {
-
-module("tabs: tickets");
-
-test('#3627 - Ajax tab with url containing a fragment identifier fails to load', function() {
- // http://dev.jqueryui.com/ticket/3627
- expect(1);
-
- el = $('#tabs2').tabs({
- active: 2,
- beforeLoad: function( event, ui ) {
- event.preventDefault();
- ok(/test.html$/.test( ui.ajaxSettings.url ), 'should ignore fragment identifier');
- }
- });
-});
-
-test('#4033 - IE expands hash to full url and misinterprets tab as ajax', function() {
- // http://dev.jqueryui.com/ticket/4033
- expect(1);
-
- el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>');
- el.appendTo('#main');
- el.tabs({
- beforeLoad: function( event, ui ) {
- event.preventDefault();
- ok( false, 'should not be an ajax tab');
- }
- });
-
- equals($('a', el).attr('aria-controls'), 'tab', 'aria-contorls attribute is correct');
-});
-
-})(jQuery);
diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js
index bfe4a7578..0bd38db85 100644
--- a/ui/jquery.ui.mouse.js
+++ b/ui/jquery.ui.mouse.js
@@ -12,6 +12,11 @@
*/
(function( $, undefined ) {
+var mouseHandled = false;
+$(document).mousedown(function(e) {
+ mouseHandled = false;
+});
+
$.widget("ui.mouse", {
options: {
cancel: ':input,option',
@@ -44,9 +49,7 @@ $.widget("ui.mouse", {
_mouseDown: function(event) {
// don't let more than one widget handle mouseStart
- // TODO: figure out why we have to use originalEvent
- event.originalEvent = event.originalEvent || {};
- if (event.originalEvent.mouseHandled) { return; }
+ if(mouseHandled) {return};
// we may have missed mouseup (out of window)
(this._mouseStarted && this._mouseUp(event));
@@ -92,7 +95,8 @@ $.widget("ui.mouse", {
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
event.preventDefault();
- event.originalEvent.mouseHandled = true;
+
+ mouseHandled = true;
return true;
},
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 58c181670..cd9b04f0d 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -621,6 +621,7 @@ $.widget( "ui.tabs", {
this.xhr
.success(function( response ) {
panel.html( response );
+ self._trigger( "load", event, eventData );
})
.complete(function( jqXHR, status ) {
if ( status === "abort" ) {
@@ -631,13 +632,11 @@ $.widget( "ui.tabs", {
// "tabs" queue must not contain more than two elements,
// which are the callbacks for the latest clicked tab...
self.element.queue( "tabs", self.element.queue( "tabs" ).splice( -2, 2 ) );
-
- delete this.xhr;
}
self.lis.eq( index ).removeClass( "ui-tabs-loading" );
- self._trigger( "load", event, eventData );
+ delete self.xhr;
});
}
@@ -705,7 +704,7 @@ if ( $.uiBackCompat !== false ) {
}
});
- ui.jqXHR.success( function() {
+ ui.jqXHR.success(function() {
if ( self.options.cache ) {
$.data( ui.tab[ 0 ], "cache.tabs", true );
}
@@ -743,34 +742,28 @@ if ( $.uiBackCompat !== false ) {
}( jQuery, jQuery.ui.tabs.prototype ) );
// spinner
- (function( $, prototype ) {
- $.extend( prototype.options, {
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
spinner: "<em>Loading&#8230;</em>"
- });
-
- var _create = prototype._create;
- prototype._create = function() {
- _create.call( this );
- var self = this;
-
- this.element.bind( "tabsbeforeload", function( event, ui ) {
- if ( self.options.spinner ) {
- var span = $( "span", ui.tab );
- if ( span.length ) {
- span.data( "label.tabs", span.html() ).html( self.options.spinner );
+ },
+ _create: function() {
+ this._super( "_create" );
+ this._bind({
+ tabsbeforeload: function( event, ui ) {
+ if ( !this.options.spinner ) {
+ return;
}
+
+ var span = ui.tab.find( "span" ),
+ html = span.html();
+ span.html( this.options.spinner );
+ ui.jqXHR.complete(function() {
+ span.html( html );
+ });
}
- ui.jqXHR.complete( function() {
- if ( self.options.spinner ) {
- var span = $( "span", ui.tab );
- if ( span.length ) {
- span.html( span.data( "label.tabs" ) ).removeData( "label.tabs" );
- }
- }
- });
});
- };
- }( jQuery, jQuery.ui.tabs.prototype ) );
+ }
+ });
// enable/disable events
(function( $, prototype ) {
@@ -1010,57 +1003,50 @@ if ( $.uiBackCompat !== false ) {
}( jQuery, jQuery.ui.tabs.prototype ) );
// cookie option
- (function( $, prototype ) {
- $.extend( prototype.options, {
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
- });
-
- var _create = prototype._create,
- _refresh = prototype._refresh,
- _eventHandler = prototype._eventHandler,
- _destroy = prototype._destroy;
-
- prototype._create = function() {
- var o = this.options;
- if ( o.active === undefined ) {
- if ( typeof o.active !== "number" && o.cookie ) {
- o.active = parseInt( this._cookie(), 10 );
+ },
+ _create: function() {
+ var options = this.options,
+ active;
+ if ( options.active == null && options.cookie ) {
+ active = parseInt( this._cookie(), 10 );
+ if ( active === -1 ) {
+ active = false;
}
+ options.active = active;
}
- _create.call( this );
- };
-
- prototype._cookie = function() {
- var cookie = this.cookie ||
- ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
- return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
- };
-
- prototype._refresh = function() {
- _refresh.call( this );
-
- // set or update cookie after init and add/remove respectively
+ this._super( "_create" );
+ },
+ _cookie: function( active ) {
+ var cookie = [ this.cookie ||
+ ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() ) ];
+ if ( arguments.length ) {
+ cookie.push( active === false ? -1 : active );
+ cookie.push( this.options.cookie );
+ }
+ return $.cookie.apply( null, cookie );
+ },
+ _refresh: function() {
+ this._super( "_refresh" );
if ( this.options.cookie ) {
this._cookie( this.options.active, this.options.cookie );
}
- };
-
- prototype._eventHandler = function( event ) {
- _eventHandler.apply( this, arguments );
-
+ },
+ _eventHandler: function( event ) {
+ this._superApply( "_eventHandler", arguments );
if ( this.options.cookie ) {
this._cookie( this.options.active, this.options.cookie );
}
- };
-
- prototype._destroy = function() {
- _destroy.call( this );
-
+ },
+ _destroy: function() {
+ this._super( "_destroy" );
if ( this.options.cookie ) {
this._cookie( null, this.options.cookie );
}
- };
- }( jQuery, jQuery.ui.tabs.prototype ) );
+ }
+ });
}
})( jQuery );