r88909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88908‎ | r88909 | r88910 >
Date:18:28, 26 May 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r88009
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -14,6 +14,8 @@
1515 'ext.articleFeedback-options', mw.config.get( 'wgArticleFeedbackOptions' )
1616 );
1717
 18+var loadUserRatings = !mw.user.anonymous() || $.cookie( prefix( 'rated' ) ) === 'true';
 19+
1820 /**
1921 * Prefixes a key for cookies or events, with extension and version information
2022 *
@@ -191,6 +193,8 @@
192194 // For anon users, keep a cookie around so we know they've rated before
193195 if ( mw.user.anonymous() ) {
194196 $.cookie( prefix( 'rated' ), 'true', { 'expires': 365, 'path': '/' } );
 197+ // Ensure that user ratings are loaded from now on
 198+ loadUserRatings = true;
195199 }
196200 $.articleFeedback.fn.enableSubmission.call( context, false );
197201 context.$ui.find( '.articleFeedback-lock' ).show();
@@ -325,22 +329,21 @@
326330 },
327331 'load': function() {
328332 var context = this;
329 - var userrating = !mw.user.anonymous() || $.cookie( prefix( 'rated' ) ) === 'true';
330333 $.ajax( {
331334 'url': mw.config.get( 'wgScriptPath' ) + '/api.php',
332335 'type': 'GET',
333336 'dataType': 'json',
334337 'context': context,
335 - 'cache': !userrating,
 338+ 'cache': !loadUserRatings,
336339 'data': {
337340 'action': 'query',
338341 'format': 'json',
339342 'list': 'articlefeedback',
340343 'afpageid': mw.config.get( 'wgArticleId' ),
341 - 'afanontoken': userrating ? mw.user.id() : '',
342 - 'afuserrating': Number( userrating ),
 344+ 'afanontoken': loadUserRatings ? mw.user.id() : '',
 345+ 'afuserrating': Number( loadUserRatings ),
343346 'maxage': 0,
344 - 'smaxage': userrating ? 0 : mw.config.get( 'wgArticleFeedbackSMaxage' )
 347+ 'smaxage': loadUserRatings ? 0 : mw.config.get( 'wgArticleFeedbackSMaxage' )
345348 },
346349 'success': function( data ) {
347350 var context = this;
@@ -782,10 +785,16 @@
783786 if ( !showOptions ) {
784787 context.$ui.find( '.articleFeedback-options' ).hide();
785788 }
786 - // Show initial form and report values when the tool is visible
787 - context.$ui.appear( function() {
788 - $.articleFeedback.fn.load.call( context );
789 - } );
 789+ if ( loadUserRatings ) {
 790+ // Show initial form and report values when the tool is visible
 791+ context.$ui.appear( function() {
 792+ $.articleFeedback.fn.load.call( context );
 793+ } );
 794+ } else {
 795+ context.$ui.find( '.articleFeedback-switch-report' ).one( 'click', function() {
 796+ $.articleFeedback.fn.load.call( context );
 797+ } );
 798+ }
790799 }
791800 }
792801 };

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88009Prevented loading data from the API until the user clicks on the "View page r...tparscal17:12, 13 May 2011

Status & tagging log