from certain IP ranges (e.g. private IPs).
* (T59603) Added new magic word {{PAGELANGUAGE}} which returns the language code
of the page being parsed.
+* Added JavaScript that provides as-you-type suggestions for reason
+ on the block, delete and protect forms.
=== External library changes in 1.29 ===
throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
}
+ $out = $this->mContext->getOutput();
+ if ( !wfMessage( 'protect-dropdown' )->inContentLanguage()->isDisabled() ) {
+ $out->addModules( 'mediawiki.reasonSuggest' );
+ $out->addJsConfigVars( [
+ 'reasons' => 'protect-dropdown'
+ ] );
+ }
+
if ( $this->mContext->getRequest()->wasPosted() ) {
if ( $this->save() ) {
$q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
- $this->mContext->getOutput()->redirect( $this->mTitle->getFullURL( $q ) );
+ $out->redirect( $this->mTitle->getFullURL( $q ) );
}
} else {
$this->show();
$title = $this->getTitle();
$ctx = $this->getContext();
$outputPage = $ctx->getOutput();
+ if ( !wfMessage( 'deletereason-dropdown' )->inContentLanguage()->isDisabled() ) {
+ $outputPage->addModules( 'mediawiki.reasonSuggest' );
+ $outputPage->addJsConfigVars( [
+ 'reasons' => 'deletereason-dropdown'
+ ] );
+ }
$useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
$outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
$outputPage->addBacklinkSubtitle( $title );
*/
protected function getFormFields() {
global $wgBlockAllowsUTEdit;
-
+ if ( !wfMessage( 'ipbreason-dropdown' )->inContentLanguage()->isDisabled() ) {
+ $this->getOutput()->addModules( 'mediawiki.reasonSuggest' );
+ $this->getOutput()->addJsConfigVars( [
+ 'reasons' => 'ipbreason-dropdown'
+ ] );
+ }
$user = $this->getUser();
$suggestedDurations = self::getSuggestedDurations();
],
'targets' => [ 'desktop', 'mobile' ],
],
+ 'mediawiki.reasonSuggest' => [
+ 'scripts' => 'resources/src/mediawiki/mediawiki.reasonSuggest.js',
+ 'dependencies' => [
+ 'jquery.suggestions',
+ 'mediawiki.api.messages'
+ ]
+ ],
'mediawiki.userSuggest' => [
'scripts' => 'resources/src/mediawiki/mediawiki.userSuggest.js',
'dependencies' => [
--- /dev/null
+/*!
+* Add autocomplete suggestions for action forms reasons.
+*/
+( function ( mw, $ ) {
+ $( function () {
+ var api = new mw.Api(), reasons = [];
+ // These messages can be really big, so its loaded on-the-go
+ api.loadMessagesIfMissing( [ mw.config.get( 'reasons' ) ] )
+ .done( function () {
+ // Convert from string to array, first index is unneeded
+ reasons = mw.msg( mw.config.get( 'reasons' ) ).split( '\n** ' );
+ reasons.splice( 0, 1 );
+ } );
+
+ // Add relevant suggestion
+ $( '#mwProtect-reason, #wpReason, #mw-input-wpReason-other' ).suggestions( {
+ fetch: function () {
+ var $this = $( this ), relevantSuggestions;
+ relevantSuggestions = $.grep( reasons, function ( reason ) {
+ return ( reason.toLowerCase().indexOf( $this.val().toLowerCase() ) > -1 );
+ } );
+ $this.suggestions( 'suggestions', relevantSuggestions );
+ },
+ highlightInput: true
+ } );
+ } );
+}( mediaWiki, jQuery ) );