3 var byteLength
= require( 'mediawiki.String' ).byteLength
;
10 * Add a visible byte limit label to a TextInputWidget.
12 * Uses jQuery#byteLimit to enforce the limit.
14 * @param {OO.ui.TextInputWidget} textInputWidget Text input widget
15 * @param {number} [limit] Byte limit, defaults to $input's maxlength
17 mw
.widgets
.visibleByteLimit = function ( textInputWidget
, limit
) {
18 limit
= limit
|| +textInputWidget
.$input
.attr( 'maxlength' );
20 function updateCount() {
21 textInputWidget
.setLabel( ( limit
- byteLength( textInputWidget
.getValue() ) ).toString() );
23 textInputWidget
.on( 'change', updateCount
);
27 // Actually enforce limit
28 textInputWidget
.$input
.byteLimit( limit
);