Module: preview/model

Members

(inner, constant) previewTypes :Object

Page Preview types as defined in Schema:Popups https://meta.wikimedia.org/wiki/Schema:Popups

Type:
  • Object
Source:

Methods

(static) createModel(title, url, languageCode, languageDirection, extract, type, thumbnailopt, pageIdopt) → {PagePreviewModel}

Creates a page preview model.

Parameters:
Name Type Attributes Description
title string
url string

The canonical URL of the page being previewed

languageCode string
languageDirection string

Either "ltr" or "rtl"

extract Array | undefined | null
type string
thumbnail Object | undefined <optional>
pageId number <optional>
Source:
Returns:
Type
PagePreviewModel

(static) createNullModel(title, url) → {PagePreviewModel}

Creates an empty page preview model.

Parameters:
Name Type Description
title string
url string
Source:
Returns:
Type
PagePreviewModel

(static) findNearestEligibleTarget(element) → {HTMLElement|null}

Recursively checks the element and its parents.

Parameters:
Name Type Description
element HTMLElement
Source:
Returns:
Type
HTMLElement | null

(static) getDwellDelay(type) → {number}

Determines the delay before showing the preview when dwelling a link.

Parameters:
Name Type Description
type string
Source:
Returns:
Type
number

(static) getPreviewType(el) → {string|null}

Determines the applicable popup type based on title and link element.

Parameters:
Name Type Description
el HTMLAnchorElement
Source:
Returns:

One of the previewTypes.TYPE_… constants

Type
string | null

(static) registerModel(type, selector, delayopt)

Allows extensions to register their own page previews.

Parameters:
Name Type Attributes Description
type string
selector string

A valid CSS selector to associate preview with

delay number <optional>

optional delay between hovering and displaying preview. If not defined, delay will be zero.

Source:

(inner) elementMatchesSelector(element, selector) → {boolean}

Parameters:
Name Type Description
element HTMLElement
selector string
Source:
Returns:
Type
boolean

(inner) getPagePreviewType(type, processedExtractopt) → {string}

Determines the page preview type based on whether or not: a. Is the preview empty. b. The preview type matches one of previewTypes. c. Assume standard page preview if both above are false

Parameters:
Name Type Attributes Description
type string
processedExtract Array | undefined <optional>
Source:
Returns:

One of the previewTypes.TYPE_… constants.

Type
string

(inner) processExtract(extract) → {Array|undefined}

Processes the extract returned by the TextExtracts MediaWiki API query module.

If the extract is undefined, null, or empty, then undefined is returned.

Parameters:
Name Type Description
extract Array | undefined | null
Source:
Returns:

Array when extract is an not empty array, undefined otherwise

Type
Array | undefined

Type Definitions

PreviewType

Type:
  • Object
Properties:
Name Type Description
name string

identifier for preview type

selector string

a CSS selector

Source: