/
eyedropper.controller.js
44 lines (34 loc) · 1.35 KB
/
eyedropper.controller.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
function EyeDropperColorPickerController($scope, angularHelper) {
var vm = this;
//setup the default config
var config = {
showAlpha: true,
showPalette: true,
allowEmpty: true
};
// map the user config
Utilities.extend(config, $scope.model.config);
// map back to the model
$scope.model.config = config;
vm.options = $scope.model.config;
vm.color = $scope.model.value || null;
vm.selectColor = function (color) {
angularHelper.safeApply($scope, function () {
vm.color = color ? color.toString() : null;
$scope.model.value = vm.color;
$scope.propertyForm.selectedColor.$setViewValue(vm.color);
});
};
// Method required by the valPropertyValidator directive (returns true if the property editor has at least one color selected)
$scope.validateMandatory = function () {
var isValid = !$scope.model.validation.mandatory || (
$scope.model.value != null
&& $scope.model.value != "");
return {
isValid: isValid,
errorMsg: $scope.model.validation.mandatoryMessage || "Value cannot be empty",
errorKey: "required"
};
};
}
angular.module("umbraco").controller("Umbraco.PropertyEditors.EyeDropperColorPickerController", EyeDropperColorPickerController);