r105613 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105612‎ | r105613 | r105614 >
Date:23:43, 8 December 2011
Author:rmoen
Status:deferred (Comments)
Tags:
Comment:
created moodbar user email input / confirm templates and js to post to new api, frontend followup to rr105385. added moodbar tool tip module, moodbar status bubble icons
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.css (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)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.css (added) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.js (added) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/images/response-error.png (added) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/images/response-success.png (added) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/images/tooltip-pokey.png (added) (history)
  • /trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js
@@ -48,6 +48,42 @@
4949 success: fb.callback,
5050 dataType: 'json'
5151 } );
 52+ },
 53+
 54+ /* ajax method to set user email.
 55+ * called when user email address is not sent.
 56+ */
 57+ 'setEmail': function( mbProps ) {
 58+ var apiRequest = {
 59+ 'action': 'moodbarsetuseremail',
 60+ 'mbaction': 'setemail',
 61+ 'email': mbProps.email,
 62+ 'token': mw.config.get('mbEditToken'),
 63+ 'format':'json'
 64+ };
 65+ return $.ajax( {
 66+ type: 'post',
 67+ url: mw.util.wikiScript( 'api' ),
 68+ data: apiRequest,
 69+ success: mbProps.callback,
 70+ dataType: 'json'
 71+ } );
 72+ },
 73+
 74+ 'resendVerification': function (mbProps) {
 75+ var apiRequest = {
 76+ 'action': 'moodbarsetuseremail',
 77+ 'mbaction': 'resendverification',
 78+ 'token': mw.config.get('mbEditToken'),
 79+ 'format':'json'
 80+ };
 81+ return $.ajax( {
 82+ type: 'post',
 83+ url: mw.util.wikiScript( 'api' ),
 84+ data: apiRequest,
 85+ success: mbProps.callback,
 86+ dataType: 'json'
 87+ } );
5288 }
5389 };
5490 } ) ( jQuery );
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js
@@ -2,12 +2,14 @@
33 * Initialization script for the MoodBar MediaWiki extension
44 *
55 * @author Timo Tijhof, 2011
 6+ * @author Rob Moen, 2011
67 */
78 ( function( $ ) {
89
910 var mb = mw.moodBar = {
1011
11 - conf: mw.config.get( 'mbConfig' ),
 12+ conf: mw.config.get( 'mbConfig' ),
 13+ userData: {}, //set by getUserInfo
1214
1315 cookiePrefix: function() {
1416 return 'ext.moodBar@' + mb.conf.bucketConfig.version + '-';
@@ -54,13 +56,40 @@
5557 .wrap( '<p>' )
5658 .parent()
5759 .appendTo( ui.pMoodbar );
58 -
 60+
5961 // Inject portlet into document, when document is ready
6062 $( mb.inject );
 63+
 64+ // Assign user props to mb.userData object.
 65+ mb.getUserInfo();
6166 },
6267
6368 inject: function() {
6469 $( '#mw-head' ).append( mb.ui.pMoodbar );
 70+ },
 71+
 72+ getUserInfo: function() {
 73+ var query = {
 74+ action: 'query',
 75+ meta: 'userinfo',
 76+ uiprop: 'email',
 77+ format: 'json'
 78+ };
 79+ $(document).ready( function() {
 80+ $.ajax( {
 81+ 'type': 'POST',
 82+ 'url': mw.util.wikiScript( 'api' ),
 83+ 'data': query,
 84+ 'success': function (data) {
 85+ mb.userData = data.query.userinfo;
 86+ },
 87+ 'error': function( jqXHR, textStatus, errorThrown ) {
 88+ mb.userData = null;
 89+ },
 90+ 'dataType': 'json'
 91+ } );
 92+ });
 93+
6594 }
6695
6796 };
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.css
@@ -96,7 +96,7 @@
9797 }
9898
9999 .mw-moodBar-feedback-invalid {
100 - border:2px solid #CC0000;
 100+ border: 2px solid #CC0000;
101101 }
102102
103103 .mw-moodBar-privacy,
@@ -123,6 +123,20 @@
124124 height: 77px;
125125 }
126126
 127+.mw-moodBar-state-success {
 128+ /* @embed */
 129+ background: url(images/response-success.png) left center no-repeat;
 130+ padding: 20px 0 0 90px;
 131+ height: 77px;
 132+}
 133+
 134+.mw-moodBar-state-error {
 135+ /* @embed */
 136+ background: url(images/response-error.png) left center no-repeat;
 137+ padding: 20px 0 0 90px;
 138+ height: 77px;
 139+}
 140+
