(function()
{
	var moduleName = 'projectDetailApp';

	angular.module(moduleName)
		.controller("projectFilesCtrl", ["$scope", projectFilesController]);

	function projectFilesController($scope)
	{
		$scope.folder_id = project_folder_id;

		// A conflict makes DMSV modals change the URL when used on this page.
		// This code will replace the buttons href attribute and open the modal manually instead
		angular.element('#add-folder-docs-btns [data-toggle="modal"]').each(function()
		{
			var button = angular.element(this);
			var target = button.prop('href');
			var bits = target.split('#');
			if (bits.length !== 2)
				return;
			target = '#' + bits[1];

			button.prop('href', '#');
			button.on('click', function(e)
			{
				e.preventDefault();
				angular.element(target).modal();
			});
		});
	}
}());