nuxt-intercom
Advanced tools
Comparing version
@@ -8,2 +8,3 @@ import path from "path"; | ||
verticalPadding: 20, | ||
enableMobilePadding: false, | ||
}; | ||
@@ -10,0 +11,0 @@ const options = Object.assign({}, defaults, this.options.intercom); |
@@ -8,8 +8,14 @@ const INTERCOM_URL = "https://widget.intercom.io/widget/"; | ||
vertical_padding: Number.parseInt("<%= options.verticalPadding %>"), | ||
enable_mobile_padding: "<%= options.enableMobilePadding %>" === "true", | ||
}; | ||
const injectScript = (appId) => { | ||
const injectScript = (settings) => { | ||
const headOrBody = document.head || document.body; | ||
if (settings.enable_mobile_padding) { | ||
const style = document.createElement("style"); | ||
style.innerHTML = `#intercom-container .intercom-borderless-frame{bottom:${settings.vertical_padding}px!important}`; | ||
headOrBody.appendChild(style); | ||
} | ||
const script = document.createElement("script"); | ||
script.async = true; | ||
script.src = `${INTERCOM_URL}${appId}`; | ||
const headOrBody = document.head || document.body; | ||
script.src = `${INTERCOM_URL}${settings.app_id}`; | ||
headOrBody.appendChild(script); | ||
@@ -32,3 +38,3 @@ return script; | ||
window.Intercom = i; | ||
let script = injectScript(settings.app_id); | ||
let script = injectScript(settings); | ||
script.addEventListener("load", () => { | ||
@@ -35,0 +41,0 @@ window.Intercom("boot", settings); |
{ | ||
"name": "nuxt-intercom", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "NuxtJS module for Intercom", | ||
@@ -5,0 +5,0 @@ "repository": "github:dogchef-be/nuxt-intercom", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10268
6.64%93
8.14%