127141 .mw-moodBar-state-title {
128142 font-weight: bold;
129143 font-size: 25px;
@@ -133,11 +147,18 @@
134148 color: #7e7e7e;
135149 }
136150
 151+.mw-moodBar-desc {
 152+ font-size: .8em;
 153+ padding: 1em;
 154+}
 155+
137156 .red-bold {
138 - font-weight:bold;
139 - color:#CC0000;
 157+ font-weight: bold;
 158+ color: #CC0000;
140159 }
141160
 161+
 162+
142163 /**
143164 * Types
144165 */
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.css
@@ -0,0 +1,35 @@
 2+#moodbar-tooltip-overlay-wrap {
 3+ width: 285px;
 4+ position: absolute;
 5+ left: 12.5em;
 6+ top: 2.5em;
 7+ background: #ff9933;
 8+ padding: 2px;
 9+}
 10+
 11+#moodbar-tooltip-pointy {
 12+ position: absolute;
 13+ top: -15px;
 14+ left: 15px;
 15+ /* @embed */
 16+ background: url(images/tooltip-pokey.png);
 17+ background-repeat: no-repeat;
 18+ background-position: left;
 19+ height: 17px;
 20+ width: 15px;
 21+}
 22+
 23+#moodbar-tooltip-overlay {
 24+ background: #fefac6;
 25+ padding: 10px;
 26+}
 27+
 28+#moodbar-tooltip-overlay #moodbar-tooltip-title {
 29+ font-weight: bold;
 30+ font-size: 0.75em;
 31+ margin-bottom: 10px;
 32+}
 33+
 34+#moodbar-tooltip-overlay #moodbar-tooltip-subtitle {
 35+ font-size: 0.7em;
 36+}
\ No newline at end of file
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js
@@ -2,13 +2,15 @@
33 * Front-end scripting core for the MoodBar MediaWiki extension
44 *
55 * @author Timo Tijhof, 2011
 6+ * @author Rob Moen, 2011
67 */
 8+
