r106516 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106515‎ | r106516 | r106517 >
Date:18:31, 17 December 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
Follow-up r92924: move the CSS/JS for e-mail validation to Special:ChangeEmail.

Also merge the different LTR/RTL styles, it is flipped anyway.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialChangeEmail.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css (added) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.js (added) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css (deleted) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialChangeEmail.php
@@ -67,6 +67,7 @@
6868
6969 $out = $this->getOutput();
7070 $out->disallowUserJs();
 71+ $out->addModules( 'mediawiki.special.changeemail' );
7172
7273 $this->mPassword = $request->getVal( 'wpPassword' );
7374 $this->mNewEmail = $request->getVal( 'wpNewEmail' );
Index: trunk/phase3/resources/Resources.php
@@ -720,6 +720,11 @@
721721 'mediawiki.special.block' => array(
722722 'scripts' => 'resources/mediawiki.special/mediawiki.special.block.js',
723723 ),
 724+ 'mediawiki.special.changeemail' => array(
 725+ 'scripts' => 'resources/mediawiki.special/mediawiki.special.changeemail.js',
 726+ 'styles' => 'resources/mediawiki.special/mediawiki.special.changeemail.css',
 727+ 'messages' => array( 'email-address-validity-valid', 'email-address-validity-invalid' ),
 728+ ),
724729 'mediawiki.special.changeslist' => array(
725730 'styles' => 'resources/mediawiki.special/mediawiki.special.changeslist.css',
726731 'dependencies' => array( 'jquery.makeCollapsible' ),
@@ -730,8 +735,6 @@
731736 ),
732737 'mediawiki.special.preferences' => array(
733738 'scripts' => 'resources/mediawiki.special/mediawiki.special.preferences.js',
734 - 'styles' => 'resources/mediawiki.special/mediawiki.special.preferences.css',
735 - 'messages' => array( 'email-address-validity-valid', 'email-address-validity-invalid' ),
736739 ),
737740 'mediawiki.special.recentchanges' => array(
738741 'scripts' => 'resources/mediawiki.special/mediawiki.special.recentchanges.js',
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
@@ -1,21 +0,0 @@
2 -#mw-emailaddress-validity {
3 - padding: 2px 1em;
4 -}
5 -body.ltr #mw-emailaddress-validity {
6 - border-bottom-right-radius: 0.8em;
7 - border-top-right-radius: 0.8em;
8 -}
9 -body.rtl #mw-emailaddress-validity {
10 - border-bottom-left-radius: 0.8em;
11 - border-top-left-radius: 0.8em;
12 -}
13 -#mw-emailaddress-validity.valid {
14 - border: 1px solid #80FF80;
15 - background-color: #C0FFC0;
16 - color: black;
17 -}
18 -#mw-emailaddress-validity.invalid {
19 - border: 1px solid #FF8080;
20 - background-color: #FFC0C0;
21 - color: black;
22 -}
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
@@ -0,0 +1,17 @@
 2+#mw-emailaddress-validity {
 3+ padding: 2px 1em;
 4+}
 5+#mw-emailaddress-validity {
 6+ border-bottom-right-radius: 0.8em;
 7+ border-top-right-radius: 0.8em;
 8+}
 9+#mw-emailaddress-validity.valid {
 10+ border: 1px solid #80FF80;
 11+ background-color: #C0FFC0;
 12+ color: black;
 13+}
 14+#mw-emailaddress-validity.invalid {
 15+ border: 1px solid #FF8080;
 16+ background-color: #FFC0C0;
 17+ color: black;
 18+}
Property changes on: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
___________________________________________________________________
Added: svn:eol-style
119 + native
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.js
@@ -0,0 +1,38 @@
 2+/*
 3+ * JavaScript for Special:ChangeEmail
 4+ */
 5+( function( $, mw ) {
 6+/**
 7+ * Given an email validity status (true, false, null) update the label CSS class
 8+ */
 9+var updateMailValidityLabel = function( mail ) {
 10+ var isValid = mw.util.validateEmail( mail ),
 11+ $label = $( '#mw-emailaddress-validity' );
 12+
 13+ // We allow empty address
 14+ if( isValid === null ) {
 15+ $label.text( '' ).removeClass( 'valid invalid' );
 16+
 17+ // Valid
 18+ } else if ( isValid ) {
 19+ $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
 20+
 21+ // Not valid
 22+ } else {
 23+ $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
 24+ }
 25+};
 26+
 27+// Lame tip to let user know if its email is valid. See bug 22449
 28+// Only bind once for 'blur' so that the user can fill it in without errors
 29+// After that look at every keypress for direct feedback if it was invalid onblur
 30+$( '#wpNewEmail' ).one( 'blur', function() {
 31+ if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
 32+ $(this).after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' );
 33+ }
 34+ updateMailValidityLabel( $(this).val() );
 35+ $(this).keyup( function() {
 36+ updateMailValidityLabel( $(this).val() );
 37+ } );
 38+} );
 39+} )( jQuery, mediaWiki );
\ No newline at end of file
Property changes on: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.js
___________________________________________________________________
Added: svn:eol-style
140 + native
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.js
@@ -58,42 +58,7 @@
5959 }
6060 } );
6161
62 -/**
63 - * Given an email validity status (true, false, null) update the label CSS class
64 - */
65 -var updateMailValidityLabel = function( mail ) {
66 - var isValid = mw.util.validateEmail( mail ),
67 - $label = $( '#mw-emailaddress-validity' );
6862
69 - // We allow empty address
70 - if( isValid === null ) {
71 - $label.text( '' ).removeClass( 'valid invalid' );
72 -
73 - // Valid
74 - } else if ( isValid ) {
75 - $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
76 -
77 - // Not valid
78 - } else {
79 - $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
80 - }
81 -};
82 -
83 -// Lame tip to let user know if its email is valid. See bug 22449
84 -// Only bind once for 'blur' so that the user can fill it in without errors
85 -// After that look at every keypress for direct feedback if it was invalid onblur
86 -$( '#mw-input-wpemailaddress' ).one( 'blur', function() {
87 - if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
88 - $(this).after( '<label for="mw-input-wpemailaddress" id="mw-emailaddress-validity"></label>' );
89 - }
90 - updateMailValidityLabel( $(this).val() );
91 - $(this).keyup( function() {
92 - updateMailValidityLabel( $(this).val() );
93 - } );
94 -} );
95 -
96 -
97 -
9863 /**
9964 * Timezone functions.
10065 * Guesses Timezone from browser and updates fields onchange

Follow-up revisions

RevisionCommit summaryAuthorDate
r108339Re-do svn copy from r106516 preserving historykrinkle00:22, 8 January 2012
r108340Re-applying change to code from r106516...krinkle00:24, 8 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92924* Moved email changing from sp:Preferences to new sp:ChangeEmail, which requi...aaron00:48, 23 July 2011

Comments

#Comment by Krinkle (talk | contribs)   10:49, 2 January 2012

Minor note: When splitting up a file into two files (mediawiki.special.preferences.js in this case) use svn copy to duplicate the file and then remove part A from file B, and remove part B from file A. That way the history is reserved.

Status & tagging log