mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Use InputWidget facilities in byte limit counter
* Don't use setTimeout() within a change event, because change fires after the text has already changed * Don't use .$input.val(), use .getValue() instead * Don't use .placeholder() ** Reaching into .$input is bad ** Any use of .placeholder() is TextInputWidget's responsibility ** All browsers we support also support placeholder natively * Remove .editSummaryByteLimit from ViewPageTarget, unused * Remove ve.bind() wrapping, we already have var saveDialog = this; Change-Id: I380575fec8d02d1191bfc1f3f235b94c64cd23b6
This commit is contained in:
parent
080b4380fa
commit
620e0e21ef
|
@ -59,7 +59,6 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
|||
currentUri.query.diff === undefined
|
||||
);
|
||||
this.originalDocumentTitle = document.title;
|
||||
this.editSummaryByteLimit = 255;
|
||||
this.tabLayout = mw.config.get( 'wgVisualEditorConfig' ).tabLayout;
|
||||
|
||||
/**
|
||||
|
|
|
@ -289,21 +289,16 @@ ve.ui.MWSaveDialog.prototype.initialize = function () {
|
|||
);
|
||||
this.editSummaryInput.$element.addClass( 've-ui-mwSaveDialog-summary' );
|
||||
this.editSummaryInput.$input
|
||||
.placeholder()
|
||||
.byteLimit( this.editSummaryByteLimit )
|
||||
.prop( 'tabIndex', 0 );
|
||||
this.editSummaryInput.on( 'change', ve.bind( function () {
|
||||
var $textarea = this.editSummaryInput.$input,
|
||||
$editSummaryCount = this.savePanel.$element.find( '.ve-ui-mwSaveDialog-editSummary-count' );
|
||||
this.editSummaryInput.on( 'change', function () {
|
||||
// TODO: This looks a bit weird, there is no unit in the UI, just numbers
|
||||
// Users likely assume characters but then it seems to count down quicker
|
||||
// than expected. Facing users with the word "byte" is bad? (bug 40035)
|
||||
setTimeout( function () {
|
||||
$editSummaryCount.text(
|
||||
saveDialog.editSummaryByteLimit - $.byteLength( $textarea.val() )
|
||||
);
|
||||
} );
|
||||
}, this ) );
|
||||
saveDialog.savePanel.$element.find( '.ve-ui-mwSaveDialog-editSummary-count' ).text(
|
||||
saveDialog.editSummaryByteLimit - $.byteLength( saveDialog.editSummaryInput.getValue() )
|
||||
);
|
||||
} );
|
||||
|
||||
this.$saveOptions = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-options' ).append(
|
||||
this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-checkboxes' ),
|
||||
|
|
Loading…
Reference in a new issue