r106402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106401‎ | r106402 | r106403 >
Date:01:04, 16 December 2011
Author:rmoen
Status:ok (Comments)
Tags:
Comment:
removeing wikipedia specific language from tooltip, remove document.ready wrap on getUserInfo method & used in callback in inject method, change order of which moodbar is initialized so that mediawiki.util is available in init script. follow up to r105613
Modified paths:
  • /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.js (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 (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -71,8 +71,7 @@
7272 'moodbar-email-resend-confirmation' => 'Resend confirmation',
7373 'moodbar-email-optout' => 'No thanks',
7474 // MoodBar Tooltip
75 - 'moodbar-tooltip-title' => 'Let us know about your experience editing Wikipedia.',
76 - 'moodbar-tooltip-subtitle' => 'Your feedback about editing Wikipedia helps us make the site better.',
 75+ 'moodbar-tooltip-title' => 'Let us know about your experience editing {{SITENAME}}.',
7776 // Special:MoodBar
7877 'right-moodbar-view' => 'View and export MoodBar feedback',
7978 'right-moodbar-admin' => 'Alter visibility on the feedback dashboard',
@@ -260,7 +259,6 @@
261260 'moodbar-email-resend-confirmation' => "Button text for resending confirmation email. This message is used in {{msg-mw|Moodbar-email-confirm-desc}}, so if you're updating this message, update that one, too.",
262261 'moodbar-email-optout' => 'Button text for email opt-out',
263262 'moodbar-tooltip-title' => 'Text for title of moodbar tooltip',
264 - 'moodbar-tooltip-subtitle' => 'Text for subtitle of moodbar tooltip',
265263 'right-moodbar-view' => '{{doc-right|moodbar-view}}',
266264 'right-moodbar-admin' => '{{doc-right|moodbar-admin}}',
267265 'moodbar-header-timestamp' => '{{Identical|Timestamp}}',
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js
@@ -58,14 +58,14 @@
5959 .appendTo( ui.pMoodbar );
6060
6161 // Inject portlet into document, when document is ready
62 - $( mb.inject );
 62+ // Send mb.getUserInfo as a callback to be ran after MoodBar injection
 63+ $( mb.inject( mb.getUserInfo ) );
6364
64 - // Assign user props to mb.userData object.
65 - mb.getUserInfo();
6665 },
6766
68 - inject: function() {
 67+ inject: function(getUserInfo) {
6968 $( '#mw-head' ).append( mb.ui.pMoodbar );
 69+ getUserInfo(); //run the callback
7070 },
7171
7272 getUserInfo: function() {
@@ -75,21 +75,17 @@
7676 uiprop: 'email',
7777 format: 'json'
7878 };
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 -
 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+ } );
9490 }
9591
9692 };
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.css
@@ -27,7 +27,6 @@
2828 #moodbar-tooltip-overlay #moodbar-tooltip-title {
2929 font-weight: bold;
3030 font-size: 0.75em;
31 - margin-bottom: 10px;
3231 }
3332
3433 #moodbar-tooltip-overlay #moodbar-tooltip-subtitle {
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js
@@ -138,7 +138,7 @@
139139 emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1');
140140
141141 if( emailOptOut === false) {
142 - if(userData.email !== "") { //check for email address
 142+ if('email' in userData && userData.email !== "") { //check for email address
143143 if('emailauthenticated' in userData) { //they have confirmed
144144 mb.showSuccess();
145145 } else { //show email confirmation form
@@ -483,18 +483,18 @@
484484 validateFeedback: function() {
485485 var comment = $( '#mw-moodBar-feedbackInput' ).val();
486486 if( $.trim( comment ).length > 0 && comment.length <= 140 && $( '.mw-moodBar-selected').length ) {
487 - mb.ui.overlay.find( '.mw-moodBar-formSubmit').removeAttr('disabled');
 487+ mb.ui.overlay.find( '.mw-moodBar-formSubmit').prop('disabled', false);
488488 } else {
489 - mb.ui.overlay.find( '.mw-moodBar-formSubmit').attr({'disabled':'true'});
 489+ mb.ui.overlay.find( '.mw-moodBar-formSubmit').prop('disabled', true);
490490 }
491491 },
492492
493493 validateEmail: function() {
494494 var email = $( '#mw-moodBar-emailInput' ).val();
495495 if( $.trim( email ).length > 0) { //find validate email method
496 - mb.ui.overlay.find( '.mw-moodBar-emailSubmit').removeAttr('disabled');
 496+ mb.ui.overlay.find( '.mw-moodBar-emailSubmit').prop('disabled', false);
497497 } else {
498 - mb.ui.overlay.find( '.mw-moodBar-emailSubmit').attr({'disabled':'true'});
 498+ mb.ui.overlay.find( '.mw-moodBar-emailSubmit').prop('disabled', true);
499499 }
500500 }
501501
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.tooltip.js
@@ -39,9 +39,10 @@
4040 .append(
4141 $('<div>').attr('id', 'moodbar-tooltip-pointy')
4242 ).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' ) )
 43+ $('<div>').attr('id', 'moodbar-tooltip-title')
 44+ .text( mw.msg( 'moodbar-tooltip-title' )
 45+ .replace( new RegExp( $.escapeRE('{{SITENAME}}'), 'g' ), mw.config.get( 'wgSiteName' ) )
 46+ )
4647 )
4748 );
4849
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
@@ -33,9 +33,7 @@
3434 * Select all comment type filters.
3535 */
3636 function selectAllTypes() {
37 - $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() {
38 - $(this).prop( 'checked', true);
39 - });
 37+ $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).prop( 'checked', true);
4038 }
4139 /**
4240 * Set the moodbar-feedback-types and moodbar-feedback-username cookies based on formState.
@@ -546,9 +544,9 @@
547545 function validateResponse($item) {
548546 var response = $.trim( $item.find('.fbd-response-text').val() );
549547 if( response.length > 0 && response.length <= 5000 ) {
550 - $item.find( '.fbd-response-submit, .fbd-response-preview').removeAttr('disabled');
 548+ $item.find( '.fbd-response-submit, .fbd-response-preview').prop('disabled', false);
551549 } else {
552 - $item.find( '.fbd-response-submit, .fbd-response-preview').attr({'disabled':'true'});
 550+ $item.find( '.fbd-response-submit, .fbd-response-preview').prop('disabled', true);
553551 }
554552 }
555553
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -89,10 +89,11 @@
9090 'tooltip-p-moodbar-trigger-share',
9191 'tooltip-p-moodbar-trigger-editing',
9292 ),
93 - 'position' => 'top',
 93+ 'position' => 'bottom',
9494 'dependencies' => array(
9595 'jquery.cookie',
9696 'jquery.client',
 97+ 'mediawiki.util'
9798 ),
9899 );
99100
@@ -101,12 +102,10 @@
102103 'scripts' => 'ext.moodBar/ext.moodBar.tooltip.js',
103104 'messages' => array(
104105 'moodbar-tooltip-title',
105 - 'moodbar-tooltip-subtitle',
106106 ),
107 - 'position' => 'top',
 107+ 'position' => 'bottom',
108108 'dependencies' => array(
109109 'jquery.cookie',
110 - 'jquery.client',
111110 'ext.moodBar.init',
112111 ),
113112 );

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 Robmoen (talk | contribs)   01:07, 16 December 2011

Need to cleanup getUserInfo as it is asynchronous and not 100% reliable. Will most likely load user info in MoodBar config on page load due to other configs needed. Follow up to come.

#Comment by Nikerabbit (talk | contribs)   10:24, 16 December 2011

Splitting unrelated stuff into different commits help reviewing.

#Comment by Catrope (talk | contribs)   18:34, 22 December 2011
+	'moodbar-tooltip-title' => 'Let us know about your experience editing {{SITENAME}}.',

Are you sure this works correctly? moodbar-tooltip-title is used in JS, and {{SITENAME}} doesn't work in JS messages. From reading the code I'm 90% sure this is broken.

#Comment by Robmoen (talk | contribs)   18:38, 22 December 2011

This is working as i'm replacing SITENAME with .replace( new RegExp( $.escapeRE('MediaWiki'), 'g' ), mw.config.get( 'wgSiteName' ) )

Btw, how do you put text in the fancy box ?

#Comment by Catrope (talk | contribs)   18:40, 22 December 2011

The fancy box text is done with <pre> tags. Escaping things like {{SITENAME}} so they aren't expanded to MediaWiki is done with <nowiki> tags.

#Comment by Robmoen (talk | contribs)   18:40, 22 December 2011

OH,

 Pre tags 

 :)

Status & tagging log