@playwire/pw-vue-component
Version:
## Customize configuration
2 lines (1 loc) • 2.77 kB
JavaScript
(function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.ramp={},n.Vue))})(this,function(n,d){"use strict";const s=(e,t)=>{const i=e.__vccOpts||e;for(const[r,o]of t)i[r]=o;return i},a={data(){return{inPageUnits:["leaderboard_atf","leaderboard_btf","med_rect_atf","med_rect_btf","sky_atf","sky_btf"],rendered:!1,unitToAdd:{}}},created(){window.ramp=window.ramp||{},window.ramp.que=window.ramp.que||[],this.unitToAdd=this.getInitialUnit()},mounted(){this.rendered||(this.rendered=!0,window.ramp.que.push(()=>{window.ramp.addUnits([this.unitToAdd]).catch(e=>{console.warn(e)}).finally(()=>{window.ramp.displayUnits()})}))},unmounted(){window.ramp.que.push(()=>{this.cleanUp(this.unitToAdd.selectorId)})},name:"RampUnit",props:{selectorId:String,type:String,className:String},methods:{getUniqueId(){let e=`pw-${this.type}`,t=1;for(;document.getElementById(`${e}${t}`);)t++;return`${e}${t}`},getInitialUnit(){const e={type:this.type};return this.inPageUnits.includes(this.type)&&(e.selectorId=this.getUniqueId(this.type)),e},cleanUp(e){if(!window.ramp.setttings||!window.ramp.settings.slots)return;let t=null;Object.entries(window.ramp.settings.slots).forEach(([i,r])=>{r.element&&r.element.parentElement&&r.element.parentElement.id===e&&(t=i)}),t&&window.ramp.destroyUnits(t)}}},p=["id","className"];function l(e,t,i,r,o,_){return d.openBlock(),d.createElementBlock("div",{id:o.unitToAdd.selectorId,className:i.className},null,8,p)}const m=s(a,[["render",l]]),u={created(){if(window.ramp=window.ramp||{},window.ramp.que=window.ramp.que||[],window.ramp.passiveMode=!0,window._pwRampComponentLoaded=window._pwRampComponentLoaded||!1,this.oopUnits=["trendi_slideshow","trendi_video","site_skin","flex_leaderboard","top_rail","right_rail","bottom_rail","left_rail"],!this.publisherId||!this.id){console.error("publisherId and id are required props.");return}this.init(this.publisherId,this.id)},name:"Ramp",props:{publisherId:String,id:String},methods:{init:(e,t)=>{if(window._pwRampComponentLoaded)return;window._pwRampComponentLoaded=!0;const i=document.createElement("script");i.src=`https://cdn.intergient.com/${e}/${t}/ramp.js`,document.head.appendChild(i),window.ramp.que.push(()=>{window.ramp.addUnits([{type:"trendi_slideshow"},{type:"trendi_video"},{type:"site_skin"},{type:"flex_leaderboard"},{type:"top_rail"},{type:"right_rail"},{type:"bottom_rail"},{type:"left_rail"}]).then(()=>{window.ramp.displayUnits()})})}}};function c(e,t,i,r,o,_){return d.renderSlot(e.$slots,"default")}const w=s(u,[["render",c]]);n.Ramp=w,n.RampUnit=m,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});