2012-04-30 00:13:34 +00:00
|
|
|
(function( $ ) {
|
2008-09-20 17:42:04 +00:00
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
module( "core - jQuery extensions" );
|
2008-11-07 13:49:23 +00:00
|
|
|
|
2012-06-15 17:42:00 +00:00
|
|
|
TestHelpers.testJshint( "core" );
|
2012-04-30 00:22:31 +00:00
|
|
|
|
2012-12-10 15:34:44 +00:00
|
|
|
asyncTest( "focus - original functionality", function() {
|
2012-04-30 00:13:34 +00:00
|
|
|
expect( 1 );
|
|
|
|
$( "#inputTabindex0" )
|
2012-12-10 15:34:44 +00:00
|
|
|
.one( "focus", function() {
|
2012-04-30 00:13:34 +00:00
|
|
|
ok( true, "event triggered" );
|
2012-12-10 15:34:44 +00:00
|
|
|
start();
|
2010-09-02 15:14:00 +00:00
|
|
|
})
|
|
|
|
.focus();
|
|
|
|
});
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
asyncTest( "focus", function() {
|
|
|
|
expect( 2 );
|
2013-07-09 18:13:24 +00:00
|
|
|
|
|
|
|
// support: IE 8
|
|
|
|
// IE sometimes gets confused about what's focused if we don't explicitly
|
|
|
|
// focus a different element first
|
|
|
|
$( "body" ).focus();
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
$( "#inputTabindex0" )
|
2012-12-10 15:34:44 +00:00
|
|
|
.one( "focus", function() {
|
2012-04-30 00:13:34 +00:00
|
|
|
ok( true, "event triggered" );
|
2013-01-08 12:54:11 +00:00
|
|
|
start();
|
2010-09-02 15:14:00 +00:00
|
|
|
})
|
2012-04-30 00:13:34 +00:00
|
|
|
.focus( 500, function() {
|
|
|
|
ok( true, "callback triggered" );
|
2010-09-02 15:14:00 +00:00
|
|
|
});
|
2009-04-18 13:04:07 +00:00
|
|
|
});
|
|
|
|
|
2010-07-22 02:17:52 +00:00
|
|
|
test( "innerWidth - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.innerWidth(), 122, "getter passthru" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.innerWidth(), 122, "getter passthru when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "innerWidth - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.innerWidth( 120 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 98, "width set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.innerWidth( 100 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 78, "width set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "innerHeight - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.innerHeight(), 70, "getter passthru" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.innerHeight(), 70, "getter passthru when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "innerHeight - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.innerHeight( 60 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 40, "height set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.innerHeight( 50 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 30, "height set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerWidth - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerWidth(), 140, "getter passthru" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerWidth(), 140, "getter passthru when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerWidth - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.outerWidth( 130 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 90, "width set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.outerWidth( 120 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 80, "width set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerWidth(true) - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerWidth(true) - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.outerWidth( 130, true );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 76, "width set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.outerWidth( 120, true );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.width(), 66, "width set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerHeight - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerHeight(), 86, "getter passthru" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerHeight(), 86, "getter passthru when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerHeight - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.outerHeight( 80 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 44, "height set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.outerHeight( 70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 34, "height set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerHeight(true) - getter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "outerHeight(true) - setter", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 2 );
|
2010-07-22 02:17:52 +00:00
|
|
|
var el = $( "#dimensions" );
|
|
|
|
|
|
|
|
el.outerHeight( 90, true );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 42, "height set properly" );
|
2010-07-22 02:17:52 +00:00
|
|
|
el.hide();
|
|
|
|
el.outerHeight( 80, true );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( el.height(), 32, "height set properly when hidden" );
|
2010-07-22 02:17:52 +00:00
|
|
|
});
|
|
|
|
|
2012-05-30 01:55:43 +00:00
|
|
|
test( "uniqueId / removeUniqueId", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
2012-05-30 01:55:43 +00:00
|
|
|
var el = $( "img" ).eq( 0 );
|
|
|
|
|
2012-06-25 18:46:45 +00:00
|
|
|
// support: jQuery <1.6.2
|
|
|
|
// support: IE <8
|
2012-06-25 18:51:51 +00:00
|
|
|
// We should use strictEqual( id, undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
|
2012-06-19 15:08:38 +00:00
|
|
|
ok( !el.attr( "id" ), "element has no initial id" );
|
2012-05-30 01:55:43 +00:00
|
|
|
el.uniqueId();
|
|
|
|
ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
|
|
|
|
el.removeUniqueId();
|
2012-06-25 18:46:45 +00:00
|
|
|
// support: jQuery <1.6.2
|
|
|
|
// support: IE <8
|
|
|
|
// see above
|
2012-06-19 15:08:38 +00:00
|
|
|
ok( !el.attr( "id" ), "unique id has been removed from element" );
|
2012-05-30 01:55:43 +00:00
|
|
|
});
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
})( jQuery );
|