From 9f3db4baa5a48b63b34328a51b88cc190573a82a Mon Sep 17 00:00:00 2001 From: Krinkle Date: Thu, 24 Feb 2011 23:10:04 +0000 Subject: [PATCH] changing implied if-statement into a real if-statment; Passes strict settings of JSHint now as well --- resources/jquery/jquery.placeholder.js | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/resources/jquery/jquery.placeholder.js b/resources/jquery/jquery.placeholder.js index bcff4e7c0a..d4c00e5075 100644 --- a/resources/jquery/jquery.placeholder.js +++ b/resources/jquery/jquery.placeholder.js @@ -19,11 +19,11 @@ $.fn.placeholder = function() { return; } - var placeholder = this.getAttribute('placeholder'); + var placeholder = this.getAttribute( 'placeholder' ); var $input = $(this); // Show initially, if empty - if ( this.value === '' || this.value == placeholder ) { + if ( this.value === '' || this.value === placeholder ) { $input.addClass( 'placeholder' ).val( placeholder ); } @@ -40,23 +40,25 @@ $.fn.placeholder = function() { // Hide on focus .focus( function() { - if ($input.hasClass('placeholder')) { + if ( $input.hasClass( 'placeholder' ) ) { this.value = ''; $input.removeClass( 'placeholder' ); } } ); // Blank on submit -- prevents submitting with unintended value - this.form && $( this.form ).submit( function() { - // $input.trigger( 'focus' ); would be problematic - // because it actually focuses $input, leading - // to nasty behavior in mobile browsers - if ( $input.hasClass('placeholder') ) { - $input - .val( '' ) - .removeClass( 'placeholder' ); - } - }); + if ( this.form ) { + $( this.form ).submit( function() { + // $input.trigger( 'focus' ); would be problematic + // because it actually focuses $input, leading + // to nasty behavior in mobile browsers + if ( $input.hasClass( 'placeholder' ) ) { + $input + .val( '' ) + .removeClass( 'placeholder' ); + } + }); + } }); }; -- 2.20.1