aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-16 15:45:55 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-16 15:45:55 +0200
commitfdeef5e874ae7a8e4a23a737e5a1e948804d768a (patch)
tree2cc093162b583210b8f878f5ab9d670c270cff2e /apps/files/js
parent60541358ac375652d74e4a5b5d8cad865833aa92 (diff)
parentc3f7d22adc59949ad41c33d450b6d3e226cdefdb (diff)
downloadnextcloud-server-fdeef5e874ae7a8e4a23a737e5a1e948804d768a.tar.gz
nextcloud-server-fdeef5e874ae7a8e4a23a737e5a1e948804d768a.zip
Merge branch 'master' into fixing-appframework-master
Conflicts: lib/private/appframework/middleware/security/securitymiddleware.php tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/file-upload.js9
-rw-r--r--apps/files/js/filelist.js80
-rw-r--r--apps/files/js/files.js11
3 files changed, 60 insertions, 40 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index f1ef485fc3d..c03e9037cec 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -345,7 +345,7 @@ $(document).ready(function() {
} else if (result[0].status !== 'success') {
//delete data.jqXHR;
data.textStatus = 'servererror';
- data.errorThrown = result.data.message; // error message has been translated on server
+ data.errorThrown = result[0].data.message; // error message has been translated on server
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
}
@@ -523,8 +523,10 @@ $(document).ready(function() {
function(result){
if (result.status == 'success') {
var date=new Date();
- FileList.addFile(name,0,date,false,hidden);
- var tr=$('tr').filterAttr('data-file',name);
+ // TODO: ideally addFile should be able to receive
+ // all attributes and set them automatically,
+ // and also auto-load the preview
+ var tr = FileList.addFile(name,0,date,false,hidden);
tr.attr('data-size',result.data.size);
tr.attr('data-mime',result.data.mime);
tr.attr('data-id', result.data.id);
@@ -533,6 +535,7 @@ $(document).ready(function() {
lazyLoadPreview(path, result.data.mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
+ FileActions.display(tr.find('td.filename'));
} else {
OC.dialogs.alert(result.data.message, t('core', 'Error'));
}
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index a9297996778..e7edd2cf388 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -677,6 +677,7 @@ var FileList={
};
$(document).ready(function(){
+ var isPublic = !!$('#isPublic').val();
// handle upload events
var file_upload_start = $('#file_upload_start');
@@ -684,28 +685,32 @@ $(document).ready(function(){
file_upload_start.on('fileuploaddrop', function(e, data) {
OC.Upload.log('filelist handle fileuploaddrop', e, data);
- var dropTarget = $(e.originalEvent.target).closest('tr');
- if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
+ var dropTarget = $(e.originalEvent.target).closest('tr, .crumb');
+ if(dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder
// remember as context
data.context = dropTarget;
var dir = dropTarget.data('file');
+ // if from file list, need to prepend parent dir
+ if (dir){
+ var parentDir = $('#dir').val() || '/';
+ if (parentDir[parentDir.length - 1] != '/'){
+ parentDir += '/';
+ }
+ dir = parentDir + dir;
+ }
+ else{
+ // read full path from crumb
+ dir = dropTarget.data('dir') || '/';
+ }
// update folder in form
data.formData = function(form) {
- var formArray = form.serializeArray();
- // array index 0 contains the max files size
- // array index 1 contains the request token
- // array index 2 contains the directory
- var parentDir = formArray[2]['value'];
- if (parentDir === '/') {
- formArray[2]['value'] += dir;
- } else {
- formArray[2]['value'] += '/' + dir;
- }
-
- return formArray;
+ return [
+ {name: 'dir', value: dir},
+ {name: 'requesttoken', value: oc_requesttoken}
+ ];
};
}
@@ -783,6 +788,10 @@ $(document).ready(function(){
data.context.find('td.filesize').text(humanFileSize(size));
} else {
+ // only append new file if dragged onto current dir's crumb (last)
+ if (data.context && data.context.hasClass('crumb') && !data.context.hasClass('last')){
+ return;
+ }
// add as stand-alone row to filelist
var size=t('files', 'Pending');
@@ -924,29 +933,32 @@ $(document).ready(function(){
return (params && params.dir) || '/';
}
- // fallback to hashchange when no history support
- if (!window.history.pushState){
- $(window).on('hashchange', function(){
- FileList.changeDirectory(parseCurrentDirFromUrl(), false);
- });
- }
- window.onpopstate = function(e){
- var targetDir;
- if (e.state && e.state.dir){
- targetDir = e.state.dir;
- }
- else{
- // read from URL
- targetDir = parseCurrentDirFromUrl();
+ // disable ajax/history API for public app (TODO: until it gets ported)
+ if (!isPublic){
+ // fallback to hashchange when no history support
+ if (!window.history.pushState){
+ $(window).on('hashchange', function(){
+ FileList.changeDirectory(parseCurrentDirFromUrl(), false);
+ });
}
- if (targetDir){
- FileList.changeDirectory(targetDir, false);
+ window.onpopstate = function(e){
+ var targetDir;
+ if (e.state && e.state.dir){
+ targetDir = e.state.dir;
+ }
+ else{
+ // read from URL
+ targetDir = parseCurrentDirFromUrl();
+ }
+ if (targetDir){
+ FileList.changeDirectory(targetDir, false);
+ }
}
- }
- if (parseInt($('#ajaxLoad').val(), 10) === 1){
- // need to initially switch the dir to the one from the hash (IE8)
- FileList.changeDirectory(parseCurrentDirFromUrl(), false, true);
+ if (parseInt($('#ajaxLoad').val(), 10) === 1){
+ // need to initially switch the dir to the one from the hash (IE8)
+ FileList.changeDirectory(parseCurrentDirFromUrl(), false, true);
+ }
}
FileList.createFileSummary();
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 37b66858840..a35ed4add8c 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -703,7 +703,12 @@ function checkTrashStatus() {
}
function onClickBreadcrumb(e){
- var $el = $(e.target).closest('.crumb');
- e.preventDefault();
- FileList.changeDirectory(decodeURIComponent($el.data('dir')));
+ var $el = $(e.target).closest('.crumb'),
+ $targetDir = $el.data('dir');
+ isPublic = !!$('#isPublic').val();
+
+ if ($targetDir !== undefined && !isPublic){
+ e.preventDefault();
+ FileList.changeDirectory(decodeURIComponent($targetDir));
+ }
}