-
Notifications
You must be signed in to change notification settings - Fork 36
/
angular-intercom.min.js
6 lines (6 loc) · 2.98 KB
/
angular-intercom.min.js
1
2
3
4
5
6
/**
* @license angular-intercom
* (c) 2014-2015 PatrickJS gdi2290.com
* License: MIT
*/
!function(t,e){if("function"==typeof define&&define.amd)define(["angular"],function(n){return e(t,n,t.Intercom)});else if("object"==typeof exports){var n=null;try{n=require("intercom")}catch(r){}module.exports=e({},require("angular"),n)}else angular&&e(t,t.angular,t.Intercom)}(this,function(t,e,n){"use strict";function r(t){return t?t.charAt(0).toUpperCase()+t.substring(1).toLowerCase():""}function o(t,e){if(document){var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=t+e;var r=document.getElementsByTagName("head")[0];r.appendChild(n)}}function c(){var c=this;e.forEach(s,function(t,e){c[e]=function(n){return s[e]=n||t,c}}),c.$get=["$rootScope","$log","IntercomSettings",function(c,a,u){function d(){return t.Intercom.apply(t.Intercom,arguments),d}function m(t,e){d[e]=t,d["$"+e]=function(){return t.apply(n,arguments),c.$$phase||c.$apply(),d}}p&&a.warn("Please use consider using either $intercom or Intercom not both"),p=!0;var I,f=function(){I={},s.appID&&(I.app_id=I.app_id||s.appID),e.extend(I,u)};f(),i&&(t.Intercom("reattach_activator"),t.Intercom("update",I)),s.asyncLoading&&o(s.scriptUrl,s.appID);var g={boot:function(n){return e.extend(I,n||{}),!I.app_id&&s.appID&&(I.app_id=s.appID),n.app_id&&n.app_id!==I.app_id&&(I.app_id=n.app_id),t.Intercom("boot",I),d},update:function(e){return e?(!e.app_id&&s.appID&&(e.app_id=s.appID),e.app_id&&e.app_id!==s.app_id&&(s.app_id=e.app_id),t.Intercom("update",e)):t.Intercom("update"),d},trackEvent:function(e,n){return t.Intercom("trackEvent",e,n),d},showMessages:function(){return t.Intercom("showMessages"),d},showNewMessage:function(e){return e?t.Intercom("showNewMessage",e):t.Intercom("showNewMessage"),d},hideMessages:function(){return t.Intercom("hideMessages"),d},shutdown:function(){return t.Intercom("shutdown"),f(),d},hide:function(){return t.Intercom("hide"),d},show:function(){return t.Intercom("show"),d},getVisitorId:function(){return t.Intercom("getVisitorId")},reattachActivator:function(){return t.Intercom("reattach_activator"),d}};e.forEach(g,m);var h={show:!0,hide:!0,activatorClick:!0};return d.$on=function(e,n){return h[e]?(t.Intercom("on"+r(e),function(){c.$$phase?n():c.$apply(n)}),d):void 0},d.on=function(e,n){return h[e]?(t.Intercom("on"+r(e),n),d):void 0},d.$$defineMethod=function(e){e&&m(e,function(){var n=Array.prototype.slice.call(arguments);return t.Intercom.apply(t.Intercom,n.unshift(e)),d})},d}]}n&&t&&!t.Intercom&&(t.Intercom=n);var a=t.IntercomSettings||t.intercomSettings,i=!1;if(e.isFunction(n))t.Intercom("reattach_activator"),a&&t.Intercom("update",a),i=!0;else{var u=function(){u.c(arguments)};u.q=[],u.c=function(t){u.q.push(t)},t.Intercom=u}var p=!1,s={asyncLoading:!1,scriptUrl:"https://widget.intercom.io/widget/",appID:"",development:!1};return e.module("ngIntercom",[]).value("IntercomSettings",{}).provider("$intercom",c).provider("Intercom",c),e.module("angular-intercom",["ngIntercom"]),e.module("ngIntercom")});