balmet.com

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

sp-scripts.js (19603B)


      1 "use strict";
      2 
      3 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
      4 
      5 /*! js-cookie v3.0.0-rc.0 | MIT */
      6 !function (e, t) {
      7   "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = e || self, function () {
      8     var r = e.Cookies,
      9         n = e.Cookies = t();
     10 
     11     n.noConflict = function () {
     12       return e.Cookies = r, n;
     13     };
     14   }());
     15 }(void 0, function () {
     16   "use strict";
     17 
     18   function e(e) {
     19     for (var t = 1; t < arguments.length; t++) {
     20       var r = arguments[t];
     21 
     22       for (var n in r) {
     23         e[n] = r[n];
     24       }
     25     }
     26 
     27     return e;
     28   }
     29 
     30   var t = {
     31     read: function read(e) {
     32       return e.replace(/%3B/g, ";");
     33     },
     34     write: function write(e) {
     35       return e.replace(/;/g, "%3B");
     36     }
     37   };
     38   return function r(n, i) {
     39     function o(r, o, u) {
     40       if ("undefined" != typeof document) {
     41         "number" == typeof (u = e({}, i, u)).expires && (u.expires = new Date(Date.now() + 864e5 * u.expires)), u.expires && (u.expires = u.expires.toUTCString()), r = t.write(r).replace(/=/g, "%3D"), o = n.write(String(o), r);
     42         var c = "";
     43 
     44         for (var f in u) {
     45           u[f] && (c += "; " + f, !0 !== u[f] && (c += "=" + u[f].split(";")[0]));
     46         }
     47 
     48         return document.cookie = r + "=" + o + c;
     49       }
     50     }
     51 
     52     return Object.create({
     53       set: o,
     54       get: function get(e) {
     55         if ("undefined" != typeof document && (!arguments.length || e)) {
     56           for (var r = document.cookie ? document.cookie.split("; ") : [], i = {}, o = 0; o < r.length; o++) {
     57             var u = r[o].split("="),
     58                 c = u.slice(1).join("="),
     59                 f = t.read(u[0]).replace(/%3D/g, "=");
     60             if (i[f] = n.read(c, f), e === f) break;
     61           }
     62 
     63           return e ? i[e] : i;
     64         }
     65       },
     66       remove: function remove(t, r) {
     67         o(t, "", e({}, r, {
     68           expires: -1
     69         }));
     70       },
     71       withAttributes: function withAttributes(t) {
     72         return r(this.converter, e({}, this.attributes, t));
     73       },
     74       withConverter: function withConverter(t) {
     75         return r(e({}, this.converter, t), this.attributes);
     76       }
     77     }, {
     78       attributes: {
     79         value: Object.freeze(i)
     80       },
     81       converter: {
     82         value: Object.freeze(n)
     83       }
     84     });
     85   }(t, {
     86     path: "/"
     87   });
     88 });
     89 var seedprodCookies = Cookies.noConflict(); // optin form
     90 
     91 var sp_emplacementRecaptcha = [];
     92 var sp_option_id = "";
     93 jQuery("form[id^=sp-optin-form]").submit(function (e) {
     94   e.preventDefault();
     95   var form_id = jQuery(this).attr("id");
     96   var id = form_id.replace("sp-optin-form-", "");
     97 
     98   if (seeprod_enable_recaptcha === 1) {
     99     grecaptcha.execute(sp_emplacementRecaptcha[id]);
    100   } else {
    101     var token = "";
    102     sp_send_request(token, id);
    103   }
    104 });
    105 
    106 var sp_CaptchaCallback = function sp_CaptchaCallback() {
    107   jQuery("div[id^=recaptcha-]").each(function (index, el) {
    108     sp_option_id = el.id.replace("recaptcha-", "");
    109     sp_emplacementRecaptcha[sp_option_id] = grecaptcha.render(el, {
    110       sitekey: "6LdfOukUAAAAAMCOEFEZ9WOSKyoYrxJcgXsf66Xr",
    111       badge: "bottomright",
    112       type: "image",
    113       size: "invisible",
    114       callback: function callback(token) {
    115         sp_send_request(token, sp_option_id);
    116       }
    117     });
    118   });
    119 };
    120 
    121 function sp_send_request(token, id) {
    122   var data = jQuery("#sp-optin-form-" + id).serialize();
    123   var j1 = jQuery.ajax({
    124     url: seedprod_api_url + "subscribers",
    125     type: "post",
    126     dataType: "json",
    127     timeout: 5000,
    128     data: data
    129   }); // add ajax class
    130 
    131   jQuery("#sp-optin-form-" + id + ' .sp-optin-submit').addClass('sp-ajax-striped sp-ajax-animated'); //var j2 = jQuery.ajax( "/" );
    132 
    133   var j2 = jQuery.ajax({
    134     url: sp_subscriber_callback_url,
    135     type: 'post',
    136     timeout: 30000,
    137     data: data
    138   });
    139   jQuery.when(j1, j2).done(function (a1, a2) {
    140     // take next action
    141     var action = jQuery("#sp-optin-form-" + id + " input[name^='seedprod_action']").val(); // show success message
    142 
    143     if (action == "1") {
    144       jQuery("#sp-optin-form-" + id).hide();
    145       jQuery("#sp-optin-success-" + id).show();
    146     } // redirect
    147 
    148 
    149     if (action === "2") {
    150       var redirect = jQuery("#sp-optin-form-" + id + " input[name^='redirect_url']").val();
    151       window.location.href = redirect;
    152     }
    153 
    154     jQuery("#sp-optin-form-" + id + ' .sp-optin-submit').removeClass('sp-ajax-striped sp-ajax-animated'); // alert( "We got what we came for!" );
    155   }).fail(function (jqXHR, textStatus, errorThrown) {
    156     jQuery("#sp-optin-form-" + id + ' .sp-optin-submit').removeClass('sp-ajax-striped sp-ajax-animated');
    157 
    158     if (seeprod_enable_recaptcha === 1) {
    159       grecaptcha.reset(sp_emplacementRecaptcha[id]);
    160     } // var response = JSON.parse(j1.responseText);
    161     // var errorString  = '';
    162     // jQuery.each( response.errors, function( key, value) {
    163     //     errorString +=  value ;
    164     // });
    165     // alert(errorString);
    166     // console.log(j1);
    167     // console.log(j2);
    168 
    169   });
    170   return;
    171 } // countdown
    172 
    173 
    174 var x = [];
    175 
    176 function countdown(type, ts, id, action, redirect) {
    177   var now = new Date().getTime();
    178 
    179   if (type == 'vt') {
    180     ts = ts + now; //console.log(ts);
    181 
    182     var seedprod_enddate = seedprodCookies.get('seedprod_enddate_' + id);
    183 
    184     if (seedprod_enddate != undefined) {
    185       ts = seedprod_enddate;
    186       seedprodCookies.set('seedprod_enddate_' + id, ts, {
    187         expires: 360
    188       });
    189     }
    190   } // Update the count down every 1 second
    191 
    192 
    193   x[id] = setInterval(function () {
    194     var now = new Date().getTime();
    195     var distance = ts - now;
    196     var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    197     var hours = Math.floor(distance % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
    198     var minutes = Math.floor(distance % (1000 * 60 * 60) / (1000 * 60));
    199     var seconds = Math.floor(distance % (1000 * 60) / 1000);
    200 
    201     if (days == 0) {
    202       jQuery("#sp-cd-days-" + id).hide();
    203     } else {
    204       jQuery("#sp-cd-days-" + id + " .sp-cd-amount").html(pad(days, 2));
    205     }
    206 
    207     jQuery("#sp-cd-hours-" + id + " .sp-cd-amount").html(pad(hours, 2));
    208     jQuery("#sp-cd-minutes-" + id + " .sp-cd-amount").html(pad(minutes, 2));
    209     jQuery("#sp-cd-seconds-" + id + " .sp-cd-amount").html(pad(seconds, 2)); //   document.getElementById(id).innerHTML = days + "d " + pad(hours,2) + "h "
    210     //   + pad(minutes,2) + "m " + pad(seconds,2) + "s ";
    211     // If the count down is finished, write some text
    212 
    213     if (distance < 0) {
    214       clearInterval(x[id]); // show success message
    215 
    216       if (action == "1") {
    217         jQuery("#sp-countdown-" + id + " .sp-countdown-group").hide();
    218         jQuery("#sp-countdown-expired-" + id).show();
    219       } // redirect
    220 
    221 
    222       if (action == "2") {
    223         jQuery("#sp-countdown-" + id + " .sp-countdown-group").hide();
    224         window.location.href = redirect;
    225       }
    226     }
    227   }, 1000);
    228 }
    229 
    230 function seedprod_animatedheadline(blockId, infiniteLoop, animationDuration, animationDelay) {
    231   //let animatewrapper = jQuery("#sp-animated-head-"+blockId+" .sp-title-highlight .sp-highlighted-text-wrapper");
    232   if (infiniteLoop == "true") {
    233     window.setInterval(function () {
    234       jQuery('#sp-animated-head-' + blockId + ' .sp-title-highlight .sp-title--headline.sp-animated').addClass('sp-hide-highlight'); //jQuery("#sp-animated-head-"+blockId+" .sp-title-highlight .sp-highlighted-text-wrapper").addClass("sp-highlighted-hide-text-wrapper");
    235 
    236       setTimeout(function () {
    237         jQuery('#sp-animated-head-' + blockId + ' .sp-title-highlight .sp-title--headline.sp-animated').removeClass('sp-hide-highlight'); //jQuery("#sp-animated-head-"+blockId+" .sp-title-highlight .sp-highlighted-text-wrapper").removeClass("sp-highlighted-hide-text-wrapper");
    238       }, 200);
    239     }, animationDelay);
    240   }
    241 }
    242 
    243 function seedprod_rotateheadline(blockId, continueLoop, animationDuration) {
    244   jQuery("#sp-animated-head-" + blockId + ' .preview-sp-title').seedprod_responsive_title_shortcode();
    245 }
    246 /* end of rotate js code */
    247 
    248 
    249 function pad(n, width, z) {
    250   z = z || "0";
    251   n = n + "";
    252   return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
    253 } // remove any theme css
    254 
    255 
    256 jQuery(document).ready(function ($) {
    257   $('link[href*="/wp-content/themes/"]').remove();
    258 }); // Dynamic Text
    259 
    260 jQuery(document).ready(function ($) {
    261   var default_format = "{MM}/{dd}/{yyyy}";
    262   var html = $("#sp-page").html();
    263   var newTxt = html.split("[#");
    264 
    265   for (var i = 1; i < newTxt.length; i++) {
    266     var format = default_format;
    267     var tag = newTxt[i].split("]")[0];
    268     var parts = tag.split(":");
    269 
    270     if (parts.length > 1) {
    271       format = parts[1];
    272     } else {
    273       format = default_format;
    274     }
    275 
    276     var d = Date.create(parts[0]);
    277     var regex = "\\[#" + tag + "]";
    278     var re = new RegExp(regex, "g");
    279     $("#sp-page *").replaceText(re, d.format(format));
    280   }
    281 
    282   $(".sp-dynamic-text").contents().unwrap();
    283 }); // Dynamic Query Parameter
    284 
    285 jQuery(document).ready(function ($) {
    286   var default_value = "";
    287   var html = $("#sp-page").html();
    288   var newTxt = html.split("[q:");
    289 
    290   for (var i = 1; i < newTxt.length; i++) {
    291     var def_val = default_value;
    292     var tag = newTxt[i].split("]")[0];
    293     var parts = tag.split("=");
    294 
    295     if (parts.length > 1) {
    296       def_val = parts[1];
    297     } else {
    298       def_val = default_value;
    299     }
    300 
    301     var d = parts[0]; //Date.create(parts[0]);
    302 
    303     var regex = "\\[q:" + tag + "]";
    304     var re = new RegExp(regex, "g");
    305     var searchParams = new URLSearchParams(window.location.search);
    306     var paramdata = searchParams.get(d);
    307 
    308     if (paramdata != null) {
    309       def_val = paramdata;
    310     } //console.log(d);
    311     //console.log(def_val);
    312     //console.log(paramdata);
    313 
    314 
    315     $("#sp-page *").replaceText(re, def_val);
    316   }
    317 
    318   $(".sp-dynamic-text").contents().unwrap();
    319 });
    320 /*!-----------------------------------------------------------------------------
    321  * seedprod_bg_slideshow()
    322  * ----------------------------------------------------------------------------
    323  * Example:
    324  * seedprod_bg_slideshow('body', ['IMG_URL', 'IMG_URL', 'IMG_URL'], 3000);
    325  * --------------------------------------------------------------------------*/
    326 
    327 function seedprod_bg_slideshow(selector, slides) {
    328   var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
    329   var transition_timing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'ease-in';
    330   var transition_duration = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 500;
    331   document.querySelector(selector).style.backgroundSize = "cover";
    332   document.querySelector(selector).style.backgroundRepeat = "no-repeat";
    333   document.querySelector(selector).style.backgroundPosition = "center center"; // Set transitions
    334 
    335   var transition = "all " + transition_duration + 'ms ' + transition_timing;
    336   document.querySelector(selector).style.WebkitTransition = transition;
    337   document.querySelector(selector).style.MozTransition = transition;
    338   document.querySelector(selector).style.MsTransition = transition;
    339   document.querySelector(selector).style.OTransition = transition;
    340   document.querySelector(selector).style.transition = transition;
    341   var currentSlideIndex = 0; // Load first slide
    342 
    343   document.querySelector(selector).style.backgroundImage = "url('" + slides[currentSlideIndex] + "')";
    344   currentSlideIndex++; // Load next slide every interval
    345 
    346   setInterval(function () {
    347     document.querySelector(selector).style.backgroundImage = "url('" + slides[currentSlideIndex] + "')";
    348     currentSlideIndex++; // Reset counter
    349 
    350     if (currentSlideIndex >= slides.length) {
    351       currentSlideIndex = 0;
    352     }
    353   }, delay); // Preload slideshow images
    354 
    355   var preloadImages = new Array();
    356   slides.forEach(function (val, i) {
    357     preloadImages[i] = new Image();
    358     preloadImages[i].src = val;
    359   });
    360 }
    361 
    362 jQuery('.sp-testimonial-nav button').click(function () {
    363   var currentId = '#' + jQuery(this).parents('.sp-testimonials-wrapper').attr('id');
    364   var currentButtonIndex = jQuery(currentId + ' .sp-testimonial-nav button').index(this);
    365   var currentIndex = 0;
    366   var testimonials = jQuery('.sp-testimonial-wrapper', jQuery(this).parents(currentId));
    367   jQuery(testimonials).each(function (index) {
    368     var o = jQuery(this).css('opacity');
    369 
    370     if (o == 1) {
    371       currentIndex = index;
    372     }
    373   });
    374   var buttonsLength = jQuery(currentId + ' .sp-testimonial-nav button').length - 1;
    375   var currentButtonIndexData = jQuery(currentId + ' .sp-testimonial-nav button').eq(currentButtonIndex).attr('data-index'); // check for previous button click
    376 
    377   if (currentButtonIndex == 0) {
    378     if (0 == currentIndex) {
    379       currentIndex = testimonials.length - 1;
    380     } else {
    381       currentIndex--;
    382     }
    383   } // check for next button click
    384 
    385 
    386   if (currentButtonIndex == buttonsLength) {
    387     if (testimonials.length - 1 == currentIndex) {
    388       currentIndex = 0;
    389     } else {
    390       currentIndex++;
    391     }
    392   } // reset states
    393 
    394 
    395   testimonials.css({
    396     'opacity': 0,
    397     'height': '0',
    398     'position': 'absolute'
    399   });
    400   jQuery(currentId + ' .sp-testimonial-nav button[data-index]').css({
    401     'opacity': 0.25
    402   }); // select testimonial and button
    403 
    404   if (currentButtonIndexData !== undefined) {
    405     currentIndex = currentButtonIndexData;
    406     jQuery(testimonials).eq(currentIndex).css({
    407       'opacity': 1,
    408       'height': 'auto',
    409       'position': 'initial'
    410     });
    411     jQuery(currentId + ' .sp-testimonial-nav button').eq(currentButtonIndex).css({
    412       'opacity': 1
    413     });
    414   } else {
    415     jQuery(testimonials).eq(currentIndex).css({
    416       'opacity': 1,
    417       'height': 'auto',
    418       'position': 'initial'
    419     });
    420     jQuery(currentId + ' .sp-testimonial-nav button').eq(currentIndex + 1).css({
    421       'opacity': 1
    422     });
    423   }
    424 });
    425 var testimonial_timers = {};
    426 jQuery(".sp-testimonials-wrapper").each(function (index) {
    427   var currentId = '#' + jQuery(this).attr('id');
    428   var autoPlay = jQuery(this).attr('data-autoplay');
    429   var speed = jQuery(this).attr('data-speed');
    430 
    431   if (speed === '') {
    432     speed = 5000;
    433   } else {
    434     speed = parseInt(speed) * 1000;
    435   }
    436 
    437   if (autoPlay !== undefined) {
    438     testimonial_timers[currentId] = setInterval(function () {
    439       jQuery(currentId + ' .sp-testimonial-nav button:last-child').trigger('click');
    440     }, speed);
    441   }
    442 });
    443 jQuery(".sp-testimonials-wrapper").hover(function () {
    444   var id = '#' + jQuery(this).attr('id');
    445   clearInterval(testimonial_timers[id]);
    446 });
    447 jQuery(".sp-testimonials-wrapper").mouseleave(function () {
    448   var currentId = '#' + jQuery(this).attr('id');
    449   var autoPlay = jQuery(this).attr('data-autoplay');
    450   var speed = jQuery(this).attr('data-speed');
    451 
    452   if (speed === '') {
    453     speed = 5000;
    454   } else {
    455     speed = parseInt(speed) * 1000;
    456   }
    457 
    458   if (autoPlay !== undefined) {
    459     testimonial_timers[currentId] = setInterval(function () {
    460       jQuery(currentId + ' .sp-testimonial-nav button:last-child').trigger('click');
    461     }, speed);
    462   }
    463 });
    464 /* start  of twitter timline js code */
    465 
    466 function seedprod_twitterembedtimeline(blockId, timelineid, showReplies, width, height, chrome, align, borderColors, colorScheme, lang) {
    467   //jQuery("#sp-animated-head-"+blockId+' .preview-sp-title' ).seedprod_responsive_title_shortcode();
    468   twttr.ready(function (twttr) {
    469     window.twttr.widgets.createTimeline({
    470       sourceType: "profile",
    471       screenName: timelineid
    472     }, document.getElementById('sp-twitterembedtimeline-preview-' + blockId), {
    473       showReplies: showReplies,
    474       width: width,
    475       height: height,
    476       chrome: chrome,
    477       align: align,
    478       borderColor: borderColors,
    479       theme: colorScheme,
    480       lang: lang
    481     }).then(function (el) {//console.log('Tweet added.'); 
    482     });
    483   });
    484 }
    485 
    486 function seedprod_twittertweetbutton(blockId, tweetUrl, buttonSize, tweetText, tweetHashTag, viaHandle, relatedTweet, lang) {
    487   twttr.ready(function (twttr) {
    488     window.twttr.widgets.createShareButton(tweetUrl, document.getElementById('sp-twittertweetbutton-preview-' + blockId), {
    489       size: buttonSize,
    490       text: tweetText,
    491       hashtags: tweetHashTag,
    492       via: viaHandle,
    493       related: relatedTweet,
    494       lang: lang
    495     });
    496   });
    497 }
    498 /* end of twitter timline js code */
    499 
    500 /* this is image carousel block code */
    501 
    502 
    503 jQuery('.sp-imagecarousel-nav button').click(function () {
    504   var currentId = '#' + jQuery(this).parents('.sp-imagecarousels-wrapper').attr('id');
    505   var currentButtonIndex = jQuery(currentId + ' .sp-imagecarousel-nav button').index(this);
    506   var currentIndex = 0;
    507   var imagecarousels = jQuery('.sp-imagecarousel-wrapper', jQuery(this).parents(currentId));
    508   jQuery(imagecarousels).each(function (index) {
    509     var o = jQuery(this).css('opacity');
    510 
    511     if (o == 1) {
    512       currentIndex = index;
    513     }
    514   });
    515   var buttonsLength = jQuery(currentId + ' .sp-imagecarousel-nav button').length - 1;
    516   var currentButtonIndexData = jQuery(currentId + ' .sp-imagecarousel-nav button').eq(currentButtonIndex).attr('data-index'); // check for previous button click
    517 
    518   if (currentButtonIndex == 0) {
    519     if (0 == currentIndex) {
    520       currentIndex = imagecarousels.length - 1;
    521     } else {
    522       currentIndex--;
    523     }
    524   } // check for next button click
    525 
    526 
    527   if (currentButtonIndex == buttonsLength) {
    528     if (imagecarousels.length - 1 == currentIndex) {
    529       currentIndex = 0;
    530     } else {
    531       currentIndex++;
    532     }
    533   } // reset states
    534 
    535 
    536   imagecarousels.css({
    537     'opacity': 0,
    538     'height': '0',
    539     'position': 'absolute'
    540   });
    541   jQuery(currentId + ' .sp-imagecarousel-nav button[data-index]').css({
    542     'opacity': 0.25
    543   }); // select imagecarousel and button
    544 
    545   if (currentButtonIndexData !== undefined) {
    546     currentIndex = currentButtonIndexData;
    547     jQuery(imagecarousels).eq(currentIndex).css({
    548       'opacity': 1,
    549       'height': 'auto',
    550       'position': 'initial'
    551     });
    552     jQuery(currentId + ' .sp-imagecarousel-nav button').eq(currentButtonIndex).css({
    553       'opacity': 1
    554     });
    555   } else {
    556     jQuery(imagecarousels).eq(currentIndex).css({
    557       'opacity': 1,
    558       'height': 'auto',
    559       'position': 'initial'
    560     });
    561     jQuery(currentId + ' .sp-imagecarousel-nav button').eq(currentIndex + 1).css({
    562       'opacity': 1
    563     });
    564   }
    565 });
    566 var imagecarousel_timers = {};
    567 jQuery(".sp-imagecarousels-wrapper").each(function (index) {
    568   var currentId = '#' + jQuery(this).attr('id');
    569   var autoPlay = jQuery(this).attr('data-autoplay');
    570   var speed = jQuery(this).attr('data-speed');
    571 
    572   if (speed === '') {
    573     speed = 5000;
    574   } else {
    575     speed = parseInt(speed) * 1000;
    576   }
    577 
    578   if (autoPlay !== undefined) {
    579     imagecarousel_timers[currentId] = setInterval(function () {
    580       jQuery(currentId + ' .sp-imagecarousel-nav button:last-child').trigger('click');
    581     }, speed);
    582   }
    583 });
    584 jQuery(".sp-imagecarousels-wrapper").hover(function () {
    585   var id = '#' + jQuery(this).attr('id');
    586   clearInterval(imagecarousel_timers[id]);
    587 });
    588 jQuery(".sp-imagecarousels-wrapper").mouseleave(function () {
    589   var currentId = '#' + jQuery(this).attr('id');
    590   var autoPlay = jQuery(this).attr('data-autoplay');
    591   var speed = jQuery(this).attr('data-speed');
    592 
    593   if (speed === '') {
    594     speed = 5000;
    595   } else {
    596     speed = parseInt(speed) * 1000;
    597   }
    598 
    599   if (autoPlay !== undefined) {
    600     imagecarousel_timers[currentId] = setInterval(function () {
    601       jQuery(currentId + ' .sp-imagecarousel-nav button:last-child').trigger('click');
    602     }, speed);
    603   }
    604 });