-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcolor-picker.js
54 lines (49 loc) · 1.3 KB
/
color-picker.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
angular.module('ngColorPicker', [])
.provider('ngColorPickerConfig', function(){
var templateUrl = 'color-picker.html';
var defaultColors = [
'#7bd148',
'#5484ed',
'#a4bdfc',
'#46d6db',
'#7ae7bf',
'#51b749',
'#fbd75b',
'#ffb878',
'#ff887c',
'#dc2127',
'#dbadff',
'#e1e1e1'
];
this.setTemplateUrl = function(url){
templateUrl = url;
return this;
};
this.setDefaultColors = function(colors){
defaultColors = colors;
return this;
};
this.$get = function(){
return {
templateUrl : templateUrl,
defaultColors: defaultColors
}
}
})
.directive('ngColorPicker', ['ngColorPickerConfig',function(ngColorPickerConfig) {
return {
scope: {
selected: '=',
customizedColors: '=colors'
},
restrict: 'AE',
templateUrl: ngColorPickerConfig.templateUrl,
link: function (scope, element, attr) {
scope.colors = scope.customizedColors || ngColorPickerConfig.defaultColors;
scope.selected = scope.selected || scope.colors[0];
scope.pick = function (color) {
scope.selected = color;
};
}
};
}]);