2010-01-20 14:00:14 +00:00
|
|
|
/*
|
|
|
|
* button_core.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("button: core");
|
|
|
|
|
|
|
|
test("checkbox", function() {
|
2012-04-19 14:50:09 +00:00
|
|
|
var input = $("#check"),
|
2010-01-20 14:00:14 +00:00
|
|
|
label = $("label[for=check]");
|
2012-02-28 14:56:32 +00:00
|
|
|
ok( input.is(":visible") );
|
2010-01-20 14:00:14 +00:00
|
|
|
ok( label.is(":not(.ui-button)") );
|
|
|
|
input.button();
|
2010-03-11 20:10:26 +00:00
|
|
|
ok( input.is(".ui-helper-hidden-accessible") );
|
2010-01-20 14:00:14 +00:00
|
|
|
ok( label.is(".ui-button") );
|
|
|
|
});
|
|
|
|
|
|
|
|
test("radios", function() {
|
2012-04-19 14:50:09 +00:00
|
|
|
var inputs = $("#radio0 input"),
|
2010-01-20 14:00:14 +00:00
|
|
|
labels = $("#radio0 label");
|
2012-02-28 14:56:32 +00:00
|
|
|
ok( inputs.is(":visible") );
|
2010-01-20 14:00:14 +00:00
|
|
|
ok( labels.is(":not(.ui-button)") );
|
|
|
|
inputs.button();
|
2010-03-11 20:10:26 +00:00
|
|
|
ok( inputs.is(".ui-helper-hidden-accessible") );
|
2010-01-20 14:00:14 +00:00
|
|
|
ok( labels.is(".ui-button") );
|
|
|
|
});
|
|
|
|
|
|
|
|
function assert(noForm, form1, form2) {
|
|
|
|
ok( $("#radio0 .ui-button" + noForm).is(".ui-state-active") );
|
|
|
|
ok( $("#radio1 .ui-button" + form1).is(".ui-state-active") );
|
|
|
|
ok( $("#radio2 .ui-button" + form2).is(".ui-state-active") );
|
|
|
|
}
|
|
|
|
|
|
|
|
test("radio groups", function() {
|
|
|
|
$(":radio").button();
|
|
|
|
assert(":eq(0)", ":eq(1)", ":eq(2)");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2010-01-20 14:00:14 +00:00
|
|
|
// click outside of forms
|
|
|
|
$("#radio0 .ui-button:eq(1)").click();
|
|
|
|
assert(":eq(1)", ":eq(1)", ":eq(2)");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2010-01-20 14:00:14 +00:00
|
|
|
// click in first form
|
|
|
|
$("#radio1 .ui-button:eq(0)").click();
|
|
|
|
assert(":eq(1)", ":eq(0)", ":eq(2)");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2010-01-20 14:00:14 +00:00
|
|
|
// click in second form
|
|
|
|
$("#radio2 .ui-button:eq(0)").click();
|
|
|
|
assert(":eq(1)", ":eq(0)", ":eq(0)");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("input type submit, don't create child elements", function() {
|
2012-04-19 14:50:09 +00:00
|
|
|
var input = $("#submit");
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( input.children().length, 0 );
|
2010-01-20 14:00:14 +00:00
|
|
|
input.button();
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( input.children().length, 0 );
|
2010-01-20 14:00:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("buttonset", function() {
|
|
|
|
var set = $("#radio1").buttonset();
|
2010-03-17 13:16:40 +00:00
|
|
|
ok( set.is(".ui-buttonset") );
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( set.children(".ui-button").length, 3 );
|
|
|
|
deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
|
2010-01-20 14:00:14 +00:00
|
|
|
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
|
|
|
|
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
|
|
|
|
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
|
|
|
|
});
|
|
|
|
|
2011-05-12 05:51:05 +00:00
|
|
|
test("buttonset (rtl)", function() {
|
2012-04-19 14:50:09 +00:00
|
|
|
var set,
|
|
|
|
parent = $("#radio1").parent();
|
2011-05-12 05:51:05 +00:00
|
|
|
// Set to rtl
|
|
|
|
parent.attr("dir", "rtl");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-19 14:50:09 +00:00
|
|
|
set = $("#radio1").buttonset();
|
2011-05-12 05:51:05 +00:00
|
|
|
ok( set.is(".ui-buttonset") );
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( set.children(".ui-button").length, 3 );
|
|
|
|
deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
|
2011-05-12 05:51:05 +00:00
|
|
|
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
|
|
|
|
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
|
|
|
|
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
|
|
|
|
});
|
|
|
|
|
2010-01-20 14:00:14 +00:00
|
|
|
})(jQuery);
|