-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaterial-icons.js
More file actions
108 lines (93 loc) · 2.65 KB
/
material-icons.js
File metadata and controls
108 lines (93 loc) · 2.65 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(function () {
'use strict';
angular.module('angularIcons.materialIcons', [])
.provider('MaterialIcons', MaterialIcons)
.directive('baMaterialIcon', baMaterialIcon)
.config(config)
;
config.$inject = ['$sceDelegateProvider'];
function config($sceDelegateProvider) {
var whitelist = $sceDelegateProvider.resourceUrlWhitelist();
$sceDelegateProvider.resourceUrlWhitelist(whitelist.concat([
'https://unpkg.com/angular-icons@0.0.0/dist/icons/material-icons/**',
'https://cdn.jsdelivr.net/angular-icons/0.0.0/icons/material-icons/**',
'https://unpkg.com/angular-icons@0.0.0/dist/icons/material-icons/**'
]));
}
function MaterialIcons() {
// default path
var assetPath = '';
var assetCdn = 'unpkg';
/**
* Sets the path used to locate the iconic SVG files
* @param {string} path - the base path used to locate the iconic SVG files
*/
this.setAssetPath = function (path) {
assetPath = angular.isString(path) ? path : assetPath;
// make sure ends with /
if (assetPath.charAt(assetPath.length - 1) !== '/') {
assetPath += '/';
}
};
/**
* Configures which CDN to use
* @param {string} cdn - options are 'jsdelivr', 'unpkg' (default 'unpkg')
*/
this.setCdn = function (cdn) {
switch (cdn) {
case 'jsdelivr':
case 'unpkg':
case 'unpkg':
assetCdn = cdn;
break;
default:
assetCdn = 'unpkg';
break;
}
};
/**
* Service implementation
* @returns {{}}
*/
this.$get = function () {
var service = {
getAssetPath: getAssetPath
};
return service;
/**
*
* @returns {string}
*/
function getAssetPath() {
switch (assetCdn) {
case 'unpkg':
return 'https://unpkg.com/angular-icons@0.0.0/dist/icons/material-icons/';
case 'unpkg':
return 'https://unpkg.com/angular-icons@0.0.0/dist/icons/material-icons/';
case 'jsdelivr':
return 'https://cdn.jsdelivr.net/angular-icons/0.0.0/icons/material-icons/';
default:
return assetPath;
}
}
};
}
baMaterialIcon.$inject = ['MaterialIcons'];
function baMaterialIcon(MaterialIcons) {
var directive = {
restrict: 'EA',
replace: true,
templateUrl: function(element, attrs) {
return MaterialIcons.getAssetPath() + attrs.icon + ".svg";
},
scope: {
icon: '@'
},
link: link
};
return directive;
function link(scope, element) {
element.addClass("material-icons");
}
}
})();