The format for this would be cleaner if T225842 were solved.
Bug: T193826
Bug: T219342
Change-Id: I9aaa52b567db254e1e79649b3b99260214da74b3
}
if ( $any ) {
- $this->getOutput()->addModules( [
- 'mediawiki.special.changecredentials.js'
- ] );
+ $this->getOutput()->addModules( 'mediawiki.misc-authed-ooui' );
}
return $descriptor;
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
$out->addModuleStyles( 'mediawiki.special' );
- $out->addModules( 'mediawiki.special.movePage' );
+ $out->addModules( 'mediawiki.misc-authed-ooui' );
$this->addHelpLink( 'Help:Moving a page' );
$out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
}
protected function preText() {
- $this->getOutput()->addModules( 'mediawiki.special.pageLanguage' );
+ $this->getOutput()->addModules( 'mediawiki.misc-authed-ooui' );
return parent::preText();
}
],
'targets' => [ 'desktop', 'mobile' ],
],
- 'mediawiki.special.changecredentials.js' => [
- 'scripts' => 'resources/src/mediawiki.special.changecredentials.js',
+ // This bundles various small (under 5 KB?) JavaScript files that:
+ // - .. are not loaded on when viewing or editing wiki pages.
+ // - .. are used by logged-in users only.
+ // - .. depend on oojs-ui-core.
+ // - .. contain UI intialisation code (e.g. no public module exports, because
+ // requiring or depending on this bundle is awkard)
+ 'mediawiki.misc-authed-ooui' => [
+ 'localBasePath' => "$IP/resources/src/mediawiki.misc-authed-ooui",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.misc-authed-ooui",
+ 'scripts' => [
+ 'special.changecredentials.js',
+ 'special.movePage.js',
+ 'special.mute.js',
+ 'special.pageLanguage.js',
+ ],
'dependencies' => [
- 'mediawiki.api',
- 'mediawiki.htmlform.ooui'
+ 'mediawiki.api', // Used by special.changecredentials.js
+ 'mediawiki.htmlform.ooui', // Used by special.changecredentials.js
+ 'mediawiki.widgets.visibleLengthLimit', // Used by special.movePage.js
+ 'mediawiki.widgets', // Used by special.movePage.js
+ 'oojs-ui-core', // Used by special.pageLanguage.js
],
'targets' => [ 'desktop', 'mobile' ],
],
'mediawiki.special.import' => [
'scripts' => 'resources/src/mediawiki.special.import.js',
],
- 'mediawiki.special.movePage' => [
- 'scripts' => 'resources/src/mediawiki.special.movePage.js',
- 'dependencies' => [
- 'mediawiki.widgets.visibleLengthLimit',
- 'mediawiki.widgets',
- ],
- ],
- 'mediawiki.special.pageLanguage' => [
- 'scripts' => [
- 'resources/src/mediawiki.special.mute.js',
- 'resources/src/mediawiki.special.pageLanguage.js'
- ],
- 'dependencies' => [
- 'oojs-ui-core',
- ],
- ],
'mediawiki.special.preferences.ooui' => [
'targets' => [ 'desktop', 'mobile' ],
'scripts' => [
--- /dev/null
+/*!
+ * JavaScript for change credentials form.
+ */
+( function () {
+ mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
+ var api = new mw.Api();
+
+ $root.find( '.mw-changecredentials-validate-password.oo-ui-fieldLayout' ).each( function () {
+ var currentApiPromise,
+ self = OO.ui.FieldLayout.static.infuse( $( this ) );
+
+ self.getField().setValidation( function ( password ) {
+ var d;
+
+ if ( currentApiPromise ) {
+ currentApiPromise.abort();
+ currentApiPromise = undefined;
+ }
+
+ password = password.trim();
+
+ if ( password === '' ) {
+ self.setErrors( [] );
+ return true;
+ }
+
+ d = $.Deferred();
+ currentApiPromise = api.post( {
+ action: 'validatepassword',
+ password: password,
+ formatversion: 2,
+ errorformat: 'html',
+ errorsuselocal: true,
+ uselang: mw.config.get( 'wgUserLanguage' )
+ } ).done( function ( resp ) {
+ var pwinfo = resp.validatepassword,
+ good = pwinfo.validity === 'Good',
+ errors = [];
+
+ currentApiPromise = undefined;
+
+ if ( !good ) {
+ pwinfo.validitymessages.map( function ( m ) {
+ errors.push( new OO.ui.HtmlSnippet( m.html ) );
+ } );
+ }
+ self.setErrors( errors );
+ d.resolve( good );
+ } ).fail( d.reject );
+
+ return d.promise( { abort: currentApiPromise.abort } );
+ } );
+ } );
+ } );
+}() );
--- /dev/null
+/*!
+ * JavaScript for Special:MovePage
+ */
+( function () {
+ $( function () {
+ var summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
+ summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
+ wpReason = OO.ui.infuse( $( '#wpReason' ) );
+
+ // Infuse for pretty dropdown
+ OO.ui.infuse( $( '#wpNewTitle' ) );
+ // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
+ if ( summaryCodePointLimit ) {
+ mw.widgets.visibleCodePointLimit( wpReason, summaryCodePointLimit );
+ } else if ( summaryByteLimit ) {
+ mw.widgets.visibleByteLimit( wpReason, summaryByteLimit );
+ }
+ } );
+}() );
--- /dev/null
+( function () {
+ 'use strict';
+
+ $( function () {
+ var $inputs = $( '#mw-specialmute-form input[type="checkbox"]' ),
+ saveButton, $saveButton = $( '#save' );
+
+ function isFormChanged() {
+ return $inputs.is( function () {
+ return this.checked !== this.defaultChecked;
+ } );
+ }
+
+ if ( $saveButton.length ) {
+ saveButton = OO.ui.infuse( $saveButton );
+ saveButton.setDisabled( !isFormChanged() );
+
+ $inputs.on( 'change', function () {
+ saveButton.setDisabled( !isFormChanged() );
+ } );
+ }
+ } );
+}() );
--- /dev/null
+/*!
+ * JavaScript module used on Special:PageLanguage
+ */
+( function () {
+ $( function () {
+ // Select the 'Language select' option if user is trying to select language
+ if ( $( '#mw-pl-languageselector' ).length ) {
+ OO.ui.infuse( $( '#mw-pl-languageselector' ) ).on( 'change', function () {
+ OO.ui.infuse( $( '#mw-pl-options' ) ).setValue( '2' );
+ } );
+ }
+ } );
+}() );
+++ /dev/null
-/*!
- * JavaScript for change credentials form.
- */
-( function () {
- mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
- var api = new mw.Api();
-
- $root.find( '.mw-changecredentials-validate-password.oo-ui-fieldLayout' ).each( function () {
- var currentApiPromise,
- self = OO.ui.FieldLayout.static.infuse( $( this ) );
-
- self.getField().setValidation( function ( password ) {
- var d;
-
- if ( currentApiPromise ) {
- currentApiPromise.abort();
- currentApiPromise = undefined;
- }
-
- password = password.trim();
-
- if ( password === '' ) {
- self.setErrors( [] );
- return true;
- }
-
- d = $.Deferred();
- currentApiPromise = api.post( {
- action: 'validatepassword',
- password: password,
- formatversion: 2,
- errorformat: 'html',
- errorsuselocal: true,
- uselang: mw.config.get( 'wgUserLanguage' )
- } ).done( function ( resp ) {
- var pwinfo = resp.validatepassword,
- good = pwinfo.validity === 'Good',
- errors = [];
-
- currentApiPromise = undefined;
-
- if ( !good ) {
- pwinfo.validitymessages.map( function ( m ) {
- errors.push( new OO.ui.HtmlSnippet( m.html ) );
- } );
- }
- self.setErrors( errors );
- d.resolve( good );
- } ).fail( d.reject );
-
- return d.promise( { abort: currentApiPromise.abort } );
- } );
- } );
- } );
-}() );
+++ /dev/null
-/*!
- * JavaScript for Special:MovePage
- */
-( function () {
- $( function () {
- var summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
- summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
- wpReason = OO.ui.infuse( $( '#wpReason' ) );
-
- // Infuse for pretty dropdown
- OO.ui.infuse( $( '#wpNewTitle' ) );
- // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
- if ( summaryCodePointLimit ) {
- mw.widgets.visibleCodePointLimit( wpReason, summaryCodePointLimit );
- } else if ( summaryByteLimit ) {
- mw.widgets.visibleByteLimit( wpReason, summaryByteLimit );
- }
- } );
-}() );
+++ /dev/null
-( function () {
- 'use strict';
-
- $( function () {
- var $inputs = $( '#mw-specialmute-form input[type="checkbox"]' ),
- saveButton, $saveButton = $( '#save' );
-
- function isFormChanged() {
- return $inputs.is( function () {
- return this.checked !== this.defaultChecked;
- } );
- }
-
- if ( $saveButton.length ) {
- saveButton = OO.ui.infuse( $saveButton );
- saveButton.setDisabled( !isFormChanged() );
-
- $inputs.on( 'change', function () {
- saveButton.setDisabled( !isFormChanged() );
- } );
- }
- } );
-}() );
+++ /dev/null
-/*!
- * JavaScript module used on Special:PageLanguage
- */
-( function () {
- $( function () {
- // Select the 'Language select' option if user is trying to select language
- if ( $( '#mw-pl-languageselector' ).length ) {
- OO.ui.infuse( $( '#mw-pl-languageselector' ) ).on( 'change', function () {
- OO.ui.infuse( $( '#mw-pl-options' ) ).setValue( '2' );
- } );
- }
- } );
-}() );