Expand all

MultimediaViewer

Analyses the page, looks for image content and sets up the hooks to manage the viewing experience of such content.

Constructor

new MultimediaViewer() #

Source:

Properties

currentIndex #

Image index on page.

Properties:

Type Description
number
Source:
Image index on page.

documentTitle #

Properties:

Name Type Description
documentTitle string

base document title, MediaViewer will expand this

Source:

metadataPreloadQueue #

Stores image metadata preloads, so they can be cancelled.

Properties:

Type Description
TaskQueue
Source:
Stores image metadata preloads, so they can be cancelled.

preloadDistance #

Preload this many prev/next images to speed up navigation. (E.g. preloadDistance = 3 means that the previous 3 and the next 3 images will be loaded.) Preloading only happens when the viewer is open.

Properties:

Type Description
number
Source:
Preload this many prev/next images to speed up navigation.

realThumbnailShown #

Stores whether the real image was loaded and displayed already. This is reset when paging, so it is not necessarily accurate.

Properties:

Type Description
boolean
Source:
Stores whether the real image was loaded and displayed already.

router #

Properties:

Name Type Description
router OO.Router
Source:

thumbnailPreloadQueue #

Stores image thumbnail preloads, so they can be cancelled.

Properties:

Type Description
TaskQueue
Source:
Stores image thumbnail preloads, so they can be cancelled.

viewLogger #

Properties:

Name Type Description
view ViewLogger
Source:

Methods

cancelImageMetadataPreloading() #

Cancels in-progress image metadata preloading.

Source:
Cancels in-progress image metadata preloading.

cancelThumbnailsPreloading() #

Cancels in-progress image thumbnail preloading.

Source:
Cancels in-progress image thumbnail preloading.

cleanupEventHandlers() #

Unregisters all event handlers. Currently only used in tests.

Source:
Unregisters all event handlers.

close() #

Handles close event coming from the lightbox

Source:
Handles close event coming from the lightbox

createDocumentTitle(imageTitle) → {string} #

Creates a string which can be shown as document title (the text at the top of the browser window).

Parameters:

Name Type Description
imageTitle mw.Title | null

the title object for the image which is displayed; null when the viewer is being closed

Returns:

Type
string
Source:
Creates a string which can be shown as document title (the text at the top of the browser window).

displayPlaceholderThumbnail(image, $initialImage, imageWidths, [recursion]) #

Display the thumbnail from the page

Parameters:

Name Type Attributes Default Description
image LightboxImage
$initialImage jQuery

The thumbnail from the page

imageWidths ThumbnailWidth
recursion boolean optional
false

for internal use, never set this when calling from outside

Source:
Display the thumbnail from the page

displayRealThumbnail(thumbnail, imageElement, imageWidths) #

Display the real, full-resolution, thumbnail that was fetched with fetchThumbnail

Parameters:

Name Type Description
thumbnail Thumbnail
imageElement HTMLImageElement
imageWidths ThumbnailWidth
Source:
Display the real, full-resolution, thumbnail that was fetched with fetchThumbnail

fetchSizeIndependentLightboxInfo(fileTitle) → {jQuery.Promise.<ImageModel>} #

Loads all the size-independent information needed by the lightbox (image metadata, repo information).

Parameters:

Name Type Description
fileTitle mw.Title

Title of the file page for the image.

Returns:

Type
jQuery.Promise.<ImageModel>
Source:

Loads all the size-independent information needed by the lightbox (image metadata, repo information).

fetchThumbnail(fileTitle, width, [sampleUrl], [originalWidth], [originalHeight], [useThumbnailGuessing0]) → {jQuery.Promise.<Thumbnail, HTMLImageElement>} #

Loads size-dependent components of a lightbox - the thumbnail model and the image itself.

Parameters:

Name Type Attributes Description
fileTitle mw.Title
width number

the width of the requested thumbnail

sampleUrl string optional

a thumbnail URL for the same file (but with different size) (might be missing)

originalWidth number optional

the width of the original, full-sized file (might be missing)

originalHeight number optional

the height of the original, full-sized file (might be missing)

useThumbnailGuessing0 boolean optional

the useThumbnailGuessing flag

Returns:

A promise resolving to a thumbnail model and an element. It might or might not have progress events which return a single number.

Type
jQuery.Promise.<Thumbnail, HTMLImageElement>
Source:
Loads size-dependent components of a lightbox - the thumbnail model and the image itself.

