/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ (function() { /* jshint validthis: true */ 'use strict'; /* * sgColorPicker - Color picker widget * @restrict element * @param {function} sgOnSelect - the function to call when clicking on a color. * One variable is available: color. * @ngInject * @example: */ function sgColorPicker() { return { restrict: 'E', require: 'ngModel', template: [ '', ' ', ' color_lens', ' ', ' ', ' ', ' ', ' ', ' ', '' ].join(''), replace: true, controller: sgColorPickerController, link: link }; function link(scope, iElement, iAttr, ngModelController) { // Expose ng-model value to scope ngModelController.$render = function() { scope.sgColor = ngModelController.$viewValue; }; } } /** * @ngInject */ sgColorPickerController.$inject = ['$scope', '$element', 'sgColors']; function sgColorPickerController($scope, $element, sgColors) { var ngModelController = $element.controller('ngModel'); $scope.sgColors = sgColors.selection; $scope.setColor = function(color) { // Update scope value and ng-model $scope.sgColor = color; ngModelController.$setViewValue(color); }; } angular .module('SOGo.Common') .directive('sgColorPicker', sgColorPicker); })();