Sophivorus has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311350

Change subject: Stability and styling
......................................................................

Stability and styling

By generating the URLs with the #filepath parser function, the extension
works when the files are hosted at places other than the local repo.

Change-Id: I05ea06e05eaad48b0784d69771cc1bcbd12b648b
---
M HoverGallery.body.php
M HoverGallery.js
2 files changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Hovergallery 
refs/changes/50/311350/1

diff --git a/HoverGallery.body.php b/HoverGallery.body.php
index c8a5513..d709c6b 100644
--- a/HoverGallery.body.php
+++ b/HoverGallery.body.php
@@ -31,9 +31,9 @@
                $FILENAMES = array_filter( explode( PHP_EOL, trim( $input ) ) );
                foreach ( $FILENAMES as $filename ) {
                        $filename = strtok( $filename, '|' ); // Remove the 
options
-                       $title = Title::newFromText( $filename, NS_FILE );
-                       $file = wfLocalFile( $title );
-                       $FILEURLS[] = $file->getFullUrl();
+                       $filename = substr( $filename, ( $position = strpos( 
$filename, ':' ) ) === false ? 0 : $position + 1 ); // Remove the File prefix
+                       $filepath = $parser->recursiveTagParse( '{{filepath:' . 
$filename . '|nowiki}}' ); // Get the filepath
+                       $FILEURLS[] = $filepath;
                }
 
                $fileUrls = json_encode( $FILEURLS );
diff --git a/HoverGallery.js b/HoverGallery.js
index 58892cd..52e2d3a 100644
--- a/HoverGallery.js
+++ b/HoverGallery.js
@@ -10,10 +10,11 @@
 
        onMouseEnter: function () {
                // First show the loading icon
-               var loadingUrl = mw.config.get( 'wgExtensionAssetsPath' ) + 
'/hovergallery/images/loading.gif',
+               var loadingUrl = mw.config.get( 'wgExtensionAssetsPath' ) + 
'/Hovergallery/images/loading.gif',
                        loadingImg = $( '<img>' ).addClass( 'hoverimage' 
).attr( 'src', loadingUrl );
                $( 'body' ).append( loadingImg );
 
+               // Get the data from the gallery
                var gallery = $( this ).closest( '.gallery' ),
                        fileUrls = gallery.data( 'hovergallery-fileurls' ),
                        maxHoverWidth = gallery.data( 
'hovergallery-maxhoverwidth' ),
@@ -21,18 +22,19 @@
 
                // Determine which of the thumbs is it
                var thumbs = $( 'img', gallery ),
-                       thumbIndex = $.inArray( this, thumbs );
+                       thumbIndex = $.inArray( this, thumbs ),
+                       url = fileUrls[ thumbIndex ],
+                       url = $( '<span>' ).html( url ).text(); // Decode the 
HTML entities in the URL
 
-               // Get the corresponding URL and build the image
-               var url = fileUrls[ thumbIndex ],
-                       image = new Image();
-                       image.src = url;
-                       image.onload = function () {
-                               loadingImg.css({
-                                       'max-width': maxHoverWidth + 'px',
-                                       'max-height': maxHoverHeight + 'px'
-                               }).attr( 'src', url );
-                       };
+               // Replace the loading icon with the image
+               var image = new Image();
+               image.src = url;
+               image.onload = function () {
+                       loadingImg.css({
+                               'max-width': maxHoverWidth + 'px',
+                               'max-height': maxHoverHeight + 'px'
+                       }).attr( 'src', url );
+               };
        },
 
        onMouseLeave: function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/311350
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05ea06e05eaad48b0784d69771cc1bcbd12b648b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Hovergallery
Gerrit-Branch: master
Gerrit-Owner: Sophivorus <scheno...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to