Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -66,6 +66,11 @@ |
67 | 67 | 'articlefeedback-form-panel-expertise-profession', |
68 | 68 | 'articlefeedback-form-panel-expertise-hobby', |
69 | 69 | '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', |
70 | 75 | 'articlefeedback-form-panel-submit', |
71 | 76 | 'articlefeedback-form-panel-success', |
72 | 77 | 'articlefeedback-form-panel-expiry-title', |
— | — | @@ -75,6 +80,9 @@ |
76 | 81 | 'articlefeedback-report-panel-description', |
77 | 82 | 'articlefeedback-report-empty', |
78 | 83 | 'articlefeedback-report-ratings', |
| 84 | + 'parentheses', |
| 85 | + 'email-address-validity-valid', |
| 86 | + 'email-address-validity-invalid', |
79 | 87 | ), |
80 | 88 | 'dependencies' => array( |
81 | 89 | 'jquery.tipsy', |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -19,6 +19,27 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
| 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 | +/** |
23 | 44 | * Article Feedback jQuery Plugin Support Code |
24 | 45 | */ |
25 | 46 | $.articleFeedback = { |
— | — | @@ -44,6 +65,14 @@ |
45 | 66 | <div><input type="checkbox" value="other" /><label><html:msg key="form-panel-expertise-other" /></label></div>\ |
46 | 67 | </div>\ |
47 | 68 | </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>\ |
48 | 77 | <button class="articleFeedback-submit articleFeedback-visibleWith-form" type="submit" disabled><html:msg key="form-panel-submit" /></button>\ |
49 | 78 | <div class="articleFeedback-success articleFeedback-visibleWith-form"><span><html:msg key="form-panel-success" /></span></div>\ |
50 | 79 | <div style="clear:both;"></div>\ |
— | — | @@ -134,6 +163,14 @@ |
135 | 164 | .find( '.articleFeedback-expertise-disabled' ) |
136 | 165 | .removeClass( 'articleFeedback-expertise-disabled' ); |
137 | 166 | }, |
| 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 | + }, |
138 | 175 | 'submit': function() { |
139 | 176 | var context = this; |
140 | 177 | $.articleFeedback.fn.enableSubmission.call( context, false ); |
— | — | @@ -257,6 +294,29 @@ |
258 | 295 | .find( '.articleFeedback-expertise-options' ) |
259 | 296 | .hide(); |
260 | 297 | } |
| 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 | + } |
261 | 321 | |
262 | 322 | // Index rating data by rating ID |
263 | 323 | var ratings = {}; |
— | — | @@ -308,7 +368,7 @@ |
309 | 369 | $(this).find( 'input:hidden' ).val( rating.userrating ); |
310 | 370 | if ( rating.userrating > 0 ) { |
311 | 371 | // 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 |
313 | 373 | $.articleFeedback.fn.enableExpertise( $expertise ); |
314 | 374 | } |
315 | 375 | } else { |
— | — | @@ -435,6 +495,37 @@ |
436 | 496 | } |
437 | 497 | } ) |
438 | 498 | .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() |
439 | 530 | .localize( { 'prefix': 'articlefeedback-' } ) |
440 | 531 | // Activate tooltips |
441 | 532 | .find( '[title]' ) |
— | — | @@ -470,6 +561,25 @@ |
471 | 562 | .attr( 'for', id ); |
472 | 563 | } ) |
473 | 564 | .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() |
474 | 584 | // Buttonify the button |
475 | 585 | .find( '.articleFeedback-submit' ) |
476 | 586 | .button() |
— | — | @@ -568,6 +678,11 @@ |
569 | 679 | .find( '.articleFeedback-expertise' ) |
570 | 680 | .each( function() { |
571 | 681 | $.articleFeedback.fn.enableExpertise( $(this) ); |
| 682 | + } ) |
| 683 | + .end() |
| 684 | + .find( '.articleFeedback-helpimprove' ) |
| 685 | + .each( function() { |
| 686 | + $.articleFeedback.fn.enableHelpimprove( $(this) ); |
572 | 687 | } ); |
573 | 688 | $(this) |
574 | 689 | .closest( '.articleFeedback-rating' ) |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css |
— | — | @@ -282,24 +282,27 @@ |
283 | 283 | float: right; |
284 | 284 | } |
285 | 285 | |
| 286 | +.articleFeedback-expertise-disabled, |
| 287 | +.articleFeedback-helpimprove-disabled { |
| 288 | + color: silver; |
| 289 | +} |
| 290 | + |
286 | 291 | .articleFeedback-expertise { |
287 | 292 | float: left; |
288 | 293 | margin-bottom: 0.5em; |
289 | 294 | margin-top: 0.75em; |
290 | 295 | } |
291 | 296 | |
292 | | -.articleFeedback-expertise-disabled { |
293 | | - color: silver; |
294 | | -} |
295 | | - |
296 | | -.articleFeedback-expertise input { |
| 297 | +.articleFeedback-expertise input, |
| 298 | +.articleFeedback-helpimprove input { |
297 | 299 | float: left; |
298 | 300 | margin-bottom: 0.5em; |
299 | 301 | clear: both; |
300 | 302 | cursor: pointer; |
301 | 303 | } |
302 | 304 | |
303 | | -.articleFeedback-expertise label { |
| 305 | +.articleFeedback-expertise label, |
| 306 | +.articleFeedback-helpimprove label { |
304 | 307 | margin-left: 0.25em; |
305 | 308 | margin-bottom: 0.5em; |
306 | 309 | float: left; |
— | — | @@ -307,7 +310,8 @@ |
308 | 311 | cursor: pointer; |
309 | 312 | } |
310 | 313 | |
311 | | -.articleFeedback-expertise-options { |
| 314 | +.articleFeedback-expertise-options, |
| 315 | +.articleFeedback-helpimprove-options { |
312 | 316 | clear: both; |
313 | 317 | display: none; |
314 | 318 | } |
— | — | @@ -316,6 +320,33 @@ |
317 | 321 | margin-left: 2em; |
318 | 322 | } |
319 | 323 | |
| 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 | + |
320 | 351 | .articleFeedback-success { |
321 | 352 | float: right; |
322 | 353 | } |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php |
— | — | @@ -36,6 +36,11 @@ |
37 | 37 | 'articlefeedback-form-panel-expertise-profession' => 'It is part of my profession', |
38 | 38 | 'articlefeedback-form-panel-expertise-hobby' => 'It is a deep personal passion', |
39 | 39 | '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', |
40 | 45 | 'articlefeedback-form-panel-submit' => 'Submit ratings', |
41 | 46 | 'articlefeedback-form-panel-success' => 'Saved successfully', |
42 | 47 | 'articlefeedback-form-panel-expiry-title' => 'Your ratings have expired', |
— | — | @@ -98,6 +103,7 @@ |
99 | 104 | {{Identical|Submit}}', |
100 | 105 | 'articlefeedback-survey-title' => 'This text appears in the title bar of the survey dialog.', |
101 | 106 | 'articlefeedback-survey-thanks' => 'This text appears when the user has successfully submitted the survey.', |
| 107 | + 'articlefeedback-form-panel-helpimprove-email-placeholder' => '{{Optional}}', |
102 | 108 | 'articlefeedback-pitch-or' => '{{Identical|Or}}', |
103 | 109 | 'articlefeedback-pitch-join-login' => '{{Identical|Log in}}', |
104 | 110 | ); |