@@ -82,7 +82,11 @@ function addIconToggle(that, $parent, $control) {
82
82
83
83
function wrapLabel ( $parent , type , inputStyle , labelStyle , elm ) {
84
84
// Wrap non-empty text nodes in span with mbsc-label class
85
- if ( type != 'button' && type != 'submit' && type != 'segmented' ) {
85
+ if ( type == 'segmented' ) {
86
+ $parent . closest ( '.mbsc-segmented' )
87
+ . addClass ( inputStyle == 'box' ? 'mbsc-input-box' : '' )
88
+ . addClass ( inputStyle == 'outline' ? 'mbsc-input-outline' : '' ) ;
89
+ } else if ( type != 'button' && type != 'submit' ) {
86
90
$parent
87
91
. addClass ( 'mbsc-control-w' )
88
92
. addClass ( inputStyle == 'box' ? 'mbsc-input-box' : '' )
@@ -132,6 +136,10 @@ export class FormControl {
132
136
const inputStyle = getAttr ( $elm , 'data-input-style' , s . inputStyle ) ;
133
137
const labelStyle = getAttr ( $elm , 'data-label-style' , s . labelStyle ) ;
134
138
139
+ if ( elm . mbscInst ) {
140
+ elm . mbscInst . destroy ( ) ;
141
+ }
142
+
135
143
if ( $frame ) {
136
144
$frame . insertAfter ( $parent ) ;
137
145
}
@@ -155,9 +163,10 @@ export class FormControl {
155
163
$elm . addClass ( 'mbsc-control' ) ;
156
164
157
165
// Attach events
166
+ this . _handle = this . _handle . bind ( this ) ;
158
167
// Prevent 300ms click latency
159
168
events . forEach ( ev => {
160
- elm . addEventListener ( ev , this ) ;
169
+ $ elm. on ( ev , this . _handle ) ;
161
170
} ) ;
162
171
163
172
this . settings = s ;
@@ -182,8 +191,9 @@ export class FormControl {
182
191
183
192
destroy ( ) {
184
193
this . _$elm . removeClass ( 'mbsc-control' ) ;
194
+ this . getClassElm ( ) . removeClass ( this . cssClass ) ;
185
195
events . forEach ( ev => {
186
- this . _elm . removeEventListener ( ev , this ) ;
196
+ this . _$elm . off ( ev , this . _handle ) ;
187
197
} ) ;
188
198
delete this . _elm . mbscInst ;
189
199
}
@@ -202,7 +212,7 @@ export class FormControl {
202
212
this . _ripple = getRipple ( this . settings . theme ) ;
203
213
}
204
214
205
- handleEvent ( ev ) {
215
+ _handle ( ev ) {
206
216
switch ( ev . type ) {
207
217
case 'touchstart' :
208
218
case 'mousedown' :
@@ -287,8 +297,11 @@ export class FormControl {
287
297
}
288
298
}
289
299
300
+ mobiscroll . themes . form . mobiscroll = { } ;
301
+
290
302
export {
291
303
addIcon ,
292
304
addIconToggle ,
305
+ getCssClass ,
293
306
wrapLabel
294
307
} ;
0 commit comments