ProtectionForm: Move JS config var to RL packageFiles
[lhc/web/wiklou.git] / resources / src / mediawiki.legacy / protect.js
index 829052d..b3707a5 100644 (file)
@@ -1,6 +1,6 @@
-/* eslint-disable no-restricted-properties */
 ( function () {
        var ProtectionForm,
+               config = require( './config.json' ),
                reasonCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
                reasonByteLimit = mw.config.get( 'wgCommentByteLimit' );
 
                                return false;
                        }
 
-                       if ( mw.config.get( 'wgCascadeableLevels' ) !== undefined ) {
-                               $( 'form#mw-Protect-Form' ).submit( this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
-                       }
+                       $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
                        this.getExpirySelectors().each( function () {
-                               $( this ).change( ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) );
+                               $( this ).on( 'change', ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) );
                        } );
                        this.getExpiryInputs().each( function () {
                                $( this ).on( 'keyup change', ProtectionForm.updateExpiry.bind( ProtectionForm, this ) );
                        } );
                        this.getLevelSelectors().each( function () {
-                               $( this ).change( ProtectionForm.updateLevels.bind( ProtectionForm, this ) );
+                               $( this ).on( 'change', ProtectionForm.updateLevels.bind( ProtectionForm, this ) );
                        } );
 
                        $( '#mwProtectSet > tbody > tr:first' ).after( $row );
@@ -39,7 +37,7 @@
                                $cell.append(
                                        $( '<input>' )
                                                .attr( { id: 'mwProtectUnchained', type: 'checkbox' } )
-                                               .click( this.onChainClick.bind( this ) )
+                                               .on( 'click', this.onChainClick.bind( this ) )
                                                .prop( 'checked', !this.areAllTypesMatching() ),
                                        document.createTextNode( ' ' ),
                                        $( '<label>' )
                 * @return {boolean}
                 */
                isCascadeableLevel: function ( level ) {
-                       var cascadeableLevels = mw.config.get( 'wgCascadeableLevels' );
-
-                       if ( !Array.isArray( cascadeableLevels ) ) {
-                               return false;
-                       }
-
-                       return cascadeableLevels.indexOf( level ) !== -1;
+                       return config.CascadingRestrictionLevels.indexOf( level ) !== -1;
                },
 
                /**
                 * @return {boolean}
                 */
                matchAttribute: function ( objects, attrName ) {
+                       // eslint-disable-next-line jquery/no-map-util
                        return $.map( objects, function ( object ) {
                                return object[ attrName ];
                        } ).filter( function ( item, index, a ) {
                 * @param {boolean} val Enable?
                 */
                toggleUnchainedInputs: function ( val ) {
-                       var setDisabled = function () { this.disabled = !val; };
+                       var setDisabled = function () {
+                               this.disabled = !val;
+                       };
                        this.getLevelSelectors().slice( 1 ).each( setDisabled );
                        this.getExpiryInputs().slice( 1 ).each( setDisabled );
                        this.getExpirySelectors().slice( 1 ).each( setDisabled );