From 1ec0b6ecc151f9701a0a8c4873c6b06ff3586136 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Tue, 26 Jul 2011 21:27:40 -0400 Subject: [PATCH] jQuery dialog for sharing files from within file browser - Not functional yet --- apps/files_sharing/appinfo/app.php | 2 + apps/files_sharing/js/share.js | 84 ++++++++++++++++++++++++++++++ files/templates/index.php | 2 +- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 apps/files_sharing/js/share.js diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index b73f7d52e60..879bd1ea0eb 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -2,6 +2,8 @@ require_once('apps/files_sharing/lib_share.php'); +OC_UTIL::addScript("files_sharing", "share"); + OC_APP::addNavigationEntry( array( "id" => "files_sharing_list", "order" => 10, "href" => OC_HELPER::linkTo( "files_sharing", "list.php" ), diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js new file mode 100644 index 00000000000..84449406ab8 --- /dev/null +++ b/apps/files_sharing/js/share.js @@ -0,0 +1,84 @@ +$(document).ready(function() { + $('.share').click(function(event) { + event.preventDefault(); + // TODO Replace with getSelectedFiles() from files.js + var files = ''; + $('td.selection input:checkbox:checked').parent().parent().each(function(i, element) { + files += ', ' + $(element).attr('data-file'); + }); + files = files.substr(1); + var html = "
"; + html += ""; + html += ""; + html += "
"; + html += "
"; + html += ""; + html += ""; + html += "
"; + html += "Advanced"; + html += "
"; + html += ""; + html += "
"; + html += ""; + html += "
"; + html += ""; + html += "
"; + $(html).dialog(); + }); + $("input[name=share_type]").live('change', function() { + $('#private').toggle(); + $('#public').toggle(); + }); + $('.uid_shared_with').live('keyup', function() { + $(this).autocomplete({ + source: "../apps/files_sharing/ajax/userautocomplete.php", + minLength: 1 + }); + }); + $('button.add-uid_shared_with').live('click', function(event) { + event.preventDefault(); + // TODO Make sure previous textbox has a valid user or group name + var html = "
"; + html += ""; + html += ""; + $(html).insertAfter('.add-uid_shared_with'); + $(this).html(" -  "); + $(this).removeClass("add-uid_shared_with fancybutton"); + $(this).addClass("remove-uid_shared_with fancybutton"); + }); + $('button.remove-uid_shared_with').live('click', function(event) { + event.preventDefault(); + alert("remove"); + // TODO Remove corresponding row + }); + $('#toggle-private-advanced').live('click', function(event) { + event.preventDefault(); + $('#private-advanced').toggle(); + }); + $('button.submit').live('click', function(event) { + event.preventDefault(); + if ($("input[name=share_type]:checked").val() == 'public') { + // TODO Construct public link + } else { + // TODO Construct shared item + // TODO Check all inputs are valid +// var source; +// var uid_shared_with; +// var permissions; +// var data = 'source='+source+'&uid_shared_with='+uid_shared_with+'&permissions='+permissions; +// $.ajax({ +// type: 'GET', +// url: 'ajax/share.php', +// cache: false, +// data: data +// }); + } + }); +}); \ No newline at end of file diff --git a/files/templates/index.php b/files/templates/index.php index efc92900637..f540ef4748c 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -15,7 +15,7 @@ t( 'Download' ); ?> - + t( 'Delete' ); ?>