mw.GallerySlideshow

Interface controls for the slideshow gallery. To use, first load the mediawiki.page.gallery.slideshow ResourceLoader module.

Constructor

new mw.GallerySlideshow(gallery) #

Encapsulates the user interface of the slideshow galleries. An object is instantiated for each .mw-gallery-slideshow element.

Parameters:

Name Type Description
gallery jQuery

The <ul> element of the gallery.

Source:

Properties

$carousel :jQuery|null #

The <li> element that contains the carousel.

Type:

Source:
The <li> element that contains the carousel.

$currentImage :jQuery #

The <li> element of the current image.

Type:

Source:
The <li> element of the current image.

$gallery :jQuery #

The <ul> element of the gallery.

Type:

Source:
The <ul> element of the gallery.

$galleryBox :jQuery #

Selection of <li> elements that have thumbnails.

Type:

Source:
Selection of <li> elements that have thumbnails.

$galleryCaption :jQuery #

The <li> that has the gallery caption.

Type:

Source:
The <li> that has the gallery caption.

$img :jQuery #

The <img> element that'll display the current image.

Type:

Source:
The <img> element that'll display the current image.

$imgCaption :jQuery #

The <p> element that holds the image caption.

Type:

Source:
The <p> element that holds the image caption.

$imgContainer :jQuery #

The <div> element that contains the image.

Type:

Source:
The <div> element that contains the image.

$interface :jQuery #

The <div> element that contains the interface buttons.

Type:

Source:
The <div> element that contains the interface buttons.

imageHeight :number #

Height of the image based on viewport size the URLs in the required size.

Type:

Source:
Height of the image based on viewport size the URLs in the required size.

imageInfoCache :Object.<string, jQuery.Promise> #

A key value pair of thumbnail URLs and image info.

Type:

Source:
A key value pair of thumbnail URLs and image info.

imageWidth :number #

Width of the image based on viewport size.

Type:

Source:
Width of the image based on viewport size.

Methods

drawCarousel() #

Draws the carousel and the interface around it.

Source:
Draws the carousel and the interface around it.

getChromeHeight() → {number} #

Gets the height of the interface elements and the gallery's caption.

Source:

Returns:

Height

Type
number

Gets the height of the interface elements and the gallery's caption.

getCurrentImage() → {jQuery} #

Getter method for $currentImage.

Source:

Returns:

Type
jQuery
Getter method for $currentImage.

getDimensionToRequest($img) → {string} #

Given an image, the method checks whether to use the height or the width to request the larger image.

Parameters:

Name Type Description
$img jQuery
Source:

Returns:

Type
string

Given an image, the method checks whether to use the height or the width to request the larger image.

getImageInfo($img) → {jQuery.Promise} #

Gets the image's info given an <img> element.

Parameters:

Name Type Description
$img Object
Source:

Returns:

Resolves with the image's info.

Type
jQuery.Promise
Gets the image's info given an <img> element.

getNextImage() → {jQuery} #

Gets the image after the current one. Returns the first image if the current one is the last.

Source:

Returns:

Type
jQuery
Gets the image after the current one.

getPrevImage() → {jQuery} #

Gets the image before the current one. Returns the last image if the current one is the first.

Source:

Returns:

Type
jQuery
Gets the image before the current one.

loadImage($img) → {jQuery.Promise} #

Loads the full image given the <img> element of the thumbnail.

Parameters:

Name Type Description
$img jQuery
Source:

Returns:

Resolves with the image's URL and original element once the image has loaded.

Type
jQuery.Promise
Loads the full image given the <img> element of the thumbnail.

nextImage() #

Sets the $currentImage to the next one and shows it in the carousel.

Source:

Sets the $currentImage to the next one and shows it in the carousel.

prevImage() #

Sets the $currentImage to the previous one and shows it in the carousel.

Source:

Sets the $currentImage to the previous one and shows it in the carousel.

setImageSize() #

Sets the height and width of $img based on the proportion of the image and the values generated by setSizeRequirement.

Source:

Sets the height and width of $img based on the proportion of the image and the values generated by setSizeRequirement.

setSizeRequirement() #

Sets the imageWidth and imageHeight properties based on the size of the window. Also flushes the imageInfoCache as we'll now need URLs for a different size.

Source:

Sets the imageWidth and imageHeight properties based on the size of the window.

showCurrentImage(init) #

Displays the image set as $currentImage in the carousel.

Parameters:

Name Type Description
init boolean

Image being shown during gallery init (i.e. first image)

Source:

Displays the image set as $currentImage in the carousel.

toggleThumbnails(show) #

Toggles visibility of the thumbnails.

Parameters:

Name Type Description
show boolean

Optional argument to control the state

Source:
Toggles visibility of the thumbnails.