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

	angular.module(moduleName)
		.controller("taskFilesCtrl", ["$scope", taskFilesController]);

	function taskFilesController($scope)
	{
		$scope.folder_id = task_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();
			});
		});
	}
}());