-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathangularjs-livechat.js
49 lines (45 loc) · 1.34 KB
/
angularjs-livechat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(function(root, factory) {
// AMD
if (typeof define === 'function' && define.amd) {
define(['angular'], function(angular) {
return factory(root, angular, root.__lc);
});
} else if (typeof exports !== 'undefined') {
// CommonJS and Node.js module support
exports = module.exports = factory({}, require('angular'), root.__lc);
} else if (angular) {
// Angular
factory(root, root.angular, root.__lc);
}
})(this, function(global, angular, __lc) {
'use strict';
angular.module('ngLiveChat', []).directive('livechat', function() {
return {
scope: {
license: '@',
group: '@'
},
bindToController: true,
controllerAs: 'vm',
controller: [
'$window',
function($window) {
$window.__lc = __lc || {};
$window.__lc.license = this.license;
if (this.group) {
$window.__lc.group = this.group;
}
(function() {
var lc = $window.document.createElement('script');
lc.type = 'text/javascript';
lc.async = true;
lc.src = 'https://cdn.livechatinc.com/tracking.js';
var s = $window.document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(lc, s);
})();
}
]
};
});
return angular.module('ngLiveChat');
});