Constructor
new mw.widgets.TitleWidget([config])abstract
#
Create an instance of mw.widgets.TitleWidget.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
Methods
createOptionWidget(data) → {OO.ui.MenuOptionWidget}
#
Create a menu option widget with specified data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data for option widget |
Returns:
Data for option widget
getApiParams(query) → {Object}
#
Get API params for a given query.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string | User query |
Returns:
API params
- Type
- Object
getMWTitle([value]) → {mw.Title|null}
#
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 |
Returns:
Title object, or null if value is invalid
- Type
-
mw.Title
|
null
getNamespace() → {number|null}
#
null}
#
Get the namespace to prepend to titles in suggestions, if any.
Returns:
Namespace number
- Type
-
number
|
null
getOptionWidgetData(title, data) → {Object}
#
getOptionsFromData(data) → {Array.<OO.ui.OptionWidget>}
#
Get option widgets from the server response.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Query result |
Returns:
Menu items
- Type
- Array.<OO.ui.OptionWidget>
getPageData(page, redirectIndex) → {Object}
#
Get the data to pass to createOptionWidget from the relevant part of the API response
Parameters:
| Name | Type | Description |
|---|---|---|
page |
Object | The page properties from the API response.pages[i] |
redirectIndex |
number
|
undefined
|
The index of the redirect, or undefined if there is no redirect to this page |
Returns:
- Type
- Object
getPrefixSearchRequest(api, query, ajaxOptions, [wiki]) → {jQuery.Promise}
#
Get a promise which resolves with an API response for a prefix search of the query, or section suggestions if the query contains a hash fragment and searchFragments is enabled.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
api |
mw.Api | API to use for the request |
|
query |
string | User query |
|
ajaxOptions |
Object | Ajax options to use for the request, including abort signal |
|
wiki |
Object |
optional |
Interwiki map entry for the wiki to search, or undefined for the current wiki |
Returns:
Suggestions promise
- Type
- jQuery.Promise
Get a promise which resolves with an API response for a prefix search of the query, or section suggestions if the query contains a hash fragment and searchFragments is enabled.
getQueryValue() → {string}abstract
#
Get the current value of the search query.
Returns:
Search query
- Type
- string
getSectionSuggestions(api, title, fragmentQuery, ajaxOptions, [wiki]) → {jQuery.Promise}
#
Suggest link fragments from the sections API.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
api |
mw.Api | API to use for the request |
|
title |
string | Title, extracted form the user input |
|
fragmentQuery |
string | Partial link fragment, from the user input |
|
ajaxOptions |
Object | Ajax options to use for the request, including abort signal |
|
wiki |
Object |
optional |
Interwiki map entry for the wiki to search, or undefined for the current wiki |
Returns:
Suggestions promise
- Type
- jQuery.Promise
getSuggestionsPromise() → {jQuery.Promise}
#
Get a promise which resolves with an API response for suggested links for the current query.
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.
Returns:
The query is valid
- Type
- boolean
processInterwikiResults(pages, wiki)
#
setNamespace(namespace)
#
Set the namespace to prepend to titles in suggestions, if any.
Parameters:
| Name | Type | Description |
|---|---|---|
namespace |
number
|
null
|
Namespace number |