Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gallery slideshow: Fix height calculation #31

Open
wants to merge 1 commit into
base: REL1_33_6-FANDOM
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions resources/src/mediawiki.page.gallery.slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
this.$galleryBox = this.$gallery.find( '.gallerybox' );
this.$currentImage = null;
this.imageInfoCache = {};
if ( this.$gallery.parent().attr( 'id' ) !== 'mw-content-text' ) {
this.$container = this.$gallery.parent();
}

// Initialize
this.drawCarousel();
Expand Down Expand Up @@ -87,11 +84,6 @@
* @property {jQuery} $currentImage The `<li>` element of the current image.
*/

/**
* @property {jQuery} $container If the gallery contained in an element that is
* not the main content element, then it stores that element.
*/

/**
* @property {Object} imageInfoCache A key value pair of thumbnail URLs and image info.
*/
Expand Down Expand Up @@ -185,15 +177,8 @@
* size.
*/
mw.GallerySlideshow.prototype.setSizeRequirement = function () {
var w, h;

if ( this.$container !== undefined ) {
w = this.$container.width() * 0.9;
h = ( this.$container.height() - this.getChromeHeight() ) * 0.9;
} else {
w = this.$imgContainer.width();
var w = this.$imgContainer.width(),
h = Math.min( $( window ).height() * ( 3 / 4 ), this.$imgContainer.width() ) - this.getChromeHeight();
}

// Only update and flush the cache if the size changed
if ( w !== this.imageWidth || h !== this.imageHeight ) {
Expand All @@ -211,7 +196,7 @@
* @return {number} Height
*/
mw.GallerySlideshow.prototype.getChromeHeight = function () {
return this.$interface.outerHeight() + this.$galleryCaption.outerHeight();
return this.$interface.outerHeight() + ( this.$galleryCaption.outerHeight() || 0 );
};

/**
Expand Down