(function()
{
	var moduleName = 'claromentis.project';
	var module;

	try {
		module = angular.module(moduleName);
	} catch(err) {
		// named module does not exist, so create one
		module = angular.module(moduleName, []);
	}

	module
		.directive('claColourPicker', claColourPicker);

	function claColourPicker()
	{
		return {
			restrict: 'E',
			require: '^ngModel',
			templateUrl: '/intranet/projects/html/components/colour_picker.html',
			scope: {
				ngModel: '='
			},
			link: link
		};

		function link(scope, iElement, iAttrs, ctrl)
		{
			scope.id = iAttrs.id;
			scope.ctrl = ctrl;

			ctrl.$viewChangeListeners.push(function() {
				scope.$eval(iAttrs.ngChange);
			});
		}
	}
}());