/* * 2018 Areama * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@areama.net so we can send you a copy immediately. * * * @author Areama * @copyright 2018 Areama * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of Areama */ "use strict"; (function($){ function ArContactUs(element, options){ this._initialized = false; this.settings = null; this.popups = []; this.options = $.extend({}, ArContactUs.Defaults, options); this.$element = $(element); this.x = 0; this.y = 0; this._interval; this._menuOpened = false; this._popupOpened = false; this._callbackOpened = false; this.countdown = null; this.svgPath = null; this.svgSteps = [], this.svgPathOpen = null; this.svgInitialPath = null; this.isAnimating = false; this.init(); }; ArContactUs.Defaults = { activated: false, pluginVersion: '2.1.3', wordpressPluginVersion: false, align: 'right', mode: 'regular', countdown: 0, drag: false, buttonText: 'Contact us', buttonSize: 'large', buttonIconSize: 24, menuSize: 'normal', buttonIcon: '', ajaxUrl: 'server.php', action: 'callback', phonePlaceholder: '+X-XXX-XXX-XX-XX', callbackSubmitText: 'Waiting for call', reCaptcha: false, reCaptchaAction: 'callbackRequest', reCaptchaKey: '', errorMessage: 'Connection error. Please try again.', callProcessText: 'We are calling you to phone', callSuccessText: 'Thank you.
We are call you back soon.', showMenuHeader: false, menuHeaderText: 'How would you like to contact us?', showHeaderCloseBtn: true, menuInAnimationClass: 'show-messageners-block', menuOutAnimationClass: '', eaderCloseBtnBgColor: '#787878', eaderCloseBtnColor: '#FFFFFF', items: [], itemsIconType: 'rounded', iconsAnimationSpeed: 800, iconsAnimationPause: 2000, promptPosition: 'side', style: null, itemsAnimation: null, popupAnimation: 'scale', callbackFormFields: { name: { name: 'name', enabled: true, required: true, type: 'text', label: 'Please enter your name', placeholder: 'Your full name' }, email: { name: 'email', enabled: true, required: false, type: 'email', label: 'Enter your email address', placeholder: 'Optional field. Example: email@domain.com' }, time: { name: 'time', enabled: true, required: false, type: 'dropdown', label: 'Please choose schedule time', values: [{value: 'asap', label: 'Call me ASAP'},'00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'] }, phone: { name: 'phone', enabled: true, required: true, type: 'tel', label: 'Please enter your phone number', placeholder: '+X-XXX-XXX-XX-XX' }, description: { name: 'description', enabled: true, required: false, type: 'textarea', label: 'Please leave a message with your request' } }, theme: '#000000', callbackFormText: 'Please enter your phone number
and we call you back soon', closeIcon: '', callbackStateIcon: '' }; ArContactUs.prototype.init = function(){ if (this._initialized){ return false; } this.destroy(); this.settings = $.extend({}, this.options); this.$element.addClass('arcontactus-widget').addClass('arcontactus-message'); if (this.settings.style == 'elastic') { this.$element.addClass('arcu-elastic'); } if (this.settings.style == 'bubble') { this.$element.addClass('arcu-bubble'); } if (this.settings.style.length == 0 && this.settings.popupAnimation) { this.$element.addClass('arcu-'+this.settings.popupAnimation); } if (this.settings.align === 'left'){ this.$element.addClass('left'); }else{ this.$element.addClass('right'); } if (this.settings.items.length){ this.$element.append(''); this._initCallbackBlock(); if (this.settings.mode == 'regular'){ this._initMessengersBlock(); } if (this.popups.length) { this._initPopups(); } this._initMessageButton(); this._initPrompt(); this._initEvents(); var $this = this; setTimeout(function(){ $this.startAnimation(); }, this.settings.iconsAnimationPause? this.settings.iconsAnimationPause : 2000); this.$element.append(''); this.$element.addClass('active'); }else{ console.info('jquery.contactus:no items'); } if (this.settings.style == 'elastic' || this.settings.style == 'bubble') { var morphEl = document.getElementById('arcu-morph-shape'); var s = Snap(morphEl.querySelector('svg')); this.svgPath = s.select('path'); this.svgPathOpen = morphEl.getAttribute('data-morph-open'); this.svgInitialPath = this.svgPath.attr('d'); this.svgSteps = this.svgPathOpen.split(';'); this.svgStepsTotal = this.svgSteps.length; } this._initialized = true; this.$element.trigger('arcontactus.init'); }; ArContactUs.prototype.destroy = function(){ if (!this._initialized){ return false; } this.stopAnimation(); this._removeEvents(); this.$element.find('.arcontactus-message-button').unbind(); this.$element.html(''); this.$element.removeClass(); this.$element.unbind().removeData('ar.contactus'); this._initialized = false; this.$element.trigger('arcontactus.destroy'); }; ArContactUs.prototype._initCallbackBlock = function(){ var $container = $('
', { class: 'callback-countdown-block', style: this._colorStyle() }); var $close = $('
', { class: 'callback-countdown-block-close', style: 'background-color:' + this.settings.theme + '; color: #FFFFFF' }); $close.append(this.settings.closeIcon); var $formBlock = $('
', { class: 'callback-countdown-block-phone' }); $formBlock.append('

' + this.settings.callbackFormText + '

'); var $form = $('
', { id: 'arcu-callback-form', action: this.settings.ajaxUrl, method: 'POST' }); var $formGroup = $('
', { class: 'callback-countdown-block-form-group' }); var $inputAction = $('', { name: 'action', type: 'hidden', value: this.settings.action }); var $inputGtoken = $('', { name: 'gtoken', class: 'ar-g-token', type: 'hidden', value: '' }); $formGroup.append($inputAction); $formGroup.append($inputGtoken); this._initCallbackFormFields($formGroup); var $inputContainer = $('
', { class: 'arcu-form-group arcu-form-button' }); var $inputSubmit = $('