summaryrefslogtreecommitdiffstats
path: root/apps/files/js/files.js
diff options
context:
space:
mode:
authorRoman Geber <rgeber@owncloudapps.com>2013-06-25 12:24:14 +0200
committerRoman Geber <rgeber@owncloudapps.com>2013-06-25 12:24:14 +0200
commitddb0ff346d3d8063f88fdba8749e098a81b92d54 (patch)
tree69004e69ed8ca2537d1029d9729d112feb6b5c20 /apps/files/js/files.js
parentc3b8f2bf64ef7b6cbdabb382b1c0a721bddb4041 (diff)
downloadnextcloud-server-ddb0ff346d3d8063f88fdba8749e098a81b92d54.tar.gz
nextcloud-server-ddb0ff346d3d8063f88fdba8749e098a81b92d54.zip
Public upload feature
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r--apps/files/js/files.js149
1 files changed, 1 insertions, 148 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 3438c1c30a1..51b3f31fb96 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -251,153 +251,6 @@ $(document).ready(function() {
e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone
});
- if ( document.getElementById('data-upload-form') ) {
- $(function() {
- $('#file_upload_start').fileupload({
- dropZone: $('#content'), // restrict dropZone to content div
- //singleFileUploads is on by default, so the data.files array will always have length 1
- add: function(e, data) {
-
- if(data.files[0].type === '' && data.files[0].size == 4096)
- {
- data.textStatus = 'dirorzero';
- data.errorThrown = t('files','Unable to upload your file as it is a directory or has 0 bytes');
- var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
- fu._trigger('fail', e, data);
- return true; //don't upload this file but go on with next in queue
- }
-
- var totalSize=0;
- $.each(data.originalFiles, function(i,file){
- totalSize+=file.size;
- });
-
- if(totalSize>$('#max_upload').val()){
- data.textStatus = 'notenoughspace';
- data.errorThrown = t('files','Not enough space available');
- var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
- fu._trigger('fail', e, data);
- return false; //don't upload anything
- }
-
- // start the actual file upload
- var jqXHR = data.submit();
-
- // remember jqXHR to show warning to user when he navigates away but an upload is still in progress
- if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
- var dirName = data.context.data('file');
- if(typeof uploadingFiles[dirName] === 'undefined') {
- uploadingFiles[dirName] = {};
- }
- uploadingFiles[dirName][data.files[0].name] = jqXHR;
- } else {
- uploadingFiles[data.files[0].name] = jqXHR;
- }
-
- //show cancel button
- if($('html.lte9').length === 0 && data.dataType !== 'iframe') {
- $('#uploadprogresswrapper input.stop').show();
- }
- },
- /**
- * called after the first add, does NOT have the data param
- * @param e
- */
- start: function(e) {
- //IE < 10 does not fire the necessary events for the progress bar.
- if($('html.lte9').length > 0) {
- return;
- }
- $('#uploadprogressbar').progressbar({value:0});
- $('#uploadprogressbar').fadeIn();
- },
- fail: function(e, data) {
- if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
- if (data.textStatus === 'abort') {
- $('#notification').text(t('files', 'Upload cancelled.'));
- } else {
- // HTTP connection problem
- $('#notification').text(data.errorThrown);
- }
- $('#notification').fadeIn();
- //hide notification after 5 sec
- setTimeout(function() {
- $('#notification').fadeOut();
- }, 5000);
- }
- delete uploadingFiles[data.files[0].name];
- },
- progress: function(e, data) {
- // TODO: show nice progress bar in file row
- },
- progressall: function(e, data) {
- //IE < 10 does not fire the necessary events for the progress bar.
- if($('html.lte9').length > 0) {
- return;
- }
- var progress = (data.loaded/data.total)*100;
- $('#uploadprogressbar').progressbar('value',progress);
- },
- /**
- * called for every successful upload
- * @param e
- * @param data
- */
- done:function(e, data) {
- // handle different responses (json or body from iframe for ie)
- var response;
- if (typeof data.result === 'string') {
- response = data.result;
- } else {
- //fetch response from iframe
- response = data.result[0].body.innerText;
- }
- var result=$.parseJSON(response);
-
- if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
- var file = result[0];
- } else {
- data.textStatus = 'servererror';
- data.errorThrown = t('files', result.data.message);
- var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
- fu._trigger('fail', e, data);
- }
-
- var filename = result[0].originalname;
-
- // delete jqXHR reference
- if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
- var dirName = data.context.data('file');
- delete uploadingFiles[dirName][filename];
- if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
- delete uploadingFiles[dirName];
- }
- } else {
- delete uploadingFiles[filename];
- }
-
- },
- /**
- * called after last upload
- * @param e
- * @param data
- */
- stop: function(e, data) {
- if(data.dataType !== 'iframe') {
- $('#uploadprogresswrapper input.stop').hide();
- }
-
- //IE < 10 does not fire the necessary events for the progress bar.
- if($('html.lte9').length > 0) {
- return;
- }
-
- $('#uploadprogressbar').progressbar('value',100);
- $('#uploadprogressbar').fadeOut();
- }
- })
- });
- }
$.assocArraySize = function(obj) {
// http://stackoverflow.com/a/6700/11236
var size = 0, key;
@@ -804,7 +657,7 @@ var dragOptions={
// sane browsers support using the distance option
if ( $('html.ie').length === 0) {
dragOptions['distance'] = 20;
-}
+}
var folderDropOptions={
drop: function( event, ui ) {