79 ( function( $ ) {
810
911 var mb = mw.moodBar;
1012 $.extend( mb, {
1113
12 - tpl: {
 14+ tpl: {
1315 overlayBase: '\
1416 <div id="mw-moodBar-overlayWrap"><div id="mw-moodBar-overlay">\
1517 <div id="mw-moodBar-pokey"></div>\
@@ -38,6 +40,30 @@
3941 </a>\
4042 <div class="mw-moodBar-overlayWhatContent"></div>\
4143 </span>',
 44+ emailinput: '\
 45+ <div class="mw-moodBar-overlayTitle"><span><html:msg key="moodbar-email-title" /></span></div>\
 46+ <div class="mw-moodBar-form">\
 47+ <div class="mw-moodBar-desc">\
 48+ <html:msg key="moodbar-email-desc" />\
 49+ </div>\
 50+ <div class="mw-moodBar-formInputs">\
 51+ <html:msg key="moodbar-email-input" />\
 52+ <input type="text" id="mw-moodBar-emailInput" class="mw-moodBar-emailInput" />\
 53+ <input type="button" class="mw-moodBar-emailSubmit" disabled="disabled" />\
 54+ <input type="button" class="mw-moodBar-emailOptOut" />\
 55+ </div>\
 56+ </div>',
 57+ emailconfirmation: '\
 58+ <div class="mw-moodBar-overlayTitle"><span><html:msg key="moodbar-email-confirm-title" /></span></div>\
 59+ <div class="mw-moodBar-form">\
 60+ <div class="mw-moodBar-desc">\
 61+ <html:msg key="moodbar-email-confirm-desc" />\
 62+ </div>\
 63+ <div class="mw-moodBar-formInputs">\
 64+ <input type="button" class="mw-moodBar-emailConfirm" />\
 65+ <input type="button" class="mw-moodBar-emailOptOut" />\
 66+ </div>\
 67+ </div>',
4268 type: '\
4369 <span class="mw-moodBar-type mw-moodBar-type-$1" rel="$1">\
4470 <span class="mw-moodBar-typeTitle"><html:msg key="moodbar-type-$1-title" /></span>\
@@ -47,6 +73,11 @@
4874 <div class="mw-moodBar-state-title"><html:msg key="moodbar-loading-title" /></div>\
4975 <div class="mw-moodBar-state-subtitle"><html:msg key="moodbar-loading-subtitle" /></div>\
5076 </div>',
 77+ updatingEmail: '\
 78+ <div class="mw-moodBar-state mw-moodBar-state-loading">\
 79+ <div class="mw-moodBar-state-title"><html:msg key="moodbar-updating-title" /></div>\
 80+ <div class="mw-moodBar-state-subtitle"><html:msg key="moodbar-updating-subtitle" /></div>\
 81+ </div>',
5182 success: '\
5283 <div class="mw-moodBar-state mw-moodBar-state-success">\
5384 <div class="mw-moodBar-state-title"><html:msg key="moodbar-success-title" /></div>\
@@ -70,6 +101,7 @@
71102 if ( mb.ui.overlay.is( ':hidden' ) ) {
72103 mb.swapContent( mb.tpl.userinput );
73104 mb.ui.overlay.show();
 105+ mb.ui.tooltip.hide();
74106 } else {
75107 mb.ui.overlay.hide();
76108 }
@@ -84,6 +116,14 @@
85117 );
86118 mb.ui.overlay.fadeOut( 'fast' );
87119 mb.ui.trigger.fadeOut( 'fast' );
 120+ },
 121+
 122+ emailOptOut: function( e ) {
 123+ $.cookie(
 124+ mb.cookiePrefix() + 'emailOptOut',
 125+ '1',
 126+ { 'path': '/', 'expires': Number( mb.conf.disableExpiration ) }
 127+ );
88128 }
89129 },
90130
@@ -93,10 +133,24 @@
94134 type: 'unknown',
95135 callback: function( data ) {
96136 if ( data && data.moodbar && data.moodbar.result === 'success' ) {
97 - mb.swapContent( mb.tpl.success );
98 - setTimeout( function() {
99 - mb.ui.overlay.fadeOut();
100 - }, 3000 );
 137+
 138+ var userData = mb.userData,
 139+ emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1');
 140+
 141+ if( emailOptOut === false) {
 142+ if(userData.email !== "") { //check for email address
 143+ if('emailauthenticated' in userData) { //they have confirmed
 144+ mb.showSuccess();
 145+ } else { //show email confirmation form
 146+ mb.swapContent ( mb.tpl.emailconfirmation );
 147+ }
 148+ } else { //no email, show email input form
 149+ mb.swapContent( mb.tpl.emailinput );
 150+ }
 151+ } else { //user has email opt-out cookie set
 152+ mb.showSuccess();
 153+ }
 154+
101155 } else if (data && data.error && data.error.code === 'blocked') {
102156 mb.swapContent( mb.tpl.blocked );
103157 setTimeout( function() {
@@ -108,6 +162,27 @@
109163 }
110164 },
111165
 166+ showSuccess: function() {
 167+ mb.swapContent( mb.tpl.success );
 168+ setTimeout( function() {
 169+ mb.ui.overlay.fadeOut();
 170+ }, 3000 );
 171+ },
 172+
 173+ emailInput: {
 174+ email: '',
 175+ callback: function( data ) {
 176+ mb.showSuccess();
 177+ }
 178+ },
 179+
 180+ emailVerify: {
 181+ callback: function ( data ) {
 182+ mb.showSuccess();
 183+ }
 184+
 185+ },
 186+
112187 prepareUserinputContent: function( overlay ) {
113188 overlay
114189 // Populate type selector
@@ -125,7 +200,7 @@
126201 $mwMoodBarTypes.addClass( 'mw-moodBar-types-select' );
127202 mb.feedbackItem.type = $el.attr( 'rel' );
128203 $el.addClass( 'mw-moodBar-selected' )
129 - .addClass( 'mw-moodBar-' + mb.feedbackItem.type + '-selected' );
 204+ .addClass( 'mw-moodBar-' + mb.feedbackItem.type + '-selected' );
130205 $el.parent()
131206 .find( '.mw-moodBar-selected' )
132207 .not( $el )
@@ -133,7 +208,7 @@
134209 .removeClass( 'mw-moodBar-happy-selected' )
135210 .removeClass( 'mw-moodBar-sad-selected' )
136211 .removeClass( 'mw-moodBar-confused-selected' );
137 - mb.validate();
 212+ mb.validateFeedback();
138213 } )
139214 .get( 0 )
140215 );
@@ -252,7 +327,7 @@
253328 // Keypress
254329 .find( '#mw-moodBar-feedbackInput' )
255330 .keyup( function(event) {
256 - mb.validate();
 331+ mb.validateFeedback();
257332 })
258333 .end();
259334
@@ -278,6 +353,51 @@
279354 });
280355 },
281356
 357+ prepareEmailInput: function ( overlay ) {
 358+ overlay
 359+ .find('#mw-moodBar-emailInput')
 360+ .keyup(function(event){
 361+ mb.validateEmail();
 362+ })
 363+ .end()
 364+ .find('.mw-moodBar-emailOptOut')
 365+ .val ( mw.msg ( 'moodbar-email-optout' ) )
 366+ .click (function(event) {
 367+ //set cookie to prevent this from coming back
 368+ mb.event.emailOptOut();
 369+ mb.showSuccess();
 370+ })
 371+ .end()
 372+ .find('.mw-moodBar-emailSubmit')
 373+ .val( mw.msg( 'moodbar-email-submit' ) )
 374+ .click( function( event ) {
 375+ //set the email address in the userdata to prevent email form on same page view
 376+ mb.userData.email = mb.emailInput.email = overlay.find('#mw-moodBar-emailInput').val();
 377+ mb.swapContent( mb.tpl.updatingEmail );
 378+ $.moodBar.setEmail (mb.emailInput);
 379+ });
 380+
 381+ },
 382+
 383+ prepareEmailVerification: function ( overlay ) {
 384+ overlay
 385+ .find( '.mw-moodBar-emailConfirm' )
 386+ .val( mw.msg ( 'moodbar-email-resend-confirmation' ) )
 387+ .click ( function() {
 388+ mb.swapContent( mb.tpl.updatingEmail );
 389+ $.moodBar.resendVerification( mb.emailVerify );
 390+ })
 391+ .end()
 392+ .find( '.mw-moodBar-emailOptOut' )
 393+ .val( mw.msg ( 'moodbar-email-optout' ) )
 394+ .click( function ( event ) {
 395+ //set cookie to prevent this from coming back
 396+ mb.event.emailOptOut();
 397+ mb.showSuccess();
 398+ });
 399+
 400+ },
 401+
