Large diffs are not rendered by default.

@@ -14,6 +14,7 @@
"unused": true,

"browser": true,
"es3": true,
"evil": true,
"jquery": true,

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>jQuery UI Tests</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.core.css">
<link rel="stylesheet" href="../../themes/base/jquery.ui.theme.css">
<link rel="stylesheet" href="../themes/base/jquery.ui.core.css">
<link rel="stylesheet" href="../themes/base/jquery.ui.theme.css">
<link rel="stylesheet" href="index.css">
<script src="jquery-1.10.2.js"></script>
<script src="index.js"></script>
@@ -18,7 +18,7 @@ <h2>Unit Tests</h2>
<p><a href="unit/index.html">Unit tests</a> exist for all functionality in jQuery UI.
The unit tests can be run locally (some tests require a web server with PHP)
to ensure proper functionality before committing changes.
The unit tests are also run on <a href="http://swarm.jquery.com/user/jqueryui">TestSwarm</a>
The unit tests are also run on <a href="http://swarm.jquery.org/project/jqueryui">TestSwarm</a>
for every commit.</p>

<h2>Visual Tests</h2>
@@ -4,6 +4,7 @@

(function($) {

// TODO add teardown callback to remove dialogs
module("dialog: core");

test("title id", function() {
@@ -180,4 +181,51 @@ asyncTest( "#9048: multiple modal dialogs opened and closed in different order",
start();
});
});

asyncTest( "interaction between overlay and other dialogs", function() {
$.widget( "ui.testWidget", $.ui.dialog, {
options: {
modal: true,
autoOpen: false
}
});
expect( 2 );
var first = $( "<div><input id='input-1'></div>" ).dialog({
modal: true
}),
firstInput = first.find( "input" ),
second = $( "<div><input id='input-2'></div>" ).testWidget(),
secondInput = second.find( "input" );

// Support: IE8
// For some reason the focus doesn't get set properly if we don't
// focus the body first.
$( "body" ).focus();

// Wait for the modal to init
setTimeout(function() {
second.testWidget( "open" );

// Simulate user tabbing from address bar to an element outside the dialog
$( "#favorite-animal" ).focus();
setTimeout(function() {
equal( document.activeElement, secondInput[ 0 ] );

// Last active dialog must receive focus
firstInput.focus();
$( "#favorite-animal" ).focus();
setTimeout(function() {
equal( document.activeElement, firstInput[ 0 ] );

// Cleanup
first.remove();
second.remove();
delete $.ui.testWidget;
delete $.fn.testWidget;
start();
});
});
});
});

})(jQuery);
@@ -31,6 +31,10 @@
<style>
.ui-menu {
font-size: 15px;
line-height: 15px;
}
.ui-menu .ui-menu-item {
padding: 0;
}
#menu3 {
height: 250px;
@@ -389,15 +389,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and without submenus"

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
equal( logOutput(), "keydown,17", "Keydown PAGE_DOWN" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
equal( logOutput(), "keydown,34", "Keydown PAGE_DOWN" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
equal( logOutput(), "keydown,17", "Keydown PAGE_UP" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
@@ -484,15 +484,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
function menukeyboard3() {
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
equal( logOutput(), "keydown,17", "Keydown PAGE_DOWN" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
equal( logOutput(), "keydown,27", "Keydown PAGE_DOWN" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );

log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
@@ -59,7 +59,9 @@ QUnit.config.urlConfig.push({

jshintLoaded = false;
TestHelpers.testJshint = function( module ) {
if ( QUnit.urlParams.nojshint ) {
// Function.prototype.bind check is needed because JSHint doesn't work in ES3 browsers anymore
// https://github.com/jshint/jshint/issues/1384
if ( QUnit.urlParams.nojshint || !Function.prototype.bind ) {
return;
}

Large diffs are not rendered by default.

@@ -14,6 +14,7 @@
"unused": true,

"browser": true,
"es3": true,
"jquery": true,

"globals": {
@@ -182,6 +182,7 @@ $.widget( "ui.dialog", {
this._isOpen = false;
this._focusedElement = null;
this._destroyOverlay();
this._untrackInstance();

if ( !this.opener.filter( ":focusable" ).focus().length ) {

@@ -562,11 +563,30 @@ $.widget( "ui.dialog", {
_trackFocus: function() {
this._on( this.widget(), {
"focusin": function( event ) {
this._untrackInstance();
this._trackingInstances().unshift( this );
this._focusedElement = $( event.target );
}
});
},

_untrackInstance: function() {
var instances = this._trackingInstances(),
exists = $.inArray( this, instances );
if ( exists !== -1 ) {
instances.splice( exists, 1 );
}
},

_trackingInstances: function() {
var instances = this.document.data( "ui-dialog-instances" );
if ( !instances ) {
instances = [];
this.document.data( "ui-dialog-instances", instances );
}
return instances;
},

_minHeight: function() {
var options = this.options;

@@ -783,8 +803,7 @@ $.widget( "ui.dialog", {

if ( !this._allowInteraction( event ) ) {
event.preventDefault();
this.document.find( ".ui-dialog:visible:last .ui-dialog-content" )
.data( this.widgetFullName )._focusTabbable();
this._trackingInstances()[ 0 ]._focusTabbable();
}
}
});