diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/colorpicker.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/colorpicker.html index 7f3e6f0b05..21727b766e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/colorpicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/colorpicker.html @@ -4,10 +4,11 @@ You haven't defined any colors - + diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.controller.js index e2f502e463..c1b432b36e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.controller.js @@ -1,5 +1,7 @@ function ColorPickerController($scope, $timeout) { + var vm = this; + //setup the default config var config = { items: [], @@ -18,10 +20,13 @@ function ColorPickerController($scope, $timeout) { for (var key in $scope.model.config.items) { if (!$scope.model.config.items[key].hasOwnProperty("value")) - $scope.model.config.items[key] = { value: $scope.model.config.items[key], label: $scope.model.config.items[key] }; + $scope.model.config.items[key] = { + value: $scope.model.config.items[key], + label: $scope.model.config.items[key] + }; } - $scope.model.useLabel = isTrue($scope.model.config.useLabel); + $scope.model.useLabel = Object.toBoolean($scope.model.config.useLabel); initActiveColor(); } @@ -54,13 +59,13 @@ function ColorPickerController($scope, $timeout) { $scope.model.config.items = items; } - $scope.selectColor = function (color) { + vm.selectColor = function (color) { // this is required to re-validate $timeout(function () { var newColor = color ? color.value : null; $scope.propertyForm.selectedColor.$setViewValue(newColor); }); - } + }; // Method required by the valPropertyValidator directive (returns true if the property editor has at least one color selected) $scope.validateMandatory = function () { @@ -74,8 +79,7 @@ function ColorPickerController($scope, $timeout) { errorMsg: $scope.model.validation.mandatoryMessage || "Value cannot be empty", errorKey: "required" }; - } - $scope.isConfigured = $scope.model.config && $scope.model.config.items && _.keys($scope.model.config.items).length > 0; + }; // Finds the color best matching the model's color, // and sets the model color to that one. This is useful when @@ -138,11 +142,6 @@ function ColorPickerController($scope, $timeout) { $scope.model.value.label = foundItem.label; } } - - // figures out if a value is trueish enough - function isTrue(bool) { - return !!bool && bool !== "0" && bool.toString().toLowerCase() !== "false"; - } } angular.module("umbraco").controller("Umbraco.PropertyEditors.ColorPickerController", ColorPickerController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.html index 9b0bdad661..b7942b7f68 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/colorpicker.html @@ -1,5 +1,4 @@ -
- +
You haven't defined any colors @@ -10,7 +9,7 @@ selected-color="model.value" size="m" use-label="model.useLabel" - on-select="selectColor(color)"> + on-select="vm.selectColor(color)">