// Share current page

define(['cla_angular', '../../../../../web/intranet/share/html/share_link_dialog.html'], function (angular, template) {
	var moduleName = 'cla.core.share';
	var module = null;
	try {
		module = angular.module(moduleName);
	} catch(err) {
		// named module does not exist, so create one
		module = angular.module(moduleName, []);
	}

	module.directive('claShare', share);

	function link(scope, element, attr) {
		var canonicalUrl = attr['canonicalUrl'];
		if (typeof canonicalUrl !== 'undefined')
			$('#shareButton').attr('data-canonical-url', canonicalUrl);
	}

	function share() {
		return {
			link: link,
			restrict: 'E',
			templateUrl: template,
			scope: {
				canonicalUrl: '@'
			}
		};
	}
});