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 // Temporarily disabled whilst upstream bug is fixed; T169982
14 function updateCount() {
15 textInputWidget.setLabel( ( limit - $.byteLength( textInputWidget.getValue() ) ).toString() );
17 textInputWidget.on( 'change', updateCount );
22 // Actually enforce limit
23 textInputWidget
.$input
.byteLimit( limit
);