$(document).ready(function() { FileActions.register('all', 'Share', OC.imagePath('core', 'actions/share'), function(filename) { createShareDialog(filename, $('#dir').val()+'/'+filename); }); $('.share').click(function(event) { event.preventDefault(); var filenames = getSelectedFiles('name'); var length = filenames.length; var files = ''; for (var i = 0; i < length; i++) { files += $('#dir').val()+'/'+filenames[i]+';'; } var lastFileName = filenames.pop(); if (filenames.length > 0) { filenames = filenames.join(', ')+' and '+lastFileName; } else { filenames = lastFileName; } createShareDialog(filenames, files); }); $('#uid_shared_with').live('keyup', function() { $(this).autocomplete({ source: '../apps/files_sharing/ajax/userautocomplete.php' }); }); $('button.remove-uid_shared_with').live('click', function(event) { event.preventDefault(); alert("remove"); // TODO Remove corresponding row }); }); function createShareDialog(filenames, files) { var html = "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
"; $.getJSON(OC.linkTo('files_sharing','ajax/getitem.php'), { source: files }, function(users) { var list = ""; $.each(users, function(index, row) { list += row.uid_shared_with; list += "
"; if (row.permissions > 0) { $('share_private_permissions').prop('checked', true); } }); $(list).appendTo('#shared_list'); }); html += "
"; html += "
"; html += ""; html += ""; html += ""; html += "
"; $(html).appendTo($('tr[data-file="'+filenames+'"] td.filename')); }