Comparing version 3.1.0 to 3.2.0
@@ -24,3 +24,2 @@ (function (global, factory) { | ||
var initializedAppId; | ||
var instance; | ||
function init(appId) { | ||
@@ -33,17 +32,12 @@ if (typeof appId !== "string" || appId === "") { | ||
} | ||
if (instance != null) { | ||
return instance; | ||
var host = window; | ||
if (host.HelpHero != null) { | ||
return host.HelpHero; | ||
} | ||
var tasks = []; | ||
var queue = function () { | ||
var instance = function () { | ||
tasks.push(arguments); | ||
}; | ||
queue.q = tasks; | ||
window.HelpHero = queue; | ||
var script = document.createElement("script"); | ||
script.src = "https://app.helphero.co/embed/" + appId; | ||
script.async = true; | ||
document.body.appendChild(script); | ||
initializedAppId = appId; | ||
instance = Object.create(null); | ||
host.HelpHero = instance; | ||
instance.q = tasks; | ||
methods.forEach(function (method) { | ||
@@ -55,5 +49,10 @@ instance[method] = function () { | ||
} | ||
return window.HelpHero.apply(null, [method].concat(args)); | ||
return host.HelpHero.apply(null, [method].concat(args)); | ||
}; | ||
}); | ||
initializedAppId = appId; | ||
var script = document.createElement("script"); | ||
script.src = "https://app.helphero.co/embed/" + appId; | ||
script.async = true; | ||
document.body.appendChild(script); | ||
return instance; | ||
@@ -60,0 +59,0 @@ } |
{ | ||
"name": "helphero", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Offical HelpHero SDK for browsers", | ||
@@ -5,0 +5,0 @@ "repository": "git://github.com/HelpHero/helphero-javascript.git", |
9564
221