Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6034241
mw.widgets.TitleSearchWidget.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
mw.widgets.TitleSearchWidget.js
View Options
/*!
* MediaWiki Widgets - TitleSearchWidget class.
*
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
(
function
()
{
/**
* @classdesc Title search widget.
*
* @class
* @extends OO.ui.SearchWidget
* @mixes OO.ui.mixin.RequestManager
* @mixes mw.widgets.TitleWidget
*
* @constructor
* @description Create an mw.widgets.TitleSearchWidget object.
* @param {Object} [config] Configuration options
*/
mw
.
widgets
.
TitleSearchWidget
=
function
MwWidgetsTitleSearchWidget
(
config
)
{
config
=
config
||
{};
// Parent constructor
mw
.
widgets
.
TitleSearchWidget
.
super
.
call
(
this
,
config
);
// Mixin constructors
mw
.
widgets
.
TitleWidget
.
call
(
this
,
config
);
OO
.
ui
.
mixin
.
RequestManager
.
call
(
this
,
config
);
this
.
query
.
setValidation
(
this
.
isQueryValid
.
bind
(
this
)
);
// Events
this
.
results
.
connect
(
this
,
{
choose
:
'onTitleSearchResultsChoose'
}
);
// Initialization
this
.
$element
.
addClass
(
'mw-widget-titleSearchWidget'
);
this
.
results
.
$element
.
addClass
(
'mw-widget-titleWidget-menu'
);
if
(
this
.
showImages
)
{
this
.
results
.
$element
.
addClass
(
'mw-widget-titleWidget-menu-withImages'
);
}
if
(
this
.
showDescriptions
)
{
this
.
results
.
$element
.
addClass
(
'mw-widget-titleWidget-menu-withDescriptions'
);
}
if
(
this
.
maxLength
!==
undefined
)
{
this
.
getQuery
().
$input
.
attr
(
'maxlength'
,
this
.
maxLength
);
}
};
/* Setup */
OO
.
inheritClass
(
mw
.
widgets
.
TitleSearchWidget
,
OO
.
ui
.
SearchWidget
);
OO
.
mixinClass
(
mw
.
widgets
.
TitleSearchWidget
,
OO
.
ui
.
mixin
.
RequestManager
);
OO
.
mixinClass
(
mw
.
widgets
.
TitleSearchWidget
,
mw
.
widgets
.
TitleWidget
);
/* Methods */
/**
* @inheritdoc
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
getQueryValue
=
function
()
{
return
this
.
getQuery
().
getValue
();
};
/**
* Handle choose events from the result widget.
*
* @param {OO.ui.OptionWidget} item Chosen item
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
onTitleSearchResultsChoose
=
function
(
item
)
{
this
.
getQuery
().
setValue
(
item
.
getData
()
);
};
/**
* @inheritdoc
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
onQueryChange
=
function
()
{
this
.
getRequestData
().
done
(
(
data
)
=>
{
if
(
this
.
query
.
isReadOnly
()
)
{
// The request object is always abortable, so just
// prevent the results from displaying
return
;
}
// Parent method
mw
.
widgets
.
TitleSearchWidget
.
super
.
prototype
.
onQueryChange
.
call
(
this
);
this
.
results
.
addItems
(
this
.
getOptionsFromData
(
data
)
);
}
);
};
/**
* @inheritdoc
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
getRequestQuery
=
function
()
{
return
this
.
getQueryValue
();
};
/**
* @inheritdoc
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
getRequest
=
function
()
{
return
this
.
getSuggestionsPromise
();
};
/**
* @inheritdoc
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
getRequestCacheDataFromResponse
=
function
(
response
)
{
return
response
.
query
||
{};
};
/**
* Check if the widget is read-only.
*
* @return {boolean}
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
isReadOnly
=
function
()
{
return
this
.
query
.
isReadOnly
();
};
/**
* Set the read-only state of the widget.
*
* @param {boolean} readOnly Make input read-only
* @chainable
* @return {mw.widgets.TitleSearchWidget} The widget, for chaining
*/
mw
.
widgets
.
TitleSearchWidget
.
prototype
.
setReadOnly
=
function
(
readOnly
)
{
this
.
query
.
setReadOnly
(
readOnly
);
if
(
readOnly
)
{
// Hide results
this
.
results
.
clearItems
();
}
return
this
;
};
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 4 2026, 18:49 (6 w, 2 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
de/e9/b87655d5bf36c8e4f96e8cb5f648
Default Alt Text
mw.widgets.TitleSearchWidget.js (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment