r82760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82759‎ | r82760 | r82761 >
Date:23:10, 24 February 2011
Author:krinkle
Status:ok
Tags:
Comment:
changing implied if-statement into a real if-statment; Passes strict settings of JSHint now as well
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.placeholder.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.placeholder.js
@@ -19,11 +19,11 @@
2020 return;
2121 }
2222
23 - var placeholder = this.getAttribute('placeholder');
 23+ var placeholder = this.getAttribute( 'placeholder' );
2424 var $input = $(this);
2525
2626 // Show initially, if empty
27 - if ( this.value === '' || this.value == placeholder ) {
 27+ if ( this.value === '' || this.value === placeholder ) {
2828 $input.addClass( 'placeholder' ).val( placeholder );
2929 }
3030
@@ -40,23 +40,25 @@
4141
4242 // Hide on focus
4343 .focus( function() {
44 - if ($input.hasClass('placeholder')) {
 44+ if ( $input.hasClass( 'placeholder' ) ) {
4545 this.value = '';
4646 $input.removeClass( 'placeholder' );
4747 }
4848 } );
4949
5050 // 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+ }
6163
6264 });
6365 };

Status & tagging log