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