-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfng-colour-picker.js
40 lines (38 loc) · 1.34 KB
/
fng-colour-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
(function () {
'use strict';
var fngColourPickerModule = angular.module('fng.colourPicker', ['color.picker']);
fngColourPickerModule.controller('FngColourPickerCtrl', ['$scope', function ($scope) {
$scope.options = {};
}])
.directive('fngColourPicker', ['$compile', 'PluginHelperService',
function ($compile, PluginHelperService) {
return {
restrict: 'E',
replace: true,
priority: 1,
controller: 'FngColourPickerCtrl',
link: function (scope, element, attrs) {
var template;
var processedAttr = PluginHelperService.extractFromAttr(attrs, 'fngColourPicker');
var overriddenDefaults = {
'alpha': false,
'swatchOnly': true,
'placeholder': 'Select colour'
};
scope.options = Object.assign({}, overriddenDefaults, processedAttr.directiveOptions);
template = PluginHelperService.buildInputMarkup(
scope,
attrs,
{
processedAttr
},
function (buildingBlocks) {
return '<color-picker options="options" ' + buildingBlocks.common + '></color-picker>';
}
);
element.replaceWith($compile(template)(scope));
}
};
}]
)
})();