Gilles has uploaded a new change for review.

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


Change subject: Make the behavior of the lightbox more consistent with scroll
......................................................................

Make the behavior of the lightbox more consistent with scroll

Makes sure that the advanced description is out of view when
the lightbox opens.
Remembers the scrollTop position that was set when the lightbox
opens, in order to restore it when it closes.

Change-Id: I534f7d718528d1e5a4911c68a524eb96cadeae90
---
M resources/ext.multimediaViewer/ext.multimediaViewer.lightboxinterface.js
1 file changed, 22 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer 
refs/changes/63/106263/1

diff --git 
a/resources/ext.multimediaViewer/ext.multimediaViewer.lightboxinterface.js 
b/resources/ext.multimediaViewer/ext.multimediaViewer.lightboxinterface.js
index c882d2e..8f86f57 100644
--- a/resources/ext.multimediaViewer/ext.multimediaViewer.lightboxinterface.js
+++ b/resources/ext.multimediaViewer/ext.multimediaViewer.lightboxinterface.js
@@ -89,6 +89,28 @@
                }
        };
 
+       LIP.attach = function ( parentId ) {
+               // Advanced description needs to be below the fold when the 
lightbox opens
+               // regardless of what the scroll value was prior to opening the 
lightbox
+               var $document = $( document );
+
+               // Save the scrollTop value because we want below to be back to 
where they were
+               // before opening the lightbox
+               this.scrollTopBeforeAttach = $document.scrollTop();
+               $document.scrollTop( 0 );
+
+               MLBInterface.prototype.attach.call( this, parentId );
+       }
+
+       LIP.unattach = function () {
+               MLBInterface.prototype.unattach.call( this );
+
+               // Restore the scrollTop as it was before opening the lightbox
+               if ( this.scrollTopBeforeAttach !== undefined ) {
+                       $( document ).scrollTop( this.scrollTopBeforeAttach );
+               }
+       }
+
        LIP.load = function ( image ) {
                var hashFragment = '#mediaviewer/' + 
mw.mediaViewer.currentImageFilename + '/' + 
mw.mediaViewer.lightbox.currentIndex;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I534f7d718528d1e5a4911c68a524eb96cadeae90
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>

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

Reply via email to