r65777 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65776‎ | r65777 | r65778 >
Date:03:46, 2 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Finished work to make the storyboard work with modification date and id continue parameters
Modified paths:
  • /trunk/extensions/Storyboard/api/ApiQueryStories.php (modified) (history)
  • /trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storyboard/storyboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js
@@ -26,8 +26,7 @@
2727 scrollDelay: 600, // The interval for checking if the user scrolled, in ms.
2828 endDelay: 100,
2929 updateBatch: null,
30 - updateEnd: null,
31 - busy: false
 30+ updateEnd: null
3231 },
3332 opt
3433 );
@@ -69,6 +68,7 @@
7069
7170 setTimeout( monEnd, opt.endDelay );
7271
 72+ // Initiate the scroll handling.
7373 if( typeof opt.updateBatch == 'function' ){
7474 setTimeout( handleScrolling, opt.scrollDelay );
7575 }
@@ -79,12 +79,12 @@
8080 var rp = opt.batchNum;
8181
8282 while( rp-- ) {
83 - $b=jQuery( opt.batchTemplate )
 83+ $b = jQuery( opt.batchTemplate )
8484 .attr({
8585 offset: offset,
86 - len: opt.batchSiz,
87 - storymodified: 0,
88 - storyid: 0
 86+ storymodified: window.storyModified,
 87+ storyid: window.storyId,
 88+ len: opt.batchSize
8989 })
9090 .addClass( opt.batchClass + " " + opt.emptyBatchClass );
9191
@@ -108,7 +108,7 @@
109109 function handleScrolling() {
110110 var so = $me.scrollTop();
111111
112 - if( lsp != so) {
 112+ if( !window.storyboardBusy && lsp != so ) {
113113 lsp = so;
114114 var co = $me.offset().top;
115115
@@ -120,7 +120,8 @@
121121 return;
122122 }
123123
124 - opt.updateBatch( $b.removeClass( opt.emptyBatchClass ), opt );
 124+ window.storyboardBusy = true;
 125+ opt.updateBatch( $b.removeClass( opt.emptyBatchClass ) );
125126 });
126127 }
127128
Index: trunk/extensions/Storyboard/tags/Storyboard/storyboard.js
@@ -11,7 +11,7 @@
1212 updateBatch: updateStoryboard,
1313 maxOffset: 500,
1414 batchSize: 8,
15 - batchNum: 2,
 15+ batchNum: 2, // TODO: change to 1. Some issue in the ajaxscroll plugin makesit break when this is the case though.
1616 batchClass: "batch",
1717 boxClass: "storyboard-box",
1818 emptyBatchClass: "storyboard-empty",
@@ -19,19 +19,27 @@
2020 } );
2121 } );
2222
23 - function updateStoryboard( $storyboard, ajaxScrollObj ) {
 23+ function updateStoryboard( $storyboard ) {
 24+ requestArgs = {
 25+ 'action': 'query',
 26+ 'list': 'stories',
 27+ 'format': 'json',
 28+ 'stlimit': 8,
 29+ 'stlanguage': window.storyboardLanguage
 30+ };
 31+
 32+ if ( $storyboard.attr( 'storymodified' ) ) {
 33+ requestArgs.stcontinue = $storyboard.attr( 'storymodified' );
 34+
 35+ requestArgs.stcontinue += '-' +
 36+ ( $storyboard.attr( 'storyid' ) ? $storyboard.attr( 'storyid' ) : '0' );
 37+ }
 38+
2439 $.getJSON( wgScriptPath + '/api.php',
25 - {
26 - 'action': 'query',
27 - 'list': 'stories',
28 - 'format': 'json',
29 - 'stcontinue': $storyboard.attr( 'storymodified' ) + '-' + $storyboard.attr( 'storyid' ),
30 - 'stlimit': 8,
31 - 'stlanguage': window.storyboardLanguage
32 - },
 40+ requestArgs,
3341 function( data ) {
3442 if ( data.query ) {
35 - addStories( $storyboard, data.query, ajaxScrollObj );
 43+ addStories( $storyboard, data.query );
3644 } else {
3745 alert( 'An error occured:\n' + data.error.info ); // TODO: i18n
3846 }
@@ -39,7 +47,7 @@
4048 );
4149 }
4250
43 - function addStories( $storyboard, query, ajaxScrollObj ) {
 51+ function addStories( $storyboard, query ) {
4452 // Remove the empty boxes.
4553 $storyboard.html('');
4654
@@ -116,7 +124,11 @@
117125 $storyboard.append( $storyBody );
118126 }
119127
120 - ajaxScrollObj.busy = false;
 128+ var story = query.stories[query.stories.length - 1];
 129+ window.storyModified = story.modified;
 130+ window.storyId = story.id;
 131+
 132+ window.storyboardBusy = false;
121133 }
122134
123135 })(jQuery);
\ No newline at end of file
Index: trunk/extensions/Storyboard/api/ApiQueryStories.php
@@ -101,7 +101,10 @@
102102 'id' => $story->story_id,
103103 'author' => $story->story_author_name,
104104 'title' => $story->story_title,
105 - 'created' => wfTimestamp( TS_ISO_8601, $story->story_created ),
 105+ //'created' => wfTimestamp( TS_ISO_8601, $story->story_created ),
 106+ //'modified' => wfTimestamp( TS_ISO_8601, $story->story_modified ),
 107+ 'created' => $story->story_created,
 108+ 'modified' => $story->story_modified,
106109 'imageurl' => $story->story_author_image,
107110 'permalink' => SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL()
108111 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r65778Follow up to r65777jeroendedauw03:57, 2 May 2010

Status & tagging log