Allow limiting comment length by characters rather than bytes in JS
[lhc/web/wiklou.git] / resources / src / mediawiki.legacy / protect.js
index aa49ae1..b96bebc 100644 (file)
@@ -1,6 +1,9 @@
 ( function ( mw, $ ) {
+       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;