jenkins-bot has submitted this change and it was merged. Change subject: Hygiene: Use View events in ErrorReportOverlay ......................................................................
Hygiene: Use View events in ErrorReportOverlay Bug: T88562 Change-Id: If876eb10431be72df6ebd8bf9c53da183bb78d22 --- M javascripts/modules/errorReport/ErrorReportOverlay.js 1 file changed, 47 insertions(+), 33 deletions(-) Approvals: Phuedx: Looks good to me, approved jenkins-bot: Verified diff --git a/javascripts/modules/errorReport/ErrorReportOverlay.js b/javascripts/modules/errorReport/ErrorReportOverlay.js index 14cb911..43b5baf 100644 --- a/javascripts/modules/errorReport/ErrorReportOverlay.js +++ b/javascripts/modules/errorReport/ErrorReportOverlay.js @@ -30,10 +30,26 @@ instructions: mw.msg( 'mobile-frontend-errorreport-instructions' ), licenseMsg: mw.msg( 'mobile-frontend-editor-licensing', mw.config.get( 'wgMFLicenseLink' ) ) }, + /** + * @inheritdoc + */ templatePartials: { content: mw.template.get( 'mobile.errorReport.overlay', 'ErrorReportOverlay.hogan' ) }, + /** + * @inheritdoc + */ className: 'error-reporting-overlay overlay', + /** + * @inheritdoc + */ + events: { + 'click button.continue': 'onContinueClick', + 'click button.submit': 'onSubmitClick', + 'keyup .error-field': 'onErrorFieldChange', + 'paste .error-field': 'onErrorFieldChange', + 'drop .error-field': 'onErrorFieldChange' + }, /** * Show the actual error reporting form @@ -42,8 +58,6 @@ * @param {Object} options The options for the overlay */ _showForm: function ( options ) { - var self = this; - options.headerButtons = [ { className: 'submit', msg: mw.msg( 'mobile-frontend-errorreport-submit' ) @@ -52,31 +66,6 @@ this.$( '.instructions' ).hide(); this.$( '.error-field, .license-panel' ).show(); this.$( 'button.submit' ).prop( 'disabled', true ); - - // Enable the submit button when the error report is at least 15 characters - this.$( '.error-field' ).on( 'keyup paste drop', function () { - // Force length check to be asynchronous in order to handle paste events - setTimeout( function () { - self.$( 'button.submit' ).prop( 'disabled', self.$( '.error-field' ).val().length <= 15 ); - }, 0 ); - } ); - - // Initialize the submit button - this.$( 'button.submit' ).on( 'click', function () { - var text = self.$( '.error-field' ).val(), - $talk = $( '.talk' ); - - if ( text.length > 15 && $talk !== undefined ) { - // Hide the textarea, show a spinner, and post the report - self.$( '.error-field' ).hide(); - self.$( '.spinner' ).show(); - self._postErrorReport( text, $talk.data( 'title' ) ); - } else { - // Close overlay and show error notification - window.history.back(); - toast.show( mw.msg( 'mobile-frontend-errorreport-error' ), 'toast' ); - } - } ); }, /** @@ -105,15 +94,40 @@ }, /** - * @inheritdoc + * Continue button click handler */ - postRender: function ( options ) { + onContinueClick: function () { + this._showForm( this.options ); + }, + /** + * Submit button click handler + */ + onSubmitClick: function () { + var text = this.$( '.error-field' ).val(), + $talk = $( '.talk' ); + + if ( text.length > 15 && $talk !== undefined ) { + // Hide the textarea, show a spinner, and post the report + this.$( '.error-field' ).hide(); + this.$( '.spinner' ).show(); + this._postErrorReport( text, $talk.data( 'title' ) ); + } else { + // Close overlay and show error notification + window.history.back(); + toast.show( mw.msg( 'mobile-frontend-errorreport-error' ), 'toast' ); + } + }, + /** + * Error field change handler + * Enable the submit button when the error report is at least 15 characters + */ + onErrorFieldChange: function () { var self = this; - Overlay.prototype.postRender.apply( this, arguments ); - this.$( 'button.continue' ).on( 'click', function () { - self._showForm( options ); - } ); + // Force length check to be asynchronous in order to handle paste events + setTimeout( function () { + self.$( 'button.submit' ).prop( 'disabled', self.$( '.error-field' ).val().length <= 15 ); + }, 0 ); } } ); -- To view, visit https://gerrit.wikimedia.org/r/188941 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If876eb10431be72df6ebd8bf9c53da183bb78d22 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org> Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Phuedx <g...@samsmith.io> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits