From 1d4220c4bc0fcee2495ab71c4abf53a2d17d0eee Mon Sep 17 00:00:00 2001 From: "michael.danielczok" <michael@pcsg.de> Date: Fri, 3 Dec 2021 10:25:56 +0100 Subject: [PATCH] fix: Do not create send button in javascript by onImport -> sporadic problem with locale. --- bin/Controls/SimpleContact.js | 53 ++++++++++------------ src/QUI/Bricks/Controls/SimpleContact.html | 11 +++++ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/bin/Controls/SimpleContact.js b/bin/Controls/SimpleContact.js index dc5cfa3..da2a6f5 100644 --- a/bin/Controls/SimpleContact.js +++ b/bin/Controls/SimpleContact.js @@ -53,37 +53,34 @@ define('package/quiqqer/bricks/bin/Controls/SimpleContact', [ this.Loader.inject(this.$Elm); this.Form = this.$Elm.getElement('form'); - var Button = new Element('button', { - 'class': 'quiqqer-simple-contact-button', - 'type' : 'button', - 'html' : QUILocale.get('quiqqer/bricks', 'control.simpleContact.sendButton'), - events : { - click: function () { - if (self.$captchaRequired && !self.$captchaResponse) { - QUI.getMessageHandler(function (MH) { - MH.options.displayTimeMessages = 2000; - - var CaptchaElm = self.$Elm.getElement('.qui-contact-captcha'); - - if (!CaptchaElm) { - CaptchaElm = undefined; - } - - MH.addError( - QUILocale.get(lg, 'brick.control.simpleContact.error.captcha_failed'), - CaptchaElm - ); - }); - - return; - } + var Button = this.Form.getElement('.quiqqer-simple-contact-button'); + + if (Button) { + Button.addEvent('click', function () { + if (self.$captchaRequired && !self.$captchaResponse) { + QUI.getMessageHandler(function (MH) { + MH.options.displayTimeMessages = 2000; + + var CaptchaElm = self.$Elm.getElement('.qui-contact-captcha'); + + if (!CaptchaElm) { + CaptchaElm = undefined; + } + + MH.addError( + QUILocale.get(lg, 'brick.control.simpleContact.error.captcha_failed'), + CaptchaElm + ); + }); - self.$Elm.getElement('form').fireEvent('submit'); + return; } - } - }); - Button.inject(this.Form); + self.$Elm.getElement('form').fireEvent('submit'); + }); + + Button.removeAttribute('disabled'); + } this.$Elm.getElement('form').addEvent('submit', function (event) { if (typeof event !== 'undefined') { diff --git a/src/QUI/Bricks/Controls/SimpleContact.html b/src/QUI/Bricks/Controls/SimpleContact.html index d42e6e8..e876382 100644 --- a/src/QUI/Bricks/Controls/SimpleContact.html +++ b/src/QUI/Bricks/Controls/SimpleContact.html @@ -23,6 +23,13 @@ {/if} <form class="quiqqer-simple-contact" method="POST" action=""> + <noscript> + <style> + .quiqqer-simple-contact-button__hideOnNoScript { + display: none !important; + } + </style> + </noscript> {if $this->getAttribute('labels')} <label for="qui-contact-name"> @@ -115,6 +122,10 @@ {$CaptchaDisplay->create()} {/if} + <button class="quiqqer-simple-contact-button quiqqer-simple-contact-button__hideOnNoScript" type="submit" disabled="disabled"> + {locale group='quiqqer/bricks' value='control.simpleContact.sendButton'} + </button> + <noscript> <input class="quiqqer-simple-contact-button" type="submit" value="{locale group='quiqqer/bricks' value='control.simpleContact.sendButton'}" /> -- GitLab