- * @return {boolean}
- */
- function init() {
- var $cell = $( '<td>' ),
- $row = $( '<tr>' ).append( $cell );
-
- if ( !$( '#mwProtectSet' ).length ) {
- return false;
- }
-
- $( 'form#mw-Protect-Form' ).on( 'submit', toggleUnchainedInputs.bind( this, true ) );
- getExpirySelectors().each( function () {
- $( this ).on( 'change', updateExpiryList );
- } );
- getExpiryInputs().each( function () {
- $( this ).on( 'keyup change', updateExpiry );
- } );
- getLevelSelectors().each( function () {
- $( this ).on( 'change', updateLevels );
- } );
-
- $( '#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(
- $( '<input>' )
- .attr( { id: 'mwProtectUnchained', type: 'checkbox' } )
- .on( 'click', onChainClick )
- .prop( 'checked', !areAllTypesMatching() ),
- document.createTextNode( ' ' ),
- $( '<label>' )
- .attr( 'for', 'mwProtectUnchained' )
- .text( mw.msg( 'protect-unchain-permissions' ) )
- );
-
- toggleUnchainedInputs( !areAllTypesMatching() );
- }
-
- // 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 );
- }
-
- updateCascadeCheckbox();
- return true;
- }
-
- /**
- * Sets the disabled attribute on the cascade checkbox depending on the current selected levels