Index: trunk/phase3/resources/jquery/jquery.placeholder.js |
— | — | @@ -19,11 +19,11 @@ |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | | - var placeholder = this.getAttribute('placeholder'); |
| 23 | + var placeholder = this.getAttribute( 'placeholder' ); |
24 | 24 | var $input = $(this); |
25 | 25 | |
26 | 26 | // Show initially, if empty |
27 | | - if ( this.value === '' || this.value == placeholder ) { |
| 27 | + if ( this.value === '' || this.value === placeholder ) { |
28 | 28 | $input.addClass( 'placeholder' ).val( placeholder ); |
29 | 29 | } |
30 | 30 | |
— | — | @@ -40,23 +40,25 @@ |
41 | 41 | |
42 | 42 | // Hide on focus |
43 | 43 | .focus( function() { |
44 | | - if ($input.hasClass('placeholder')) { |
| 44 | + if ( $input.hasClass( 'placeholder' ) ) { |
45 | 45 | this.value = ''; |
46 | 46 | $input.removeClass( 'placeholder' ); |
47 | 47 | } |
48 | 48 | } ); |
49 | 49 | |
50 | 50 | // Blank on submit -- prevents submitting with unintended value |
51 | | - this.form && $( this.form ).submit( function() { |
52 | | - // $input.trigger( 'focus' ); would be problematic |
53 | | - // because it actually focuses $input, leading |
54 | | - // to nasty behavior in mobile browsers |
55 | | - if ( $input.hasClass('placeholder') ) { |
56 | | - $input |
57 | | - .val( '' ) |
58 | | - .removeClass( 'placeholder' ); |
59 | | - } |
60 | | - }); |
| 51 | + if ( this.form ) { |
| 52 | + $( this.form ).submit( function() { |
| 53 | + // $input.trigger( 'focus' ); would be problematic |
| 54 | + // because it actually focuses $input, leading |
| 55 | + // to nasty behavior in mobile browsers |
| 56 | + if ( $input.hasClass( 'placeholder' ) ) { |
| 57 | + $input |
| 58 | + .val( '' ) |
| 59 | + .removeClass( 'placeholder' ); |
| 60 | + } |
| 61 | + }); |
| 62 | + } |
61 | 63 | |
62 | 64 | }); |
63 | 65 | }; |