282402 core: function() {
283403
284404 // Create overlay
@@ -336,17 +456,33 @@
337457 if ( tpl == mb.tpl.userinput ) {
338458 mb.prepareUserinputContent( mb.ui.overlay );
339459 }
 460+ if ( tpl == mb.tpl.emailinput ) {
 461+ mb.prepareEmailInput ( mb.ui.overlay );
 462+ }
 463+ if (tpl == mb.tpl.emailconfirmation) {
 464+ mb.prepareEmailVerification ( mb.ui.overlay );
 465+ }
340466 return true;
341467 },
342468
343 - validate: function() {
 469+ validateFeedback: function() {
344470 var comment = $( '#mw-moodBar-feedbackInput' ).val();
345471 if( $.trim( comment ).length > 0 && comment.length <= 140 && $( '.mw-moodBar-selected').length ) {
346472 mb.ui.overlay.find( '.mw-moodBar-formSubmit').removeAttr('disabled');
347473 } else {
348474 mb.ui.overlay.find( '.mw-moodBar-formSubmit').attr({'disabled':'true'});
349475 }
 476+ },
 477+
 478+ validateEmail: function() {
 479+ var email = $( '#mw-moodBar-emailInput' ).val();
 480+ if( $.trim( email ).length > 0) { //find validate email method
 481+ mb.ui.overlay.find( '.mw-moodBar-emailSubmit').removeAttr('disabled');
 482+ } else {
 483+ mb.ui.overlay.find( '.mw-moodBar-emailSubmit').attr({'disabled':'true'});
 484+ }
350485 }
 486+
351487 } );
352488
353489 if ( !mb.isDisabled() ) {
Index: trunk/extensions/MoodBar/modules/ext.moodBar/images/tooltip-pokey.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar/images/tooltip-pokey.png
___________________________________________________________________
Added: svn:mime-type
354490 + application/octet-stream
Index: trunk/extensions/MoodBar/modules/ext.moodBar/images/response-error.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar/images/response-error.png
___________________________________________________________________
Added: svn:mime-type
355491 + application/octet-stream
Index: trunk/extensions/MoodBar/modules/ext.moodBar/images/response-success.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar/images/response-success.png
___________________________________________________________________
Added: svn:mime-type
356492 + application/octet-stream
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.js
@@ -0,0 +1,52 @@
 2+/**
 3+ * Script for the MoodBar ToolTip
 4+ *
 5+ * @author Rob Moen, 2011
 6+ */
 7+jQuery( document ).ready( function( $ ) {
 8+
 9+ var mb = mw.moodBar;
 10+
 11+ $.extend( mb.ui, {
 12+ tooltip: null,
 13+
 14+ // returns true if cookie is not set, otherwise returns false
 15+ shouldShow: function() {
 16+
 17+ shown = ( $.cookie( mb.cookiePrefix() + 'tooltip' ) == '1' ); // has this been shown ?
 18+ if ( !shown ) {
 19+ return true;
 20+ }
 21+ return false;
 22+
 23+ },
 24+
 25+ showTooltip: function () {
 26+ //set tooltip cookie
 27+ $.cookie( mb.cookiePrefix() + 'tooltip', '1', { 'path': '/', 'expires': Number( mb.conf.disableExpiration ) } );
 28+ $( '#mw-head' ).append( mb.ui.tooltip ); // attach tooltip
 29+ setTimeout( function() {
 30+ mb.ui.tooltip.fadeOut();
 31+ }, 4000 );
 32+ }
 33+
 34+ } );
 35+
 36+ // Build Tooltip
 37+ mb.ui.tooltip = $('<div>').attr('id', 'moodbar-tooltip-overlay-wrap')
 38+ .append(
 39+ $('<div>').attr('id', 'moodbar-tooltip-overlay')
 40+ .append(
 41+ $('<div>').attr('id', 'moodbar-tooltip-pointy')
 42+ ).append(
 43+ $('<div>').attr('id', 'moodbar-tooltip-title').text( mw.msg( 'moodbar-tooltip-title' ) )
 44+ ).append(
 45+ $('<div>').attr('id', 'moodbar-tooltip-subtitle').text( mw.msg( 'moodbar-tooltip-subtitle' ) )
 46+ )
 47+ );
 48+
 49+ if ( !mb.isDisabled() && mb.ui.shouldShow()) {
 50+ mb.ui.showTooltip();
 51+ }
 52+
 53+} );
\ No newline at end of file
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css
@@ -343,6 +343,6 @@
344344 text-align:center;
345345 }
346346 .red-bold {
347 - font-weight:bold;
348 - color:#CC0000;
 347+ font-weight: bold;
 348+ color: #CC0000;
349349 }
\ No newline at end of file
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
@@ -30,6 +30,14 @@
3131 }
3232
3333 /**
 34+ * Select all comment type filters.
 35+ */
 36+ function selectAllTypes() {
 37+ $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() {
 38+ $(this).prop( 'checked', true);
 39+ });
 40+ }
 41+ /**
3442 * Set the moodbar-feedback-types and moodbar-feedback-username cookies based on formState.
3543 * This function uses the form state saved in formState, so you may want to call saveFormState() first.
3644 */
@@ -57,6 +65,8 @@
5866 changed = true;
5967 }
6068 } );
 69+ } else {
 70+ selectAllTypes();
6171 }
6272 return changed;
6373 }
@@ -262,7 +272,7 @@
263273 .append( $('<button>').attr('class', 'fbd-action-cancel').text( mw.msg('moodbar-feedback-action-cancel')) )
264274 .append( $('<span>').attr('class', 'fbd-item-reason-msg') )
265275 .append( $('<div>').attr('class', 'fbd-item-reason-msg') );
266 -
 276+
