$(document).ready(function() { FileActions.register('all', 'Share', OC.imagePath('core', 'actions/share'), function(filename) { createDropdown(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]+';'; } createDropdown(false, files); }); $(this).click(function(event) { if ($(event.target).parents().index($('#dropdown')) == -1) { if ($('#dropdown').is(':visible')) { $('#dropdown').hide('blind', function() { $('#dropdown').remove(); $('tr').removeClass('mouseOver'); }); } } }); $('#share_with').live('change', function() { var source = $('#dropdown').data('file'); var uid_shared_with = $(this).val(); var permissions = 0; var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions); $.ajax({ type: 'POST', url: OC.linkTo('files_sharing','ajax/share.php'), cache: false, data: data, success: function() { addUser(uid_shared_with, 0, false); } }); }); $('#shared_list > li').live('mouseenter', function(event) { $(':hidden', this).show(); }); $('#shared_list > li').live('mouseleave', function(event) { $('a', this).hide(); if (!$('input:[type=checkbox]', this).is(':checked')) { $('input:[type=checkbox]', this).hide(); $('label', this).hide(); } }); $('.permissions').live('change', function() { var permissions = (this.checked) ? 1 : 0; var source = $('#dropdown').data('file'); var uid_shared_with = $(this).parent().data('uid_shared_with'); var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions); $.ajax({ type: 'GET', url: OC.linkTo('files_sharing','ajax/setpermissions.php'), cache: false, data: data }); }); $('.unshare').live('click', function(event) { // TODO Fix unshare event.preventDefault(); event.stopPropagation(); var source = $('#dropdown').data('file'); var uid_shared_with = $(this).parent().data('uid_shared_with'); var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with); $.ajax({ type: 'GET', url: OC.linkTo('files_sharing','ajax/unshare.php'), cache: false, data: data, success: function() { $(this).parent().remove(); } }); }); $('#makelink').live('change', function() { if (this.checked) { var data = 'path='+$('#dropdown').data('file')+'&expire=0'; $.ajax({ type: 'GET', url: OC.linkTo('files_publiclink','ajax/makelink.php'), cache: false, data: data, success: function(token) { if (token) { $('#link').data('token', token); $('#link').val('http://'+location.host+OC.linkTo('files_publiclink','get.php')+'?token='+token); $('#link').show('blind'); } } }); } else { var data = 'token='+$('#link').data('token'); $.ajax({ type: 'GET', url: OC.linkTo('files_publiclink','ajax/deletelink.php'), cache: false, data: data, success: function(){ $('#link').hide('blind'); } }); } }); $('#link').live('click', function() { $(this).focus(); $(this).select(); }); }); function createDropdown(filename, files) { var html = "