aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-06-10 18:29:09 +0200
committerGitHub <noreply@github.com>2016-06-10 18:29:09 +0200
commit842cc2a7889d1ff8004fddd2546aec1232e0eaed (patch)
treee309a759b4ebee9ab9fa32d839d8ebb819c145f6 /apps/files_sharing/js
parent74580daa23016fab370b2f6c14d82401032733cb (diff)
parent54e2ac57130666add0ad5d3c583c6f29527b4ebc (diff)
downloadnextcloud-server-842cc2a7889d1ff8004fddd2546aec1232e0eaed.tar.gz
nextcloud-server-842cc2a7889d1ff8004fddd2546aec1232e0eaed.zip
Merge pull request #19 from nextcloud/files-drop
add "hide file list" option
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r--apps/files_sharing/js/files_drop.js81
-rw-r--r--apps/files_sharing/js/public.js4
2 files changed, 83 insertions, 2 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
new file mode 100644
index 00000000000..0a6a1c7567f
--- /dev/null
+++ b/apps/files_sharing/js/files_drop.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+(function ($) {
+ var Drop = {
+ initialize: function () {
+ $(document).bind('drop dragover', function (e) {
+ // Prevent the default browser drop action:
+ e.preventDefault();
+ });
+ $('#public-upload').fileupload({
+ url: OC.linkTo('files', 'ajax/upload.php'),
+ dataType: 'json',
+ dropZone: $('#public-upload'),
+ formData: {
+ dirToken: $('#sharingToken').val()
+ },
+ add: function(e, data) {
+ var errors = [];
+ if(data.files[0]['size'] && data.files[0]['size'] > $('#maxFilesizeUpload').val()) {
+ errors.push('File is too big');
+ }
+
+ $('#drop-upload-done-indicator').addClass('hidden');
+ $('#drop-upload-progress-indicator').removeClass('hidden');
+ _.each(data['files'], function(file) {
+ if(errors.length === 0) {
+ $('#public-upload ul').append('<li data-toggle="tooltip" title="'+escapeHTML(file.name)+'" data-name="'+escapeHTML(file.name)+'"><span class="icon-loading-small"></span> '+escapeHTML(file.name)+'</li>');
+ $('[data-toggle="tooltip"]').tooltip();
+ data.submit();
+ } else {
+ OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: file.name}));
+ $('#public-upload ul').append('<li data-toggle="tooltip" title="'+escapeHTML(file.name)+'" data-name="'+escapeHTML(file.name)+'"><img src="'+OC.imagePath('core', 'actions/error.svg')+'"/> '+escapeHTML(file.name)+'</li>');
+ $('[data-toggle="tooltip"]').tooltip();
+ }
+ });
+ },
+ success: function (response) {
+ if(response.status !== 'error') {
+ var mimeTypeUrl = OC.MimeType.getIconUrl(response['mimetype']);
+ $('#public-upload ul li[data-name="' + escapeHTML(response['filename']) + '"]').html('<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + escapeHTML(response['filename']));
+ $('[data-toggle="tooltip"]').tooltip();
+ }
+ },
+ progressall: function (e, data) {
+ var progress = parseInt(data.loaded / data.total * 100, 10);
+ if(progress === 100) {
+ $('#drop-upload-done-indicator').removeClass('hidden');
+ $('#drop-upload-progress-indicator').addClass('hidden');
+ } else {
+ $('#drop-upload-done-indicator').addClass('hidden');
+ $('#drop-upload-progress-indicator').removeClass('hidden');
+ }
+ }
+ });
+ $('#public-upload .button.icon-upload').click(function(e) {
+ e.preventDefault();
+ $('#public-upload #emptycontent input').focus().trigger('click');
+ });
+ }
+ };
+
+ $(document).ready(function() {
+ if($('#upload-only-interface').val() === "1") {
+ $('.avatardiv').avatar($('#sharingUserId').val(), 128, true);
+ }
+
+ OCA.Files_Sharing_Drop = Drop;
+ OCA.Files_Sharing_Drop.initialize();
+ });
+
+
+})(jQuery);
+
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 572ccc47b71..f207eff7909 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -302,7 +302,7 @@ OCA.Sharing.PublicApp = {
$('#save-button-confirm')
.removeClass("icon-loading-small")
.addClass("icon-confirm");
-
+
}
else {
$('#save-button-confirm')
@@ -314,7 +314,7 @@ OCA.Sharing.PublicApp = {
toggleLoading();
var location = window.location.protocol + '//' + window.location.host + OC.webroot;
-
+
if(remote.substr(-1) !== '/') {
remote += '/'
};