angular-tawk
Version:
An Angular component to integrate tawk free chat plugin for websites. This package woks for Angular 7/8/9 etc.
2 lines • 2.38 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core")):"function"==typeof define&&define.amd?define("angular-tawk",["exports","@angular/common","@angular/core"],t):t(e["angular-tawk"]={},e.ng.common,e.ng.core)}(this,function(e,t,n){"use strict";var i=(o.prototype.ngOnInit=function(){(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i))&&(this.isMobile=!0),window.$_Tawk&&window.$_Tawk.downloaded?this.isMobile&&"no"===this.isVisibleOnMobile?window.$_Tawk.hideWidget():window.$_Tawk.showWidget():(this.script.text="var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date(), isVisible = '"+this.isVisibleOnMobile+'\';\n (function () {\n var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];\n s1.async = true;\n s1.src = \'https://embed.tawk.to/'+this.id+"/default';\n s1.charset = 'UTF-8';\n s1.setAttribute('crossorigin', '*');\n s0.parentNode.insertBefore(s1, s0);\n })();\n Tawk_API.onLoad = function() {\n if ("+this.isMobile+" && isVisible === 'no') {\n Tawk_API.hideWidget();\n }\n };\n ",this.renderer.appendChild(this.document.body,this.script))},o.prototype.ngOnDestroy=function(){window.$_Tawk&&window.$_Tawk.ready&&window.$_Tawk.hideWidget()},o.decorators=[{type:n.Component,args:[{selector:"angular-tawk",template:""}]}],o.ctorParameters=function(){return[{type:n.Renderer2},{type:undefined,decorators:[{type:n.Inject,args:[t.DOCUMENT]}]}]},o.propDecorators={id:[{type:n.Input}],isVisibleOnMobile:[{type:n.Input}]},o);function o(e,t){this.renderer=e,this.document=t,this.isMobile=!1,this.script=this.renderer.createElement("script")}var r=(a.decorators=[{type:n.NgModule,args:[{declarations:[i],imports:[],exports:[i]}]}],a);function a(){}e.AngularTawkComponent=i,e.AngularTawkModule=r,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=angular-tawk.umd.min.js.map