File tree 1 file changed +31
-14
lines changed
1 file changed +31
-14
lines changed Original file line number Diff line number Diff line change 115
115
}
116
116
}
117
117
}
118
-
119
118
function setPlaceholder ( ) {
120
- var $replacement ,
121
- input = this ,
122
- $input = $ ( input ) ,
123
- $origInput = $input ,
124
- id = this . id ;
125
- if ( input . value == '' ) {
126
- if ( input . type == 'password' ) {
119
+ var
120
+ $replacement ,
121
+ input ,
122
+ $input ,
123
+ id ;
124
+
125
+ id = this . id ;
126
+ input = this ;
127
+ $input = $ ( input ) ;
128
+
129
+ if ( input . value === '' ) {
130
+ if ( input . type === 'password' ) {
127
131
if ( ! $input . data ( 'placeholder-textinput' ) ) {
128
132
try {
129
- $replacement = $input . clone ( ) . attr ( { 'type' : 'text' } ) ;
133
+ $replacement = $input
134
+ . clone ( )
135
+ . attr ( {
136
+ type : 'text'
137
+ } ) ;
130
138
} catch ( e ) {
131
- $replacement = $ ( '<input>' ) . attr ( $ . extend ( args ( this ) , { 'type' : 'text' } ) ) ;
139
+ $replacement = $ ( '<input>' )
140
+ . attr ( $ . extend ( args ( this ) , {
141
+ type : 'text'
142
+ } ) ) ;
132
143
}
144
+
133
145
$replacement
134
146
. removeAttr ( 'name' )
135
147
. data ( {
136
148
'placeholder-password' : true ,
137
149
'placeholder-id' : id
138
150
} )
139
151
. bind ( 'focus.placeholder' , clearPlaceholder ) ;
152
+
140
153
$input
141
154
. data ( {
142
155
'placeholder-textinput' : $replacement ,
143
156
'placeholder-id' : id
144
157
} )
145
158
. before ( $replacement ) ;
146
159
}
147
- $input = $input . removeAttr ( 'id' ) . hide ( ) . prev ( ) . attr ( 'id' , id ) . show ( ) ;
160
+ $input = $input
161
+ . removeAttr ( 'id' )
162
+ . hide ( )
163
+ . prev ( )
164
+ . attr ( 'id' , id )
165
+ . show ( ) ;
148
166
// Note: `$input[0] != input` now!
149
167
}
150
168
$input . addClass ( 'placeholder' ) ;
151
169
$input [ 0 ] . value = $input . attr ( 'placeholder' ) ;
152
- } else {
170
+ } else if ( input . value !== $input . attr ( 'placeholder' ) ) {
153
171
$input . removeClass ( 'placeholder' ) ;
154
172
}
155
173
}
156
-
157
- } ( this , document , jQuery ) ) ;
174
+ } ( this , document , jQuery ) ) ;
You can’t perform that action at this time.
0 commit comments