-
Notifications
You must be signed in to change notification settings - Fork 0
/
minicolors-angular.js
51 lines (48 loc) · 1.27 KB
/
minicolors-angular.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
(function () {
var minicolors = angular.module('minicolors', []);
minicolors.provider('minicolors', function () {
this.defaults = {
animationSpeed: 50,
animationEasing: 'swing',
change: null,
changeDelay: 0,
control: 'hue',
dataUris: true,
hide: null,
hideSpeed: 100,
inline: false,
letterCase: 'lowercase',
opacity: false,
position: 'bottom left',
show: null,
showSpeed: 100,
theme: 'default'
};
this.$get = function () {
return this;
};
});
minicolors.directive('minicolors', ['$parse', 'minicolors', function ($parse, minicolors) {
return {
restrict: 'AC',
scope: {
'color': '=ngModel'
},
link: function (scope, element, attrs) {
var options = $parse(attrs.options || '{}')(scope.$parent);
angular.extend(options, minicolors.defaults);
options.defaultValue = scope.color;
if (element.hasClass('minicolors-input')) {
element.minicolors('destroy');
}
element.minicolors(options);
element.on('change', function () {
var value = element.val();
scope.$apply(function () {
scope.color = value;
});
});
}
};
}]);
})();