diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index fed85b35b53..eb075f0c43f 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -1,17 +1,8 @@ $(document).ready(function() { - $(this).click(function(event) { - if ($(event.target).parents().index($('#dropdown')) == -1) { - if ($('#dropdown').is(':visible')) { - $('#dropdown').hide('blind', function() { - $('#dropdown').remove(); - $('tr').removeClass('mouseOver'); - }); - } - } - }); FileActions.register('all', 'Share', OC.imagePath('core', 'actions/share'), function(filename) { - createShareDropdown(filename, $('#dir').val()+'/'+filename); + createDropdown(filename, $('#dir').val()+'/'+filename); }); + $('.share').click(function(event) { event.preventDefault(); var filenames = getSelectedFiles('name'); @@ -20,15 +11,21 @@ $(document).ready(function() { 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; + 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'); + }); + } } - createShareDropdown(filenames, files); }); - $('#uid_shared_with').live('change', function() { + + $('#share_with').live('change', function() { var source = $('#dropdown').data('file'); var uid_shared_with = $(this).val(); var permissions = 0; @@ -39,20 +36,15 @@ $(document).ready(function() { cache: false, data: data, success: function() { - $('#uid_shared_with option[value="'+uid_shared_with+'"]').remove(); - $('#uid_shared_with').trigger('liszt:updated'); - var list = "
  • "; - list += uid_shared_with; - list += ""; - list += ""; - list += "
  • "; - $(list).prependTo('#shared_list'); + 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')) { @@ -60,13 +52,9 @@ $(document).ready(function() { $('label', this).hide(); } }); + $('.permissions').live('change', function() { - var permissions; - if (this.checked) { - permissions = 1; - } else { - permissions = 0; - } + 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); @@ -77,6 +65,7 @@ $(document).ready(function() { data: data }); }); + $('.unshare').live('click', function(event) { // TODO Fix unshare event.preventDefault(); @@ -94,11 +83,10 @@ $(document).ready(function() { } }); }); + $('#makelink').live('change', function() { if (this.checked) { - var path = $('#dropdown').data('file'); - var expire = 0; - var data = 'path='+path+'&expire='+expire; + var data = 'path='+$('#dropdown').data('file')+'&expire=0'; $.ajax({ type: 'GET', url: OC.linkTo('files_publiclink','ajax/makelink.php'), @@ -113,8 +101,7 @@ $(document).ready(function() { } }); } else { - var token = $('#link').data('token'); - var data = 'token='+token; + var data = 'token='+$('#link').data('token'); $.ajax({ type: 'GET', url: OC.linkTo('files_publiclink','ajax/deletelink.php'), @@ -126,16 +113,17 @@ $(document).ready(function() { }); } }); + $('#link').live('click', function() { $(this).focus(); $(this).select(); }); }); -function createShareDropdown(filenames, files) { +function createDropdown(filename, files) { var html = "