Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions tests/unit/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,6 @@ module( "core - jQuery extensions" );

TestHelpers.testJshint( "core" );

asyncTest( "focus - original functionality", function() {
expect( 1 );
$( "#inputTabindex0" )
.one( "focus", function() {
ok( true, "event triggered" );
start();
})
.focus();
});

asyncTest( "focus", function() {
expect( 2 );

// support: IE 8
// IE sometimes gets confused about what's focused if we don't explicitly
// focus a different element first
$( "body" ).focus();

$( "#inputTabindex0" )
.one( "focus", function() {
ok( true, "event triggered" );
start();
})
.focus( 500, function() {
ok( true, "callback triggered" );
});
});

test( "innerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" );
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/core/core_deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

module( "core - deprecated" );

asyncTest( "focus - original functionality", function() {
expect( 1 );
$( "#inputTabindex0" )
.one( "focus", function() {
ok( true, "event triggered" );
start();
})
.focus();
});

asyncTest( "focus", function() {
expect( 2 );

// support: IE 8
// IE sometimes gets confused about what's focused if we don't explicitly
// focus a different element first
$( "body" ).focus();

$( "#inputTabindex0" )
.one( "focus", function() {
ok( true, "event triggered" );
start();
})
.focus( 500, function() {
ok( true, "callback triggered" );
});
});

test( "zIndex", function() {
expect( 7 );
var el = $( "#zIndexAutoWithParent" ),
Expand Down
32 changes: 16 additions & 16 deletions ui/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,6 @@ $.extend( $.ui, {

// plugins
$.fn.extend({
focus: (function( orig ) {
return function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
orig.apply( this, arguments );
};
})( $.fn.focus ),

scrollParent: function() {
var position = this.css( "position" ),
excludeStaticParent = position === "absolute",
Expand Down Expand Up @@ -225,6 +209,22 @@ $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );

$.support.selectstart = "onselectstart" in document.createElement( "div" );
$.fn.extend({
focus: (function( orig ) {
return function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
orig.apply( this, arguments );
};
})( $.fn.focus ),

disableSelection: function() {
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".ui-disableSelection", function( event ) {
Expand Down
8 changes: 6 additions & 2 deletions ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,14 @@ return $.widget( "ui.dialog", {
last = tabbables.filter( ":last" );

if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
first.focus( 1 );
this._delay(function() {
first.focus();
});
event.preventDefault();
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
last.focus( 1 );
this._delay(function() {
first.focus();
});
event.preventDefault();
}
},
Expand Down