-( function ( mw, $ ) {
+/* eslint-disable no-restricted-properties */
+( function () {
+ var ProtectionForm,
+ reasonCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
+ reasonByteLimit = mw.config.get( 'wgCommentByteLimit' );
- var ProtectionForm = window.ProtectionForm = {
+ ProtectionForm = window.ProtectionForm = {
/**
* Set up the protection chaining interface (i.e. "unlock move permissions" checkbox)
* on the protection form
this.toggleUnchainedInputs( !this.areAllTypesMatching() );
}
- $( '#mwProtect-reason' ).byteLimit( 180 );
+ // Arbitrary 75 to leave some space for the autogenerated null edit's summary
+ if ( reasonCodePointLimit ) {
+ $( '#mwProtect-reason' ).codePointLimit( reasonCodePointLimit - 75 );
+ } else if ( reasonByteLimit ) {
+ $( '#mwProtect-reason' ).byteLimit( reasonByteLimit - 75 );
+ }
this.updateCascadeCheckbox();
return true;
* @return {boolean}
*/
isCascadeableLevel: function ( level ) {
- return $.inArray( level, mw.config.get( 'wgCascadeableLevels' ) ) !== -1;
+ var cascadeableLevels = mw.config.get( 'wgCascadeableLevels' );
+
+ if ( !Array.isArray( cascadeableLevels ) ) {
+ return false;
+ }
+
+ return cascadeableLevels.indexOf( level ) !== -1;
},
/**
$( ProtectionForm.init.bind( ProtectionForm ) );
-}( mediaWiki, jQuery ) );
+}() );