forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolgroup.js
More file actions
107 lines (86 loc) · 2.78 KB
/
controlgroup.js
File metadata and controls
107 lines (86 loc) · 2.78 KB
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
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Visually groups sets of buttons, checks, radios, etc.
//>>label: Controlgroups
//>>group: Forms
//>>css.structure: ../css/structure/jquery.mobile.controlgroup.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
define( [ "jquery",
"./addFirstLastClasses",
"../jquery.mobile.registry",
"../jquery.mobile.widget" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.widget( "mobile.controlgroup", $.extend( {
options: {
theme: null,
shadow: false,
corners: true,
excludeInvisible: true,
type: "vertical",
mini: false,
initSelector: ":jqmData(role='controlgroup')"
},
_create: function() {
var $el = this.element,
inner = $( "<div class='ui-controlgroup-controls'></div>" ),
grouplegend = $el.children( "legend" );
// Apply the proto
$el.wrapInner( inner ).addClass( "ui-controlgroup" );
if ( grouplegend.length ) {
$( "<div role='heading' class='ui-controlgroup-label'></div>" ).append( grouplegend ).insertBefore( $el.children( 0 ) );
}
$.extend( this, {
_initialRefresh: true
});
this._setOptions( this.options );
},
_init: function() {
this.refresh();
},
_setOptions: function( o ) {
var $el = this.element;
if ( o.type !== undefined ) {
$el
.removeClass( "ui-controlgroup-horizontal ui-controlgroup-vertical" )
.addClass( "ui-controlgroup-" + o.type );
this.refresh();
}
if ( o.theme !== undefined ) {
$el.removeClass( "ui-group-theme-" + this.options.theme );
if ( o.theme ) {
$el.addClass( "ui-group-theme-" + o.theme );
}
}
if ( o.corners !== undefined ) {
$el.toggleClass( "ui-corner-all", o.corners );
}
if ( o.shadow !== undefined ) {
$el.find( ".ui-controlgroup-controls" ).toggleClass( "ui-shadow", o.shadow );
}
if ( o.mini !== undefined ) {
$el.toggleClass( "ui-mini", o.mini );
}
return this._super( o );
},
container: function() {
return this.element.children( ".ui-controlgroup-controls" );
},
refresh: function() {
var $el = this.container(),
els = $el.find( ".ui-btn" ).not( ".ui-slider-handle" ),
create = this._initialRefresh;
if ( $.mobile.checkboxradio ) {
$el.find( ":mobile-checkboxradio" ).checkboxradio( "refresh" );
}
this._addFirstLastClasses( els, this.options.excludeInvisible ? this._getVisibles( els, create ) : els, create );
this._initialRefresh = false;
}
}, $.mobile.behaviors.addFirstLastClasses ) );
$.mobile.controlgroup.initSelector = ":jqmData(role='controlgroup')";
$.mobile._enhancer.add( "mobile.controlgroup", {
dependencies: [ "mobile.selectmenu", "mobile.button", "mobile.checkboxradio" ]
});
})(jQuery);
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");