2013-04-29 18:47:02 +00:00
|
|
|
(function ( $ ) {
|
2011-10-19 17:47:02 +00:00
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
module( "selectmenu: events", {
|
2012-01-13 18:49:42 +00:00
|
|
|
setup: function () {
|
2013-02-13 22:58:14 +00:00
|
|
|
this.element = $( "#speed" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
test( "change", function () {
|
2013-04-29 18:48:48 +00:00
|
|
|
expect( 4 );
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
2013-02-13 22:58:14 +00:00
|
|
|
change: function ( event, ui ) {
|
|
|
|
ok( event, "change event fired on change" );
|
|
|
|
equal( event.type, "selectmenuchange", "event type set to selectmenuchange" );
|
2013-04-29 21:15:56 +00:00
|
|
|
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui.item.element[ 0 ] points to original option element" );
|
2013-02-13 22:58:14 +00:00
|
|
|
equal( ui.item.value, value, "ui.item.value property updated correctly" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-07 18:15:46 +00:00
|
|
|
var button = this.element.selectmenu( "widget" ),
|
2013-02-13 22:58:14 +00:00
|
|
|
menu = this.element.selectmenu( "menuWidget" ).parent(),
|
|
|
|
value = this.element.find( "option" ).first().text();
|
2012-01-22 13:12:52 +00:00
|
|
|
|
2013-03-07 18:15:46 +00:00
|
|
|
button.simulate( "focus" ).simulate( "click" );
|
2013-04-29 18:49:06 +00:00
|
|
|
menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
test( "close", function () {
|
2013-04-29 18:51:01 +00:00
|
|
|
expect( 2 );
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
2013-02-13 22:58:14 +00:00
|
|
|
close: function ( event, ui ) {
|
|
|
|
ok( event, "close event fired on close" );
|
|
|
|
equal( event.type, "selectmenuclose", "event type set to selectmenuclose" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
this.element.selectmenu( "open" ).selectmenu( "close" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
test( "focus", function () {
|
2013-04-29 18:51:01 +00:00
|
|
|
expect( 3 );
|
2012-01-13 18:49:42 +00:00
|
|
|
|
2013-04-29 18:59:35 +00:00
|
|
|
var button, menu, links;
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
2013-02-13 22:58:14 +00:00
|
|
|
focus: function ( event, ui ) {
|
|
|
|
ok( event, "focus event fired on mouseover" );
|
|
|
|
equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
|
2013-04-29 21:15:56 +00:00
|
|
|
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui points to original option element" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
2013-02-13 22:58:14 +00:00
|
|
|
|
|
|
|
button = this.element.selectmenu( "widget" ),
|
|
|
|
menu = this.element.selectmenu( "menuWidget" );
|
2012-12-12 17:37:57 +00:00
|
|
|
|
|
|
|
button.simulate( "focus" );
|
2013-02-13 22:58:14 +00:00
|
|
|
links = menu.find( "li.ui-menu-item a" );
|
|
|
|
|
2012-12-12 17:37:57 +00:00
|
|
|
button.simulate( "click" );
|
2013-02-13 22:58:14 +00:00
|
|
|
|
|
|
|
menu.find( "a" ).last().simulate( "mouseover" );
|
|
|
|
|
|
|
|
this.element.selectmenu( "close" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
test( "open", function () {
|
2013-04-29 18:51:01 +00:00
|
|
|
expect( 2 );
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
2013-02-13 22:58:14 +00:00
|
|
|
open: function ( event, ui ) {
|
|
|
|
ok( event, "open event fired on open" );
|
|
|
|
equal( event.type, "selectmenuopen", "event type set to selectmenuopen" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
this.element.selectmenu( "open" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-02-13 22:58:14 +00:00
|
|
|
test( "select", function () {
|
2013-04-29 18:51:01 +00:00
|
|
|
expect( 3 );
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
2013-02-13 22:58:14 +00:00
|
|
|
select: function ( event, ui ) {
|
|
|
|
ok( event, "select event fired on item select" );
|
|
|
|
equal( event.type, "selectmenuselect", "event type set to selectmenuselect" );
|
2013-04-29 21:15:56 +00:00
|
|
|
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui points to original option element" );
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-07 18:15:46 +00:00
|
|
|
var button = this.element.selectmenu( "widget" ),
|
2013-02-13 22:58:14 +00:00
|
|
|
menu = this.element.selectmenu( "menuWidget" ).parent();
|
2012-01-13 18:49:42 +00:00
|
|
|
|
2013-03-07 18:15:46 +00:00
|
|
|
button.simulate( "focus" ).simulate( "click" );
|
2013-04-29 18:49:06 +00:00
|
|
|
menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
2011-11-24 15:50:20 +00:00
|
|
|
|
|
|
|
})(jQuery);
|