Add logging for redundant parsing to WikitextContent.
[lhc/web/wiklou.git] / resources / src / mediawiki.special.block.js
index 180f040..1852231 100644 (file)
@@ -1,7 +1,7 @@
 /*!
  * JavaScript for Special:Block
  */
-( function ( mw, $ ) {
+( function () {
        // Like OO.ui.infuse(), but if the element doesn't exist, return null instead of throwing an exception.
        function infuseOrNull( elem ) {
                try {
@@ -19,7 +19,9 @@
                        enableAutoblockField = infuseOrNull( $( '#mw-input-wpAutoBlock' ).closest( '.oo-ui-fieldLayout' ) ),
                        hideUserField = infuseOrNull( $( '#mw-input-wpHideUser' ).closest( '.oo-ui-fieldLayout' ) ),
                        watchUserField = infuseOrNull( $( '#mw-input-wpWatch' ).closest( '.oo-ui-fieldLayout' ) ),
-                       expiryWidget = infuseOrNull( 'mw-input-wpExpiry' );
+                       expiryWidget = infuseOrNull( 'mw-input-wpExpiry' ),
+                       editingRestrictionWidget = infuseOrNull( 'mw-input-wpEditingRestriction' ),
+                       pageRestrictionsWidget = infuseOrNull( 'mw-input-wpPageRestrictions' );
 
                function updateBlockOptions() {
                        var blocktarget = blockTargetWidget.getValue().trim(),
@@ -30,7 +32,8 @@
                                expiryValue = expiryWidget.getValue(),
                                // infinityValues  are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity)
                                infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ],
-                               isIndefinite = infinityValues.indexOf( expiryValue ) !== -1;
+                               isIndefinite = infinityValues.indexOf( expiryValue ) !== -1,
+                               editingRestrictionValue = editingRestrictionWidget ? editingRestrictionWidget.getValue() : undefined;
 
                        if ( enableAutoblockField ) {
                                enableAutoblockField.toggle( !( isNonEmptyIp ) );
                        if ( watchUserField ) {
                                watchUserField.toggle( !( isIpRange && !isEmpty ) );
                        }
+                       if ( pageRestrictionsWidget ) {
+                               pageRestrictionsWidget.setDisabled( editingRestrictionValue === 'sitewide' );
+                       }
                }
 
                if ( blockTargetWidget ) {
                        // Bind functions so they're checked whenever stuff changes
                        blockTargetWidget.on( 'change', updateBlockOptions );
                        expiryWidget.on( 'change', updateBlockOptions );
+                       editingRestrictionWidget.on( 'change', updateBlockOptions );
 
                        // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
                        updateBlockOptions();
                }
        } );
-}( mediaWiki, jQuery ) );
+}() );