267277 var storedParams = params;
268278 var $storedItem = $item;
269279
@@ -388,7 +398,7 @@
389399 'target': '_new'
390400 }, mw.msg( 'moodbar-response-link' ) );
391401
392 - //ULA
 402+ //ULA
393403 var ula = mw.msg( 'moodbar-response-terms' )
394404 .replace ( /\$1/g, termsLink );
395405
@@ -643,6 +653,13 @@
644654 loadComments( 'more' );
645655 } );
646656
 657+ $( '#fbd-filters-types input[type=checkbox]' ).click( function() {
 658+ var types = getSelectedTypes();
 659+ if(types.length === 0) { //check for 0 because onclick it will already have unchecked itself.
 660+ $(this).prop('checked', true);
 661+ }
 662+ });
 663+
647664 saveFormState();
648665 var filterType = $( '#fbd-filters' ).children( 'form' ).data( 'filtertype' );
649666 // If filtering already happened on the PHP side, don't load the form state from cookies
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -91,6 +91,21 @@
9292 ),
9393 );
9494
 95+$wgResourceModules['ext.moodBar.tooltip'] = $mbResourceTemplate + array(
 96+ 'styles' => 'ext.moodBar/ext.moodBar.tooltip.css',
 97+ 'scripts' => 'ext.moodBar/ext.moodBar.tooltip.js',
 98+ 'messages' => array(
 99+ 'moodbar-tooltip-title',
 100+ 'moodbar-tooltip-subtitle',
 101+ ),
 102+ 'position' => 'top',
 103+ 'dependencies' => array(
 104+ 'jquery.cookie',
 105+ 'jquery.client',
 106+ 'ext.moodBar.init',
 107+ ),
 108+);
 109+
