6 * Add a visible byte limit label to a TextInputWidget.
8 * Uses jQuery#byteLimit to enforce the limit.
10 * @param {OO.ui.TextInputWidget} textInputWidget Text input widget
11 * @param {number} [limit] Byte limit, defaults to $input's maxlength
13 mediaWiki
.widgets
.visibleByteLimit = function ( textInputWidget
, limit
) {
14 limit
= limit
|| +textInputWidget
.$input
.attr( 'maxlength' );
16 function updateCount() {
17 textInputWidget
.setLabel( ( limit
- $.byteLength( textInputWidget
.getValue() ) ).toString() );
19 textInputWidget
.on( 'change', updateCount
);
23 // Actually enforce limit
24 textInputWidget
.$input
.byteLimit( limit
);