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, config, title) → {string|null}

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

Parameters:
Name Type Description
el Element
config mw.Map
title mw.Title
Source:
Returns:
Type
string | null

(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