From da5bdcfdad7f6b8e3eb51e4f90f04db990e37a31 Mon Sep 17 00:00:00 2001 From: Antoine Beaubien Date: Mon, 20 Apr 2020 03:16:06 -0400 Subject: [PATCH] Update perform-edits-dialog.js to trap [RETURN] in editSummary and proceed to action (#2550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update perform-edits-dialog.js Adding PerformEditsDialog.doFormSubmit() to share with keypress() [RETURN] from editField and « Edit Uploads ». * var doFormSubmit = function()… Change PerformEditsDialog.doFormSubmit to var doFormSubmit = function() * Update perform-edits-dialog.js Convert [TAB] to 2x [SPACE]. * Update perform-edits-dialog.js Move evt.preventDefault(); to where it belongs. * Update perform-edits-dialog.js Spacing corrections. * Update perform-edits-dialog.js Spacing corrections. --- .../scripts/dialogs/perform-edits-dialog.js | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js index 8b91b6153..eed847bf6 100644 --- a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js @@ -18,54 +18,60 @@ PerformEditsDialog.launch = function(logged_in_username, max_severity) { this._elmts.performEditsButton.text($.i18n('perform-wikidata-edits/perform-edits')); this._elmts.cancelButton.text($.i18n('perform-wikidata-edits/cancel')); + var hiddenIframe = $('#hiddenIframe').contents(); + var dismiss = function() { DialogSystem.dismissUntil(self._level - 1); }; + + var doFormSubmit = function() { + hiddenIframe.find('body').append(elmts.performEditsForm.clone()); + var formCopy = hiddenIframe.find("#wikibase-perform-edits-form"); + formCopy.submit(); + + if(elmts.editSummary.val().length == 0) { + elmts.editSummary.focus(); + } else { + Refine.postProcess( + "wikidata", + "perform-wikibase-edits", + {}, + { summary: elmts.editSummary.val(), }, + { includeEngine: true, cellsChanged: true, columnStatsChanged: true }, + { onDone: function() { dismiss(); } } + ); + } + } + elmts.loggedInUsername .text(logged_in_username) .attr('href','https://www.wikidata.org/wiki/User:'+logged_in_username); frame.find('.cancel-button').click(function() { - dismiss(); + dismiss(); }); - var hiddenIframe = $('#hiddenIframe').contents(); + this._elmts.editSummary.keypress(function (evt) { + if (evt.which === 13) { + doFormSubmit(); + evt.preventDefault(); + } + }); if (max_severity === 'CRITICAL') { - elmts.performEditsButton.prop("disabled",true).addClass("button-disabled"); + elmts.performEditsButton.prop("disabled",true).addClass("button-disabled"); } else { elmts.performEditsButton.click(function() { - hiddenIframe.find('body').append( - elmts.performEditsForm.clone()); - var formCopy = hiddenIframe.find("#wikibase-perform-edits-form"); - formCopy.submit(); - - if(elmts.editSummary.val().length == 0) { - elmts.editSummary.focus(); - } else { - Refine.postProcess( - "wikidata", - "perform-wikibase-edits", - {}, - { - summary: elmts.editSummary.val(), - }, - { includeEngine: true, cellsChanged: true, columnStatsChanged: true }, - { onDone: - function() { - dismiss(); - } - }); - } + doFormSubmit(); }); } }; PerformEditsDialog.updateEditCount = function(edit_count) { this._elmts.reviewYourEdits.html( - $.i18n('perform-wikidata-edits/review-your-edits') - .replace('{nb_edits}', edit_count)); + $.i18n('perform-wikidata-edits/review-your-edits') + .replace('{nb_edits}', edit_count)); } PerformEditsDialog._updateWarnings = function(data) {