abstract mw.widgets.TitleWidget(configopt)

new mw.widgets.TitleWidget(configopt)abstract #

Mixin for title widgets.

Parameters:

Name Type Attributes Description
config Object <optional>

Configuration options

Properties
Name Type Attributes Default Description
limit number <optional>
10

Number of results to show

namespace number <optional>

Namespace to prepend to queries

maxLength number <optional>
255

Maximum query length

relative boolean <optional>
true

If a namespace is set, display titles relative to it

suggestions boolean <optional>
true

Display search suggestions

showRedirectTargets boolean <optional>
true

Show the targets of redirects

showImages boolean <optional>
false

Show page images

showDescriptions boolean <optional>
false

Show page descriptions

showDisambigsLast boolean <optional>
false

Show disambiguation pages as the last results

showMissing boolean <optional>

Show the user's input as a missing page when a page with this exact name doesn't exist. Disabled by default when the namespace option is used, otherwise enabled by default.

showInterwikis boolean <optional>
false

Show pages with a valid interwiki prefix

searchFragments boolean <optional>
false

Search for hash fragments on a specific page when typed

addQueryInput boolean <optional>
true

Add exact user's input query to results

excludeCurrentPage boolean <optional>
false

Exclude the current page from suggestions

excludeDynamicNamespaces boolean <optional>
false

Exclude pages whose namespace is negative

validateTitle boolean <optional>
true

Whether the input must be a valid title

required boolean <optional>
false

Whether the input must not be empty

highlightSearchQuery boolean <optional>
true

Highlight the partial query the user used for this title

cache Object <optional>

Result cache which implements a 'set' method, taking keyed values as an argument

api mw.Api <optional>

API object to use, creates a default mw.Api instance if not specified

Source:
Mixin for title widgets.

Methods

createOptionWidget(data) → {OO.ui.MenuOptionWidget} #

Create a menu option widget with specified data.

Parameters:

Name Type Description
data Object

Data for option widget

Source:

Returns:

Data for option widget

Type
OO.ui.MenuOptionWidget
Create a menu option widget with specified data.

getApi() → {mw.Api} #

Get the API object for title requests.

Source:

Returns:

MediaWiki API

Type
mw.Api
Get the API object for title requests.

getApiParams(query) → {Object} #

Get API params for a given query.

Parameters:

Name Type Description
query string

User query

Source:

Returns:

API params

Type
Object
Get API params for a given query.

getMWTitle(valueopt) → {mw.Title|null} #

Get title object corresponding to given value, or #getQueryValue if not given.

Parameters:

Name Type Attributes Description
value string <optional>

Value to get a title for

Source:

Returns:

Title object, or null if value is invalid

Type
mw.Title | null
Get title object corresponding to given value, or #getQueryValue if not given.

getNamespace() → {number|null} #

Get the namespace to prepend to titles in suggestions, if any.

Source:

Returns:

Namespace number

Type
number | null
Get the namespace to prepend to titles in suggestions, if any.

getOptionWidgetData(title, data) → {Object} #

Get menu option widget data from the title and page data.

Parameters:

Name Type Description
title string

Title object

data Object

Page data

Source:

Returns:

Data for option widget

Type
Object
Get menu option widget data from the title and page data.

getOptionsFromData(data) → {Array.<OO.ui.OptionWidget>} #

Get option widgets from the server response.

Parameters:

Name Type Description
data Object

Query result

Source:

Returns:

Menu items

Type
Array.<OO.ui.OptionWidget>
Get option widgets from the server response.

getQueryValue() → {string}abstract #

Get the current value of the search query.

Source:

Returns:

Search query

Type
string
Get the current value of the search query.

getSectionSuggestions(title, fragmentQuery) → {jQuery.Promise} #

Suggest link fragments from the sections API.

Parameters:

Name Type Description
title string

Title, extracted form the user input

fragmentQuery string

Partial link fragment, from the user input

Source:

Returns:

Suggestions promise

Type
jQuery.Promise
Suggest link fragments from the sections API.

getSuggestionsPromise() → {jQuery.Promise} #

Get a promise which resolves with an API response for suggested links for the current query.

Source:

Returns:

Suggestions promise

Type
jQuery.Promise

Get a promise which resolves with an API response for suggested links for the current query.

isQueryValid() → {boolean} #

Check if the query is valid.

Source:

Returns:

The query is valid

Type
boolean
Check if the query is valid.

setNamespace(namespace) #

Set the namespace to prepend to titles in suggestions, if any.

Parameters:

Name Type Description
namespace number | null

Namespace number

Source:
Set the namespace to prepend to titles in suggestions, if any.