@@ -27,14 +27,15 @@ $.widget( "mobile.flipswitch", $.extend({
27
27
} ,
28
28
29
29
_create : function ( ) {
30
+ this . type = this . element [ 0 ] . nodeName . toLowerCase ( ) ;
31
+
30
32
if ( ! this . options . enhanced ) {
31
33
this . _enhance ( ) ;
32
34
} else {
33
35
$ . extend ( this , {
34
36
flipswitch : this . element . parent ( ) ,
35
37
on : this . element . find ( ".ui-flipswitch-on" ) . eq ( 0 ) ,
36
- off : this . element . find ( ".ui-flipswitch-off" ) . eq ( 0 ) ,
37
- type : this . element . get ( 0 ) . tagName
38
+ off : this . element . find ( ".ui-flipswitch-off" ) . eq ( 0 )
38
39
} ) ;
39
40
}
40
41
@@ -81,7 +82,7 @@ $.widget( "mobile.flipswitch", $.extend({
81
82
82
83
_left : function ( ) {
83
84
this . flipswitch . removeClass ( "ui-flipswitch-active" ) ;
84
- if ( this . type === "SELECT " ) {
85
+ if ( this . type === "select " ) {
85
86
this . element . get ( 0 ) . selectedIndex = 0 ;
86
87
} else {
87
88
this . element . prop ( "checked" , false ) ;
@@ -91,7 +92,7 @@ $.widget( "mobile.flipswitch", $.extend({
91
92
92
93
_right : function ( ) {
93
94
this . flipswitch . addClass ( "ui-flipswitch-active" ) ;
94
- if ( this . type === "SELECT " ) {
95
+ if ( this . type === "select " ) {
95
96
this . element . get ( 0 ) . selectedIndex = 1 ;
96
97
} else {
97
98
this . element . prop ( "checked" , true ) ;
@@ -110,10 +111,9 @@ $.widget( "mobile.flipswitch", $.extend({
110
111
"href" : "#"
111
112
} ) ,
112
113
off = $ ( "<span></span>" ) ,
113
- type = element . get ( 0 ) . tagName ,
114
- onText = ( type === "INPUT" ) ?
114
+ onText = ( this . type === "input" ) ?
115
115
options . onText : element . find ( "option" ) . eq ( 1 ) . text ( ) ,
116
- offText = ( type === "INPUT " ) ?
116
+ offText = ( this . type === "input " ) ?
117
117
options . offText : element . find ( "option" ) . eq ( 0 ) . text ( ) ;
118
118
119
119
on
@@ -145,8 +145,7 @@ $.widget( "mobile.flipswitch", $.extend({
145
145
$ . extend ( this , {
146
146
flipswitch : flipswitch ,
147
147
on : on ,
148
- off : off ,
149
- type : type
148
+ off : off
150
149
} ) ;
151
150
} ,
152
151
@@ -158,7 +157,7 @@ $.widget( "mobile.flipswitch", $.extend({
158
157
var direction ,
159
158
existingDirection = this . flipswitch . hasClass ( "ui-flipswitch-active" ) ? "_right" : "_left" ;
160
159
161
- if ( this . type === "SELECT " ) {
160
+ if ( this . type === "select " ) {
162
161
direction = ( this . element . get ( 0 ) . selectedIndex > 0 ) ? "_right" : "_left" ;
163
162
} else {
164
163
direction = this . element . prop ( "checked" ) ? "_right" : "_left" ;
0 commit comments