ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

customizer-shortcodes.js (6034B)


      1 (function (root, CP_Customizer, $) {
      2 
      3     var countUpSelector = '[data-countup="true"]';
      4 
      5     var countupControls = {
      6         min: {
      7             control: {
      8                 label: 'Start counter from',
      9                 type: 'text',
     10                 attr: 'data-min',
     11                 default: 0
     12             }
     13         },
     14 
     15         max: {
     16             control: {
     17                 label: 'End counter to',
     18                 type: 'text',
     19                 attr: 'data-max',
     20                 default: 100
     21             }
     22 
     23         },
     24 
     25         stop: {
     26             control: {
     27                 label: 'Stop circle at value',
     28                 type: 'text',
     29                 attr: 'data-stop',
     30                 active: function ($item) {
     31                     return $item.closest('.circle-counter').length > 0;
     32                 },
     33                 default: 50
     34             }
     35 
     36         },
     37 
     38         prefix: {
     39             control: {
     40                 label: 'Prefix ( text in front of the number )',
     41                 type: 'text',
     42                 attr: 'data-prefix',
     43                 default: ""
     44             }
     45 
     46         },
     47 
     48         suffix: {
     49             control: {
     50                 label: 'Suffix ( text after the number )',
     51                 type: 'text',
     52                 attr: 'data-suffix',
     53                 default: "%"
     54             }
     55 
     56         },
     57 
     58         duration: {
     59             control: {
     60                 label: 'Counter duration ( in milliseconds )',
     61                 type: 'text',
     62                 attr: 'data-duration',
     63                 default: 2000
     64             }
     65 
     66         }
     67 
     68 
     69     };
     70 
     71     CP_Customizer.hooks.addFilter('filter_custom_popup_controls', function (controls) {
     72         var extendedControls = _.extend(_.clone(controls),
     73             {
     74                 countup: countupControls
     75             }
     76         );
     77         return extendedControls;
     78     });
     79 
     80     CP_Customizer.preview.registerContainerDataHandler(countUpSelector, function ($item) {
     81         CP_Customizer.openCustomPopupEditor($item, 'countup', function (values, $item) {
     82             console.log(values, $item);
     83             CP_Customizer.preview.jQuery($item[0]).data().restartCountUp();
     84         });
     85     });
     86 
     87     CP_Customizer.hooks.addAction('clean_nodes', function ($nodes) {
     88         $nodes.find(countUpSelector).each(function () {
     89             this.innerHTML = "";
     90             this.removeAttribute('data-max-computed');
     91         });
     92 
     93         $nodes.find('.circle-counter svg.circle-bar').removeAttr('style');
     94     });
     95 
     96 
     97 })(window, CP_Customizer, jQuery);
     98 
     99 
    100 (function (root, CP_Customizer, $) {
    101 
    102     var countBarSelector = '[data-countbar="true"]';
    103 
    104     var countbarControls = {
    105         min: {
    106             control: {
    107                 label: 'Start counter from',
    108                 type: 'text',
    109                 attr: 'data-min',
    110                 default: 0
    111             }
    112         },
    113 
    114         max: {
    115             control: {
    116                 label: 'End counter to',
    117                 type: 'text',
    118                 attr: 'data-max',
    119                 default: 100
    120             }
    121 
    122         },
    123 
    124         stop: {
    125             control: {
    126                 label: 'Stop counter at value',
    127                 type: 'text',
    128                 attr: 'data-stop',
    129                 default: 50
    130             }
    131 
    132         },
    133 
    134         suffix: {
    135             control: {
    136                 label: 'Suffix ( text after the number )',
    137                 type: 'text',
    138                 attr: 'data-suffix',
    139                 default: "%"
    140             }
    141 
    142         },
    143 
    144         text: {
    145             control: {
    146                 label: 'Text',
    147                 type: 'text',
    148                 attr: 'data-text',
    149                 default: "Category"
    150             }
    151 
    152         },
    153 
    154         color: {
    155             control: {
    156                 label: 'Color',
    157                 type: 'colorselect',
    158                 attr: 'data-bgcolor',
    159                 default: "#2987E2"
    160             }
    161 
    162         }
    163 
    164     };
    165 
    166     CP_Customizer.hooks.addFilter('filter_custom_popup_controls', function (controls) {
    167         var extendedControls = _.extend(_.clone(controls),
    168             {
    169                 countBar: countbarControls
    170             }
    171         );
    172         return extendedControls;
    173     });
    174 
    175     CP_Customizer.preview.registerContainerDataHandler(countBarSelector, function ($item) {
    176         CP_Customizer.openCustomPopupEditor($item, 'countBar', function (values, $item) {
    177             CP_Customizer.preview.jQuery($item[0]).data().restartCountBar($item);
    178         });
    179     });
    180 
    181     CP_Customizer.hooks.addAction('clean_nodes', function ($nodes) {
    182         $nodes.find(countBarSelector).each(function () {
    183             this.innerHTML = "";
    184         });
    185     });
    186 
    187 
    188 })(window, CP_Customizer, jQuery);
    189 
    190 
    191 (function (root, CP_Customizer, $) {
    192     CP_Customizer.registerShortcodePopupControls(
    193         "materialis_contact_form",
    194         {
    195             "shortcode": {
    196                 control: {
    197                     label: "3rd party form shortcode",
    198                     type: "text",
    199                     setParse: function (value) {
    200                         return value.replace(/^\[+/, '').replace(/\]+$/, '');
    201                     },
    202 
    203                     getParse: function (value) {
    204 
    205                         var val = value.replace(/^\[+/, '').replace(/\]+$/, '');
    206 
    207                         if (!val) return "";
    208                         return "[" + CP_Customizer.utils.htmlDecode(val) + "]";
    209                     }
    210                 }
    211             }
    212         }
    213     );
    214 
    215     CP_Customizer.hooks.addAction('shortcode_edit_materialis_contact_form', CP_Customizer.editEscapedShortcodeAtts);
    216 
    217 })(window, CP_Customizer, jQuery);
    218 
    219 (function (root, CP_Customizer, $) {
    220     CP_Customizer.hooks.addFilter('can_edit_icon', function (value, $node) {
    221         if ($node.closest('.header-homepage-arrow-c').length) {
    222             return false;
    223         }
    224 
    225         return value;
    226     });
    227 })(window, CP_Customizer, jQuery);