jenkins-bot has submitted this change and it was merged. Change subject: Move destroy-form functionality in its own function, instead of binding cancel ......................................................................
Move destroy-form functionality in its own function, instead of binding cancel Not only is this cleaner, binding to cancel is insufficient too: when form is destroyed e.g. upon encountering an edit conflict, cancel btn isn't triggered. In fact, clicking cancel button executes destroyEditForm ;) Change-Id: I024fe34c7a98e5fe165971b7a5542028ccf54ec3 --- M modules/discussion/post.js M modules/header/forms.js 2 files changed, 24 insertions(+), 18 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/discussion/post.js b/modules/discussion/post.js index d44c366..681040f 100644 --- a/modules/discussion/post.js +++ b/modules/discussion/post.js @@ -131,9 +131,6 @@ * @param {function} [loadFunction] callback to be executed when form is loaded */ mw.flow.action.post.edit.prototype.setupEditForm = function ( data, loadFunction ) { - var $editLink = this.object.$container.find( '.flow-edit-post-link' ), - $container = this.object.$container.addClass( 'flow-post-nocontrols' ); - // call parent setupEditForm function mw.flow.action.prototype.setupEditForm.call( this, @@ -141,13 +138,19 @@ loadFunction ); - // hide post controls & edit link and re-reveal it if the cancel link - // - which is added by flow( 'setupEditForm' ) - is clicked. - $editLink.hide(); - this.object.$container.find( '.flow-cancel-link' ).on( 'click.mw-flow-discussion', function () { - $editLink.show(); - $container.removeClass( 'flow-post-nocontrols' ); - } ); + this.object.$container.find( '.flow-edit-post-link' ).hide(); + this.object.$container.addClass( 'flow-post-nocontrols' ); + }; + + /** + * Removes the edit form & restores content. + */ + mw.flow.action.post.edit.prototype.destroyEditForm = function () { + this.object.$container.find( '.flow-edit-post-link' ).show(); + this.object.$container.removeClass( 'flow-post-nocontrols' ); + + // call parent destroyEditForm function + mw.flow.action.prototype.destroyEditForm.call( this ); }; /** diff --git a/modules/header/forms.js b/modules/header/forms.js index 0e44927..ff4f78a 100644 --- a/modules/header/forms.js +++ b/modules/header/forms.js @@ -121,8 +121,6 @@ * @param {function} [loadFunction] callback to be executed when form is loaded */ mw.flow.action.header.edit.prototype.setupEditForm = function ( data, loadFunction ) { - var $editLink = this.object.$container.find( '.flow-header-edit-link' ); - // call parent setupEditForm function mw.flow.action.prototype.setupEditForm.call( this, @@ -130,12 +128,17 @@ loadFunction ); - // hide edit link and re-reveal it if the cancel link - which is - // added by flow( 'setupEditForm' ) - is clicked. - $editLink.hide(); - this.object.$container.find( '.flow-cancel-link' ).click( function () { - $editLink.show(); - } ); + this.object.$container.find( '.flow-header-edit-link' ).hide(); + }; + + /** + * Removes the edit form & restores content. + */ + mw.flow.action.header.edit.prototype.destroyEditForm = function () { + this.object.$container.find( '.flow-header-edit-link' ).show(); + + // call parent destroyEditForm function + mw.flow.action.prototype.destroyEditForm.call( this ); }; /** -- To view, visit https://gerrit.wikimedia.org/r/109310 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I024fe34c7a98e5fe165971b7a5542028ccf54ec3 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: Bsitu <bs...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits