UNPKG

@visitscotland/component-library

Version:
1 lines 4.57 kB
"use strict";!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.VsCookieChecker=n():t.VsCookieChecker=n()}(self,(function(){return(self.webpackChunk_visitscotland_component_library=self.webpackChunk_visitscotland_component_library||[]).push([[833],{7260:function(t,n){n.A=function(){return Math.random().toString(36).substring(7)}},12085:function(t,n,e){var o=e(2829),i=e(24057),r=null;n.A={data:function(){return{oneTrust:new i.A,activeGroups:""}},watch:{activeGroups:function(){var t=this.activeGroups.split(",").filter((function(t){return""!==t}));r&&(r.setCookieArray(t),r.setTestRun(!0))}},mounted:function(){r=(0,o.A)()},created:function(){this.checkOneTrust(),this.checkActiveGroups()},methods:{checkOneTrust:function(){var t=this;"undefined"!=typeof window&&this.oneTrust.checkThirdPartyLibrary("OneTrust",(function(){window.OneTrust.OnConsentChanged((function(){t.oneTrust.checkThirdPartyLibrary("OnetrustActiveGroups",(function(){t.activeGroups=window.OnetrustActiveGroups}))}))}))},checkActiveGroups:function(){var t=this;"undefined"!=typeof window&&this.oneTrust.checkThirdPartyLibrary("OnetrustActiveGroups",(function(){t.activeGroups=window.OnetrustActiveGroups}))}}}},20311:function(t,n,e){e.d(n,{X:function(){return r}});var o=e(20641),i={class:"d-none"};function r(t,n,e,r,c,s){return(0,o.uX)(),(0,o.CE)("span",i)}},24057:function(t,n,e){e.d(n,{A:function(){return a}});var o=e(92901),i=e(23029),r=e(64467),c=e(7260),s=e(96763),a=(0,o.A)((function t(){var n=this;(0,i.A)(this,t),(0,r.A)(this,"init",(function(){window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)})),(0,r.A)(this,"instaOT",(function(t,e,o,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;s.log("insta");var c=n;n.checkThirdPartyLibrary("OneTrust",(function(){n.onetrustCookieCheck(t,(function(n){if(n)c.setIframeSrc();else if(i){s.log("fallback",o),s.log("container",i);var a=Array.from(o.classList)[0];i.length>1?i.forEach((function(n,s){i[s].querySelector(".".concat(a))||c.showOneTrustFallback(t,e,o,i[s],r)})):i.querySelector(".".concat(a))||c.showOneTrustFallback(t,e,o,i,r)}})),window.OneTrust.OnConsentChanged((function(){c.onetrustCookieCheck(t,(function(n){n&&(window.OneTrustEventBus.dispatchEvent("otCategory-approved"),c.hideOneTrustFallback(t),c.setIframeSrc())}))}))}))})),(0,r.A)(this,"showOneTrustFallback",(function(t,e,o,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;s.log("showfallback");var a={visible:!1,fallback:o};if(a.visible)return!1;if(i.length>1&&a.fallback)s.log("aqui"),i.forEach((function(e){var o=a.fallback.cloneNode(!0);o.id=(0,c.A)(),e.insertAdjacentHTML("afterend",o.outerHTML);var i=document.getElementById(o.id);i.style.display="block",a.visible=!0,o.classList.add("vscookies-".concat(t)),n.fallbacks.push({id:i.id,cat:t,visible:!0}),n.setFBButtonListener(o)}));else{s.log("aca");var u=a.fallback.cloneNode(!0);u.id=(0,c.A)(),u.style.display="block",u.classList.add("vscookies-".concat(t)),r?i.insertBefore(u,i.childNodes[r]):i.appendChild(u),n.fallbacks.push({id:u.id,cat:t}),a.visible=!0,n.setFBButtonListener(u)}})),(0,r.A)(this,"onetrustCookieCheck",(function(t,n){if("undefined"!=typeof window)return n(window.OnetrustActiveGroups.includes(t))})),(0,r.A)(this,"hideOneTrustFallback",(function(t){n.fallbacks.map((function(n){n.cat===t&&document.getElementById(n.id)&&(document.getElementById(n.id).style.display="none")}));var e=document.querySelectorAll(".vscookies-".concat(t));e.size>0&&e.map((function(t){t.style.display="none"}))})),(0,r.A)(this,"checkThirdPartyLibrary",(function(t,e){var o=n;window.setTimeout((function(){window[t]?e(window[t]):o.checkThirdPartyLibrary(t,e)}),500)})),(0,r.A)(this,"setFBButtonListener",(function(t){t.querySelector("#ot-sdk-btn").addEventListener("click",(function(){window.OneTrust.ToggleInfoDisplay()}))})),(0,r.A)(this,"setIframeSrc",(function(){var t=document.querySelectorAll('iframe[data-src]:not([data-src=""])');t&&t.forEach((function(t){t.src=t.dataset.src,t.removeAttribute("data-src")}))})),this.fallbacks=[]}))},76665:function(t,n,e){e.d(n,{A:function(){return o.A}});var o=e(12085)},87203:function(t,n,e){e.r(n);var o=e(99271),i=e(76665);const r=(0,e(66262).A)(i.A,[["render",o.X]]);n.default=r},99271:function(t,n,e){e.d(n,{X:function(){return o.X}});var o=e(20311)}},function(t){return t.O(0,[641,6262,3751,4467,7527,8086,6057,2829],(function(){return t(t.s=87203)})),t.O()}])}));