From 17c2f17e361051737ac9a820fc5b82840b029fd8 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 2 Apr 2019 12:21:06 +0200 Subject: [PATCH] protect.js: Simplify by removing object ProtectionForm Change-Id: If7060c41c9b904e174a34dfc7ea2c053ecc1c3fc --- resources/src/mediawiki.legacy/protect.js | 482 +++++++++++----------- 1 file changed, 240 insertions(+), 242 deletions(-) diff --git a/resources/src/mediawiki.legacy/protect.js b/resources/src/mediawiki.legacy/protect.js index 4f89f7c49f..18f1c38cb2 100644 --- a/resources/src/mediawiki.legacy/protect.js +++ b/resources/src/mediawiki.legacy/protect.js @@ -1,255 +1,253 @@ +/* eslint-disable no-use-before-define */ ( function () { - var ProtectionForm, - config = require( './config.json' ), + var config = require( './config.json' ), reasonCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ), reasonByteLimit = mw.config.get( 'wgCommentByteLimit' ); - ProtectionForm = { - /** - * Set up the protection chaining interface (i.e. "unlock move permissions" checkbox) - * on the protection form - * - * @return {boolean} - */ - init: function () { - var $cell = $( '' ), - $row = $( '' ).append( $cell ); - - if ( !$( '#mwProtectSet' ).length ) { - return false; - } - - $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) ); - this.getExpirySelectors().each( function () { - $( 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 ).on( 'change', ProtectionForm.updateLevels.bind( ProtectionForm, this ) ); - } ); + /** + * Set up the protection chaining interface (i.e. "unlock move permissions" checkbox) + * on the protection form + * + * @return {boolean} + */ + function init() { + var $cell = $( '' ), + $row = $( '' ).append( $cell ); + + if ( !$( '#mwProtectSet' ).length ) { + return false; + } - $( '#mwProtectSet > tbody > tr:first' ).after( $row ); - - // If there is only one protection type, there is nothing to chain - if ( $( '[id ^= mw-protect-table-]' ).length > 1 ) { - $cell.append( - $( '' ) - .attr( { id: 'mwProtectUnchained', type: 'checkbox' } ) - .on( 'click', this.onChainClick.bind( this ) ) - .prop( 'checked', !this.areAllTypesMatching() ), - document.createTextNode( ' ' ), - $( '