if(document.readyState!=='loading'){
tnp_ajax_init();
}else{
document.addEventListener("DOMContentLoaded", function (){
tnp_ajax_init();
});
}
function tnp_ajax_init(){
document.querySelectorAll('form.tnp-ajax').forEach(el=> {
el.addEventListener('submit', async function(ev){
ev.preventDefault();
ev.stopPropagation();
const response=await fetch(newsletter_data.action_url + '?action=tnp&na=sa', {
method: "POST",
body: new FormData(this)
});
this.innerHTML=await response.text();
});
});
};
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.Vimeo=e.Vimeo||{},e.Vimeo.Player=t())}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t,n){var r=E.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),E.set(e.element,r)}function n(e,t){return(E.get(e.element)||{})[t]||[]}function r(e,t,n){var r=E.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],E.set(e.element,r),!0;var i=r[t].indexOf(n);return-1!==i&&r[t].splice(i,1),E.set(e.element,r),r[t]&&0===r[t].length}function i(e,t){var i=n(e,t);if(i.length<1)return!1;var o=i.shift();return r(e,t,o),o}function o(e,t){var n=E.get(e);E.set(t,n),E.delete(e)}function a(e,t){return 0===e.indexOf(t.toLowerCase())?e:""+t.toLowerCase()+e.substr(0,1).toUpperCase()+e.substr(1)}function u(e){return e instanceof window.HTMLElement}function s(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function c(e){return/^(https?:)?\/\/((player|www).)?vimeo.com(?=$|\/)/.test(e)}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw new Error("An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.");if(s(r))return"https://vimeo.com/"+r;if(c(r))return r.replace("http:","https:");if(t)throw new TypeError("“"+t+"” is not a valid video id.");throw new TypeError("“"+r+"” is not a vimeo.com url.")}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T.reduce(function(t,n){var r=e.getAttribute("data-vimeo-"+n);return(r||""===r)&&(t[n]=""===r?1:r),t},t)}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(n,r){if(!c(e))throw new TypeError("“"+e+"” is not a vimeo.com url.");var i="https://vimeo.com/api/oembed.json?url="+encodeURIComponent(e);for(var o in t)t.hasOwnProperty(o)&&(i+="&"+o+"="+encodeURIComponent(t[o]));var a="XDomainRequest"in window?new XDomainRequest:new XMLHttpRequest;a.open("GET",i,!0),a.onload=function(){if(404===a.status)return void r(new Error("“"+e+"” was not found."));if(403===a.status)return void r(new Error("“"+e+"” is not embeddable."));try{var t=JSON.parse(a.responseText);n(t)}catch(e){r(e)}},a.onerror=function(){var e=a.status?" ("+a.status+")":"";r(new Error("There was an error fetching the embed code from Vimeo"+e+"."))},a.send()})}function d(e,t){var n=e.html;if(!t)throw new TypeError("An element must be provided");if(null!==t.getAttribute("data-vimeo-initialized"))return t.querySelector("iframe");var r=document.createElement("div");return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute("data-vimeo-initialized","true"),t.querySelector("iframe")}function v(e){return"string"==typeof e&&(e=JSON.parse(e)),e}function p(e,t,n){if(e.element.contentWindow&&e.element.contentWindow.postMessage){var r={method:t};void 0!==n&&(r.value=n);var i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1"));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}}function y(e,t){t=v(t);var o=[],a=void 0;if(t.event){if("error"===t.event){n(e,t.data.method).forEach(function(n){var i=new Error(t.data.message);i.name=t.data.name,n.reject(i),r(e,t.data.method,n)})}o=n(e,"event:"+t.event),a=t.data}else if(t.method){var u=i(e,t.method);u&&(o.push(u),a=t.value)}o.forEach(function(t){try{if("function"==typeof t)return void t.call(e,a);t.resolve(a)}catch(e){}})}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var g=void 0!==Array.prototype.indexOf,w=void 0!==window.postMessage;if(!g||!w)throw new Error("Sorry, the Vimeo Player API is not available in this browser.");var k="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b=(e(function(e,t){!function(e){function t(e,t){function r(e){if(!this||this.constructor!==r)return new r(e);this._keys=[],this._values=[],this._itp=[],this.objectOnly=t,e&&n.call(this,e)}return t||w(e,"size",{get:y}),e.constructor=r,r.prototype=e,r}function n(e){this.add?e.forEach(this.add,this):e.forEach(function(e){this.set(e[0],e[1])},this)}function r(e){return this.has(e)&&(this._keys.splice(g,1),this._values.splice(g,1),this._itp.forEach(function(e){g<e[0]&&e[0]--})),-1<g}function i(e){return this.has(e)?this._values[g]:void 0}function o(e,t){if(this.objectOnly&&t!==Object(t))throw new TypeError("Invalid value used as weak collection key");if(t!=t||0===t)for(g=e.length;g--&&!k(e[g],t););else g=e.indexOf(t);return-1<g}function a(e){return o.call(this,this._values,e)}function u(e){return o.call(this,this._keys,e)}function s(e,t){return this.has(e)?this._values[g]=t:this._values[this._keys.push(e)-1]=t,this}function c(e){return this.has(e)||this._values.push(e),this}function f(){(this._keys||0).length=this._values.length=0}function l(){return p(this._itp,this._keys)}function h(){return p(this._itp,this._values)}function d(){return p(this._itp,this._keys,this._values)}function v(){return p(this._itp,this._values,this._values)}function p(e,t,n){var r=[0],i=!1;return e.push(r),{next:function(){var o,a=r[0];return!i&&a<t.length?(o=n?[t[a],n[a]]:t[a],r[0]++):(i=!0,e.splice(e.indexOf(r),1)),{done:i,value:o}}}}function y(){return this._values.length}function m(e,t){for(var n=this.entries();;){var r=n.next();if(r.done)break;e.call(t,r.value[1],r.value[0],this)}}var g,w=Object.defineProperty,k=function(e,t){return e===t||e!==e&&t!==t};"undefined"==typeof WeakMap&&(e.WeakMap=t({delete:r,clear:f,get:i,has:u,set:s},!0)),"undefined"!=typeof Map&&"function"==typeof(new Map).values&&(new Map).values().next||(e.Map=t({delete:r,has:u,get:i,set:s,keys:l,values:h,entries:d,forEach:m,clear:f})),"undefined"!=typeof Set&&"function"==typeof(new Set).values&&(new Set).values().next||(e.Set=t({has:a,add:c,delete:r,clear:f,keys:h,values:h,entries:v,forEach:m})),"undefined"==typeof WeakSet&&(e.WeakSet=t({delete:r,add:c,clear:f,has:a},!0))}(void 0!==k?k:window)}),e(function(e){var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(t,n,r){n[t]=n[t]||r(),e.exports&&(e.exports=n[t])}("Promise",k,function(){function e(e,t){d.add(e,t),h||(h=p(d.drain))}function n(e){var n,r=void 0===e?"undefined":t(e);return null==e||"object"!=r&&"function"!=r||(n=e.then),"function"==typeof n&&n}function r(){for(var e=0;e<this.chain.length;e++)i(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function i(e,t,r){var i,o;try{!1===t?r.reject(e.msg):(i=!0===t?e.msg:t.call(void 0,e.msg),i===r.promise?r.reject(TypeError("Promise-chain cycle")):(o=n(i))?o.call(i,r.resolve,r.reject):r.resolve(i))}catch(e){r.reject(e)}}function o(t){var i,u=this;if(!u.triggered){u.triggered=!0,u.def&&(u=u.def);try{(i=n(t))?e(function(){var e=new s(u);try{i.call(t,function(){o.apply(e,arguments)},function(){a.apply(e,arguments)})}catch(t){a.call(e,t)}}):(u.msg=t,u.state=1,u.chain.length>0&&e(r,u))}catch(e){a.call(new s(u),e)}}}function a(t){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=t,n.state=2,n.chain.length>0&&e(r,n))}function u(e,t,n,r){for(var i=0;i<t.length;i++)!function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)}(i)}function s(e){this.def=e,this.triggered=!1}function c(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function f(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new c(this);this.then=function(t,i){var o={success:"function"!=typeof t||t,failure:"function"==typeof i&&i};return o.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");o.resolve=e,o.reject=t}),n.chain.push(o),0!==n.state&&e(r,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{t.call(void 0,function(e){o.call(n,e)},function(e){a.call(n,e)})}catch(e){a.call(n,e)}}var l,h,d,v=Object.prototype.toString,p="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),l=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==r})}}catch(e){l=function(e,t,n){return e[t]=n,e}}d=function(){function e(e,t){this.fn=e,this.self=t,this.next=void 0}var t,n,r;return{add:function(i,o){r=new e(i,o),n?n.next=r:t=r,n=r,r=void 0},drain:function(){var e=t;for(t=n=h=void 0;e;)e.fn.call(e.self),e=e.next}}}();var y=l({},"constructor",f,!1);return f.prototype=y,l(y,"__NPO__",0,!1),l(f,"resolve",function(e){var n=this;return e&&"object"==(void 0===e?"undefined":t(e))&&1===e.__NPO__?e:new n(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),l(f,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),l(f,"all",function(e){var t=this;return"[object Array]"!=v.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");var i=e.length,o=Array(i),a=0;u(t,e,function(e,t){o[e]=t,++a===i&&n(o)},r)})}),l(f,"race",function(e){var t=this;return"[object Array]"!=v.call(e)?t.reject(TypeError("Not an array")):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");u(t,e,function(e,t){n(t)},r)})}),f})})),E=new WeakMap,T=["id","url","width","maxwidth","height","maxheight","portrait","title","byline","color","autoplay","autopause","loop","responsive","speed"],_=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),j=new WeakMap,x=new WeakMap,Player=function(){function Player(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,Player),window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),e=e[0]),"string"==typeof e&&(e=document.getElementById(e)),!u(e))throw new TypeError("You must pass either a valid element or a valid id.");if("IFRAME"!==e.nodeName){var r=e.querySelector("iframe");r&&(e=r)}if("IFRAME"===e.nodeName&&!c(e.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(j.has(e))return j.get(e);this.element=e,this.origin="*";var i=new b(function(r,i){var a=function(e){if(c(e.origin)&&t.element.contentWindow===e.source){"*"===t.origin&&(t.origin=e.origin);var n=v(e.data),i="event"in n&&"ready"===n.event,o="method"in n&&"ping"===n.method;if(i||o)return t.element.setAttribute("data-ready","true"),void r();y(t,n)}};if(window.addEventListener?window.addEventListener("message",a,!1):window.attachEvent&&window.attachEvent("onmessage",a),"IFRAME"!==t.element.nodeName){var u=l(e,n);h(f(u),u).then(function(n){var r=d(n,e);return t.element=r,o(e,r),j.set(t.element,t),n}).catch(function(e){return i(e)})}});return x.set(this,i),j.set(this.element,this),"IFRAME"===this.element.nodeName&&p(this,"ping"),this}return _(Player,[{key:"callMethod",value:function(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new b(function(i,o){return n.ready().then(function(){t(n,e,{resolve:i,reject:o}),p(n,e,r)})})}},{key:"get",value:function(e){var n=this;return new b(function(r,i){return e=a(e,"get"),n.ready().then(function(){t(n,e,{resolve:r,reject:i}),p(n,e)})})}},{key:"set",value:function(e,n){var r=this;return b.resolve(n).then(function(n){if(e=a(e,"set"),void 0===n||null===n)throw new TypeError("There must be a value to set.");return r.ready().then(function(){return new b(function(i,o){t(r,e,{resolve:i,reject:o}),p(r,e,n)})})})}},{key:"on",value:function(e,r){if(!e)throw new TypeError("You must pass an event name.");if(!r)throw new TypeError("You must pass a callback function.");if("function"!=typeof r)throw new TypeError("The callback must be a function.");0===n(this,"event:"+e).length&&this.callMethod("addEventListener",e).catch(function(){}),t(this,"event:"+e,r)}},{key:"off",value:function(e,t){if(!e)throw new TypeError("You must pass an event name.");if(t&&"function"!=typeof t)throw new TypeError("The callback must be a function.");r(this,"event:"+e,t)&&this.callMethod("removeEventListener",e).catch(function(e){})}},{key:"loadVideo",value:function(e){return this.callMethod("loadVideo",e)}},{key:"ready",value:function(){var e=x.get(this);return b.resolve(e)}},{key:"addCuePoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.callMethod("addCuePoint",{time:e,data:t})}},{key:"removeCuePoint",value:function(e){return this.callMethod("removeCuePoint",e)}},{key:"enableTextTrack",value:function(e,t){if(!e)throw new TypeError("You must pass a language.");return this.callMethod("enableTextTrack",{language:e,kind:t})}},{key:"disableTextTrack",value:function(){return this.callMethod("disableTextTrack")}},{key:"pause",value:function(){return this.callMethod("pause")}},{key:"play",value:function(){return this.callMethod("play")}},{key:"unload",value:function(){return this.callMethod("unload")}},{key:"getAutopause",value:function(){return this.get("autopause")}},{key:"setAutopause",value:function(e){return this.set("autopause",e)}},{key:"getColor",value:function(){return this.get("color")}},{key:"setColor",value:function(e){return this.set("color",e)}},{key:"getCuePoints",value:function(){return this.get("cuePoints")}},{key:"getCurrentTime",value:function(){return this.get("currentTime")}},{key:"setCurrentTime",value:function(e){return this.set("currentTime",e)}},{key:"getDuration",value:function(){return this.get("duration")}},{key:"getEnded",value:function(){return this.get("ended")}},{key:"getLoop",value:function(){return this.get("loop")}},{key:"setLoop",value:function(e){return this.set("loop",e)}},{key:"getPaused",value:function(){return this.get("paused")}},{key:"getPlaybackRate",value:function(){return this.get("playbackRate")}},{key:"setPlaybackRate",value:function(e){return this.set("playbackRate",e)}},{key:"getTextTracks",value:function(){return this.get("textTracks")}},{key:"getVideoEmbedCode",value:function(){return this.get("videoEmbedCode")}},{key:"getVideoId",value:function(){return this.get("videoId")}},{key:"getVideoTitle",value:function(){return this.get("videoTitle")}},{key:"getVideoWidth",value:function(){return this.get("videoWidth")}},{key:"getVideoHeight",value:function(){return this.get("videoHeight")}},{key:"getVideoUrl",value:function(){return this.get("videoUrl")}},{key:"getVolume",value:function(){return this.get("volume")}},{key:"setVolume",value:function(e){return this.set("volume",e)}}]),Player}();return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=[].slice.call(e.querySelectorAll("[data-vimeo-id], [data-vimeo-url]")),n=function(e){"console"in window&&console.error&&console.error("There was an error creating an embed: "+e)};t.forEach(function(e){try{if(null!==e.getAttribute("data-vimeo-defer"))return;var t=l(e);h(f(t),t).then(function(t){return d(t,e)}).catch(n)}catch(e){n(e)}})}(),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=function(t){if(c(t.origin)&&t.data&&"spacechange"===t.data.event)for(var n=e.querySelectorAll("iframe"),r=0;r<n.length;r++)if(n[r].contentWindow===t.source){var i=n[r].parentElement;i&&-1!==i.className.indexOf("vimeo-space")&&(i.style.paddingBottom=t.data.data[0].bottom+"px");break}};window.addEventListener?window.addEventListener("message",t,!1):window.attachEvent&&window.attachEvent("onmessage",t)}(),Player});
!function ($){
var Pinterest=function (){
var initialized=false;
function getUtils(){
return window.pys.Utils;
}
function getOptions(){
return window.pysOptions;
}
function flattenObject(obj, prefix='', res={}){
for (const [key, value] of Object.entries(obj)){
const prefixedKey=prefix ? `${prefix}[${key}]`:key;
if(value!==null&&typeof value==='object'&&!(value instanceof File)){
flattenObject(value, prefixedKey, res);
}else{
res[prefixedKey]=value;
}}
return res;
}
function sendServerAjaxRequest(url, data){
if(data.action==='pys_pinterest_api_event'&&getOptions().pinterest&&getOptions().pinterest.serverApiEnabled){
const restApiUrl=window.pysPinterestRest ? window.pysPinterestRest.restApiUrl:'/wp-json/pys-pinterest/v1/event';
const nonce=window.pysPinterestRest ? window.pysPinterestRest.restNonce:'';
const restApiData={
event: data.event,
event_slug: data.event_slug,
data: JSON.stringify(data.data||{}),
ids: JSON.stringify(data.ids||[]),
eventID: data.event_id||data.eventID||'',
woo_order: data.woo_order||'0',
edd_order: data.edd_order||'0'
};
if(getOptions().hasOwnProperty('useSendBeacon')&&getOptions().useSendBeacon&&navigator.sendBeacon){
try {
const formData=new URLSearchParams();
for (const [key, value] of Object.entries(restApiData)){
formData.append(key, value);
}
if(navigator.sendBeacon(restApiUrl, formData)){
return;
}} catch (e){
}}
if(window.fetch){
const headers={
'Content-Type': 'application/json'
};
if(nonce){
headers['X-WP-Nonce']=nonce;
}
fetch(restApiUrl, {
method: 'POST',
headers: headers,
body: JSON.stringify(restApiData)
})
.then(response=> {
if(!response.ok){
throw new Error('REST API request failed: ' + response.status);
}})
.catch(error=> {
sendAjaxFallback(data);
});
}else{
sendAjaxFallback(data);
}
return;
}
if(getOptions().hasOwnProperty('useSendBeacon')&&getOptions().useSendBeacon&&navigator.sendBeacon){
try {
const flattenedData=flattenObject(data);
const formData=new URLSearchParams();
for (const [key, value] of Object.entries(flattenedData)){
if(value!==null&&value!==undefined){
formData.append(key, value);
}}
if(navigator.sendBeacon(url, formData)){
return;
}} catch (e){
}}
jQuery.ajax({
type: 'POST',
url: url,
data: data,
headers: {
'Cache-Control': 'no-cache'
}});
}
function sendAjaxFallback(data){
jQuery.ajax({
type: 'POST',
url: getOptions().ajaxUrl,
data: data,
headers: {
'Cache-Control': 'no-cache'
}});
}
var notCachedEventsIds=new Array();
var isAddToCartFromJs=getOptions().woo.hasOwnProperty("addToCartCatchMethod")
&& getOptions().woo.addToCartCatchMethod==="add_cart_js";
if(!isAddToCartFromJs){
notCachedEventsIds.push('woo_add_to_cart_on_button_click')
}
function fireEvent(name, event){
if(typeof window.pys_event_data_filter==="function"&&window.pys_disable_event_filter(name,'pinterest')){
return;
}
var data=event.params;
var ids=event.pixelIds.filter(function (pixelId){
if(getUtils().hasOwnProperty('hideMatchingPixel')){
return !getUtils().hideMatchingPixel(pixelId, 'pinterest');
}else{
return true;
}});
if(ids.length){
var params={};
window.pys.Utils.copyProperties(data, params);
window.pys.Utils.copyProperties(window.pys.Utils.getRequestParams(), params);
if(getOptions().pinterest.serverApiEnabled){
if(!isAddToCartFromJs&&event.e_id==="woo_add_to_cart_on_button_click"){
Pinterest.updateEventId(event.name);
event.eventID=getUtils().generateUniqueId(event);
}else if(!notCachedEventsIds.includes(event.e_id)){
var isApiDisabled=getOptions().gdpr.all_disabled_by_api ||
getOptions().gdpr.facebook_disabled_by_api ||
getOptions().gdpr.tiktok_disabled_by_api ||
getOptions().gdpr.cookiebot_integration_enabled ||
getOptions().gdpr.cookie_notice_integration_enabled ||
getOptions().gdpr.consent_magic_integration_enabled ||
getOptions().gdpr.cookie_law_info_integration_enabled;
event.eventID=getUtils().generateUniqueId(event);
if(getOptions().ajaxForServerEvent||isApiDisabled||event.delay > 0||event.type!=="static"||(event.hasOwnProperty('ajaxFire')&&event.ajaxFire)){
var json={
action: 'pys_pinterest_api_event',
pixel: Pinterest.tag(),
event: name,
event_slug: event.e_id,
ids: ids,
data: params,
url: window.location.href,
eventID: event.eventID,
ajax_event: getOptions().ajax_event
};
if(event.hasOwnProperty('woo_order')){
json['woo_order']=event.woo_order;
}
if(event.hasOwnProperty('edd_order')){
json['edd_order']=event.edd_order;
}
if(event.e_id==="automatic_event_internal_link"
|| event.e_id==="automatic_event_outbound_link"
){
setTimeout(function (){
sendServerAjaxRequest(getOptions().ajaxUrl, json);
}, 500)
}else if(event.type!=='static'){
sendServerAjaxRequest(getOptions().ajaxUrl, json);
}
if(( event.type==='static'&&getOptions().ajaxForServerStaticEvent)||(event.hasOwnProperty('ajaxFire')&&event.ajaxFire)){
sendServerAjaxRequest(getOptions().ajaxUrl, json);
}}
}}
params.eventID=event.eventID;
if(getOptions().debug){
console.log('[Pinterest] ' + name, params);
}
pintrk('track', name, params);
}}
return {
tag: function(){
return "pinterest";
},
isEnabled: function (){
return getOptions().hasOwnProperty('pinterest');
},
getHidePixel: function(){
if(this.isEnabled()&&getOptions().pinterest.hasOwnProperty('hide_pixels')){
return getOptions().pinterest.hide_pixels;
}
return [];
},
disable: function (){
initialized=false;
},
initEventIdCookies: function (key){
var ids={};
ids[key]=pys_generate_token(36)
Cookies.set('pys_pinterest_event_id', JSON.stringify(ids));
},
updateEventId:function(key){
var cooData=Cookies.get("pys_pinterest_event_id")
if(cooData===undefined){
this.initEventIdCookies(key);
}else{
var data=JSON.parse(cooData);
data[key]=pys_generate_token(36);
Cookies.set('pys_pinterest_event_id', JSON.stringify(data));
}},
getEventId:function (key){
var data=Cookies.get("pys_pinterest_event_id");
if(data===undefined){
this.initEventIdCookies(key);
data=Cookies.get("pys_pinterest_event_id");
}
return JSON.parse(data)[key];
},
loadPixel: function (){
if(initialized||!this.isEnabled()||!getUtils().consentGiven('pinterest')){
return;
}
var tagId=getOptions().pinterest.pixelIds;
tagId=tagId.filter(function (pixelId){
if(getUtils().hasOwnProperty('hideMatchingPixel')){
return !getUtils().hideMatchingPixel(pixelId, 'pinterest');
}else{
return true;
}});
if(tagId.length > 0){
!function (e){
if(!window.pintrk){
window.pintrk=function (){
window.pintrk.queue.push(Array.prototype.slice.call(arguments))
};
var n=window.pintrk;
n.queue=[], n.version="3.0";
var t=document.createElement("script");
t.async = !0, t.src=e;
var r=document.getElementsByTagName("script")[0];
r.parentNode.insertBefore(t, r)
}}("https://s.pinimg.com/ct/core.js");
tagId.forEach(function (pixelId){
pintrk('load', pixelId, {em: getOptions().pinterest.advancedMatching.em, external_id: getOptions().pinterest.advancedMatching.external_id, np: 'pixelyoursite'});
pintrk('page');
});
initialized=true;
getUtils().fireStaticEvents('pinterest');
}},
fireEvent: function (name, data){
if(!initialized||!this.isEnabled()){
return false;
}
data.delay=data.delay||0;
data.params=data.params||{};
if(data.delay===0){
fireEvent(name, data);
}else{
setTimeout(function (name, params){
fireEvent(name, params);
}, data.delay * 1000, name, data);
}},
onAdSenseEvent: function (event){
this.fireEvent(event.name, event);
},
onClickEvent: function (event){
this.fireEvent(event.name, event);
},
onWatchVideo: function (event){
this.fireEvent(event.name, event);
},
onCommentEvent: function (event){
this.fireEvent(event.name, event);
},
onFormEvent: function (event){
this.fireEvent(event.name, event);
},
onDownloadEvent: function (event){
this.fireEvent(event.name, event);
},
onWooAddToCartOnButtonEvent: function (product_id){
if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
return;
if(window.pysWooProductData.hasOwnProperty(product_id)){
if(window.pysWooProductData[product_id].hasOwnProperty('pinterest')){
var event=getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]);
getUtils().copyProperties(window.pysWooProductData[product_id]['pinterest'].params, event.params);
this.fireEvent(event.name, event);
}}
},
onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, is_external, $form){
window.pys_woo_product_data=window.pys_woo_product_data||[];
if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
return;
if(product_type===getUtils().PRODUCT_VARIABLE&&!getOptions().pinterest.wooVariableAsSimple){
product_id=parseInt($form.find('input[name="variation_id"]').val());
}
if(window.pysWooProductData.hasOwnProperty(product_id)){
if(window.pysWooProductData[product_id].hasOwnProperty('pinterest')){
var event=getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()])
getUtils().copyProperties(window.pysWooProductData[product_id]['pinterest'].params, event.params);
if(product_type===getUtils().PRODUCT_GROUPED){
var total=0;
$form.find(".woocommerce-grouped-product-list .qty").each(function(index){
var childId=$(this).attr('name').replaceAll("quantity[","").replaceAll("]","");
var quantity=parseInt($(this).val());
if(isNaN(quantity)){
quantity=0;
}
var price=window.pysWooProductData[product_id]['pinterest'].grouped[childId].price;
total +=price * quantity;
});
if(total==0) return;
if(getOptions().woo.addToCartOnButtonValueEnabled &&
getOptions().woo.addToCartOnButtonValueOption!=='global'){
event.params.value=total;
}}else{
if(getOptions().woo.addToCartOnButtonValueEnabled &&
getOptions().woo.addToCartOnButtonValueOption!=='global'){
event.params.value=event.params.value * qty;
}}
event.params.product_quantity=qty;
if(product_type===getUtils().PRODUCT_BUNDLE){
var data=$(".bundle_form .bundle_data").data("bundle_form_data");
var items_sum=getBundlePriceOnSingleProduct(data);
var price=(data.base_price+items_sum)* qty;
if(getOptions().woo.addToCartOnButtonValueEnabled&&getOptions().woo.addToCartOnButtonValueOption!=='global'){
event.params.value=price;
}}
var event_name=is_external ? getOptions().woo.affiliateEventName:event.name;
this.fireEvent(event_name, event);
}}
},
onWooRemoveFromCartEvent: function (event){
this.fireEvent(event.name, event);
},
onWooAffiliateEvent: function (product_id){
if(!getOptions().dynamicEvents.woo_affiliate.hasOwnProperty(this.tag()))
return;
var event=getOptions().dynamicEvents.woo_affiliate[this.tag()];
if(window.pysWooProductData.hasOwnProperty(product_id)){
if(window.pysWooProductData[product_id].hasOwnProperty('pinterest')){
event=getUtils().copyProperties(event, {})
getUtils().copyProperties(window.pysWooProductData[product_id][this.tag()].params, event.params)
this.fireEvent(getOptions().woo.affiliateEventName, event);
}}
},
onWooPayPalEvent: function (event){
this.fireEvent(event.name, event);
},
onEddAddToCartOnButtonEvent: function (download_id, price_index, qty){
if(!getOptions().dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
return;
var event=getOptions().dynamicEvents.edd_add_to_cart_on_button_click[this.tag()];
if(window.pysEddProductData.hasOwnProperty(download_id)){
var index;
if(price_index){
index=download_id + '_' + price_index;
}else{
index=download_id;
}
if(window.pysEddProductData[download_id].hasOwnProperty(index)){
if(window.pysEddProductData[download_id][index].hasOwnProperty('pinterest')){
event=getUtils().copyProperties(event, {})
getUtils().copyProperties(window.pysEddProductData[download_id][index]['pinterest'].params, event.params);
if(getOptions().edd.addToCartOnButtonValueEnabled&&getOptions().edd.addToCartOnButtonValueOption!=='global'){
event.params.value=event.params.value * qty;
}
event.params.product_quantity=qty;
this.fireEvent(event.name,event);
}}
}},
onEddRemoveFromCartEvent: function (event){
this.fireEvent(event.name, event);
},
onPageScroll: function (event){
this.fireEvent(event.name, event);
},
onTime: function (event){
this.fireEvent(event.name, event);
},
};}(jQuery);
window.pys=window.pys||{};
window.pys.Pinterest=Pinterest;
}(jQuery);
jQuery(document).ready(function (){
if(window.pysOptions&&Object.keys(window.pysOptions.track_dynamic_fields).length > 0){
let expires=new Date(new Date().getTime() + 30 * 60 * 1000);
Object.entries(window.pysOptions.track_dynamic_fields).forEach(( item)=> {
jQuery(document).on("blur", 'input[name="' + item[ 1 ] + '"]', function (){
let value=$(this).val().trim();
if(value.length > 0){
Cookies.set('pys_dyn_field_' + item[ 1 ], value, { expires: expires });
}})
})
}});