/* -*- 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:
*/
sgColorPicker.$inject = ['$parse'];
function sgColorPicker($parse) {
return {
restrict: 'E',
template: [
'',
' ',
' color_lens',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join(''),
replace: true,
bindToController: true,
controller: sgColorPickerController,
controllerAs: '$sgColorPickerController',
link: link
};
function link(scope, iElement, iAttr, controller) {
// Associate callback to controller
controller.doSelect = $parse(iElement.attr('sg-on-select'));
}
}
/**
* @ngInject
*/
sgColorPickerController.$inject = ['$scope', 'sgColors'];
function sgColorPickerController($scope, sgColors) {
var vm = this;
vm.colors = sgColors.selection;
vm.select = function(color) {
vm.doSelect($scope, { color: color });
};
}
angular
.module('SOGo.Common')
.directive('sgColorPicker', sgColorPicker);
})();