r72913 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72912‎ | r72913 | r72914 >
Date:16:08, 13 September 2010
Author:adam
Status:ok
Tags:
Comment:
a few small js tweaks to article assessment
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js
@@ -56,7 +56,7 @@
5757 </span> \
5858 <span class="article-assessment-rating-count"></span> \
5959 </div>',
60 - 'staleMSG': '<span class="article-assessment-stale-msg">{MSG}</span>'
 60+ 'staleMSG': '<span class="article-assessment-stale-msg"></span>'
6161 },
6262
6363 'fn' : {
@@ -249,7 +249,7 @@
250250 var settings = $( '#article-assessment' ).data( 'articleAssessment-context' ).settings;
251251 // add the correct data to the markup
252252 if ( data.query.articleassessment && data.query.articleassessment.length > 0 ) {
253 - for ( var r in data.query.articleassessment[0].ratings) {
 253+ for ( var r in data.query.articleassessment[0].ratings ) {
254254 var rating = data.query.articleassessment[0].ratings[r],
255255 $rating = $( '#' + rating.ratingdesc ),
256256 count = rating.count,
@@ -272,9 +272,7 @@
273273 $( '.ui-stars-star-on' )
274274 .addClass( 'ui-stars-star-stale' );
275275 // add the stale message
276 - var msg = $.ArticleAssessment.fn.getMsg( 'articleassessment-stalemessage-revisioncount' )
277 - .replace( /'''([^']*)'''/g, '<strong>$1</strong>' )
278 - .replace( /''([^']*)''/g, '<em>$1</em>' );
 276+ var msg = $.ArticleAssessment.fn.getMsg( 'articleassessment-stalemessage-revisioncount' );
279277 $.ArticleAssessment.fn.flashNotice( msg, { 'class': 'article-assessment-stale-msg' } );
280278 } else {
281279 // if it's not a stale rating, we want to make the stars blue
@@ -320,28 +318,29 @@
321319 'format': 'json'
322320 },
323321 dataType: 'json',
324 - success: function( data ) {
325 - // update the ratings
326 - $.ArticleAssessment.fn.getRatingData();
327 - // set the stars to rated status
328 - $( '.ui-stars-star-on' ).addClass( 'ui-stars-star-rated' );
329 - // unlock the stars & submit
330 - $( '.rating-field' ).stars( 'enable' );
331 - $( '#article-assessment input:disabled' ).removeAttr( 'disabled' );
332 - // update the results
333 -
334 - // show the results
335 - $( '#article-assessment .article-assessment-show-ratings a' ).click();
336 - // say thank you
337 - $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-thanks' ),
338 - { 'class': 'article-assessment-success-msg' } );
339 - },
 322+ success: $.ArticleAssessment.fn.afterSubmitRating,
340323 error: function( XMLHttpRequest, textStatus, errorThrown ) {
341324 $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-error' ),
342325 { 'class': 'article-assessment-error-msg' } );
343326 }
344327 } );
345328 },
 329+ 'afterSubmitRating': function ( data ) {
 330+ // update the ratings
 331+ $.ArticleAssessment.fn.getRatingData();
 332+ // set the stars to rated status
 333+ $( '.ui-stars-star-on' ).addClass( 'ui-stars-star-rated' );
 334+ // unlock the stars & submit
 335+ $( '.rating-field' ).stars( 'enable' );
 336+ $( '#article-assessment input:disabled' ).removeAttr( 'disabled' );
 337+ // update the results
 338+
 339+ // show the results
 340+ $( '#article-assessment .article-assessment-show-ratings a' ).click();
 341+ // say thank you
 342+ $.ArticleAssessment.fn.flashNotice( $.ArticleAssessment.fn.getMsg( 'articleassessment-thanks' ),
 343+ { 'class': 'article-assessment-success-msg' } );
 344+ },
346345 // places a message on the interface
347346 'flashNotice': function( text, options ) {
348347 if ( arguments.length == 0 ) {
@@ -380,7 +379,7 @@
381380 var msg = $.ArticleAssessment.messages[key];
382381 if ( typeof args == 'object' || typeof args == 'array' ) {
383382 for ( var i = 0; i < args.length; i++ ) {
384 - msg = msg.replace( new RegExp( '\$' + ( parseInt( i ) + 1 ), 'g' ), args[i] );
 383+ msg = msg.replace( new RegExp( '\\$' + ( parseInt( i ) + 1 ), 'g' ), args[i] );
385384 }
386385 } else if ( typeof args == 'string' || typeof args == 'number' ) {
387386 msg = msg.replace( /\$1/g, args );

Status & tagging log