From 599a39ba2250350d796bdae864fcf101d3bff4e7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 14 Oct 2012 02:06:31 +0200 Subject: [PATCH] Package installation dialogs submits on [Enter] within input Fixes #649 --- wcfsetup/install/files/acp/js/WCF.ACP.js | 47 +++++++++++++++--------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 5ff0d8528d..d20ea2863a 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -380,29 +380,20 @@ WCF.ACP.Package.Installation.prototype = { // handle inner template if (data.innerTemplate) { - $('#packageInstallationInnerContent').html(data.innerTemplate); + var self = this; + + $('#packageInstallationInnerContent').html(data.innerTemplate).find('input').keyup(function(event) { + if (event.keyCode === 13) { // Enter + self._submitDialog(data); + } + }); // create button to handle next step if (data.step && data.node) { var $id = WCF.getRandomID(); $('#packageInstallationInnerContent').append('
'); - $('#' + $id).click($.proxy(function() { - // collect form values - var $additionalData = {}; - $('#packageInstallationInnerContent input').each(function(index, inputElement) { - var $inputElement = $(inputElement); - var $type = $inputElement.attr('type'); - - if (($type == 'checkbox' || $type == 'radio') && !$inputElement.attr('checked')) { - return false; - } - - $additionalData[$inputElement.attr('name')] = $inputElement.val(); - }); - - this._executeStep(data.step, data.node, $additionalData); - }, this)); + $('#' + $id).click(function() { self._submitDialog(data); }); } $('#packageInstallationInnerContentContainer').show(); @@ -425,6 +416,28 @@ WCF.ACP.Package.Installation.prototype = { }, this)); }, + /** + * Submits the dialog content. + * + * @param object data + */ + _submitDialog: function(data) { + // collect form values + var $additionalData = {}; + $('#packageInstallationInnerContent input').each(function(index, inputElement) { + var $inputElement = $(inputElement); + var $type = $inputElement.attr('type'); + + if (($type == 'checkbox' || $type == 'radio') && !$inputElement.attr('checked')) { + return false; + } + + $additionalData[$inputElement.attr('name')] = $inputElement.val(); + }); + + this._executeStep(data.step, data.node, $additionalData); + }, + /** * Purges template content. * -- 2.20.1