UNPKG

@playwire/pw-vue-component

Version:

## Customize configuration

120 lines (119 loc) 3.42 kB
import { openBlock as s, createElementBlock as a, renderSlot as p } from "vue"; const d = (e, t) => { const i = e.__vccOpts || e; for (const [n, r] of t) i[n] = r; return i; }, l = { 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, n]) => { n.element && n.element.parentElement && n.element.parentElement.id === e && (t = i); }), t && window.ramp.destroyUnits(t); } } }, m = ["id", "className"]; function c(e, t, i, n, r, o) { return s(), a("div", { id: r.unitToAdd.selectorId, className: i.className }, null, 8, m); } const h = /* @__PURE__ */ d(l, [["render", c]]), w = { 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 u(e, t, i, n, r, o) { return p(e.$slots, "default"); } const f = /* @__PURE__ */ d(w, [["render", u]]); export { f as Ramp, h as RampUnit };