Autocomplete

Autocomplete

Autocomplete dropdown class.

Constructor

new Autocomplete(options)

Source:

Create an autocomplete instance. An instance is a set of settings and inputs to which these settings apply.

Parameters:
Name Type Description
options object
Properties
Name Type Attributes Description
types Array.<('mentions'|'commentLinks'|'wikilinks'|'templates'|'tags')>

Which values should be autocompleted.

inputs Array.<external:OO.ui.TextInputWidget>

Inputs to attach the autocomplete to. Please note that these should be CD's TextInputWidgets, not OO.ui.TextInputWidgets, since we use CD's method TextInputWidget#cdInsertContent on the inputs here. This is not essential, so if you borrow the source code, you can replace it with native OO.ui.TextInputWidget#insertContent.

comments Array.<string> <optional>

List of comments in the section for the mentions and comment links autocomplete.

defaultUserNames Array.<string> <optional>

Default list of user names for the mentions autocomplete.

Members

tribute :Tribute

Source:

Tribute object.

Type:
  • Tribute

Methods

(static) getActiveMenu() → {Element}

Source:

Get the active autocomplete menu element.

Returns:
Type
Element

(static) getConfig(type, …args) → {object}

Source:

For internal use. Get an autocomplete configuration for the specified type.

Parameters:
Name Type Attributes Description
type string
args * <repeatable>
Returns:
Type
object

(static) getRelevantPageNames(text) → {Promise.<Array.<string>>}

Source:

Get a list of 10 page names matching the specified search text. Page names are sorted as OpenSearch sorts them. Redirects are not resolved.

Reuses the existing request if available.

Parameters:
Name Type Description
text string
Throws:
Returns:
Type
Promise.<Array.<string>>

(static) getRelevantTemplateNames(text) → {Promise.<Array.<string>>}

Source:

Get a list of 10 template names matching the specified search text. Template names are sorted as OpenSearch sorts them. Redirects are not resolved.

Reuses the existing request if available.

Parameters:
Name Type Description
text string
Throws:
Returns:
Type
Promise.<Array.<string>>

(static) getRelevantUserNames(text) → {Promise.<Array.<string>>}

Source:

Get a list of 10 user names matching the specified search text. User names are sorted as OpenSearch sorts them. Only users with a talk page existent are included. Redirects are resolved.

Reuses the existing request if available.

Parameters:
Name Type Description
text string
Throws:
Returns:
Type
Promise.<Array.<string>>

(static) useOriginalFirstCharCase(result, query) → {string}

Source:

Given a query and a case-insensitively matching result, replace the first character of the result with the first character of in the query. E.g., the query "huma" finds the article "Human", but we restore the first "h".

Parameters:
Name Type Description
result string
query string
Returns:
Type
string

cleanUp()

Source:

Clean up event handlers.

init()

Source:

Initialize autocomplete for the inputs.