Plugin Directory

Changeset 1744693


Ignore:
Timestamp:
10/11/2017 11:03:10 AM (8 years ago)
Author:
chatx
Message:

Version 0.1.6 update

Location:
chatx-ai
Files:
130 added
8 edited

Legend:

Unmodified
Added
Removed
  • chatx-ai/trunk/chatx-ai.php

    r1742261 r1744693  
    44 * Plugin URI:        https://chatx.ai
    55 * Description:       Recover abandoned carts on WooCommerce using an intelligent Facebook Messenger chatbot.
    6  * Version:           0.1.5
     6 * Version:           0.1.6
    77 * Author:            chatx.ai
    88 * Author URI:        https://chatx.ai
  • chatx-ai/trunk/includes/class-chatx-ai-rest-api.php

    r1742261 r1744693  
    351351                    'button-selector' => isset($template['button-selector']) ? $template['button-selector'] : null,
    352352                    'type'            => isset($template['type']) ? $template['type'] : null,
     353                    'bubble'            => isset($template['bubble']) ? $template['bubble'] : null
    353354                ];
    354355
  • chatx-ai/trunk/includes/lib/config.php

    r1733642 r1744693  
    44// define('CHATX_BAESURL', 'https://bman-bot.herokuapp.com');
    55define('CHATX_BAESURL', 'https://app.chatx.ai');
    6 // define('CHATX_BAESURL', 'https://chatx-dev.herokuapp.com');
     6//define('CHATX_BAESURL', 'https://chatx-dev.herokuapp.com');
  • chatx-ai/trunk/public/class-chatx-ai-public.php

    r1742261 r1744693  
    163163            'type'            => 'form',
    164164            'button-selector' => '',
    165             'template'        => null
     165            'template'        => null,
     166            'bubble'          => ''
    166167        ], $atts, 'messenger_checkbox');
    167168
     
    185186                        'campaign' => 'add_to_cart_form',
    186187                        'type' => $atts['type'],
    187                         'button-selector' => $atts['button-selector']
     188                        'button-selector' => $atts['button-selector'],
     189                        'bubble' => '173 customers got amazing discounts by checking this.'
    188190                    ];
    189191                    Chatx_Ai_Options::update('chatxai_checkbox_templates', $checkbox_templates);
     
    195197                        'campaign' => 'add_to_cart_form',
    196198                        'type' => 'button',
    197                         'button-selector' => '.product a.add_to_cart_button,.product button.add_to_cart_button'
     199                        'button-selector' => '.product a.add_to_cart_button,.product button.add_to_cart_button',
     200                        'bubble' => '173 customers got amazing discounts by checking this.'
    198201                    ];
    199202                    Chatx_Ai_Options::update('chatxai_checkbox_templates', $checkbox_templates);
     
    208211                $atts['type'] = isset($foundTemplate['type']) ? $foundTemplate['type'] : '';
    209212                $atts['button-selector'] = isset($foundTemplate['button-selector']) ? $foundTemplate['button-selector'] : '';
     213                $atts['bubble'] = isset($foundTemplate['bubble']) ? $foundTemplate['bubble'] : '173 customers got amazing discounts by checking this.';
    210214            }
    211215        }
  • chatx-ai/trunk/public/css/chatx-ai-public.css

    r1733642 r1744693  
    33 * included in this file.
    44 */
     5
     6.chatx-clearfix:after {
     7    visibility: hidden;
     8    display: block;
     9    font-size: 0;
     10    content: " ";
     11    clear: both;
     12    height: 0;
     13}
     14
     15.chatx-clearfix {
     16    display: inline-block;
     17}
     18
     19* html .chatx-clearfix {
     20    height: 1%;
     21}
     22
     23.chatx-clearfix {
     24    display: block;
     25}
     26
     27.chatx-checkbox-plugin,
     28.chatx-checkbox-plugin-container {
     29    position: relative;
     30}
     31
     32.chatx-speech-bubble {
     33    position: absolute;
     34    top: 65px;
     35    left: 0;
     36    z-index: 12;
     37    margin: 0 auto;
     38    padding: 10px;
     39    width: 300px;
     40    height: 65px;
     41    border-radius: 5px;
     42    transform: rotate(4deg) rotateY(15deg) translate3d(0, 0, 0);
     43    background: #717171;
     44    font-size: 15px;
     45    line-height: normal;
     46    text-align: center;
     47    display: none;
     48}
     49
     50.chatx-modal-close {
     51    background: #f9f9f9;
     52    border-radius: 50%;
     53    width: 30px;
     54    height: 30px;
     55    position: absolute;
     56    right: -10px;
     57    top: -10px;
     58    border: solid 2px #717171;
     59    font-size: 20px;
     60    padding: 0;
     61    outline: none;
     62}
     63
     64.chatx-speech-bubble:before,
     65.chatx-speech-bubble:after {
     66    position: absolute;
     67    z-index: -1;
     68    content: '';
     69}
     70
     71.chatx-speech-bubble:after {
     72    top: 0;
     73    right: 0;
     74    bottom: 0;
     75    left: 0;
     76    border-radius: inherit;
     77    background: #fff;
     78    transform: rotate(0deg) translate(-.01em, 0.01em) scaleX(0.987) scaleY(0.95);
     79}
     80
     81.chatx-speech-bubble:before {
     82    border: solid 0 transparent;
     83    border-left: solid 50px #fff;
     84    border-top: solid 6px #717171;
     85    top: 1px;
     86    left: 24px;
     87    width: 0;
     88    height: 1em;
     89    transform: rotate(45deg) skewX(75deg);
     90}
     91
     92.chatx-speech-bubble p{
     93    font-size: 13px;
     94}
     95
     96
     97.chatx-checkbox-plugin .chatx-circle-mark {
     98    position: absolute;
     99    border: solid 2px #717171;
     100    border-radius: 50%;
     101    display: block;
     102    width: 30px;
     103    height: 30px;
     104    top: 9px;
     105    left: 5px;
     106    z-index: 123;
     107    display: none;
     108}
     109
     110.chatx-checkbox-plugin.unchecked .chatx-circle-mark {
     111    display: block;
     112}
     113
     114.chatx-checkbox-plugin.unchecked:hover .chatx-circle-mark {
     115    display: none;
     116}
     117
     118.chatx-checkbox-plugin.unchecked .chatx-speech-bubble {
     119    display: block;
     120    animation: shake 4s cubic-bezier(.36, .07, .19, .97) both;
     121    animation-iteration-count: infinite;
     122    backface-visibility: hidden;
     123    perspective: 1000px;
     124}
     125
     126@keyframes shake {
     127    1%,
     128    9% {
     129        transform: rotate(4deg) rotateY(15deg) translate3d(-1px, 0, 0);
     130    }
     131
     132    2%,
     133    8% {
     134        transform: rotate(4deg) rotateY(15deg) translate3d(2px, 0, 0);
     135    }
     136
     137    3%,
     138    5%,
     139    7% {
     140        transform: rotate(4deg) rotateY(15deg) translate3d(-4px, 0, 0);
     141    }
     142
     143    4%,
     144    6%,
     145    10% {
     146        transform: rotate(4deg) rotateY(15deg) translate3d(4px, 0, 0);
     147    }
     148
     149    90% {
     150        transform: rotate(4deg) rotateY(15deg) translate3d(4px, 0, 0);
     151    }
     152}
  • chatx-ai/trunk/public/js/chatx-ai-public.js

    r1739526 r1744693  
    11var ChatxAI = {
     2    canClick: false,
    23    startup: function() {
    34        this.loadFB();
     5        this.initBubble();
     6
     7        /*
     8        jQuery('[name="add-to-cart"]').on('mousemove', function(event) {
     9            var offset = jQuery(this).offset();
     10
     11            var btnX = event.pageX - offset.left;
     12            var btnY = event.pageY - offset.top;
     13
     14            ChatxAI.canClick = true;
     15
     16            jQuery('.chatx-checkbox-plugin').css({
     17                position: "fixed",
     18                opacity: "0.4",
     19                left: (event.pageX) + "px",
     20                top: (event.pageY) + "px",
     21                height: "12px",
     22                width: "12px",
     23                overflow: "hidden"
     24            });
     25
     26            jQuery("html").css("cursor", "pointer");
     27
     28            jQuery('.chatx-checkbox-plugin .fb-messenger-checkbox').css({
     29                position: "relative",
     30                top: "-18px",
     31                left: "-15px"
     32            })
     33       });
     34       */
     35    },
     36    cookies: {
     37        set: function(name, value, hours) {
     38            var expires = "";
     39            if (hours) {
     40                var date = new Date();
     41                date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
     42                expires = "; expires=" + date.toUTCString();
     43            }
     44            document.cookie = name + "=" + value + expires + "; path=/";
     45        },
     46        get: function(name) {
     47            var nameEQ = name + "=";
     48            var ca = document.cookie.split(';');
     49            for (var i = 0; i < ca.length; i++) {
     50                var c = ca[i];
     51                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
     52                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
     53            }
     54            return null;
     55        },
     56        erase: function(name) {
     57            this.set(name, "", -1);
     58        }
     59    },
     60    initBubble:function(){
     61        jQuery(document).on('click', '.chatx-modal-close', function(event) {
     62            jQuery('.chatx-checkbox-plugin').removeClass('unchecked');
     63            ChatxAI.cookies.set('chatx_speech_bubble_show', 1, 6);
     64            event.preventDefault();
     65            return false;
     66        });
    467    },
    568    startupFB: function() {
     
    1275
    1376        jQuery('.fb-send-to-messenger').each(function(index, el) {
    14              fb_app_id = jQuery(el).attr('messenger_app_id');
     77            fb_app_id = jQuery(el).attr('messenger_app_id');
    1578        });
    1679
     
    3194                    var checkboxState = e.state;
    3295                    ChatxAI.log("Checkbox state: " + checkboxState);
     96                    if (checkboxState == "unchecked") {
     97                        if(parseInt(ChatxAI.cookies.get('chatx_speech_bubble_show')) !== 1){
     98                            jQuery('.chatx-checkbox-plugin').addClass('unchecked');
     99                        }
     100                    }
     101                    if (checkboxState == "checked") {
     102                        jQuery('.chatx-checkbox-plugin').removeClass('unchecked');
     103                    }
    33104                } else if (e.event == 'not_you') {
    34105                    ChatxAI.log("User clicked 'not you'");
     
    42113    loadFB: function() {
    43114        var oldCB = window.fbAsyncInit;
    44         window.fbAsyncInit = function(){
    45             if(typeof oldCB === 'function'){
     115        window.fbAsyncInit = function() {
     116            if (typeof oldCB === 'function') {
    46117                oldCB();
    47118            }
    48119
    49120            ChatxAI.startupFB();
    50          };
     121        };
    51122
    52123        (function(d, s, id) {
     
    62133    },
    63134    confirmOptIn: function(data) {
    64         if(!data) return;
     135        if (!data) return;
    65136
    66137        FB.AppEvents.logEvent('MessengerCheckboxUserConfirmation', null, {
     
    93164        ChatxAI.log(checkboxType == "form" ? $el.closest('form') : jQuery($el.data('button-selector')));
    94165
    95         if(checkboxType == "button"){
     166        if (checkboxType == "button") {
    96167            jQuery($el.data('button-selector')).data('settings', settings);
    97168            jQuery('body').on('click', $el.data('button-selector'), function(event) {
    98                 if(!ChatxAI.doTriggerButton(jQuery(this))){
     169                if (!ChatxAI.doTriggerButton(jQuery(this))) {
    99170                    event.preventDefault();
    100171                    event.stopPropagation();
     
    102173                }
    103174            });
    104         }
    105         else{
     175        } else {
    106176            $el.closest('form').data('settings', settings);
    107177            $el.closest('form').on('submit', function(event) {
    108                 if(!ChatxAI.doTriggerForm(jQuery(this))){
     178                if (!ChatxAI.doTriggerForm(jQuery(this))) {
    109179                    event.preventDefault();
    110180                    event.stopPropagation();
     
    114184        }
    115185    },
    116     getElementData: function($element){
    117          var elementSettings = $element.data('settings');
    118          if(elementSettings){
     186    getElementData: function($element) {
     187        var elementSettings = $element.data('settings');
     188        if (elementSettings) {
    119189            return {
    120190                app_id: elementSettings.messenger_app_id,
     
    126196        return null;
    127197    },
    128     doTriggerForm: function($element){
     198    doTriggerForm: function($element) {
    129199        ChatxAI.log('Trigger form called');
    130         if(!$element.data('triggered')){
     200        if (!$element.data('triggered')) {
    131201            ChatxAI.log('Form not triggered. Confirm the checkbox ... ');
    132202            var data = ChatxAI.getElementData($element);
     
    137207            $element.find('[type="submit"]').attr('disabled', 'true');
    138208
    139             setTimeout(function(){
     209            setTimeout(function() {
    140210                $element.find('[type="submit"]').removeAttr('disabled').click();
    141211            }, 500)
     
    147217        return true;
    148218    },
    149     doTriggerButton: function($element){
     219    doTriggerButton: function($element) {
    150220        ChatxAI.log('Trigger button called');
    151         if(!$element.data('triggered')){
     221        if (!$element.data('triggered')) {
    152222            ChatxAI.log('Button not triggered. Confirm the checkbox ... ');
    153223            var data = ChatxAI.getElementData($element);
     
    159229            $element.attr('disabled', 'true');
    160230
    161             setTimeout(function(){
     231            setTimeout(function() {
    162232                $element.removeAttr('disabled');
    163233                $element.get(0).click();
     
    170240        return true;
    171241    },
    172     isDev: function(){
     242    isDev: function() {
    173243        return document.cookie.indexOf('chatxdev=') !== -1;
    174244    },
    175     log: function(log){
    176         if(!this.isDev()) return;
    177         if(typeof log == "object"){
     245    log: function(log) {
     246        if (!this.isDev()) return;
     247        if (typeof log == "object") {
    178248            return console.log(log);
    179249        }
  • chatx-ai/trunk/public/partials/checkbox-plugin.php

    r1733642 r1744693  
    1 <div
    2     class="chatx-checkbox-plugin"
    3     data-type="<?php echo $atts['type']; ?>"
    4     data-button-selector="<?php echo $atts['button-selector']; ?>"
    5     data-messenger_app_id="<?php echo $mess_app_id; ?>"
    6     data-page_id="<?php echo $page_id; ?>"
    7     data-origin="<?php echo $origin; ?>"
    8     data-user_ref="<?php echo $user_ref; ?>">
     1<div class="chatx-clearfix"></div>
     2<div class="chatx-checkbox-plugin-container">
     3    <div
     4        class="chatx-checkbox-plugin"
     5        data-type="<?php echo $atts['type']; ?>"
     6        data-button-selector="<?php echo $atts['button-selector']; ?>"
     7        data-messenger_app_id="<?php echo $mess_app_id; ?>"
     8        data-page_id="<?php echo $page_id; ?>"
     9        data-origin="<?php echo $origin; ?>"
     10        data-user_ref="<?php echo $user_ref; ?>">
     11
     12        <div class="chatx-speech-bubble">
     13            <button type="button" class="chatx-modal-close">&times;</button>
     14            <p><?php echo $atts['bubble']; ?></p>
     15        </div>
     16
     17        <span class="chatx-circle-mark"></span>
     18    </div>
    919</div>
  • chatx-ai/trunk/readme.txt

    r1742261 r1744693  
    33Tags: abandoned cart, recover abandoned cart, woocommerce, chatbot, facebook messenger
    44Tested up to: 4.8.2
    5 Stable tag: 0.1.5
     5Stable tag: 0.1.6
    66Requires at least: 3.0
    77
     
    3838
    3939== Changelog ==
     40= 0.1.6 =
     41* Added a quick fix for the checkbox not being checked by default.
     42
    4043= 0.1.5 =
    4144* Fixed issue for when you don't have WooCommerce installed or active and you try to activate ChatX.
Note: See TracChangeset for help on using the changeset viewer.