https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113221
Revision: 113221
Author: hashar
Date: 2012-03-07 09:56:24 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
(bug 34302) Add CSS classes to email fields in user preferences
Patch by Nischay Nahata whom I have mentored earlier this week.
Modified Paths:
--------------
trunk/phase3/CREDITS
trunk/phase3/RELEASE-NOTES-1.20
trunk/phase3/includes/Preferences.php
trunk/phase3/resources/Resources.php
trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
trunk/phase3/tests/phpunit/includes/PreferencesTest.php
Added Paths:
-----------
trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
Modified: trunk/phase3/CREDITS
===================================================================
--- trunk/phase3/CREDITS 2012-03-07 09:05:44 UTC (rev 113220)
+++ trunk/phase3/CREDITS 2012-03-07 09:56:24 UTC (rev 113221)
@@ -159,6 +159,7 @@
* Nx.devnull
* Nikola Kovacs
* Nikolaos S. Karastathis
+* Nischay Nahata
* Olaf Lenz
* Olivier Finlay Beaton
* Paul Copperman
Modified: trunk/phase3/RELEASE-NOTES-1.20
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.20 2012-03-07 09:05:44 UTC (rev 113220)
+++ trunk/phase3/RELEASE-NOTES-1.20 2012-03-07 09:56:24 UTC (rev 113221)
@@ -21,6 +21,7 @@
contentSub, ... The same div often also contains the class
mw-content-ltr/rtl.
* (bug 27619) Remove preference option to display broken links as link?
* (bug 34896) Update jQuery JSON plugin to v2.3 (2011-09-17)
+* (bug 34302) Add CSS classes to email fields in user preferences
=== Bug fixes in 1.20 ===
* (bug 30245) Use the correct way to construct a log page title.
Modified: trunk/phase3/includes/Preferences.php
===================================================================
--- trunk/phase3/includes/Preferences.php 2012-03-07 09:05:44 UTC (rev
113220)
+++ trunk/phase3/includes/Preferences.php 2012-03-07 09:56:24 UTC (rev
113221)
@@ -354,16 +354,19 @@
$emailAddress .= $emailAddress == '' ? $link :
" ($link)";
}
+
$defaultPreferences['emailaddress'] = array(
'type' => 'info',
'raw' => true,
'default' => $emailAddress,
'label-message' => 'youremail',
'section' => 'personal/email',
+ # 'cssclass' chosen below
);
$disableEmailPrefs = false;
+ $emailauthenticationclass =
'mw-email-not-authenticated';
if ( $wgEmailAuthentication ) {
if ( $user->getEmail() ) {
if (
$user->getEmailAuthenticationTimestamp() ) {
@@ -378,6 +381,7 @@
$emailauthenticated =
$context->msg( 'emailauthenticated',
$time, $d, $t
)->parse() . '<br />';
$disableEmailPrefs = false;
+ $emailauthenticationclass =
'mw-email-authenticated';
} else {
$disableEmailPrefs = true;
$emailauthenticated =
$context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
@@ -385,10 +389,12 @@
SpecialPage::getTitleFor( 'Confirmemail' ),
$context->msg(
'emailconfirmlink' )->escaped()
) . '<br />';
+
$emailauthenticationclass="mw-email-not-authenticated";
}
} else {
$disableEmailPrefs = true;
$emailauthenticated = $context->msg(
'noemailprefs' )->escaped();
+ $emailauthenticationclass =
'mw-email-none';
}
$defaultPreferences['emailauthentication'] =
array(
@@ -397,9 +403,11 @@
'section' => 'personal/email',
'label-message' =>
'prefs-emailconfirm-label',
'default' => $emailauthenticated,
+ # Apply the same CSS class used on the
input to the message:
+ 'cssclass' => $emailauthenticationclass,
);
-
}
+ $defaultPreferences['emailaddress']['cssclass'] =
$emailauthenticationclass;
if ( $wgEnableUserEmail && $user->isAllowed(
'sendemail' ) ) {
$defaultPreferences['disablemail'] = array(
Modified: trunk/phase3/resources/Resources.php
===================================================================
--- trunk/phase3/resources/Resources.php 2012-03-07 09:05:44 UTC (rev
113220)
+++ trunk/phase3/resources/Resources.php 2012-03-07 09:56:24 UTC (rev
113221)
@@ -786,6 +786,7 @@
),
'mediawiki.special.preferences' => array(
'scripts' =>
'resources/mediawiki.special/mediawiki.special.preferences.js',
+ 'styles' =>
'resources/mediawiki.special/mediawiki.special.preferences.css',
),
'mediawiki.special.recentchanges' => array(
'scripts' =>
'resources/mediawiki.special/mediawiki.special.recentchanges.js',
Modified:
trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
===================================================================
--- trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
2012-03-07 09:05:44 UTC (rev 113220)
+++ trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
2012-03-07 09:56:24 UTC (rev 113221)
@@ -5,6 +5,8 @@
border-bottom-right-radius: 0.8em;
border-top-right-radius: 0.8em;
}
+
+/** colors also used in mediawiki.special.preferences.css */
#mw-emailaddress-validity.valid {
border: 1px solid #80FF80;
background-color: #C0FFC0;
Added:
trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
===================================================================
--- trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
(rev 0)
+++ trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
2012-03-07 09:56:24 UTC (rev 113221)
@@ -0,0 +1,11 @@
+/** Reuses colors from mediawiki.special.changeemail.css */
+.mw-email-not-authenticated .mw-input,
+.mw-email-none .mw-input{
+ border: 1px solid #FF8080;
+ background-color: #FFC0C0;
+ color: black;
+}
+/** Authenticated email field has its own class too. Unstyled by default */
+/*
+.mw-email-authenticated .mw-input { }
+*/
Property changes on:
trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/phase3/tests/phpunit/includes/PreferencesTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/PreferencesTest.php 2012-03-07
09:05:44 UTC (rev 113220)
+++ trunk/phase3/tests/phpunit/includes/PreferencesTest.php 2012-03-07
09:56:24 UTC (rev 113221)
@@ -31,9 +31,10 @@
*/
function testEmailFieldsWhenUserHasNoEmail() {
$prefs = $this->prefsFor( 'noemail' );
- $this->assertArrayNotHasKey( 'class',
+ $this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
);
+ $this->assertEquals( 'mw-email-none',
$prefs['emailaddress']['cssclass'] );
}
/**
* Placeholder to verify bug 34302
@@ -41,9 +42,10 @@
*/
function testEmailFieldsWhenUserEmailNotAuthenticated() {
$prefs = $this->prefsFor( 'notauth' );
- $this->assertArrayNotHasKey( 'class',
+ $this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
);
+ $this->assertEquals( 'mw-email-not-authenticated',
$prefs['emailaddress']['cssclass'] );
}
/**
* Placeholder to verify bug 34302
@@ -51,9 +53,10 @@
*/
function testEmailFieldsWhenUserEmailIsAuthenticated() {
$prefs = $this->prefsFor( 'auth' );
- $this->assertArrayNotHasKey( 'class',
+ $this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
);
+ $this->assertEquals( 'mw-email-authenticated',
$prefs['emailaddress']['cssclass'] );
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs