r86442 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86441‎ | r86442 | r86443 >
Date:23:11, 19 April 2011
Author:krinkle
Status:deferred
Tags:
Comment:
Start of EmailCapture front-end
* Committing initial work
* TODO: Server side processing (to be linked in .submit / .load)
** action=articlefeedback: extraction from request, address validation, storage, etc.)
** list=articlefeedback: include helpimprove on the return
Modified paths:
  • /trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php
@@ -66,6 +66,11 @@
6767 'articlefeedback-form-panel-expertise-profession',
6868 'articlefeedback-form-panel-expertise-hobby',
6969 'articlefeedback-form-panel-expertise-other',
 70+ 'articlefeedback-form-panel-helpimprove',
 71+ 'articlefeedback-form-panel-helpimprove-note',
 72+ 'articlefeedback-form-panel-helpimprove-email-placeholder',
 73+ 'articlefeedback-form-panel-helpimprove-privacy',
 74+ 'articlefeedback-form-panel-helpimprove-privacylink',
7075 'articlefeedback-form-panel-submit',
7176 'articlefeedback-form-panel-success',
7277 'articlefeedback-form-panel-expiry-title',
@@ -75,6 +80,9 @@
7681 'articlefeedback-report-panel-description',
7782 'articlefeedback-report-empty',
7883 'articlefeedback-report-ratings',
 84+ 'parentheses',
 85+ 'email-address-validity-valid',
 86+ 'email-address-validity-invalid',
7987 ),
8088 'dependencies' => array(
8189 'jquery.tipsy',
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -19,6 +19,27 @@
2020 }
2121
2222 /**
 23+ * Given an email sting, gets validity status (true, false, null) and updates the label CSS class
 24+ */
 25+var updateMailValidityLabel = function( mail, context ) {
 26+ var isValid = mw.util.validateEmail( mail ),
 27+ $label = context.$ui.find( '.articleFeedback-helpimprove-email-validity' );
 28+
 29+ // We allow empty address
 30+ if( isValid === null ) {
 31+ $label.text( '' ).removeClass( 'valid invalid' );
 32+
 33+ // Valid
 34+ } else if ( isValid ) {
 35+ $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
 36+
 37+ // Not valid
 38+ } else {
 39+ $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
 40+ }
 41+};
 42+
 43+/**
2344 * Article Feedback jQuery Plugin Support Code
2445 */
2546 $.articleFeedback = {
@@ -44,6 +65,14 @@
4566 <div><input type="checkbox" value="other" /><label><html:msg key="form-panel-expertise-other" /></label></div>\
4667 </div>\
4768 </div>\
 69+ <div style="clear:both;"></div>\
 70+ <div class="articleFeedback-helpimprove articleFeedback-visibleWith-form" >\
 71+ <input type="checkbox" value="on" disabled="disabled" /><label class="articleFeedback-helpimprove-disabled"><html:msg key="form-panel-helpimprove" /></label>\
 72+ <div class="articleFeedback-helpimprove-options">\
 73+ <div><input type="text" placeholder="" class="articleFeedback-helpimprove-email" /></div>\
 74+ <div class="articleFeedback-helpimprove-note"></div>\
 75+ </div>\
 76+ </div>\
4877 <button class="articleFeedback-submit articleFeedback-visibleWith-form" type="submit" disabled><html:msg key="form-panel-submit" /></button>\
4978 <div class="articleFeedback-success articleFeedback-visibleWith-form"><span><html:msg key="form-panel-success" /></span></div>\
5079 <div style="clear:both;"></div>\
@@ -134,6 +163,14 @@
135164 .find( '.articleFeedback-expertise-disabled' )
136165 .removeClass( 'articleFeedback-expertise-disabled' );
137166 },
 167+ 'enableHelpimprove': function( $helpimprove ) {
 168+ $helpimprove
 169+ .find( 'input:checkbox[value=on]' )
 170+ .attr( 'disabled', false )
 171+ .end()
 172+ .find( '.articleFeedback-helpimprove-disabled' )
 173+ .removeClass( 'articleFeedback-helpimprove-disabled' );
 174+ },
138175 'submit': function() {
139176 var context = this;
140177 $.articleFeedback.fn.enableSubmission.call( context, false );
@@ -257,6 +294,29 @@
258295 .find( '.articleFeedback-expertise-options' )
259296 .hide();
260297 }
 298+
 299+ // Help improve
 300+ var $helpimprove = context.$ui.find( '.articleFeedback-helpimprove' );
 301+ // @FIXME: Needs serverside handling to actually pass this
 302+ feedback.helpimprove = 'on test@example.org';
 303+ if ( typeof feedback.helpimprove === 'string' ) {
 304+ var tags = feedback.helpimprove.split( ' ', 2 );
 305+ if ( tags.length == 2 && tags[0] == 'on' ) {
 306+ $helpimprove.find( 'input:checkbox[value=on]' ).attr( 'checked', 'checked' );
 307+ $helpimprove.find( '.articleFeedback-helpimprove-email' ).val( tags[1] );
 308+ // IE7 seriously has issues, and we have to hide, then show
 309+ $helpimprove.find( '.articleFeedback-helpimprove-options' )
 310+ .hide().show();
 311+ $.articleFeedback.fn.enableHelpimprove( $helpimprove );
 312+ }
 313+ } else {
 314+ $helpimprove
 315+ .find( 'input:checkbox' )
 316+ .removeAttr( 'checked' )
 317+ .end()
 318+ .find( '.articleFeedback-helpimprove-options' )
 319+ .hide();
 320+ }
261321
262322 // Index rating data by rating ID
263323 var ratings = {};
@@ -308,7 +368,7 @@
309369 $(this).find( 'input:hidden' ).val( rating.userrating );
310370 if ( rating.userrating > 0 ) {
311371 // If any ratings exist, make sure expertise is enabled so users can
312 - // suppliment their ratings with expertise information
 372+ // supplement their ratings with expertise information
313373 $.articleFeedback.fn.enableExpertise( $expertise );
314374 }
315375 } else {
@@ -435,6 +495,37 @@
436496 }
437497 } )
438498 .end()
 499+ .find( '.articleFeedback-helpimprove' )
 500+ .find( '.articleFeedback-helpimprove-note' )
 501+ // Can't use .text() with mw.message(, /* $1 */ link).toString(),
 502+ // because 'link' should not be re-escaped (which would happen if done by mw.message)
 503+ .html( function(){
 504+ var link = mw.html.element(
 505+ 'a', {
 506+ href: mw.util.wikiGetlink( mw.msg('articlefeedback-form-panel-helpimprove-privacylink') )
 507+ }, mw.msg('articlefeedback-form-panel-helpimprove-privacy')
 508+ );
 509+ return mw.html.escape( mw.msg( 'articlefeedback-form-panel-helpimprove-note') )
 510+ .replace( /\$1/, link );
 511+ })
 512+ .end()
 513+ .find( '.articleFeedback-helpimprove-email' )
 514+ .attr( 'placeholder', mw.msg( 'articlefeedback-form-panel-helpimprove-email-placeholder' ) )
 515+ .placeholder() // back. compat. for older browsers
 516+
 517+ // Basically from mediawiki.special.preferences.js
 518+ .one( 'blur', function() {
 519+ if ( context.$ui.find( '.articleFeedback-helpimprove-email-validity' ).length === 0 ) {
 520+ $(this).after( '<div class="articleFeedback-helpimprove-email-validity"></div>' );
 521+ }
 522+ updateMailValidityLabel( $(this).val(), context );
 523+ mw.log(context);
 524+ $(this).keyup( function() {
 525+ updateMailValidityLabel( $(this).val(), context );
 526+ } );
 527+ } )
 528+ .end()
 529+ .end()
439530 .localize( { 'prefix': 'articlefeedback-' } )
440531 // Activate tooltips
441532 .find( '[title]' )
@@ -470,6 +561,25 @@
471562 .attr( 'for', id );
472563 } )
473564 .end()
 565+ .find( '.articleFeedback-helpimprove > input:checkbox' )
 566+ .each( function() {
 567+ var id = 'articleFeedback-expertise-' + $(this).attr( 'value' );
 568+ $(this)
 569+ .attr( 'id', id )
 570+ .next()
 571+ .attr( 'for', id );
 572+ })
 573+ .change( function() {
 574+ var $options = context.$ui.find( '.articleFeedback-helpimprove-options' );
 575+ if ( $(this).is( ':checked' ) ) {
 576+ $options.slideDown( 'fast' );
 577+ } else {
 578+ $options.slideUp( 'fast', function() {
 579+ $options.find( 'input:checkbox' ).attr( 'checked', false );
 580+ } );
 581+ }
 582+ } )
 583+ .end()
474584 // Buttonify the button
475585 .find( '.articleFeedback-submit' )
476586 .button()
@@ -568,6 +678,11 @@
569679 .find( '.articleFeedback-expertise' )
570680 .each( function() {
571681 $.articleFeedback.fn.enableExpertise( $(this) );
 682+ } )
 683+ .end()
 684+ .find( '.articleFeedback-helpimprove' )
 685+ .each( function() {
 686+ $.articleFeedback.fn.enableHelpimprove( $(this) );
572687 } );
573688 $(this)
574689 .closest( '.articleFeedback-rating' )
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css
@@ -282,24 +282,27 @@
283283 float: right;
284284 }
285285
 286+.articleFeedback-expertise-disabled,
 287+.articleFeedback-helpimprove-disabled {
 288+ color: silver;
 289+}
 290+
286291 .articleFeedback-expertise {
287292 float: left;
288293 margin-bottom: 0.5em;
289294 margin-top: 0.75em;
290295 }
291296
292 -.articleFeedback-expertise-disabled {
293 - color: silver;
294 -}
295 -
296 -.articleFeedback-expertise input {
 297+.articleFeedback-expertise input,
 298+.articleFeedback-helpimprove input {
297299 float: left;
298300 margin-bottom: 0.5em;
299301 clear: both;
300302 cursor: pointer;
301303 }
302304
303 -.articleFeedback-expertise label {
 305+.articleFeedback-expertise label,
 306+.articleFeedback-helpimprove label {
304307 margin-left: 0.25em;
305308 margin-bottom: 0.5em;
306309 float: left;
@@ -307,7 +310,8 @@
308311 cursor: pointer;
309312 }
310313
311 -.articleFeedback-expertise-options {
 314+.articleFeedback-expertise-options,
 315+.articleFeedback-helpimprove-options {
312316 clear: both;
313317 display: none;
314318 }
@@ -316,6 +320,33 @@
317321 margin-left: 2em;
318322 }
319323
 324+.articleFeedback-helpimprove-options input {
 325+ margin-left: 2em;
 326+}
 327+
 328+.articleFeedback-helpimprove-note {
 329+ margin-left: 2em;
 330+ font-size: 0.8em;
 331+ clear: both;
 332+}
 333+
 334+.articleFeedback-helpimprove-email-validity {
 335+ float: left;
 336+ padding: 2px 0.5em;
 337+}
 338+
 339+.articleFeedback-helpimprove-email-validity.valid {
 340+ border: 1px solid #80FF80;
 341+ background-color: #C0FFC0;
 342+ color: black;
 343+}
 344+
 345+.articleFeedback-helpimprove-email-validity.invalid {
 346+ border: 1px solid #FF8080;
 347+ background-color: #FFC0C0;
 348+ color: black;
 349+}
 350+
320351 .articleFeedback-success {
321352 float: right;
322353 }
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php
@@ -36,6 +36,11 @@
3737 'articlefeedback-form-panel-expertise-profession' => 'It is part of my profession',
3838 'articlefeedback-form-panel-expertise-hobby' => 'It is a deep personal passion',
3939 'articlefeedback-form-panel-expertise-other' => 'The source of my knowledge is not listed here',
 40+ 'articlefeedback-form-panel-helpimprove' => "I'd like to help improve Wikipedia, send me an email",
 41+ 'articlefeedback-form-panel-helpimprove-note' => "We'll send you a confirmation email. We won't share your address with anyone. \$1",
 42+ 'articlefeedback-form-panel-helpimprove-email-placeholder' => 'email@example.org', // Optional
 43+ 'articlefeedback-form-panel-helpimprove-privacy' => 'Privacy policy',
 44+ 'articlefeedback-form-panel-helpimprove-privacylink' => 'Project:Privacy policy',
4045 'articlefeedback-form-panel-submit' => 'Submit ratings',
4146 'articlefeedback-form-panel-success' => 'Saved successfully',
4247 'articlefeedback-form-panel-expiry-title' => 'Your ratings have expired',
@@ -98,6 +103,7 @@
99104 {{Identical|Submit}}',
100105 'articlefeedback-survey-title' => 'This text appears in the title bar of the survey dialog.',
101106 'articlefeedback-survey-thanks' => 'This text appears when the user has successfully submitted the survey.',
 107+ 'articlefeedback-form-panel-helpimprove-email-placeholder' => '{{Optional}}',
102108 'articlefeedback-pitch-or' => '{{Identical|Or}}',
103109 'articlefeedback-pitch-join-login' => '{{Identical|Log in}}',
104110 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r86444Follow-up r86442; Add parentheses as shown in the original mockup, cache jQue...krinkle23:29, 19 April 2011

Status & tagging log