vue-gorgias
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -21,2 +21,3 @@ /*! | ||
chatId: null, | ||
injectCSS: null, | ||
debug: false | ||
@@ -78,16 +79,18 @@ }; | ||
Gorgias.prototype.updateCSS = function updateCSS () { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', '/static/css/gorgias.css'); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
if (this.params.injectCSS) { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', this.params.injectCSS); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
@@ -94,0 +97,0 @@ }; |
@@ -19,2 +19,3 @@ /*! | ||
chatId: null, | ||
injectCSS: null, | ||
debug: false | ||
@@ -76,16 +77,18 @@ }; | ||
Gorgias.prototype.updateCSS = function updateCSS () { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', '/static/css/gorgias.css'); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
if (this.params.injectCSS) { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', this.params.injectCSS); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
@@ -92,0 +95,0 @@ }; |
@@ -25,2 +25,3 @@ /*! | ||
chatId: null, | ||
injectCSS: null, | ||
debug: false | ||
@@ -82,16 +83,18 @@ }; | ||
Gorgias.prototype.updateCSS = function updateCSS () { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', '/static/css/gorgias.css'); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
if (this.params.injectCSS) { | ||
var iframe = document.querySelector('#gorgias-web-messenger-container'); | ||
logDebug('Update CSS called.', this.params); | ||
if (iframe) { | ||
try { | ||
var link = document.createElement('link'); | ||
link.setAttribute('href', this.params.injectCSS); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
// @ts-ignore | ||
iframe.contentDocument.head.appendChild(link); | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
catch (e) { | ||
console.error('Gorgias: Could not append CSS in Gorgias iframe.', e); | ||
} | ||
} | ||
@@ -98,0 +101,0 @@ }; |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueGorgias=e()}(this,function(){"use strict";function t(t,e){e.debug&&console.log("Gorgias: "+t)}var e=function(t){this.params={apiKey:null,chatId:null,debug:!1},this.BASE_URL="https://config.gorgias.io/production/";var e=Object.assign({},this.params,t);if(!e.apiKey)throw new Error("API key is missing.");if(!e.chatId)throw new Error("Chat ID is missing.");this.params=e,this.scriptTag=document.createElement("script")};e.prototype.getScriptSrc=function(){return""+this.BASE_URL+this.params.apiKey+"/chat/"+this.params.chatId+".js"},e.prototype.inject=function(){if("undefined"==typeof window)throw new Error("Could not inject Gorgias script in the DOM.");window.gorgiasChatParameters={};var t=document.createElement("div");t.setAttribute("id","gorgias-chat"),this.scriptTag.setAttribute("src",this.getScriptSrc()),this.scriptTag.setAttribute("defer","defer"),t.appendChild(this.scriptTag),document.body.appendChild(t)},e.prototype.ready=function(e){var i=this;t("Ready function called.",this.params),"GorgiasChat"in window?(t("Script was already loaded, run callback.",this.params),this.updateCSS(),e()):this.scriptTag.addEventListener("load",function(){t("Script loaded, run callback.",i.params),i.updateCSS(),e()})},e.prototype.updateCSS=function(){var e=document.querySelector("#gorgias-web-messenger-container");if(t("Update CSS called.",this.params),e)try{var i=document.createElement("link");i.setAttribute("href","/static/css/gorgias.css"),i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),e.contentDocument.head.appendChild(i)}catch(t){console.error("Gorgias: Could not append CSS in Gorgias iframe.",t)}},e.prototype.updateUser=function(e){var i=this;"undefined"!=typeof window&&"Smooch"in window&&(t("Update user requested.",this.params),window.Smooch.on("ready",function(){t("Smooch is ready, can request update.",i.params),window.Smooch.updateUser(e).then(function(){t("User data update done.",i.params)}).catch(function(t){console.error("Gorgias: ",t)})}))};var i=function(t,i){var r=new e(i);r.inject(),t.gorgias=r},r={install:i,version:"1.0.0"};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(r),r}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueGorgias=e()}(this,function(){"use strict";function t(t,e){e.debug&&console.log("Gorgias: "+t)}var e=function(t){this.params={apiKey:null,chatId:null,injectCSS:null,debug:!1},this.BASE_URL="https://config.gorgias.io/production/";var e=Object.assign({},this.params,t);if(!e.apiKey)throw new Error("API key is missing.");if(!e.chatId)throw new Error("Chat ID is missing.");this.params=e,this.scriptTag=document.createElement("script")};e.prototype.getScriptSrc=function(){return""+this.BASE_URL+this.params.apiKey+"/chat/"+this.params.chatId+".js"},e.prototype.inject=function(){if("undefined"==typeof window)throw new Error("Could not inject Gorgias script in the DOM.");window.gorgiasChatParameters={};var t=document.createElement("div");t.setAttribute("id","gorgias-chat"),this.scriptTag.setAttribute("src",this.getScriptSrc()),this.scriptTag.setAttribute("defer","defer"),t.appendChild(this.scriptTag),document.body.appendChild(t)},e.prototype.ready=function(e){var i=this;t("Ready function called.",this.params),"GorgiasChat"in window?(t("Script was already loaded, run callback.",this.params),this.updateCSS(),e()):this.scriptTag.addEventListener("load",function(){t("Script loaded, run callback.",i.params),i.updateCSS(),e()})},e.prototype.updateCSS=function(){if(this.params.injectCSS){var e=document.querySelector("#gorgias-web-messenger-container");if(t("Update CSS called.",this.params),e)try{var i=document.createElement("link");i.setAttribute("href",this.params.injectCSS),i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),e.contentDocument.head.appendChild(i)}catch(t){console.error("Gorgias: Could not append CSS in Gorgias iframe.",t)}}},e.prototype.updateUser=function(e){var i=this;"undefined"!=typeof window&&"Smooch"in window&&(t("Update user requested.",this.params),window.Smooch.on("ready",function(){t("Smooch is ready, can request update.",i.params),window.Smooch.updateUser(e).then(function(){t("User data update done.",i.params)}).catch(function(t){console.error("Gorgias: ",t)})}))};var i=function(t,i){var r=new e(i);r.inject(),t.gorgias=r},r={install:i,version:"1.0.0"};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(r),r}); |
{ | ||
"name": "vue-gorgias", | ||
"description": "Import Gorgias easily", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "William DA SILVA", |
@@ -16,3 +16,3 @@ import { logDebug } from './utils/debug' | ||
constructor (params: GorgiasOptions | undefined) { | ||
const overrideParams = Object.assign({}, this.params, params); | ||
const overrideParams = Object.assign({}, this.params, params) | ||
@@ -80,3 +80,3 @@ if (!overrideParams.apiKey) throw new Error('API key is missing.') | ||
link.setAttribute('rel', 'stylesheet') | ||
link.setAttribute('type', 'text/css'); | ||
link.setAttribute('type', 'text/css') | ||
@@ -83,0 +83,0 @@ // @ts-ignore |
import _Vue from 'vue' | ||
import GorgiasOptions from './interfaces/GorgiasOptions' | ||
import VueGorgiasOptions, { PluginFunction } from './interfaces/VueGorgiasOptions' | ||
import Gorgias from './gorgias'; | ||
import Gorgias from './gorgias' | ||
@@ -6,0 +6,0 @@ const version = '__VERSION__' |
@@ -1,2 +0,2 @@ | ||
import GorgiasOptions from './../interfaces/GorgiasOptions'; | ||
import GorgiasOptions from './../interfaces/GorgiasOptions' | ||
@@ -3,0 +3,0 @@ /** |
export default interface GorgiasOptions { | ||
apiKey: String | null; | ||
chatId: String | null; | ||
debug?: Boolean; | ||
apiKey: string | null; | ||
chatId: string | null; | ||
injectCSS: string | null; | ||
debug?: boolean; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30845
637