-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-badgerly.js
61 lines (56 loc) · 1.91 KB
/
angular-badgerly.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
50
51
52
53
54
55
56
57
58
59
60
61
/*****************************
* Angular Badgerly
* Written by Steven Hunt
* MIT License
*****************************/
(function (root) {
/**
* Handles registration of the directive to the given module.
* @param ngModule The Angular module instance to register the directive to.
*/
function register(ngModule) {
if (!ngModule) {
throw 'The given Angular module must not be null!';
}
if (!ngModule.directive || typeof ngModule.directive !== 'function') {
throw 'Expected directive to be a function!';
}
// register the directive.
ngModule.directive('badgerly', function () {
return {
restrict: 'EA',
scope: {
color: '@',
size: '@',
shape: '@',
ribbon: '@',
type: '@',
border: '@'
},
transclude: true,
template: '<div class="badge {{size}}">'+
'<div ng-show="type === \'lanyard\'" class="lanyard">'+
'<div class="ribbon left {{ribbon}}"></div>'+
'<div class="ribbon right {{ribbon}}"></div>'+
'</div>'+
'<div ng-show="type !== \'lanyard\'" class="ribbon {{ribbon}}">'+
'</div>'+
'<div class="{{shape}} {{color}}{{ (border === \'yes\' ? \' border\' : \'\') }}" ng-transclude>'+
'</div>'+
'</div>'
}
});
}
// check for RequireJS
if(typeof define === "function" && define.amd) {
define(["angular-badgerly"], register);
}
// check for CommonJS
else if(typeof module === "object" && module.exports) {
module.exports = register;
}
// we're in an ordinary browser apparently.
else {
root.badgerly = register;
}
})(window);