r103364 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103363‎ | r103364 | r103365 >
Date:19:51, 16 November 2011
Author:rsterbin
Status:deferred (Comments)
Tags:
Comment:
Option 1 button events:
- Make the selected button blue and the unselected one gray
- Check the associated hidden radio
- Switch out the default text
- Enable the form
Also updated the focus/blur event for textarea to take the two default messages
into account
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.css (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -39,7 +39,8 @@
4040 'articlefeedbackv5-bucket1-toggle-found-no' => 'No',
4141 'articlefeedbackv5-bucket1-toggle-found-yes-full' => 'Yes, I found what I was looking for.',
4242 'articlefeedbackv5-bucket1-toggle-found-no-full' => 'No, I did not find what I was looking for.',
43 - 'articlefeedbackv5-bucket1-question-comment' => 'What\'s missing? Any suggestions for improvement?',
 43+ 'articlefeedbackv5-bucket1-question-comment-yes' => 'What did you like most? Share your praise with the editors.',
 44+ 'articlefeedbackv5-bucket1-question-comment-no' => 'What\'s missing? Any suggestions for improvement?',
4445 'articlefeedbackv5-bucket1-disclosure' => 'Your Feedback will be shared $1. Seee our $2 for more details.',
4546 'articlefeedbackv5-bucket1-disclosure-shared-linktext' => 'here',
4647 'articlefeedbackv5-bucket1-disclosure-privacy-policy-linktext' => 'privacy policy',
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.css
@@ -449,7 +449,7 @@
450450 cursor: pointer;
451451 text-decoration: none;
452452 }
453 -.articleFeedbackv5-panel .button-placeholder {
 453+.articleFeedbackv5-panel .articleFeedbackv5-button-placeholder {
454454 display: inline-block;
455455 height: 20px;
456456 width: 50px;
@@ -477,11 +477,11 @@
478478 .articleFeedbackv5-panel .buttons input {
479479 display: none;
480480 }
481 -.articleFeedbackv5-panel .buttons .button-placeholder:hover {
 481+.articleFeedbackv5-panel .buttons .articleFeedbackv5-button-placeholder:hover {
482482 background: url(images/bg-button.png) repeat-x;
483483 cursor: pointer;
484484 }
485 -.articleFeedbackv5-panel .buttons .button-placeholder-active {
 485+.articleFeedbackv5-panel .buttons .articleFeedbackv5-button-placeholder-active {
486486 background: url(images/bg-button.png) repeat-x;
487487 }
488488 .articleFeedbackv5-panel .feedback-text {
@@ -519,4 +519,4 @@
520520 text-align: center;
521521 color: #fff;
522522 text-shadow: 1px 1px 1px #000;
523 -}
\ No newline at end of file
 523+}
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -145,18 +145,18 @@
146146 </div>\
147147 <div class="clear"></div>\
148148 </div>\
149 - <div class="form-row">\
 149+ <div class="form-row articleFeedbackv5-bucket1-toggle">\
150150 <p class="instructions-left"><html:msg key="bucket1-question-toggle" /></p>\
151151 <div class="buttons">\
152 - <div class="form-item">\
153 - <label for="find-yes"><html:msg key="bucket1-toggle-found-yes-full" /></label>\
154 - <span class="button-placeholder"><html:msg key="bucket1-toggle-found-yes" /></span>\
155 - <input type="radio" name="toggle" id="find-yes" class="query-button" />\
 152+ <div class="form-item" rel="yes" id="articleFeedbackv5-bucket1-toggle-wrapper-yes">\
 153+ <label for="articleFeedbackv5-bucket1-toggle-yes"><html:msg key="bucket1-toggle-found-yes-full" /></label>\
 154+ <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket1-toggle-found-yes" value="yes" /></span>\
 155+ <input type="radio" name="toggle" id="articleFeedbackv5-bucket1-toggle-yes" class="query-button" />\
156156 </div>\
157 - <div class="form-item">\
158 - <label for="find-no"><html:msg key="bucket1-toggle-found-no-full" /></label>\
159 - <span class="button-placeholder"><html:msg key="bucket1-toggle-found-no" /></span>\
160 - <input type="radio" name="toggle" id="find-no" class="query-button last" />\
 157+ <div class="form-item" rel="no" id="articleFeedbackv5-bucket1-toggle-wrapper-no">\
 158+ <label for="articleFeedbackv5-bucket1-toggle-no"><html:msg key="bucket1-toggle-found-no-full" /></label>\
 159+ <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket1-toggle-found-no" /></span>\
 160+ <input type="radio" name="toggle" id="articleFeedbackv5-bucket1-toggle-no" class="query-button last" value="no" />\
161161 </div>\
162162 <div class="clear"></div>\
163163 </div>\
@@ -177,10 +177,6 @@
178178 // Start out the tooltip hidden
179179 $block.find( '.articleFeedbackv5-tooltip' ).hide();
180180
181 - // Set the default comment text
182 - $block.find( '.articleFeedbackv5-comment textarea' )
183 - .val( mw.msg( 'articlefeedbackv5-bucket1-question-comment' ) );
184 -
185181 // Fill in the disclosure text
186182 $block.find( '.articleFeedbackv5-disclosure p' )
187183 .html( $.articleFeedbackv5.buildLink(
@@ -221,6 +217,7 @@
222218 */
223219 bindEvents: function ( $block ) {
224220
 221+ // Tooltip
225222 $block.find( '.articleFeedbackv5-tooltip-trigger' ).hover( function () {
226223 // mouse on
227224 $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-tooltip' ).show();
@@ -232,26 +229,52 @@
233230 // Clear out the question on focus
234231 $block.find( '.articleFeedbackv5-comment textarea' )
235232 .focus( function () {
236 - var def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment' );
 233+ var def_msg = '';
 234+ var val = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket1-toggle input:checked' ).val();
 235+ if ( val == 'yes' ) {
 236+ def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-yes' );
 237+ } else if ( val == 'no' ) {
 238+ def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-no' );
 239+ }
237240 if ( $( this ).val() == def_msg ) {
238241 $( this ).val( '' );
239242 }
240243 } )
241244 .blur( function () {
 245+ var def_msg = '';
 246+ var val = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket1-toggle input:checked' ).val();
 247+ if ( val == 'yes' ) {
 248+ def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-yes' );
 249+ } else if ( val == 'no' ) {
 250+ def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-no' );
 251+ }
242252 if ( $( this ).val() == '' ) {
243 - $( this ).val( mw.msg( 'articlefeedbackv5-bucket1-question-comment' ) );
 253+ $( this ).val( def_msg );
244254 }
245255 } );
246256
247 - // Enable submission on toggle selection
248 - $block.find( '.articleFeedbackv5-bucket1-toggle input' )
249 - .change( function () {
250 - var $h = $.articleFeedbackv5.$holder;
251 - if ( $h.find( '.articleFeedbackv5-bucket1-toggle input:checked' ).length > 0 ) {
252 - $.articleFeedbackv5.currentBucket().enableSubmission( true );
253 - } else {
254 - $.articleFeedbackv5.currentBucket().enableSubmission( false );
 257+ // Enable submission and switch out the comment default on toggle selection
 258+ $block.find( '.articleFeedbackv5-button-placeholder' )
 259+ .click( function ( e ) {
 260+ var new_val = $( this ).parent().attr( 'rel' );
 261+ var old_val = ( new_val == 'yes' ? 'no' : 'yes' );
 262+ var $wrap = $.articleFeedbackv5.$holder.find( '#articleFeedbackv5-bucket1-toggle-wrapper-' + new_val );
 263+ var $other_wrap = $.articleFeedbackv5.$holder.find( '#articleFeedbackv5-bucket1-toggle-wrapper-' + old_val );
 264+ // make the button blue
 265+ $wrap.find( 'span' ).addClass( 'articleFeedbackv5-button-placeholder-active' );
 266+ $other_wrap.find( 'span' ).removeClass( 'articleFeedbackv5-button-placeholder-active' );
 267+ // check/uncheck radio buttons
 268+ $wrap.find( 'input' ).attr( 'checked', 'checked' );
 269+ $other_wrap.find( 'input' ).attr( 'checked', '' );
 270+ // set default comment message
 271+ var $txt = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-comment textarea' );
 272+ var def_msg_yes = mw.msg( 'articlefeedbackv5-bucket1-question-comment-yes' );
 273+ var def_msg_no = mw.msg( 'articlefeedbackv5-bucket1-question-comment-no' );
 274+ if ( $txt.val() == '' || $txt.val() == def_msg_yes || $txt.val() == def_msg_no ) {
 275+ $txt.val( new_val == 'yes' ? def_msg_yes : def_msg_no );
255276 }
 277+ // enable submission
 278+ $.articleFeedbackv5.currentBucket().enableSubmission( true );
256279 } );
257280
258281 // Attach the submit
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -69,7 +69,8 @@
7070 'articlefeedbackv5-bucket1-toggle-found-yes-full',
7171 'articlefeedbackv5-bucket1-toggle-found-no',
7272 'articlefeedbackv5-bucket1-toggle-found-no-full',
73 - 'articlefeedbackv5-bucket1-question-comment',
 73+ 'articlefeedbackv5-bucket1-question-comment-yes',
 74+ 'articlefeedbackv5-bucket1-question-comment-no',
7475 'articlefeedbackv5-bucket1-disclosure',
7576 'articlefeedbackv5-bucket1-disclosure-shared-linktext',
7677 'articlefeedbackv5-bucket1-disclosure-privacy-policy-linktext',

Comments

#Comment by Johnduhart (talk | contribs)   03:48, 18 November 2011
+						var def_msg = '';
+						var val = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket1-toggle input:checked' ).val();
+						if ( val == 'yes' ) {
+							def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-yes' );
+						} else if ( val == 'no' ) {
+							def_msg = mw.msg( 'articlefeedbackv5-bucket1-question-comment-no' );
+						}

Move this into a function so it's less repetitive.

Status & tagging log