r89033 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89032‎ | r89033 | r89034 >
Date:11:30, 28 May 2011
Author:janpaul123
Status:ok
Tags:
Comment:
* Fixed bug in gallery loading
* Fading away the gallery spinner now happens only when all the images are visible
Modified paths:
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -454,7 +454,9 @@
455455 imageList.splice(id, 1);
456456 }
457457
458 - var index = 0;
 458+ var index = 0,
 459+ loadingType = currentTypeOrSubtype
 460+ loadingIndex = 0;
459461 $.ajax({
460462 url: mw.util.wikiScript( 'api' ),
461463 data: {
@@ -468,11 +470,10 @@
469471 dataType: 'json',
470472 type: 'POST',
471473 success: function( data ) {
472 - $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
473 -
474 - if ( !data || !data.query || !data.query.pages ) {
 474+ if ( !data || !data.query || !data.query.pages || loadingType != currentTypeOrSubtype ) {
475475 return;
476476 }
 477+
477478 $.each( data.query.pages, function( id, page ) {
478479 if ( page.imageinfo && page.imageinfo.length ) {
479480 // build an image tag with the correct url and width
@@ -480,7 +481,13 @@
481482 .attr( 'src', page.imageinfo[0].thumburl )
482483 .attr( 'width', currentTypeOrSubtype.gallery.width )
483484 .hide()
484 - .load( function() { $( this ).css( 'display', 'inline-block' ); } );
 485+ .load( function() {
 486+ $( this ).css( 'display', 'inline-block' );
 487+ loadingIndex++;
 488+ if ( loadingIndex >= currentTypeOrSubtype.gallery.number ) {
 489+ $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
 490+ }
 491+ } );
485492 $( '#mw-wikilove-gallery-content' ).append(
486493 $( '<a href="#"></a>' )
487494 .attr( 'id', 'mw-wikilove-gallery-img-' + index )

Status & tagging log