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) 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) isAnythingEligible() → {boolean}

Check whether any kind of preview is enabled.

Source:
Returns:
Type
boolean

(static) isEligible(element) → {boolean}

Check whether the element is eligible for previews.

Parameters:
Name Type Description
element Element
Source:
Returns:
Type
boolean

(static) registerModel(type, selector)

Allows extensions to register their own page previews.

Parameters:
Name Type Description
type string
selector string

A valid CSS selector to associate preview with

Source:

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

Parameters:
Name Type Description
element Element
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: