2011-11-24 15:50:20 +00:00
|
|
|
(function ($) {
|
2011-10-19 17:47:02 +00:00
|
|
|
|
2012-01-13 18:49:42 +00:00
|
|
|
module("selectmenu: events", {
|
|
|
|
setup: function () {
|
|
|
|
this.element = $("#speed");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test("change", function () {
|
|
|
|
expect(5);
|
|
|
|
|
|
|
|
this.element.selectmenu({
|
|
|
|
change: function (event, ui) {
|
|
|
|
ok(event, "change event fired on change");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(event.type, "selectmenuchange", "event type set to selectmenuchange");
|
2012-01-13 18:49:42 +00:00
|
|
|
ok(ui, "ui object is passed as second argument to event handler");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(ui.item.element[0].nodeName, "OPTION", "ui.item.element[0] points to original option element");
|
|
|
|
equal(ui.item.value, value, "ui.item.value property updated correctly");
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-02-21 19:22:13 +00:00
|
|
|
var button = this.element.selectmenu("widget").parent(),
|
|
|
|
menu = this.element.selectmenu("menuWidget").parent(),
|
2012-01-13 18:49:42 +00:00
|
|
|
value = this.element.find("option").first().text();
|
2012-01-22 13:12:52 +00:00
|
|
|
|
2012-03-01 03:09:13 +00:00
|
|
|
button.find("a").simulate( "focus" ).simulate( "click" );
|
|
|
|
menu.find("a").first().simulate( "mouseover" ).trigger( "click" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("close", function () {
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
this.element.selectmenu({
|
|
|
|
close: function (event, ui) {
|
|
|
|
ok(event, "close event fired on close");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(event.type, "selectmenuclose", "event type set to selectmenuclose");
|
2012-01-13 18:49:42 +00:00
|
|
|
ok(ui, "ui object is passed as second argument to event handler");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.element.selectmenu("open").selectmenu("close");
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("focus", function () {
|
|
|
|
expect(4);
|
|
|
|
|
2012-05-24 16:54:47 +00:00
|
|
|
var counter = 0,
|
|
|
|
button,
|
|
|
|
menu;
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
this.element.selectmenu({
|
|
|
|
focus: function (event, ui) {
|
|
|
|
counter++;
|
|
|
|
if (counter === 1) {
|
|
|
|
ok(event, "focus event fired on mouseover");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(event.type, "selectmenufocus", "event type set to selectmenufocus");
|
2012-01-13 18:49:42 +00:00
|
|
|
ok(ui, "ui object is passed as second argument to event handler");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(ui.item.element[0].nodeName, "OPTION", "ui points to original option element");
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-05-24 16:54:47 +00:00
|
|
|
button = this.element.selectmenu("widget").parent();
|
|
|
|
menu = this.element.selectmenu("menuWidget").parent();
|
2012-01-13 18:49:42 +00:00
|
|
|
|
2012-03-01 03:09:13 +00:00
|
|
|
button.find("a").simulate( "focus" ).simulate( "click" );
|
|
|
|
menu.find(".ui-menu-item").simulate("mouseover");
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("open", function () {
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
this.element.selectmenu({
|
|
|
|
open: function (event, ui) {
|
|
|
|
ok(event, "open event fired on open");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(event.type, "selectmenuopen", "event type set to selectmenuopen");
|
2012-01-13 18:49:42 +00:00
|
|
|
ok(ui, "ui object is passed as second argument to event handler");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.element.selectmenu("open");
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("select", function () {
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
this.element.selectmenu({
|
|
|
|
select: function (event, ui) {
|
|
|
|
ok(event, "select event fired on item select");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(event.type, "selectmenuselect", "event type set to selectmenuselect");
|
2012-01-13 18:49:42 +00:00
|
|
|
ok(ui, "ui object is passed as second argument to event handler");
|
2012-03-01 03:11:20 +00:00
|
|
|
equal(ui.item.element[0].nodeName, "OPTION", "ui points to original option element");
|
2012-01-13 18:49:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-02-21 19:22:13 +00:00
|
|
|
var button = this.element.selectmenu("widget").parent(),
|
|
|
|
menu = this.element.selectmenu("menuWidget").parent();
|
2012-01-13 18:49:42 +00:00
|
|
|
|
2012-03-01 03:09:13 +00:00
|
|
|
button.find("a").simulate( "focus" ).simulate( "click" );
|
|
|
|
menu.find("a").first().simulate( "mouseover" ).trigger("click");
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
2011-11-24 15:50:20 +00:00
|
|
|
|
|
|
|
})(jQuery);
|