1 |
/* |
2 |
* button_options.js |
3 |
*/ |
4 |
(function($) { |
5 |
|
6 |
module("button: options"); |
7 |
|
8 |
test("disabled, explicit value", function() { |
9 |
expect( 4 ); |
10 |
$("#radio01").button({ disabled: false }); |
11 |
deepEqual(false, $("#radio01").button("option", "disabled"), |
12 |
"disabled option set to false"); |
13 |
deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); |
14 |
|
15 |
$("#radio02").button({ disabled: true }); |
16 |
deepEqual(true, $("#radio02").button("option", "disabled"), |
17 |
"disabled option set to true"); |
18 |
deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); |
19 |
}); |
20 |
|
21 |
test("disabled, null", function() { |
22 |
expect( 4 ); |
23 |
$("#radio01").button({ disabled: null }); |
24 |
deepEqual(false, $("#radio01").button("option", "disabled"), |
25 |
"disabled option set to false"); |
26 |
deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); |
27 |
|
28 |
$("#radio02").prop("disabled", true).button({ disabled: null }); |
29 |
deepEqual(true, $("#radio02").button("option", "disabled"), |
30 |
"disabled option set to true"); |
31 |
deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); |
32 |
}); |
33 |
|
34 |
test("text false without icon", function() { |
35 |
expect( 1 ); |
36 |
$("#button").button({ |
37 |
text: false |
38 |
}); |
39 |
ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") ); |
40 |
|
41 |
$("#button").button("destroy"); |
42 |
}); |
43 |
|
44 |
test("text false with icon", function() { |
45 |
expect( 1 ); |
46 |
$("#button").button({ |
47 |
text: false, |
48 |
icons: { |
49 |
primary: "iconclass" |
50 |
} |
51 |
}); |
52 |
ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") ); |
53 |
|
54 |
$("#button").button("destroy"); |
55 |
}); |
56 |
|
57 |
test("label, default", function() { |
58 |
expect( 2 ); |
59 |
$("#button").button(); |
60 |
deepEqual( $("#button").text(), "Label" ); |
61 |
deepEqual( $( "#button").button( "option", "label" ), "Label" ); |
62 |
|
63 |
$("#button").button("destroy"); |
64 |
}); |
65 |
|
66 |
test("label", function() { |
67 |
expect( 2 ); |
68 |
$("#button").button({ |
69 |
label: "xxx" |
70 |
}); |
71 |
deepEqual( $("#button").text(), "xxx" ); |
72 |
deepEqual( $("#button").button( "option", "label" ), "xxx" ); |
73 |
|
74 |
$("#button").button("destroy"); |
75 |
}); |
76 |
|
77 |
test("label default with input type submit", function() { |
78 |
expect( 2 ); |
79 |
deepEqual( $("#submit").button().val(), "Label" ); |
80 |
deepEqual( $("#submit").button( "option", "label" ), "Label" ); |
81 |
}); |
82 |
|
83 |
test("label with input type submit", function() { |
84 |
expect( 2 ); |
85 |
var label = $("#submit").button({ |
86 |
label: "xxx" |
87 |
}).val(); |
88 |
deepEqual( label, "xxx" ); |
89 |
deepEqual( $("#submit").button( "option", "label" ), "xxx" ); |
90 |
}); |
91 |
|
92 |
test("icons", function() { |
93 |
expect( 1 ); |
94 |
$("#button").button({ |
95 |
text: false, |
96 |
icons: { |
97 |
primary: "iconclass", |
98 |
secondary: "iconclass2" |
99 |
} |
100 |
}); |
101 |
ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") ); |
102 |
|
103 |
$("#button").button("destroy"); |
104 |
}); |
105 |
|
106 |
test( "#5295 - button does not remove hoverstate if disabled" , function() { |
107 |
expect( 1 ); |
108 |
var btn = $("#button").button(); |
109 |
btn.hover( function() { |
110 |
btn.button( "disable" ); |
111 |
}); |
112 |
btn.trigger( "mouseenter" ); |
113 |
btn.trigger( "mouseleave" ); |
114 |
ok( !btn.is( ".ui-state-hover") ); |
115 |
}); |
116 |
|
117 |
})(jQuery); |