From 32b5d0a1c0a424e5ccc5b602ef49e13ab12d9b9b Mon Sep 17 00:00:00 2001
From: Michael <michael.danielczok@gmail.com>
Date: Fri, 19 Feb 2016 16:29:37 +0100
Subject: [PATCH] =?UTF-8?q?Bricks:=20Kontaktformular=20ist=20fertig.=20Anp?=
 =?UTF-8?q?assung=20der=20=C3=9Cbersetzungen=20(=C3=9Cbertragung=20der=20T?=
 =?UTF-8?q?exte=20in=20locale.xml).=20Der=20Sendebutton=20wurde=20als=20HT?=
 =?UTF-8?q?ML=20gemacht=20und=20die=20js=20Datei=20entsprechend=20angepass?=
 =?UTF-8?q?t.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 bin/Controls/SimpleContact.js              | 128 ++++++++++-----------
 locale.xml                                 |   4 +
 src/QUI/Bricks/Controls/SimpleContact.html |   2 +
 src/QUI/Bricks/Controls/SimpleContact.php  |   2 +-
 4 files changed, 66 insertions(+), 70 deletions(-)

diff --git a/bin/Controls/SimpleContact.js b/bin/Controls/SimpleContact.js
index a31c04c..2236b65 100644
--- a/bin/Controls/SimpleContact.js
+++ b/bin/Controls/SimpleContact.js
@@ -1,4 +1,3 @@
-
 /**
  * QUIQQER Contact Control
  *
@@ -6,7 +5,7 @@
  * @module Bricks\Controls\SimpleContact
  */
 
-define('Controls/SimpleContact', [
+define('package/quiqqer/bricks/bin/Controls/SimpleContact', [
 
     'qui/QUI',
     'qui/controls/Control',
@@ -15,107 +14,100 @@ define('Controls/SimpleContact', [
     'Ajax',
     'Locale'
 
-], function(QUI, QUIControl, QUIButton, QUILoader, Ajax, Locale)
-{
+], function (QUI, QUIControl, QUIButton, QUILoader, Ajax, QUILocale) {
     "use strict";
 
     return new Class({
 
-        Extends : QUIControl,
-        Type    : 'Controls/SimpleContact',
+        Extends: QUIControl,
+        Type   : 'Controls/SimpleContact',
 
-        Binds : ['$onImport'],
+        Binds: ['$onImport'],
 
-        initialize : function(options)
-        {
-            this.parent( options );
+        initialize: function (options) {
+            this.parent(options);
 
             this.Loader = new QUILoader();
 
-            this.$Text  = null;
+            this.$Text = null;
             this.$Email = null;
-            this.$Name  = null;
+            this.$Name = null;
 
             this.addEvents({
-                onImport : this.$onImport
-            });
+                               onImport: this.$onImport
+                           });
         },
 
         /**
          * event : on import
          */
-        $onImport : function()
-        {
+        $onImport: function () {
             var self = this;
 
-            this.Loader.inject( this.$Elm );
-            this.Loader.show();
-/*
+            this.Loader.inject(this.$Elm);
+
+            /*
             var Send = new QUIButton({
-                text   : 'senden',
-                textimage : 'fa fa-envelope-o icon-envelope-alt',
-                events :
-                {
-                    onClick : function() {
-                        self.$Elm.getElement('form').fireEvent('submit');
-                    }
-                }
-            }).inject( this.$Elm );
-*/
-            new Element('button', {
-                html : 'sendenNNnN',
-                'class' : 'button qui-button',
-                events : {
-                    click : function() {
+                text     : 'senden',
+                textimage: 'fa fa-envelope-o icon-envelope-alt',
+                events   : {
+                    onClick: function () {
                         self.$Elm.getElement('form').fireEvent('submit');
                     }
                 }
             }).inject(this.$Elm);
+            */
+
+            //new Element('button', {
+            //    html : 'sendenNNnN',
+            //    'class' : 'button qui-button',
+            //    events : {
+            //        click : function() {
+            //            self.$Elm.getElement('form').fireEvent('submit');
+            //        }
+            //    }
+            //}).inject(this.$Elm);
+
+            var Button = this.$Elm.getElement('.quiqqer-simple-contact-button');
 
+            Button.set('disabled', false);
+            Button.set('html', QUILocale.get('quiqqer/bricks', 'control.simpleContact.sentButton'));
 
-            this.$Elm.getElement('form').addEvent('submit', function(event)
-            {
+            this.$Elm.getElement('form').addEvent('submit', function (event) {
                 var sendViaAjax = self.getElm().get('data-ajax').toInt();
 
-                if ( sendViaAjax === 0 )
-                {
+                if (sendViaAjax === 0) {
                     self.getElm().getElement('form').submit();
                     return;
                 }
 
-                if ( typeof event !== 'undefined' ) {
+                if (typeof event !== 'undefined') {
                     event.stop();
                 }
 
                 self.send();
             });
 
-            this.$Text  = this.$Elm.getElement( '[name="message"]' );
-            this.$Email = this.$Elm.getElement( '[name="email"]' );
-            this.$Name  = this.$Elm.getElement( '[name="name"]' );
-
-            this.Loader.hide();
+            this.$Text = this.$Elm.getElement('[name="message"]');
+            this.$Email = this.$Elm.getElement('[name="email"]');
+            this.$Name = this.$Elm.getElement('[name="name"]');
         },
 
         /**
          * Send contact message
          */
-        send : function()
-        {
-            if ( this.$Text.value === '' )
-            {
+        send: function () {
+            if (this.$Text.value === '') {
                 this.$Text.focus();
                 return;
             }
 
-            if ( this.$Email.value === '' )
-            {
+            if (this.$Email.value === '') {
                 this.$Email.focus();
                 return;
             }
 
-            if ( this.$Name.value === '' )
-            {
+            if (this.$Name.value === '') {
                 this.$Name.focus();
                 return;
             }
@@ -125,28 +117,26 @@ define('Controls/SimpleContact', [
             this.Loader.show();
 
 
-            Ajax.post('ajax_contact', function(result)
-            {
-                if ( result ) {
-                    self.$Elm.set( 'html', Locale.get( 'quiqqer/system', 'message.contact.successful' ) );
+            Ajax.post('ajax_contact', function (result) {
+                if (result) {
+                    self.$Elm.set('html', QUILocale.get('quiqqer/system', 'message.contact.successful'));
                 }
 
                 self.Loader.hide();
 
             }, {
-                message   : this.$Text.value,
-                email     : this.$Email.value,
-                name      : this.$Name.value,
-                showError : false,
-                onError   : function(Exception)
-                {
-                    self.Loader.hide();
-
-                    QUI.getMessageHandler(function(MH) {
-                        MH.addError( Exception.getMessage(), self.$Elm );
-                    });
-                }
-            });
+                          message  : this.$Text.value,
+                          email    : this.$Email.value,
+                          name     : this.$Name.value,
+                          showError: false,
+                          onError  : function (Exception) {
+                              self.Loader.hide();
+
+                              QUI.getMessageHandler(function (MH) {
+                                  MH.addError(Exception.getMessage(), self.$Elm);
+                              });
+                          }
+                      });
         }
     });
 });
\ No newline at end of file
diff --git a/locale.xml b/locale.xml
index a89ada1..dbdfab6 100644
--- a/locale.xml
+++ b/locale.xml
@@ -88,6 +88,10 @@
             <de><![CDATA[Ihre Nachricht an uns...]]></de>
             <en><![CDATA[Your message to us]]></en>
         </locale>
+        <locale name="control.simpleContact.sentButton">
+            <de><![CDATA[Senden]]></de>
+            <en><![CDATA[Sent]]></en>
+        </locale>
 
 
 
diff --git a/src/QUI/Bricks/Controls/SimpleContact.html b/src/QUI/Bricks/Controls/SimpleContact.html
index bfc669b..f5d33b8 100644
--- a/src/QUI/Bricks/Controls/SimpleContact.html
+++ b/src/QUI/Bricks/Controls/SimpleContact.html
@@ -48,4 +48,6 @@
         placeholder="{locale group="quiqqer/bricks" value="control.simpleContact.message.placeholder"}"
     >{$this->getAttribute('POST_MESSAGE')}</textarea>
 
+    <button class="quiqqer-simple-contact-button" type="button" disabled="disabled"><span class="fa fa-spinner fa-spin"></span></button>
+
 </form>
\ No newline at end of file
diff --git a/src/QUI/Bricks/Controls/SimpleContact.php b/src/QUI/Bricks/Controls/SimpleContact.php
index 6e02be7..2c5b044 100644
--- a/src/QUI/Bricks/Controls/SimpleContact.php
+++ b/src/QUI/Bricks/Controls/SimpleContact.php
@@ -39,7 +39,7 @@ public function __construct($attributes = array())
         );
 
         $this->setAttribute('class', 'quiqqer-simple-contact');
-        $this->setAttribute('qui-class', "Bricks/Controls/SimpleContact");
+        $this->setAttribute('qui-class', "package/quiqqer/bricks/bin/Controls/SimpleContact");
         $this->setAttribute('labels', true);
     }
 
-- 
GitLab