r106831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106830‎ | r106831 | r106832 >
Date:18:39, 20 December 2011
Author:rmoen
Status:resolved (Comments)
Tags:
Comment:
remove asynchronous user data gathering on moodbar load, add preferences into javascript config, revise email prompt in moodbar. follow up to r105613
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -57,12 +57,12 @@
5858 * ResourceLoaderGetConfigVars hook
5959 */
6060 public static function resourceLoaderGetConfigVars( &$vars ) {
61 - global $wgMoodBarConfig, $wgUser;
 61+ global $wgMoodBarConfig, $wgUser, $wgEnableEmail;
6262 $vars['mbConfig'] = array(
6363 'validTypes' => MBFeedbackItem::getValidTypes(),
6464 'userBuckets' => MoodBarHooks::getUserBuckets( $wgUser ),
65 - 'canReceiveEmail' => $wgUser->canReceiveEmail() ,
66 - 'userEmail' => strlen($wgUser->getEmail()) > 0 ? true : false,
 65+ 'emailEnabled' => $wgEnableEmail,
 66+ 'userEmail' => strlen( $wgUser->getEmail() ) > 0 ? true : false,
6767 'isEmailConfirmationPending' => $wgUser->isEmailConfirmationPending() //returns false if email authentication off, and if email is confimed already
6868
6969 ) + $wgMoodBarConfig;
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js
@@ -58,36 +58,13 @@
5959 .appendTo( ui.pMoodbar );
6060
6161 // Inject portlet into document, when document is ready
62 - // Send mb.getUserInfo as a callback to be ran after MoodBar injection
63 - $( mb.inject( mb.getUserInfo ) );
 62+ $( mb.inject() );
6463
6564 },
6665
67 - inject: function(getUserInfo) {
 66+ inject: function() {
6867 $( '#mw-head' ).append( mb.ui.pMoodbar );
69 - getUserInfo(); //run the callback
70 - },
71 -
72 - getUserInfo: function() {
73 - var query = {
74 - action: 'query',
75 - meta: 'userinfo',
76 - uiprop: 'email',
77 - format: 'json'
78 - };
79 - $.ajax( {
80 - 'url': mw.util.wikiScript( 'api' ),
81 - 'data': query,
82 - 'success': function (data) {
83 - mb.userData = data.query.userinfo;
84 - },
85 - 'error': function( jqXHR, textStatus, errorThrown ) {
86 - mb.userData = null;
87 - },
88 - 'dataType': 'json'
89 - } );
9068 }
91 -
9269 };
9370
9471 if ( !mb.isDisabled() ) {
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js
@@ -134,20 +134,25 @@
135135 callback: function( data ) {
136136 if ( data && data.moodbar && data.moodbar.result === 'success' ) {
137137
138 - var userData = mb.userData,
139 - emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1');
 138+ var emailFlag,emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1');
140139
141 - if( emailOptOut === false) {
142 - if('email' in userData && userData.email !== "") { //check for email address
143 - if('emailauthenticated' in userData) { //they have confirmed
 140+ // if opt out cookie not set and if email is on globally, proceed with email prompt
 141+ if( emailOptOut === false && mb.conf.emailEnabled ) {
 142+
 143+ if( mb.conf.userEmail ) { // if user has email
 144+
 145+ if ( !mb.conf.isEmailConfirmationPending ) { // if no confirmation pending, show form.
144146 mb.showSuccess();
 147+
145148 } else { //show email confirmation form
146149 mb.swapContent ( mb.tpl.emailconfirmation );
147150 }
 151+
148152 } else { //no email, show email input form
149153 mb.swapContent( mb.tpl.emailinput );
150154 }
151 - } else { //user has email opt-out cookie set
 155+
 156+ } else { //user has email opt-out cookie set, or email is disabled
152157 mb.showSuccess();
153158 }
154159
@@ -173,12 +178,17 @@
174179 email: '',
175180 callback: function( data ) {
176181 mb.showSuccess();
 182+ //set email flag to true so we do not ask again on this page load.
 183+ mb.conf.userEmail = true;
 184+ mb.conf.isEmailConfirmationPending = true;
177185 }
178186 },
179187
180188 emailVerify: {
181189 callback: function ( data ) {
182190 mb.showSuccess();
 191+ //set conf pending flag to false so we do not ask again on this page load.
 192+ mb.conf.isEmailConfirmationPending = false;
183193 }
184194
185195 },

Follow-up revisions

RevisionCommit summaryAuthorDate
r107024prevent automatic injection of moodbar by removing parentheses, follow up to ...rmoen00:53, 22 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105613created moodbar user email input / confirm templates and js to post to new ap...rmoen23:43, 8 December 2011

Comments

#Comment by Krinkle (talk | contribs)   00:24, 22 December 2011

+			$( mb.inject() );

$( .. ) is a shortcut for jQuery( document ).ready( .. );. The way it's used now, the value undefined (instead of mb.inject) is added to the document ready queue. Remove the () if this is meant to execute at document ready. Otherwise remove the $( .. ) if you want it to execute right away (which it is doing already now, as it's calling it and passing the return value (undefined) to jQuery).

#Comment by Robmoen (talk | contribs)   00:55, 22 December 2011

Ahh yes, I accidentally left those in there =/ Thank you. follow up r107024

Status & tagging log