Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -454,7 +454,9 @@ |
455 | 455 | imageList.splice(id, 1); |
456 | 456 | } |
457 | 457 | |
458 | | - var index = 0; |
| 458 | + var index = 0, |
| 459 | + loadingType = currentTypeOrSubtype |
| 460 | + loadingIndex = 0; |
459 | 461 | $.ajax({ |
460 | 462 | url: mw.util.wikiScript( 'api' ), |
461 | 463 | data: { |
— | — | @@ -468,11 +470,10 @@ |
469 | 471 | dataType: 'json', |
470 | 472 | type: 'POST', |
471 | 473 | 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 ) { |
475 | 475 | return; |
476 | 476 | } |
| 477 | + |
477 | 478 | $.each( data.query.pages, function( id, page ) { |
478 | 479 | if ( page.imageinfo && page.imageinfo.length ) { |
479 | 480 | // build an image tag with the correct url and width |
— | — | @@ -480,7 +481,13 @@ |
481 | 482 | .attr( 'src', page.imageinfo[0].thumburl ) |
482 | 483 | .attr( 'width', currentTypeOrSubtype.gallery.width ) |
483 | 484 | .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 | + } ); |
485 | 492 | $( '#mw-wikilove-gallery-content' ).append( |
486 | 493 | $( '<a href="#"></a>' ) |
487 | 494 | .attr( 'id', 'mw-wikilove-gallery-img-' + index ) |