summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/js/versions.js
blob: a74096e92589607210579648603f1f11ea2f76e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$(document).ready(function(){
	
	// Add history button to files/index.php
	FileActions.register('file','History',function(){return OC.imagePath('core','actions/history')},function(filename){
		
		if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback
		
		var file = $('#dir').val()+'/'+filename;
		
		createVersionsDropdown(filename, file)

		//window.location='../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);

		
	});
	
});

function createVersionsDropdown(filename, files) {
	
	var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
	html += '<div id="private">';
	html += '<select data-placeholder="File Version" id="share_with" class="chzen-select">';
	html += '<option value=""></option>';
	html += '</select>';
	html += '<ul id="shared_list"></ul>';
	html += '</div>';
	html += '<div id="public">';
	html += '<input type="button" name="makelink" id="makelink" value="Revert file" />';
	html += '<input type="button" name="makelink" id="makelink" value="More..." />';
	//html += '<input type="checkbox" name="public_link_write" id="public_link_write" value="1" /><label for="public_link_write">allow upload</label>';
	html += '<br />';
	html += '<input id="link" style="display:none; width:90%;" />';
	html += '</div>';
	
	if (filename) {
		$('tr').filterAttr('data-file',filename).addClass('mouseOver');
		$(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename'));
	} else {
		$(html).appendTo($('thead .share'));
	}
// 			$.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) {
// 				if (users) {
// 					$.each(users, function(index, row) {
// 						$(row).appendTo('#share_with');
// 					});
// 					$('#share_with').trigger('liszt:updated');
// 				}
// 			});
// 			$.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
// 				if (users) {
// 					$.each(users, function(index, row) {
// 						if (row.uid_shared_with == 'public') {
// 							showPublicLink(row.token, '/'+filename);
// 						} else if (isNaN(index)) {
// 							addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-')));
// 						} else {
// 							addUser(row.uid_shared_with, row.permissions, false);
// 						}
// 					});
// 				}
// 			});

	$('#dropdown').show('blind');
	$('#share_with').chosen();
	
}