From: Krinkle Date: Thu, 24 Feb 2011 23:10:04 +0000 (+0000) Subject: changing implied if-statement into a real if-statment; Passes strict settings of... X-Git-Tag: 1.31.0-rc.0~31779 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=9f3db4baa5a48b63b34328a51b88cc190573a82a;p=lhc%2Fweb%2Fwiklou.git changing implied if-statement into a real if-statment; Passes strict settings of JSHint now as well --- 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' ); + } + }); + } }); };