preview/model

Properties

previewTypes :Objectinnerconstant #

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

Type:

  • Object
Source:

Methods

createModel(title, url, languageCode, languageDirection, extract, type, thumbnail, pageId) → {PagePreviewModel}static #

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

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

Creates an empty page preview model.

Parameters:

Name Type Description
title string
url string
Source:

Returns:

Type
PagePreviewModel

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

Recursively checks the element and its parents.

Parameters:

Name Type Description
element HTMLElement
Source:

Returns:

Type
HTMLElement | null

getDwellDelay(type) → {number}static #

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

Parameters:

Name Type Description
type string
Source:

Returns:

Type
number

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

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

registerModel(type, selector, delay)static #

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:

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

Parameters:

Name Type Description
element HTMLElement
selector string
Source:

Returns:

Type
boolean

getPagePreviewType(type, processedExtract) → {string}inner #

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

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

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

PagePreviewModel #

Type:

  • Object

Properties:

Name Type Description
title string
extract Array | undefined

undefined if the extract isn't viable, e.g. if it's empty after having ellipsis and parentheticals removed; this can be used to present default or error states

languageCode string
languageDirection string

Either "ltr" or "rtl", or an empty string if undefined.

thumbnail Object | undefined
pageId number

Currently not used by any known popup type.

Source:

PreviewModel #

Preview Model

Type:

  • Object

Properties:

Name Type Description
url string

The canonical URL of the page being previewed

type string

One of the previewTypes.TYPE_… constants.

Source:

PreviewType #

Type:

  • Object

Properties:

Name Type Description
name string

identifier for preview type

selector string

a CSS selector

Source:

ReferencePreviewModel #

Type:

  • Object

Properties:

Name Type Description
extract string

An HTML snippet, not necessarily with a single top-level node

referenceType string

A type identifier, e.g. "web"

sourceElementId string

ID of the parent element that triggered the preview

Source: