UNPKG

thalassa-aqueduct

Version:

Dynamic haproxy load balancer and configuration. Part of Thalassa

53 lines (44 loc) 1.22 kB
angular.module('ui.bootstrap.rating', []) .constant('ratingConfig', { max: 5 }) .directive('rating', ['ratingConfig', '$parse', function(ratingConfig, $parse) { return { restrict: 'EA', scope: { value: '=' }, templateUrl: 'template/rating/rating.html', replace: true, link: function(scope, element, attrs) { var maxRange = angular.isDefined(attrs.max) ? scope.$eval(attrs.max) : ratingConfig.max; scope.range = []; for (var i = 1; i <= maxRange; i++) { scope.range.push(i); } scope.rate = function(value) { if ( ! scope.readonly ) { scope.value = value; } }; scope.enter = function(value) { if ( ! scope.readonly ) { scope.val = value; } }; scope.reset = function() { scope.val = angular.copy(scope.value); }; scope.reset(); scope.$watch('value', function(value) { scope.val = value; }); scope.readonly = false; if (attrs.readonly) { scope.$parent.$watch($parse(attrs.readonly), function(value) { scope.readonly = !!value; }); } } }; }]);