fetchThumbnailForLightboxImage(image, width) → {jQuery.Promise.<Thumbnail, HTMLImageElement>} #

Loads size-dependent components of a lightbox - the thumbnail model and the image itself.

Parameters:

Name Type Description
image LightboxImage
width number

the width of the requested thumbnail

Returns:

Type
jQuery.Promise.<Thumbnail, HTMLImageElement>
Source:
Loads size-dependent components of a lightbox - the thumbnail model and the image itself.

firstImage() #

Opens the last image

Source:
Opens the last image

initWithThumbs(thumbs) #

Initialize the lightbox interface given an array of thumbnail objects.

Parameters:

Name Type Description
thumbs Array.<LightboxImage>
Source:

Initialize the lightbox interface given an array of thumbnail objects.

lastImage() #

Opens the last image

Source:
Opens the last image

loadExtensionPlugins(extension) → {jQuery.Promise} #

Loads the RL module defined for a given file extension, if any

Parameters:

Name Type Description
extension string

File extension

Returns:

Type
jQuery.Promise
Source:
Loads the RL module defined for a given file extension, if any

loadImage(image) #

Loads a specified image.

Parameters:

Name Type Description
image LightboxImage
Source:
Loads a specified image.

loadImageByTitle(title, [position]) #

Loads an image by its title

Parameters:

Name Type Attributes Description
title mw.Title
position number optional
Source:
Loads an image by its title

loadIndex(index) #

Loads an image at a specified index in the viewer's thumbnail array.

Parameters:

Name Type Description
index number
Source:
Loads an image at a specified index in the viewer's thumbnail array.

nextImage() #

Opens the next image

Source:
Opens the next image

preloadImagesMetadata() #

Preload metadata for next and prev N image (N = MMVP.preloadDistance). Two images will be loaded at a time (one forward, one backward), with closer images being loaded sooner.

Source:
Preload metadata for next and prev N image (N = MMVP.preloadDistance).

preloadThumbnails() #

Preload thumbnails for next and prev N image (N = MMVP.preloadDistance). Two images will be loaded at a time (one forward, one backward), with closer images being loaded sooner.

Source:
Preload thumbnails for next and prev N image (N = MMVP.preloadDistance).

prevImage() #

Opens the previous image

Source:
Opens the previous image

resetThumbnailStates() #

Resets the cross-request states needed to handle the thumbnail logic.

Source:
Resets the cross-request states needed to handle the thumbnail logic.

resize() #

Handles resize events in viewer.

Source:
Handles resize events in viewer.

setImage(thumbnail, imageElement, imageWidths) #

Loads and sets the specified image. It also updates the controls.

Parameters:

Name Type Description
thumbnail Thumbnail

thumbnail information

imageElement HTMLImageElement
imageWidths ThumbnailWidth
Source:
Loads and sets the specified image.

setTitle() #

Updates the page title to reflect the current title.

Source:
Updates the page title to reflect the current title.

setupEventHandlers() #

Registers all event handlers

Source:
Registers all event handlers

setupProgressBar(image, imagePromise, imageWidth) #

Displays a progress bar for the image loading, if necessary, and sets up handling of all the related callbacks.

Parameters:

Name Type Description
image LightboxImage
imagePromise jQuery.Promise.<Thumbnail, HTMLImageElement>
imageWidth number

needed for caching progress (FIXME)

Source:

Displays a progress bar for the image loading, if necessary, and sets up handling of all the related callbacks.

Events

mmv-close() #

Fired when the viewer is closed. This is used by the lightbox to notify the main app.

Source:
Fired when the viewer is closed.

mmv-next() #

Fired when the user requests the next image.

Source:
Fired when the user requests the next image.

mmv-prev() #

Fired when the user requests the previous image.

Source:
Fired when the user requests the previous image.

mmv-request-thumbnail(size) #

Used by components to request a thumbnail URL for the current thumbnail, with a given size.

Parameters:

Name Type Description
size number
Source:
Used by components to request a thumbnail URL for the current thumbnail, with a given size.

mmv-resize-end() #

Fired when the screen size changes. Debounced to avoid continuous triggering while resizing with a mouse.

Source:
Fired when the screen size changes.

mmv-resize-end() #

Fired when the screen size changes. Debounced to avoid continuous triggering while resizing with a mouse.

Source:
Fired when the screen size changes.