Merge "EditPage: Drop 80% width restriction on wpSummary for OOUI form"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets.visibleByteLimit / mediawiki.widgets.visibleByteLimit.js
1 /**
2 * Add a visible byte limit label to a TextInputWidget
3 *
4 * Uses jQuery.byteLimit to enforce the limit.
5
6 * @param {OO.ui.TextInputWidget} textInputWidget Text input widget
7 * @param {number} [limit] Byte limit, defaults to $input's maxlength
8 */
9 mediaWiki.widgets.visibleByteLimit = function ( textInputWidget, limit ) {
10 limit = limit || +textInputWidget.$input.attr( 'maxlength' );
11
12 // Temporarily disabled whilst upstream bug is fixed; T169982
13 /*
14 function updateCount() {
15 textInputWidget.setLabel( ( limit - $.byteLength( textInputWidget.getValue() ) ).toString() );
16 }
17 textInputWidget.on( 'change', updateCount );
18 // Initialise value
19 updateCount();
20 */
21
22 // Actually enforce limit
23 textInputWidget.$input.byteLimit( limit );
24 };