Skip to content
Code-Schnipsel Gruppen Projekte
SimpleContact.js 3,81 KiB
Newer Older
/**
 * QUIQQER Contact Control
 *
 * @author www.pcsg.de (Henning Leutz)
 * @author www.pcsg.de (Michael Danielczok)
 * @module Bricks\Controls\SimpleContact
 *
 * @require qui/QUI
 * @require qui/controls/Control
 * @require qui/controls/buttons/Button
 * @require qui/controls/loader/Loader
 * @require Ajax
 * @require Locale
define('package/quiqqer/bricks/bin/Controls/SimpleContact', [

    'qui/QUI',
    'qui/controls/Control',
    'qui/controls/buttons/Button',
    'qui/controls/loader/Loader',
    'Ajax',
    'Locale'

], function (QUI, QUIControl, QUIButton, QUILoader, Ajax, QUILocale) {
        Extends: QUIControl,
        Type   : 'Controls/SimpleContact',
        Binds: [
            '$onImport'
        ],
        initialize: function (options) {
            this.parent(options);
            this.$Text  = null;
            this.$Name  = null;
                onImport: this.$onImport
            });
            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 () {
                        self.$Elm.getElement('form').fireEvent('submit');
                    }
            this.$Elm.getElement('form').addEvent('submit', function (event) {
                if (typeof event !== 'undefined') {
            this.$Text  = this.$Elm.getElement('[name="message"]');
            this.$Email = this.$Elm.getElement('[name="email"]');
            this.$Name  = this.$Elm.getElement('[name="name"]');
            Ajax.post('package_quiqqer_bricks_ajax_contact', function (result) {
                    var html = '<span class="fa fa-check fa-check-simple-contact control-color"></span>';
                    html += QUILocale.get('quiqqer/bricks', 'brick.control.simpleContact.successful');
                    self.Form.set('html', html);
                'package': 'quiqqer/bricks',
                brickId  : this.$Elm.get('data-brickid'),
                message  : this.$Text.value,
                email    : this.$Email.value,
                name     : this.$Name.value,
                showError: false,
                project  : JSON.encode(QUIQQER_PROJECT),
                siteId   : QUIQQER_SITE.id,
                onError  : function (Exception) {
                    self.Loader.hide();

                    QUI.getMessageHandler(function (MH) {
                        MH.options.displayTimeMessages = 8000;
                        MH.addError(Exception.getMessage(), self.$Elm);
                    });
                }
            });