95110 $oldVersion = version_compare( $wgVersion, '1.17', '<=' );
96111
97112 if ( !$oldVersion ) {
@@ -137,6 +152,16 @@
138153 'moodbar-success-subtitle',
139154 'moodbar-blocked-title',
140155 'moodbar-blocked-subtitle',
 156+ 'moodbar-email-title',
 157+ 'moodbar-email-input',
 158+ 'moodbar-email-desc',
 159+ 'moodbar-email-submit',
 160+ 'moodbar-updating-title',
 161+ 'moodbar-updating-subtitle',
 162+ 'moodbar-email-confirm-title',
 163+ 'moodbar-email-confirm-desc',
 164+ 'moodbar-email-resend-confirmation',
 165+ 'moodbar-email-optout',
141166 ),
142167 'dependencies' => array(
143168 'mediawiki.util',
@@ -222,4 +247,4 @@
223248 'infoUrl' => 'http://www.mediawiki.org/wiki/MoodBar',
224249 'privacyUrl' => 'about:blank',
225250 'disableExpiration' => 365,
226 -);
 251+);
\ No newline at end of file
Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -59,6 +59,19 @@
6060 'moodbar-error-subtitle' => 'Something went wrong! Please try sharing your feedback again later.',
6161 'moodbar-blocked-title' => 'Blocked!',
6262 'moodbar-blocked-subtitle' => 'You have been blocked from editing.',
 63+ 'moodbar-email-title' => 'Receive Notifications?',
 64+ 'moodbar-email-input' => 'Your email address',
 65+ 'moodbar-email-desc' => 'Please enter your email address to receive notifications regarding responses to your feedback.',
 66+ 'moodbar-email-submit' => 'Update',
 67+ 'moodbar-updating-title' => 'Updating...',
 68+ 'moodbar-updating-subtitle' => 'We are updating your email settings.',
 69+ 'moodbar-email-confirm-title' => 'Email Confirmation?',
 70+ 'moodbar-email-confirm-desc' => 'In order to receive notifications regarding responses to your feedback, you must confirm your email address. To resend the confirmation email, click the "Resend Confirmation" button.',
 71+ 'moodbar-email-resend-confirmation' => 'Resend Confirmation',
 72+ 'moodbar-email-optout' => 'No Thanks',
 73+ // MoodBar Tooltip
 74+ 'moodbar-tooltip-title' => 'Are you sad, happy, or confused about editing Wikipedia?',
 75+ 'moodbar-tooltip-subtitle' => 'Your feedback about editing Wikipedia helps us make the site better.',
6376 // Special:MoodBar
6477 'right-moodbar-view' => 'View and export MoodBar feedback',
6578 'right-moodbar-admin' => 'Alter visibility on the feedback dashboard',
@@ -214,6 +227,19 @@
215228 'moodbar-error-subtitle' => 'Subtitle of screen when an error occurred. $1 is the SITENAME',
216229 'moodbar-blocked-title' => 'Title of the screen after blocked user attempts to post feedback.',
217230 'moodbar-blocked-subtitle' => 'Subtitle of screen after blocked user attempts to post feedback.',
 231+ 'moodbar-email-title' => 'Title of MoodBar when user has no email addresss',
 232+ 'moodbar-email-input' => 'Field label for Email address',
 233+ 'moodbar-email-desc' => 'Message prompting user to enter their email address.',
 234+ 'moodbar-email-submit' => 'Button text for updating email address',
 235+ 'moodbar-updating-title' => 'Title for MoodBar when updating email address and requesting confirmation',
 236+ 'moodbar-updating-subtitle' => 'Subtitle for MoodBar when updating email address and requesting confirmation',
 237+ 'moodbar-email-confirm-title' => 'Title of moodbar when email address has not been confirmed',
 238+ 'moodbar-email-confirm-desc' => 'Subtitle of moodBar when email address has not been confirmed.',
 239+ 'moodbar-email-resend-confirmation' => 'Button text for resnding confirmation email',
 240+ 'moodbar-email-optout' => 'Button text for email opt-out',
 241+ //MoodBar Tooltip
 242+ 'moodbar-tooltip-title' => 'Text for title of moodbar tooltip',
 243+ 'moodbar-tooltip-subtitle' => 'Text for subtitle of moodbar tooltip',
218244 'right-moodbar-view' => '{{doc-right|moodbar-view}}',
219245 'right-moodbar-admin' => '{{doc-right|moodbar-admin}}',
220246 'moodbar-header-timestamp' => '{{Identical|Timestamp}}',
Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -7,9 +7,10 @@
88 * @param $output OutputPage
99 * @param $skin Skin
1010 */
 11+
1112 public static function onPageDisplay( &$output, &$skin ) {
1213 if ( self::shouldShowMoodbar( $output, $skin ) ) {
13 - $output->addModules( array( 'ext.moodBar.init', 'ext.moodBar.core' ) );
 14+ $output->addModules( array( 'ext.moodBar.init', 'ext.moodBar.tooltip', 'ext.moodBar.core' ) );
1415 }
1516
1617 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r105624Fix image mime-types from r105613reedy00:00, 9 December 2011
r105667Consistency tweaks for r105613raymond12:11, 9 December 2011
r106402removeing wikipedia specific language from tooltip, remove document.ready wra...rmoen01:04, 16 December 2011
r106453un-hardcoded sitename from dashboard description followup r105613rmoen18:17, 16 December 2011
r106831remove asynchronous user data gathering on moodbar load, add preferences into...rmoen18:39, 20 December 2011

Comments

#Comment by Catrope (talk | contribs)   21:07, 14 December 2011
+			$(document).ready( function() {
+				$.ajax( {
+					'type': 'POST',
+					'url': mw.util.wikiScript( 'api' ),
+					'data': query,
+					'success': function (data) {
+						mb.userData = data.query.userinfo;
+					},
+					'error': function( jqXHR, textStatus, errorThrown ) {
+						mb.userData = null;
+					},
+					'dataType': 'json'
+				} );
+			});

Why is this AJAX call in a document ready wrapper? I mean I'm sure it's har

#Comment by Catrope (talk | contribs)   21:07, 14 December 2011
+			$(document).ready( function() {
+				$.ajax( {
+					'type': 'POST',
+					'url': mw.util.wikiScript( 'api' ),
+					'data': query,
+					'success': function (data) {
+						mb.userData = data.query.userinfo;
+					},
+					'error': function( jqXHR, textStatus, errorThrown ) {
+						mb.userData = null;
+					},
+					'dataType': 'json'
+				} );
+			});

Why is this AJAX call in a document ready wrapper? I mean I'm sure it's harmless, but it looks strange to me.

#Comment by Krinkle (talk | contribs)   21:37, 14 December 2011
+	'moodbar-tooltip-title' => 'Are you sad, happy, or confused about editing Wikipedia?',
+	'moodbar-tooltip-subtitle' => 'Your feedback about editing Wikipedia helps us make the site better.',

Don't hardcode anything Wikipedia specific, or Wikimedia specific in general (Wikimedia has other projects as well, not to mention use by third-parties). Use {{SITENAME}}. This means in JavaScript it will likely need to be replaced manually with a regexp as this is not done by default yet. (a simple .replace( new RegExp( $.escapeRE('MediaWiki'), 'g' ), mw.config.get( 'wgSiteName' ) ); will do the trick.

+		$( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() {
+			$(this).prop( 'checked', true);
+		});

No need for .each(). All jQuery methods (except for very few) always run on the entire jQuery collection. No need to create a new jQuery collection for this and then run .prop()( when loops over the single-item collection). The following is how jQuery prototype is intended:

	$( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).prop( 'checked', true);
+				mb.ui.overlay.find( '.mw-moodBar-emailSubmit').removeAttr('disabled');
+			} else {
+				mb.ui.overlay.find( '.mw-moodBar-emailSubmit').attr({'disabled':'true'});		

Initial states are set by the "disabled" attribute, but the interactive state should be triggered by manipulating the property directly, not the attribtue. Use .prop( 'disabled', false ); and .prop( 'disabled', true ); respectively (which sets element.disabled = ..; property, as supposed element.setAttribute( 'disabled', .. );



+++ trunk/extensions/MoodBar/MoodBar.php	(revision 105613)
@@ -91,6 +91,21 @@
 	),
 );
 
+$wgResourceModules['ext.moodBar.tooltip'] = $mbResourceTemplate + array(

+	'dependencies' => array(

+		'jquery.client',
+	),

jQuery.client doesn't appear to be used by ext.moodBar.tooltip.

Roan already touched this area:

+++ trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js	(revision 105613)

 	var mb = mw.moodBar = {

+		userData: {}, //set by getUserInfo

@@ -54,13 +56,40 @@
+			// Assign user props to mb.userData object.
+			mb.getUserInfo();
 		},

+		getUserInfo: function() {
+			var query = {
+				action: 'query',
+				meta: 'userinfo',
+				uiprop: 'email',
+				format: 'json'
+			};
+			$(document).ready( function() {
+				$.ajax( {
+					'type': 'POST',
+					'url': mw.util.wikiScript( 'api' ),
+					'data': query,
+					'success': function (data) {
+						mb.userData = data.query.userinfo;
+					},
+					'error': function( jqXHR, textStatus, errorThrown ) {
+						mb.userData = null;
+					},
+					'dataType': 'json'
+				} );
+			});
+			

ApiQueryUserInfo is't a POST module. and userData appears unused. Wherever it would be used, it would probably risk being not defined yet. Since getuserInfo is delayed asynchronously by both document-ready and the AJAX-request, it's hard impossibly to reliably use mw.moodBar.userData.

Should probably take a callback as argument and cache it in a local variable for immediate callback-calling if already fetched.

#Comment by Robmoen (talk | contribs)   01:10, 16 December 2011

Thanks for the review. I've followed up with r105613 which addresses most of this.

#Comment by Robmoen (talk | contribs)   23:06, 28 December 2011

All remaining items addressed. Code is deployed. Please follow ups.

Status & tagging log