Expand all

MultimediaViewerBootstrap

Bootstrap code listening to thumb clicks checking the initial location.hash Loads the mmv and opens it if necessary

Constructor

new MultimediaViewerBootstrap() #

Properties

eventHandlersHaveBeenSetUp :boolean #

tracks domready event handler state

Type:

  • boolean
Source:
tracks domready event handler state

viewerIsBroken :boolean #

This flag is set to true when we were unable to load the viewer.

Type:

  • boolean
Source:
This flag is set to true when we were unable to load the viewer.

Methods

cleanupEventHandlers() #

Cleans up event handlers, used for tests

Source:
Cleans up event handlers, used for tests

cleanupOverlay() #

Cleans up the overlay

Source:
Cleans up the overlay

click(e, image) → {boolean} #

Handles a click event on a link

Parameters:

Name Type Description
e jQuery.Event

jQuery event object

image LightboxImage

Image

Returns:

a value suitable for an event handler (ie. true if the click should be handled by the browser).

Type
boolean
Source:
Handles a click event on a link

ensureEventHandlersAreSetUp() #

Makes sure event handlers are set up properly via MultimediaViewerBootstrap.setupEventHandlers(). Called before loading the main mmv module. At this point, event handlers for MultimediaViewerBootstrap should have been set up, but due to bug 70756 it cannot be guaranteed.

Source:
Makes sure event handlers are set up properly via MultimediaViewerBootstrap.setupEventHandlers().

findCaption($thumbContainer, $link) → {string|undefined} #

Finds the caption for an image.

Parameters:

Name Type Description
$thumbContainer jQuery

The container for the thumbnail.

$link jQuery

The link that encompasses the thumbnail.

Returns:

Unsafe HTML may be present - caution

Type
string | undefined
Source:
Finds the caption for an image.

findGalleryCaption($thumbContainer) → {jQuery} #

Finds the caption of a gallery image

Parameters:

Name Type Description
$thumbContainer jQuery

The container for the thumbnail.

Returns:

Type
jQuery
Source:
Finds the caption of a gallery image

findInfoboxCaption($link) → {string|undefined} #

Finds the caption for an image that lives in an infobox (T429839).

The lookup is deliberately scoped to the image's own cell and never to the whole infobox: a caption belonging to a different image (a signature, a secondary photo) must never be shown. For the same reason we only return a caption when the cell holds exactly one image and one caption, so a shared cell (e.g. light/dark logo variants) can't attach one caption to several images. When in doubt, return nothing.

Parameters:

Name Type Description
$link jQuery

The link (a.mw-file-description / a.image) around the image

Returns:

Unsafe HTML may be present - caution

Type
string | undefined
Source:
Finds the caption for an image that lives in an infobox (T429839).

findLegacyCaption($thumbContainer, $link) → {string|undefined} #

Finds the caption for an image.

Parameters:

Name Type Description
$thumbContainer jQuery

The container for the thumbnail.

$link jQuery

The link that encompasses the thumbnail.

Returns:

Unsafe HTML may be present - caution

Type
string | undefined
Source:
Finds the caption for an image.

hash() #

Handles the browser location hash on pageload or hash change

Source:
Handles the browser location hash on pageload or hash change

isAllowedThumb($thumb) → {boolean} #

Check if this thumbnail should be handled by MediaViewer

Parameters:

Name Type Description
$thumb jQuery

the thumbnail (an <img> element) in question

Returns:

Type
boolean
Source:
Check if this thumbnail should be handled by MediaViewer

isBetaMode() → {boolean} #

Whether the beta UI should be used instead of the legacy viewer. Enabled by the server for mobile views when $wgMediaViewerMobileBeta is set (T428774), or by the ?mmvBeta=1 URL parameter on any skin.

Returns:

Type
boolean
Source:
Whether the beta UI should be used instead of the legacy viewer.

isValidExtension(title) → {boolean} #

Parameters:

Name Type Description
title mw.Title | null

Returns:

Type
boolean
Source:

loadViewer() → {jQuery.Promise} #

Loads the mmv module asynchronously and passes the thumb data to it

Returns:

Type
jQuery.Promise
Source:
Loads the mmv module asynchronously and passes the thumb data to it

openImage(image) #

Opens MediaViewer and loads the given thumbnail. Requires processThumb() to be called first.

Parameters:

Name Type Description
image LightboxImage

Image

Source:
Opens MediaViewer and loads the given thumbnail.

preloadAssets($thumbContainer) #

Preload JS/CSS when the mouse cursor hovers the thumb container (thumb image + caption + border)

Parameters:

Name Type Description
$thumbContainer jQuery
Source:

Preload JS/CSS when the mouse cursor hovers the thumb container (thumb image + caption + border)

processFilePageThumb($thumb, title) #

Processes the main thumbnail of a file page by adding some buttons below to open MediaViewer.

Parameters:

Name Type Description
$thumb jQuery
title mw.Title
Source:

Processes the main thumbnail of a file page by adding some buttons below to open MediaViewer.

processLegacyThumb(thumb) #

Processes a legacy thumb

Parameters:

Name Type Description
thumb Object
Source:
Processes a legacy thumb

processThumb(thumb) #

Processes a thumb, making use of the specified structure, https://www.mediawiki.org/wiki/Specs/HTML#Media

Parameters:

Name Type Description
thumb Object
Source:

Processes a thumb, making use of the specified structure, https://www.mediawiki.org/wiki/Specs/HTML#Media

processThumbs($content) #

Processes all thumbs found on the page

Parameters:

Name Type Description
$content jQuery

Element to search for thumbs

Source:
Processes all thumbs found on the page

route(fileName) #

Routes to a given file.

Parameters:

Name Type Description
fileName string
Source:
Routes to a given file.

setupEventHandlers() #

Listens to events on the window/document

Source:
Listens to events on the window/document

setupOverlay() #

Sets up the overlay while the viewer loads

Source:
Sets up the overlay while the viewer loads

setupRouter(router) #

Sets up the route handlers

Parameters:

Name Type Description
router OO.Router
Source:
Sets up the route handlers