Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -14,6 +14,8 @@ |
15 | 15 | 'ext.articleFeedback-options', mw.config.get( 'wgArticleFeedbackOptions' ) |
16 | 16 | ); |
17 | 17 | |
| 18 | +var loadUserRatings = !mw.user.anonymous() || $.cookie( prefix( 'rated' ) ) === 'true'; |
| 19 | + |
18 | 20 | /** |
19 | 21 | * Prefixes a key for cookies or events, with extension and version information |
20 | 22 | * |
— | — | @@ -191,6 +193,8 @@ |
192 | 194 | // For anon users, keep a cookie around so we know they've rated before |
193 | 195 | if ( mw.user.anonymous() ) { |
194 | 196 | $.cookie( prefix( 'rated' ), 'true', { 'expires': 365, 'path': '/' } ); |
| 197 | + // Ensure that user ratings are loaded from now on |
| 198 | + loadUserRatings = true; |
195 | 199 | } |
196 | 200 | $.articleFeedback.fn.enableSubmission.call( context, false ); |
197 | 201 | context.$ui.find( '.articleFeedback-lock' ).show(); |
— | — | @@ -325,22 +329,21 @@ |
326 | 330 | }, |
327 | 331 | 'load': function() { |
328 | 332 | var context = this; |
329 | | - var userrating = !mw.user.anonymous() || $.cookie( prefix( 'rated' ) ) === 'true'; |
330 | 333 | $.ajax( { |
331 | 334 | 'url': mw.config.get( 'wgScriptPath' ) + '/api.php', |
332 | 335 | 'type': 'GET', |
333 | 336 | 'dataType': 'json', |
334 | 337 | 'context': context, |
335 | | - 'cache': !userrating, |
| 338 | + 'cache': !loadUserRatings, |
336 | 339 | 'data': { |
337 | 340 | 'action': 'query', |
338 | 341 | 'format': 'json', |
339 | 342 | 'list': 'articlefeedback', |
340 | 343 | '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 ), |
343 | 346 | 'maxage': 0, |
344 | | - 'smaxage': userrating ? 0 : mw.config.get( 'wgArticleFeedbackSMaxage' ) |
| 347 | + 'smaxage': loadUserRatings ? 0 : mw.config.get( 'wgArticleFeedbackSMaxage' ) |
345 | 348 | }, |
346 | 349 | 'success': function( data ) { |
347 | 350 | var context = this; |
— | — | @@ -782,10 +785,16 @@ |
783 | 786 | if ( !showOptions ) { |
784 | 787 | context.$ui.find( '.articleFeedback-options' ).hide(); |
785 | 788 | } |
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 | + } |
790 | 799 | } |
791 | 800 | } |
792 | 801 | }; |