mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-11 16:59:09 +00:00
Merge "Use the search title if configured"
This commit is contained in:
commit
040cbb7dc4
|
@ -10,6 +10,7 @@
|
|||
:title="searchTitle"
|
||||
:placeholder="searchPlaceholder"
|
||||
:aria-label="searchPlaceholder"
|
||||
:search-page-title="searchPageTitle"
|
||||
:initial-input-value="searchQuery"
|
||||
:button-label="$i18n( 'searchbutton' ).text()"
|
||||
:form-action="action"
|
||||
|
@ -74,6 +75,10 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
props: {
|
||||
searchPageTitle: {
|
||||
type: String,
|
||||
default: 'Special:Search'
|
||||
},
|
||||
autofocusInput: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
|
|
@ -7,9 +7,11 @@ var
|
|||
/**
|
||||
* @param {HTMLElement} searchForm
|
||||
* @param {HTMLInputElement} search
|
||||
* @param {string|null} searchPageTitle title of page used for searching e.g. Special:Search
|
||||
* If null then this will default to Special:Search.
|
||||
* @return {void}
|
||||
*/
|
||||
function initApp( searchForm, search ) {
|
||||
function initApp( searchForm, search, searchPageTitle ) {
|
||||
// eslint-disable-next-line no-new
|
||||
new Vue( {
|
||||
el: searchForm,
|
||||
|
@ -24,6 +26,7 @@ function initApp( searchForm, search ) {
|
|||
autofocusInput: search === document.activeElement,
|
||||
action: searchForm.getAttribute( 'action' ),
|
||||
searchAccessKey: search.getAttribute( 'accessKey' ),
|
||||
searchPageTitle: searchPageTitle,
|
||||
searchTitle: search.getAttribute( 'title' ),
|
||||
searchPlaceholder: search.getAttribute( 'placeholder' ),
|
||||
searchQuery: search.value
|
||||
|
@ -42,9 +45,12 @@ function initApp( searchForm, search ) {
|
|||
function main( document ) {
|
||||
var
|
||||
searchForm = /** @type {HTMLElement} */ ( document.querySelector( '#searchform' ) ),
|
||||
titleInput = /** @type {HTMLInputElement|null} */ (
|
||||
searchForm.querySelector( 'input[name=title]' )
|
||||
),
|
||||
search = /** @type {HTMLInputElement|null} */ ( document.getElementById( 'searchInput' ) );
|
||||
if ( search && searchForm ) {
|
||||
initApp( searchForm, search );
|
||||
initApp( searchForm, search, titleInput && titleInput.value );
|
||||
}
|
||||
}
|
||||
main( document );
|
||||
|
|
Loading…
Reference in a new issue