http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89033

Revision: 89033
Author:   janpaul123
Date:     2011-05-28 11:30:29 +0000 (Sat, 28 May 2011)
Log Message:
-----------
* 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: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
===================================================================
--- trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-05-28 11:22:32 UTC (rev 89032)
+++ trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-05-28 11:30:29 UTC (rev 89033)
@@ -454,7 +454,9 @@
                        imageList.splice(id, 1);
                }
                
-               var index = 0;
+               var     index = 0,
+                       loadingType = currentTypeOrSubtype
+                       loadingIndex = 0;
                $.ajax({
                        url: mw.util.wikiScript( 'api' ),
                        data: {
@@ -468,11 +470,10 @@
                        dataType: 'json',
                        type: 'POST',
                        success: function( data ) {
-                               $( '#mw-wikilove-gallery-spinner' ).fadeOut( 
200 );
-                               
-                               if ( !data || !data.query || !data.query.pages 
) {
+                               if ( !data || !data.query || !data.query.pages 
|| loadingType != currentTypeOrSubtype ) {
                                        return;
                                }
+                               
                                $.each( data.query.pages, function( id, page ) {
                                        if ( page.imageinfo && 
page.imageinfo.length ) {
                                                // build an image tag with the 
correct url and width
@@ -480,7 +481,13 @@
                                                        .attr( 'src', 
page.imageinfo[0].thumburl )
                                                        .attr( 'width', 
currentTypeOrSubtype.gallery.width )
                                                        .hide()
-                                                       .load( function() { $( 
this ).css( 'display', 'inline-block' ); } );
+                                                       .load( function() { 
+                                                               $( this ).css( 
'display', 'inline-block' );
+                                                               loadingIndex++;
+                                                               if ( 
loadingIndex >= currentTypeOrSubtype.gallery.number ) {
+                                                                       $( 
'#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
+                                                               }
+                                                       } );
                                                $( 
'#mw-wikilove-gallery-content' ).append( 
                                                        $( '<a href="#"></a>' )
                                                                .attr( 'id', 
'mw-wikilove-gallery-img-' + index )


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to