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-04-30 00:22:31 +00:00
|
|
|
TestHelpers.testJshint( "ui.core" );
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
test( "focus - original functionality", function() {
|
|
|
|
expect( 1 );
|
|
|
|
$( "#inputTabindex0" )
|
2010-09-02 15:14:00 +00:00
|
|
|
.focus(function() {
|
2012-04-30 00:13:34 +00:00
|
|
|
ok( true, "event triggered" );
|
2010-09-02 15:14:00 +00:00
|
|
|
})
|
|
|
|
.focus();
|
|
|
|
});
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
asyncTest( "focus", function() {
|
|
|
|
expect( 2 );
|
|
|
|
$( "#inputTabindex0" )
|
2010-09-02 15:14:00 +00:00
|
|
|
.focus(function() {
|
2012-04-30 00:13:34 +00:00
|
|
|
ok( true, "event triggered" );
|
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
|
|
|
start();
|
|
|
|
});
|
2009-04-18 13:04:07 +00:00
|
|
|
});
|
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
test( "zIndex", function() {
|
|
|
|
var el = $( "#zIndexAutoWithParent" ),
|
2010-01-29 18:38:21 +00:00
|
|
|
parent = el.parent();
|
2012-04-30 00:13:34 +00:00
|
|
|
equal( el.zIndex(), 100, "zIndex traverses up to find value" );
|
|
|
|
equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" );
|
|
|
|
equal( el.zIndex(), 200, "zIndex setter changed zIndex" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
el = $( "#zIndexAutoWithParentViaCSS" );
|
|
|
|
equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
el = $( "#zIndexAutoWithParentViaCSSPositioned" );
|
|
|
|
equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" );
|
|
|
|
el.parent().zIndex( 200 );
|
|
|
|
equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-30 00:13:34 +00:00
|
|
|
equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" );
|
2009-08-05 13:30:55 +00:00
|
|
|
});
|
|
|
|
|
2010-07-22 02:17:52 +00:00
|
|
|
test( "innerWidth - getter", function() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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() {
|
|
|
|
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-04-30 00:13:34 +00:00
|
|
|
})( jQuery );
|