r73656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73655‎ | r73656 | r73657 >
Date:14:24, 24 September 2010
Author:catrope
Status:deferred
Tags:
Comment:
ArticleAssessment: Make sure that all calls to .dialog() are in a withJUI() block. It seems to pretty much be impossible to hit the code paths where I wrapped .dialog() in this commit before JUI is loaded, but apparently someone managed to somehow and reported it.
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.combined.js (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.combined.min.js (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
@@ -21,16 +21,16 @@
2222
2323 private static $scriptFiles = array(
2424 'raw' => array(
25 - array( 'src' => 'js/ArticleAssessment.js', 'version' => 3 ),
 25+ array( 'src' => 'js/ArticleAssessment.js', 'version' => 4 ),
2626 array( 'src' => 'js/jquery.cookie.js', 'version' => 1 ),
2727 array( 'src' => 'js/jquery.tipsy.js', 'version' => 1 ),
2828 array( 'src' => 'js/jquery.stars.js', 'version' => 1 ),
2929 ),
3030 'combined' => array(
31 - array( 'src' => 'js/ArticleAssessment.combined.js', 'version' => 2 )
 31+ array( 'src' => 'js/ArticleAssessment.combined.js', 'version' => 3 )
3232 ),
3333 'minified' => array(
34 - array( 'src' => 'js/ArticleAssessment.combined.min.js', 'version' => 2 )
 34+ array( 'src' => 'js/ArticleAssessment.combined.min.js', 'version' => 3 )
3535 ),
3636 );
3737
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.combined.js
@@ -463,9 +463,14 @@
464464 .addClass( success ? 'article-assessment-success-msg' : 'article-assessment-error-msg' )
465465 .html( $.ArticleAssessment.fn.getMsg( success? 'articleassessment-survey-thanks' : 'articleassessment-error' ) )
466466 .appendTo( $dialogDiv );
467 - $dialogDiv
468 - .dialog( 'option', 'height', $msgDiv.height() + 100 )
469 - .removeClass( 'loading' );
 467+ $dialogDiv.removeClass( 'loading' );
 468+
 469+ // This is absurdly unnecessary from the looks of it, but it seems this is somehow
 470+ // needed in certain cases.
 471+ $.ArticleAssessment.fn.withJUI( function() {
 472+ $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 )
 473+ } );
 474+
470475 if ( success ) {
471476 // Hide the dialog link
472477 $( '#article-assessment .article-assessment-rate-feedback' ).hide();
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js
@@ -463,9 +463,14 @@
464464 .addClass( success ? 'article-assessment-success-msg' : 'article-assessment-error-msg' )
465465 .html( $.ArticleAssessment.fn.getMsg( success? 'articleassessment-survey-thanks' : 'articleassessment-error' ) )
466466 .appendTo( $dialogDiv );
467 - $dialogDiv
468 - .dialog( 'option', 'height', $msgDiv.height() + 100 )
469 - .removeClass( 'loading' );
 467+ $dialogDiv.removeClass( 'loading' );
 468+
 469+ // This is absurdly unnecessary from the looks of it, but it seems this is somehow
 470+ // needed in certain cases.
 471+ $.ArticleAssessment.fn.withJUI( function() {
 472+ $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 )
 473+ } );
 474+
470475 if ( success ) {
471476 // Hide the dialog link
472477 $( '#article-assessment .article-assessment-rate-feedback' ).hide();
@@ -480,9 +485,10 @@
481486 .addClass( 'article-assessment-error-msg' )
482487 .html( $.ArticleAssessment.fn.getMsg( 'articleassessment-error' ) )
483488 .appendTo( $dialogDiv );
484 - $dialogDiv
485 - .dialog( 'option', 'height', $msgDiv.height() + 100 )
486 - .removeClass( 'loading' );
 489+ $dialogDiv.removeClass( 'loading' );
 490+ $.ArticleAssessment.fn.withJUI( function() {
 491+ $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 )
 492+ } );
487493 }
488494 } );
489495 return false;
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.combined.min.js
@@ -49,7 +49,7 @@
5050 $('.article-assessment-rating-field-value').each(function(){$(this).css({'width':120-(120*(parseFloat($(this).text())/5))+'px'})});},'submitRating':function(){var config=$('#article-assessment').data('articleAssessment-context').config;$.ArticleAssessment.fn.flashNotice();$('.rating-field').stars('disable');$('#article-assessment input').attr('disabled','disabled');var results={};$('.rating-field input').each(function(){var fieldName=$(this).attr('name').match(/\[([a-zA-Z0-9\-]*)\]/)[1];results[fieldName]=$(this).val();});var request=$.ajax({url:wgScriptPath+'/api.php',type:'POST',data:{'action':'articleassessment','revid':config.revID,'pageid':config.pageID,'r1':results['wellsourced'],'r2':results['neutrality'],'r3':results['completeness'],'r4':results['readability'],'anontoken':config.userID,'format':'json'},dataType:'json',success:$.ArticleAssessment.fn.afterSubmitRating,error:function(XMLHttpRequest,textStatus,errorThrown){$.ArticleAssessment.fn.flashNotice($.ArticleAssessment.fn.getMsg('articleassessment-error'),{'class':'article-assessment-error-msg'});}});},'afterSubmitRating':function(data){$.ArticleAssessment.fn.getRatingData();$('.ui-stars-star-on').addClass('ui-stars-star-rated');$('.rating-field').stars('enable');$('#article-assessment input:disabled').removeAttr('disabled');$.ArticleAssessment.fn.showRatings();$.ArticleAssessment.fn.flashNotice($.ArticleAssessment.fn.getMsg('articleassessment-thanks'),{'class':'article-assessment-success-msg'});},'flashNotice':function(text,options){if(arguments.length==0){$('#article-assessment .article-assessment-flash').remove();}else{$('#article-assessment .article-assessment-flash').remove();var className=options['class'];$msg=$('<div />').addClass('article-assessment-flash').html(text);if(options['class']){$msg.addClass(options['class']);}
5151 $('#article-assessment .article-assessment-submit').append($msg);}},'showFeedback':function(){$.ArticleAssessment.fn.withJUI(function(){var $dialogDiv=$('#article-assessment-dialog');if($dialogDiv.size()==0){$dialogDiv=$('<div id="article-assessment-dialog" class="loading" />').dialog({width:600,height:400,bgiframe:true,autoOpen:true,modal:true,title:$.ArticleAssessment.fn.getMsg('articleassessment-survey-title'),close:function(){$(this).dialog('option','height',400).find('.article-assessment-success-msg, .article-assessment-error-msg').remove().end().find('form').show();}});$dialogDiv.load(wgScript+'?title=Special:SimpleSurvey&survey=articlerating&raw=1',function(){$(this).find('form').bind('submit',$.ArticleAssessment.fn.submitFeedback);$(this).removeClass('loading');});}
5252 $dialogDiv.dialog('open');});return false;},'submitFeedback':function(){var $dialogDiv=$('#article-assessment-dialog');$dialogDiv.find('form').hide().end().addClass('loading');var formData={};$dialogDiv.find('input').each(function(){var name=$(this).attr('name');if(name!==''){if(name.substr(-2)=='[]'){var trimmedName=name.substr(0,name.length-2);if(typeof formData[trimmedName]=='undefined'){formData[trimmedName]=[];}
53 -formData[trimmedName].push($(this).val());}else{formData[name]=$(this).val();}}});formData.title='Special:SimpleSurvey';$.ajax({url:wgScript,type:'POST',data:formData,dataType:'html',success:function(data){var success=$(data).find('.simplesurvey-success').size()>0;var $msgDiv=$('<div />').addClass(success?'article-assessment-success-msg':'article-assessment-error-msg').html($.ArticleAssessment.fn.getMsg(success?'articleassessment-survey-thanks':'articleassessment-error')).appendTo($dialogDiv);$dialogDiv.dialog('option','height',$msgDiv.height()+100).removeClass('loading');if(success){$('#article-assessment .article-assessment-rate-feedback').hide();$.cookie('mwArticleAssessmentHideFeedback',true,{'expires':30,'path':'/'});}},error:function(XMLHttpRequest,textStatus,errorThrown){var $msgDiv=$('<div />').addClass('article-assessment-error-msg').html($.ArticleAssessment.fn.getMsg('articleassessment-error')).appendTo($dialogDiv);$dialogDiv.dialog('option','height',$msgDiv.height()+100).removeClass('loading');}});return false;},'addMessages':function(messages){for(var key in messages){$.ArticleAssessment.messages[key]=messages[key];}},'getMsg':function(key,args){if(!(key in $.ArticleAssessment.messages)){return'['+key+']';}
 53+formData[trimmedName].push($(this).val());}else{formData[name]=$(this).val();}}});formData.title='Special:SimpleSurvey';$.ajax({url:wgScript,type:'POST',data:formData,dataType:'html',success:function(data){var success=$(data).find('.simplesurvey-success').size()>0;var $msgDiv=$('<div />').addClass(success?'article-assessment-success-msg':'article-assessment-error-msg').html($.ArticleAssessment.fn.getMsg(success?'articleassessment-survey-thanks':'articleassessment-error')).appendTo($dialogDiv);$dialogDiv.removeClass('loading');$.ArticleAssessment.fn.withJUI(function(){$dialogDiv.dialog('option','height',$msgDiv.height()+100)});if(success){$('#article-assessment .article-assessment-rate-feedback').hide();$.cookie('mwArticleAssessmentHideFeedback',true,{'expires':30,'path':'/'});}},error:function(XMLHttpRequest,textStatus,errorThrown){var $msgDiv=$('<div />').addClass('article-assessment-error-msg').html($.ArticleAssessment.fn.getMsg('articleassessment-error')).appendTo($dialogDiv);$dialogDiv.dialog('option','height',$msgDiv.height()+100).removeClass('loading');}});return false;},'addMessages':function(messages){for(var key in messages){$.ArticleAssessment.messages[key]=messages[key];}},'getMsg':function(key,args){if(!(key in $.ArticleAssessment.messages)){return'['+key+']';}
5454 var msg=$.ArticleAssessment.messages[key];if(typeof args=='object'||typeof args=='array'){for(var i=0;i<args.length;i++){msg=msg.replace(new RegExp('\\$'+(parseInt(i)+1),'g'),args[i]);}}else if(typeof args=='string'||typeof args=='number'){msg=msg.replace(/\$1/g,args);}
5555 return msg;},'withJUI':function(callback){if(typeof $.ui=='undefined'){$.getScript(wgArticleAssessmentJUIPath,callback);}else{callback();}}}};$(document).ready(function(){$.ArticleAssessment.fn.init();});})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
5656 var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}

Status & tagging log