forked from jquery-archive/jquery-mobile
/
controlgroup_core.js
108 lines (87 loc) · 5.31 KB
/
controlgroup_core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* mobile checkboxradio unit tests
*/
(function($){
module( 'vertical controlgroup', {
setup: function() {
this.vcontrolgroup = $( "#vertical-controlgroup" );
this.vcontrolgroup.find( ".ui-btn" ).show();
this.vcontrolgroup.controlgroup("refresh");
}
});
test( "vertical controlgroup classes", function() {
var buttons = this.vcontrolgroup.find( ".ui-btn" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-top" ), "first button should have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
ok( buttons.last().hasClass( "ui-corner-bottom"), "last button should have class 'ui-corner-bottom'" );
});
test( "vertical controlgroup after first button was hidden", function() {
//https://github.com/jquery/jquery-mobile/issues/1929
//We hide the first button and refresh
this.vcontrolgroup.find( ".ui-btn" ).first().hide();
this.vcontrolgroup.controlgroup("refresh");
var buttons = this.vcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-top" ), "first visible button should have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
ok( buttons.last().hasClass( "ui-corner-bottom"), "last visible button should have class 'ui-corner-bottom'" );
});
test( "vertical controlgroup after last button was hidden", function() {
//https://github.com/jquery/jquery-mobile/issues/1929
//We hide the last button and refresh
this.vcontrolgroup.find( ".ui-btn" ).last().hide();
this.vcontrolgroup.controlgroup("refresh");
var buttons = this.vcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-top" ), "first visible button should have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
ok( buttons.last().hasClass( "ui-corner-bottom"), "last visible button should have class 'ui-corner-bottom'" );
});
module( 'horizontal controlgroup', {
setup: function() {
this.hcontrolgroup = $( "#horizontal-controlgroup" );
this.hcontrolgroup.find( ".ui-btn" ).show();
this.hcontrolgroup.controlgroup("refresh");
}
});
test( "horizontal controlgroup classes", function() {
var buttons = this.hcontrolgroup.find( ".ui-btn" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-left" ), "first button should have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
ok( buttons.last().hasClass( "ui-corner-right"), "last button should have class 'ui-corner-right'" );
});
test( "horizontal controlgroup after first button was hidden", function() {
//We hide the first button and refresh
this.hcontrolgroup.find( ".ui-btn" ).first().hide();
this.hcontrolgroup.controlgroup("refresh");
var buttons = this.hcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-left" ), "first visible button should have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
ok( buttons.last().hasClass( "ui-corner-right"), "last visible button should have class 'ui-corner-right'" );
});
test( "horizontal controlgroup after last button was hidden", function() {
//We hide the last button and refresh
this.hcontrolgroup.find( ".ui-btn" ).last().hide();
this.hcontrolgroup.controlgroup("refresh");
var buttons = this.hcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
length = buttons.length;
ok( buttons.first().hasClass( "ui-corner-left" ), "first visible button should have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
ok( buttons.last().hasClass( "ui-corner-right"), "last visible button should have class 'ui-corner-right'" );
});
})(jQuery);