2015-04-06 14:56:48 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
|
|
|
"lib/common",
|
|
|
|
"ui/core"
|
|
|
|
], function( $, common ) {
|
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
|
|
|
|
2015-04-06 14:56:48 +00:00
|
|
|
common.testJshint( "core" );
|
2012-04-30 00:22:31 +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 );
|
2015-03-23 22:42:23 +00:00
|
|
|
equal( el.attr( "id" ), null, "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();
|
2015-03-23 22:42:23 +00:00
|
|
|
equal( el.attr( "id" ), null, "unique id has been removed from element" );
|
2012-05-30 01:55:43 +00:00
|
|
|
});
|
|
|
|
|
2015-04-06 14:56:48 +00:00
|
|
|
} );
|