Skip to content
Code-Schnipsel Gruppen Projekte
SimpleContact.js 3,62 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * 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.Loader.inject(this.$Elm);
    
                var Button = this.$Elm.getElement('.quiqqer-simple-contact-button');
    
                Button.set('html', QUILocale.get('quiqqer/bricks', 'control.simpleContact.sendButton'));
    
                    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/system', 'message.contact.successful');
                        self.$Elm.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.addError(Exception.getMessage(), self.$Elm);
                        });
                    }
                });