|
|
@ -1,7 +1,7 @@ |
|
|
|
var FileList={ |
|
|
|
var FileList={ |
|
|
|
useUndo:true, |
|
|
|
useUndo:true, |
|
|
|
postProcessList: function(){ |
|
|
|
postProcessList: function() { |
|
|
|
$('#fileList tr').each(function(){ |
|
|
|
$('#fileList tr').each(function() { |
|
|
|
//little hack to set unescape filenames in attribute
|
|
|
|
//little hack to set unescape filenames in attribute
|
|
|
|
$(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); |
|
|
|
$(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -16,13 +16,13 @@ var FileList={ |
|
|
|
$fileList.trigger(jQuery.Event("fileActionsReady")); |
|
|
|
$fileList.trigger(jQuery.Event("fileActionsReady")); |
|
|
|
FileList.postProcessList(); |
|
|
|
FileList.postProcessList(); |
|
|
|
// "Files" might not be loaded in extending apps
|
|
|
|
// "Files" might not be loaded in extending apps
|
|
|
|
if (window.Files){ |
|
|
|
if (window.Files) { |
|
|
|
Files.setupDragAndDrop(); |
|
|
|
Files.setupDragAndDrop(); |
|
|
|
} |
|
|
|
} |
|
|
|
FileList.updateFileSummary(); |
|
|
|
FileList.updateFileSummary(); |
|
|
|
$fileList.trigger(jQuery.Event("updated")); |
|
|
|
$fileList.trigger(jQuery.Event("updated")); |
|
|
|
}, |
|
|
|
}, |
|
|
|
createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions){ |
|
|
|
createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions) { |
|
|
|
var td, simpleSize, basename, extension; |
|
|
|
var td, simpleSize, basename, extension; |
|
|
|
//containing tr
|
|
|
|
//containing tr
|
|
|
|
var tr = $('<tr></tr>').attr({ |
|
|
|
var tr = $('<tr></tr>').attr({ |
|
|
@ -43,7 +43,7 @@ var FileList={ |
|
|
|
"href": linktarget |
|
|
|
"href": linktarget |
|
|
|
}); |
|
|
|
}); |
|
|
|
//split extension from filename for non dirs
|
|
|
|
//split extension from filename for non dirs
|
|
|
|
if (type != 'dir' && name.indexOf('.')!=-1) { |
|
|
|
if (type !== 'dir' && name.indexOf('.') !== -1) { |
|
|
|
basename=name.substr(0,name.lastIndexOf('.')); |
|
|
|
basename=name.substr(0,name.lastIndexOf('.')); |
|
|
|
extension=name.substr(name.lastIndexOf('.')); |
|
|
|
extension=name.substr(name.lastIndexOf('.')); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -52,11 +52,11 @@ var FileList={ |
|
|
|
} |
|
|
|
} |
|
|
|
var name_span=$('<span></span>').addClass('nametext').text(basename); |
|
|
|
var name_span=$('<span></span>').addClass('nametext').text(basename); |
|
|
|
link_elem.append(name_span); |
|
|
|
link_elem.append(name_span); |
|
|
|
if(extension){ |
|
|
|
if (extension) { |
|
|
|
name_span.append($('<span></span>').addClass('extension').text(extension)); |
|
|
|
name_span.append($('<span></span>').addClass('extension').text(extension)); |
|
|
|
} |
|
|
|
} |
|
|
|
//dirs can show the number of uploaded files
|
|
|
|
//dirs can show the number of uploaded files
|
|
|
|
if (type == 'dir') { |
|
|
|
if (type === 'dir') { |
|
|
|
link_elem.append($('<span></span>').attr({ |
|
|
|
link_elem.append($('<span></span>').attr({ |
|
|
|
'class': 'uploadtext', |
|
|
|
'class': 'uploadtext', |
|
|
|
'currentUploads': 0 |
|
|
|
'currentUploads': 0 |
|
|
@ -66,9 +66,9 @@ var FileList={ |
|
|
|
tr.append(td); |
|
|
|
tr.append(td); |
|
|
|
|
|
|
|
|
|
|
|
//size column
|
|
|
|
//size column
|
|
|
|
if(size!=t('files', 'Pending')){ |
|
|
|
if (size !== t('files', 'Pending')) { |
|
|
|
simpleSize = humanFileSize(size); |
|
|
|
simpleSize = humanFileSize(size); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
simpleSize=t('files', 'Pending'); |
|
|
|
simpleSize=t('files', 'Pending'); |
|
|
|
} |
|
|
|
} |
|
|
|
var sizeColor = Math.round(160-Math.pow((size/(1024*1024)),2)); |
|
|
|
var sizeColor = Math.round(160-Math.pow((size/(1024*1024)),2)); |
|
|
@ -90,7 +90,7 @@ var FileList={ |
|
|
|
tr.append(td); |
|
|
|
tr.append(td); |
|
|
|
return tr; |
|
|
|
return tr; |
|
|
|
}, |
|
|
|
}, |
|
|
|
addFile:function(name,size,lastModified,loading,hidden,param){ |
|
|
|
addFile:function(name, size, lastModified, loading, hidden, param) { |
|
|
|
var imgurl; |
|
|
|
var imgurl; |
|
|
|
|
|
|
|
|
|
|
|
if (!param) { |
|
|
|
if (!param) { |
|
|
@ -120,9 +120,9 @@ var FileList={ |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
FileList.insertElement(name, 'file', tr); |
|
|
|
FileList.insertElement(name, 'file', tr); |
|
|
|
if(loading){ |
|
|
|
if (loading) { |
|
|
|
tr.data('loading',true); |
|
|
|
tr.data('loading', true); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
tr.find('td.filename').draggable(dragOptions); |
|
|
|
tr.find('td.filename').draggable(dragOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
if (hidden) { |
|
|
|
if (hidden) { |
|
|
@ -130,7 +130,7 @@ var FileList={ |
|
|
|
} |
|
|
|
} |
|
|
|
return tr; |
|
|
|
return tr; |
|
|
|
}, |
|
|
|
}, |
|
|
|
addDir:function(name,size,lastModified,hidden){ |
|
|
|
addDir:function(name, size, lastModified, hidden) { |
|
|
|
|
|
|
|
|
|
|
|
var tr = this.createRow( |
|
|
|
var tr = this.createRow( |
|
|
|
'dir', |
|
|
|
'dir', |
|
|
@ -142,7 +142,7 @@ var FileList={ |
|
|
|
$('#permissions').val() |
|
|
|
$('#permissions').val() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
FileList.insertElement(name,'dir',tr); |
|
|
|
FileList.insertElement(name, 'dir', tr); |
|
|
|
var td = tr.find('td.filename'); |
|
|
|
var td = tr.find('td.filename'); |
|
|
|
td.draggable(dragOptions); |
|
|
|
td.draggable(dragOptions); |
|
|
|
td.droppable(folderDropOptions); |
|
|
|
td.droppable(folderDropOptions); |
|
|
@ -156,25 +156,26 @@ var FileList={ |
|
|
|
* @brief Changes the current directory and reload the file list. |
|
|
|
* @brief Changes the current directory and reload the file list. |
|
|
|
* @param targetDir target directory (non URL encoded) |
|
|
|
* @param targetDir target directory (non URL encoded) |
|
|
|
* @param changeUrl false if the URL must not be changed (defaults to true) |
|
|
|
* @param changeUrl false if the URL must not be changed (defaults to true) |
|
|
|
|
|
|
|
* @param {boolean} force set to true to force changing directory |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
changeDirectory: function(targetDir, changeUrl, force){ |
|
|
|
changeDirectory: function(targetDir, changeUrl, force) { |
|
|
|
var $dir = $('#dir'), |
|
|
|
var $dir = $('#dir'), |
|
|
|
url, |
|
|
|
url, |
|
|
|
currentDir = $dir.val() || '/'; |
|
|
|
currentDir = $dir.val() || '/'; |
|
|
|
targetDir = targetDir || '/'; |
|
|
|
targetDir = targetDir || '/'; |
|
|
|
if (!force && currentDir === targetDir){ |
|
|
|
if (!force && currentDir === targetDir) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
FileList.setCurrentDir(targetDir, changeUrl); |
|
|
|
FileList.setCurrentDir(targetDir, changeUrl); |
|
|
|
FileList.reload(); |
|
|
|
FileList.reload(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
linkTo: function(dir){ |
|
|
|
linkTo: function(dir) { |
|
|
|
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); |
|
|
|
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setCurrentDir: function(targetDir, changeUrl){ |
|
|
|
setCurrentDir: function(targetDir, changeUrl) { |
|
|
|
$('#dir').val(targetDir); |
|
|
|
$('#dir').val(targetDir); |
|
|
|
if (changeUrl !== false){ |
|
|
|
if (changeUrl !== false) { |
|
|
|
if (window.history.pushState && changeUrl !== false){ |
|
|
|
if (window.history.pushState && changeUrl !== false) { |
|
|
|
url = FileList.linkTo(targetDir); |
|
|
|
url = FileList.linkTo(targetDir); |
|
|
|
window.history.pushState({dir: targetDir}, '', url); |
|
|
|
window.history.pushState({dir: targetDir}, '', url); |
|
|
|
} |
|
|
|
} |
|
|
@ -187,9 +188,9 @@ var FileList={ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @brief Reloads the file list using ajax call |
|
|
|
* @brief Reloads the file list using ajax call |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
reload: function(){ |
|
|
|
reload: function() { |
|
|
|
FileList.showMask(); |
|
|
|
FileList.showMask(); |
|
|
|
if (FileList._reloadCall){ |
|
|
|
if (FileList._reloadCall) { |
|
|
|
FileList._reloadCall.abort(); |
|
|
|
FileList._reloadCall.abort(); |
|
|
|
} |
|
|
|
} |
|
|
|
FileList._reloadCall = $.ajax({ |
|
|
|
FileList._reloadCall = $.ajax({ |
|
|
@ -198,7 +199,7 @@ var FileList={ |
|
|
|
dir : $('#dir').val(), |
|
|
|
dir : $('#dir').val(), |
|
|
|
breadcrumb: true |
|
|
|
breadcrumb: true |
|
|
|
}, |
|
|
|
}, |
|
|
|
error: function(result){ |
|
|
|
error: function(result) { |
|
|
|
FileList.reloadCallback(result); |
|
|
|
FileList.reloadCallback(result); |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function(result) { |
|
|
|
success: function(result) { |
|
|
@ -206,7 +207,7 @@ var FileList={ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
reloadCallback: function(result){ |
|
|
|
reloadCallback: function(result) { |
|
|
|
var $controls = $('#controls'); |
|
|
|
var $controls = $('#controls'); |
|
|
|
|
|
|
|
|
|
|
|
delete FileList._reloadCall; |
|
|
|
delete FileList._reloadCall; |
|
|
@ -217,17 +218,17 @@ var FileList={ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (result.status === 404){ |
|
|
|
if (result.status === 404) { |
|
|
|
// go back home
|
|
|
|
// go back home
|
|
|
|
FileList.changeDirectory('/'); |
|
|
|
FileList.changeDirectory('/'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (result.data.permissions){ |
|
|
|
if (result.data.permissions) { |
|
|
|
FileList.setDirectoryPermissions(result.data.permissions); |
|
|
|
FileList.setDirectoryPermissions(result.data.permissions); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(typeof(result.data.breadcrumb) != 'undefined'){ |
|
|
|
if (typeof(result.data.breadcrumb) !== 'undefined') { |
|
|
|
$controls.find('.crumb').remove(); |
|
|
|
$controls.find('.crumb').remove(); |
|
|
|
$controls.prepend(result.data.breadcrumb); |
|
|
|
$controls.prepend(result.data.breadcrumb); |
|
|
|
|
|
|
|
|
|
|
@ -236,14 +237,14 @@ var FileList={ |
|
|
|
Files.resizeBreadcrumbs(width, true); |
|
|
|
Files.resizeBreadcrumbs(width, true); |
|
|
|
|
|
|
|
|
|
|
|
// in case svg is not supported by the browser we need to execute the fallback mechanism
|
|
|
|
// in case svg is not supported by the browser we need to execute the fallback mechanism
|
|
|
|
if(!SVGSupport()) { |
|
|
|
if (!SVGSupport()) { |
|
|
|
replaceSVG(); |
|
|
|
replaceSVG(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileList.update(result.data.files); |
|
|
|
FileList.update(result.data.files); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setDirectoryPermissions: function(permissions){ |
|
|
|
setDirectoryPermissions: function(permissions) { |
|
|
|
var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; |
|
|
|
var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; |
|
|
|
$('#permissions').val(permissions); |
|
|
|
$('#permissions').val(permissions); |
|
|
|
$('.creatable').toggleClass('hidden', !isCreatable); |
|
|
|
$('.creatable').toggleClass('hidden', !isCreatable); |
|
|
@ -278,66 +279,68 @@ var FileList={ |
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); |
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); |
|
|
|
$('tr').filterAttr('data-file',name).remove(); |
|
|
|
$('tr').filterAttr('data-file',name).remove(); |
|
|
|
FileList.updateFileSummary(); |
|
|
|
FileList.updateFileSummary(); |
|
|
|
if($('tr[data-file]').length==0){ |
|
|
|
if ( ! $('tr[data-file]').exists() ) { |
|
|
|
$('#emptycontent').removeClass('hidden'); |
|
|
|
$('#emptycontent').removeClass('hidden'); |
|
|
|
$('#filescontent th').addClass('hidden'); |
|
|
|
$('#filescontent th').addClass('hidden'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
insertElement:function(name,type,element){ |
|
|
|
insertElement:function(name, type, element) { |
|
|
|
//find the correct spot to insert the file or folder
|
|
|
|
//find the correct spot to insert the file or folder
|
|
|
|
var pos, fileElements=$('tr[data-file][data-type="'+type+'"]:visible'); |
|
|
|
var pos, fileElements=$('tr[data-file][data-type="'+type+'"]:visible'); |
|
|
|
if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){ |
|
|
|
if (name.localeCompare($(fileElements[0]).attr('data-file')) < 0) { |
|
|
|
pos=-1; |
|
|
|
pos = -1; |
|
|
|
}else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){ |
|
|
|
} else if (name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file')) > 0) { |
|
|
|
pos=fileElements.length-1; |
|
|
|
pos = fileElements.length - 1; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
for(pos=0;pos<fileElements.length-1;pos++){ |
|
|
|
for(pos = 0; pos<fileElements.length-1; pos++) { |
|
|
|
if(name.localeCompare($(fileElements[pos]).attr('data-file'))>0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){ |
|
|
|
if (name.localeCompare($(fileElements[pos]).attr('data-file')) > 0 |
|
|
|
|
|
|
|
&& name.localeCompare($(fileElements[pos+1]).attr('data-file')) < 0) |
|
|
|
|
|
|
|
{ |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(fileElements.length){ |
|
|
|
if (fileElements.exists()) { |
|
|
|
if(pos==-1){ |
|
|
|
if (pos === -1) { |
|
|
|
$(fileElements[0]).before(element); |
|
|
|
$(fileElements[0]).before(element); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$(fileElements[pos]).after(element); |
|
|
|
$(fileElements[pos]).after(element); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(type=='dir' && $('tr[data-file]').length>0){ |
|
|
|
} else if (type === 'dir' && $('tr[data-file]').exists()) { |
|
|
|
$('tr[data-file]').first().before(element); |
|
|
|
$('tr[data-file]').first().before(element); |
|
|
|
} else if(type=='file' && $('tr[data-file]').length>0) { |
|
|
|
} else if (type === 'file' && $('tr[data-file]').exists()) { |
|
|
|
$('tr[data-file]').last().before(element); |
|
|
|
$('tr[data-file]').last().before(element); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$('#fileList').append(element); |
|
|
|
$('#fileList').append(element); |
|
|
|
} |
|
|
|
} |
|
|
|
$('#emptycontent').addClass('hidden'); |
|
|
|
$('#emptycontent').addClass('hidden'); |
|
|
|
$('#filestable th').removeClass('hidden'); |
|
|
|
$('#filestable th').removeClass('hidden'); |
|
|
|
FileList.updateFileSummary(); |
|
|
|
FileList.updateFileSummary(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
loadingDone:function(name, id){ |
|
|
|
loadingDone:function(name, id) { |
|
|
|
var mime, tr=$('tr').filterAttr('data-file',name); |
|
|
|
var mime, tr = $('tr[data-file="'+name+'"]'); |
|
|
|
tr.data('loading',false); |
|
|
|
tr.data('loading', false); |
|
|
|
mime=tr.data('mime'); |
|
|
|
mime = tr.data('mime'); |
|
|
|
tr.attr('data-mime',mime); |
|
|
|
tr.attr('data-mime', mime); |
|
|
|
if (id != null) { |
|
|
|
if (id) { |
|
|
|
tr.attr('data-id', id); |
|
|
|
tr.attr('data-id', id); |
|
|
|
} |
|
|
|
} |
|
|
|
var path = getPathForPreview(name); |
|
|
|
var path = getPathForPreview(name); |
|
|
|
lazyLoadPreview(path, mime, function(previewpath){ |
|
|
|
lazyLoadPreview(path, mime, function(previewpath) { |
|
|
|
tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); |
|
|
|
tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
tr.find('td.filename').draggable(dragOptions); |
|
|
|
tr.find('td.filename').draggable(dragOptions); |
|
|
|
}, |
|
|
|
}, |
|
|
|
isLoading:function(name){ |
|
|
|
isLoading:function(name) { |
|
|
|
return $('tr').filterAttr('data-file',name).data('loading'); |
|
|
|
return $('tr[data-file="'+name+'"]').data('loading'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
rename:function(name){ |
|
|
|
rename:function(oldname) { |
|
|
|
var tr, td, input, form; |
|
|
|
var tr, td, input, form; |
|
|
|
tr=$('tr').filterAttr('data-file',name); |
|
|
|
tr = $('tr[data-file="'+oldname+'"]'); |
|
|
|
tr.data('renaming',true); |
|
|
|
tr.data('renaming',true); |
|
|
|
td=tr.children('td.filename'); |
|
|
|
td = tr.children('td.filename'); |
|
|
|
input=$('<input type="text" class="filename"/>').val(name); |
|
|
|
input = $('<input type="text" class="filename"/>').val(oldname); |
|
|
|
form=$('<form></form>'); |
|
|
|
form = $('<form></form>'); |
|
|
|
form.append(input); |
|
|
|
form.append(input); |
|
|
|
td.children('a.name').hide(); |
|
|
|
td.children('a.name').hide(); |
|
|
|
td.append(form); |
|
|
|
td.append(form); |
|
|
@ -347,18 +350,29 @@ var FileList={ |
|
|
|
if (len === -1) { |
|
|
|
if (len === -1) { |
|
|
|
len = input.val().length; |
|
|
|
len = input.val().length; |
|
|
|
} |
|
|
|
} |
|
|
|
input.selectRange(0,len); |
|
|
|
input.selectRange(0, len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var checkInput = function () { |
|
|
|
|
|
|
|
var filename = input.val(); |
|
|
|
|
|
|
|
if (filename !== oldname) { |
|
|
|
|
|
|
|
if (!Files.isFileNameValid(filename)) { |
|
|
|
|
|
|
|
// Files.isFileNameValid(filename) throws an exception itself
|
|
|
|
|
|
|
|
} else if($('#dir').val() === '/' && filename === 'Shared') { |
|
|
|
|
|
|
|
throw t('files','In the home folder \'Shared\' is a reserved filename'); |
|
|
|
|
|
|
|
} else if (FileList.inList(filename)) { |
|
|
|
|
|
|
|
throw t('files', '{new_name} already exists', {new_name: filename}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
form.submit(function(event){ |
|
|
|
form.submit(function(event) { |
|
|
|
event.stopPropagation(); |
|
|
|
event.stopPropagation(); |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
var newname=input.val(); |
|
|
|
try { |
|
|
|
if (!Files.isFileNameValid(newname)) { |
|
|
|
var newname = input.val(); |
|
|
|
return false; |
|
|
|
if (newname !== oldname) { |
|
|
|
} else if (newname != name) { |
|
|
|
checkInput(); |
|
|
|
if (FileList.checkName(name, newname, false)) { |
|
|
|
|
|
|
|
newname = name; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// save background image, because it's replaced by a spinner while async request
|
|
|
|
// save background image, because it's replaced by a spinner while async request
|
|
|
|
var oldBackgroundImage = td.css('background-image'); |
|
|
|
var oldBackgroundImage = td.css('background-image'); |
|
|
|
// mark as loading
|
|
|
|
// mark as loading
|
|
|
@ -368,16 +382,16 @@ var FileList={ |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
dir : $('#dir').val(), |
|
|
|
dir : $('#dir').val(), |
|
|
|
newname: newname, |
|
|
|
newname: newname, |
|
|
|
file: name |
|
|
|
file: oldname |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function(result) { |
|
|
|
success: function(result) { |
|
|
|
if (!result || result.status === 'error') { |
|
|
|
if (!result || result.status === 'error') { |
|
|
|
OC.Notification.show(result.data.message); |
|
|
|
OC.dialogs.alert(result.data.message, t('core', 'Could not rename file')); |
|
|
|
newname = name; |
|
|
|
|
|
|
|
// revert changes
|
|
|
|
// revert changes
|
|
|
|
|
|
|
|
newname = oldname; |
|
|
|
tr.attr('data-file', newname); |
|
|
|
tr.attr('data-file', newname); |
|
|
|
var path = td.children('a.name').attr('href'); |
|
|
|
var path = td.children('a.name').attr('href'); |
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname))); |
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newname))); |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
var basename=newname.substr(0,newname.lastIndexOf('.')); |
|
|
|
var basename=newname.substr(0,newname.lastIndexOf('.')); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -385,7 +399,7 @@ var FileList={ |
|
|
|
} |
|
|
|
} |
|
|
|
td.find('a.name span.nametext').text(basename); |
|
|
|
td.find('a.name span.nametext').text(basename); |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
if (td.find('a.name span.extension').length === 0 ) { |
|
|
|
if ( ! td.find('a.name span.extension').exists() ) { |
|
|
|
td.find('a.name span.nametext').append('<span class="extension"></span>'); |
|
|
|
td.find('a.name span.nametext').append('<span class="extension"></span>'); |
|
|
|
} |
|
|
|
} |
|
|
|
td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); |
|
|
|
td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); |
|
|
@ -393,70 +407,76 @@ var FileList={ |
|
|
|
tr.find('.fileactions').effect('highlight', {}, 5000); |
|
|
|
tr.find('.fileactions').effect('highlight', {}, 5000); |
|
|
|
tr.effect('highlight', {}, 5000); |
|
|
|
tr.effect('highlight', {}, 5000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// reinsert row
|
|
|
|
|
|
|
|
tr.detach(); |
|
|
|
|
|
|
|
FileList.insertElement( tr.attr('data-file'), tr.attr('data-type'),tr ); |
|
|
|
// remove loading mark and recover old image
|
|
|
|
// remove loading mark and recover old image
|
|
|
|
td.css('background-image', oldBackgroundImage); |
|
|
|
td.css('background-image', oldBackgroundImage); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
input.tipsy('hide'); |
|
|
|
tr.data('renaming',false); |
|
|
|
tr.data('renaming',false); |
|
|
|
tr.attr('data-file', newname); |
|
|
|
tr.attr('data-file', newname); |
|
|
|
var path = td.children('a.name').attr('href'); |
|
|
|
var path = td.children('a.name').attr('href'); |
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname))); |
|
|
|
// FIXME this will fail if the path contains the filename.
|
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { |
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newname))); |
|
|
|
var basename=newname.substr(0,newname.lastIndexOf('.')); |
|
|
|
var basename = newname; |
|
|
|
} else { |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
var basename=newname; |
|
|
|
basename = newname.substr(0, newname.lastIndexOf('.')); |
|
|
|
}
|
|
|
|
}
|
|
|
|
td.find('a.name span.nametext').text(basename); |
|
|
|
td.find('a.name span.nametext').text(basename); |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { |
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { |
|
|
|
if (td.find('a.name span.extension').length == 0 ) { |
|
|
|
if ( ! td.find('a.name span.extension').exists() ) { |
|
|
|
td.find('a.name span.nametext').append('<span class="extension"></span>'); |
|
|
|
td.find('a.name span.nametext').append('<span class="extension"></span>'); |
|
|
|
} |
|
|
|
} |
|
|
|
td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); |
|
|
|
td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); |
|
|
|
} |
|
|
|
} |
|
|
|
form.remove(); |
|
|
|
form.remove(); |
|
|
|
td.children('a.name').show(); |
|
|
|
td.children('a.name').show(); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
input.attr('title', error); |
|
|
|
|
|
|
|
input.tipsy({gravity: 'w', trigger: 'manual'}); |
|
|
|
|
|
|
|
input.tipsy('show'); |
|
|
|
|
|
|
|
input.addClass('error'); |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
input.keyup(function(event){ |
|
|
|
input.keyup(function(event) { |
|
|
|
if (event.keyCode == 27) { |
|
|
|
// verify filename on typing
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
checkInput(); |
|
|
|
|
|
|
|
input.tipsy('hide'); |
|
|
|
|
|
|
|
input.removeClass('error'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
input.attr('title', error); |
|
|
|
|
|
|
|
input.tipsy({gravity: 'w', trigger: 'manual'}); |
|
|
|
|
|
|
|
input.tipsy('show'); |
|
|
|
|
|
|
|
input.addClass('error'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (event.keyCode === 27) { |
|
|
|
|
|
|
|
input.tipsy('hide'); |
|
|
|
tr.data('renaming',false); |
|
|
|
tr.data('renaming',false); |
|
|
|
form.remove(); |
|
|
|
form.remove(); |
|
|
|
td.children('a.name').show(); |
|
|
|
td.children('a.name').show(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
input.click(function(event){ |
|
|
|
input.click(function(event) { |
|
|
|
event.stopPropagation(); |
|
|
|
event.stopPropagation(); |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
input.blur(function(){ |
|
|
|
input.blur(function() { |
|
|
|
form.trigger('submit'); |
|
|
|
form.trigger('submit'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
checkName:function(oldName, newName, isNewFile) { |
|
|
|
inList:function(filename) { |
|
|
|
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) { |
|
|
|
return $('#fileList tr[data-file="'+filename+'"]').length; |
|
|
|
var html; |
|
|
|
|
|
|
|
if(isNewFile){ |
|
|
|
|
|
|
|
html = t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span> <span class="cancel">'+t('files', 'cancel')+'</span>'; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
html = t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
html = $('<span>' + html + '</span>'); |
|
|
|
|
|
|
|
html.attr('data-oldName', oldName); |
|
|
|
|
|
|
|
html.attr('data-newName', newName); |
|
|
|
|
|
|
|
html.attr('data-isNewFile', isNewFile); |
|
|
|
|
|
|
|
OC.Notification.showHtml(html); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
replace:function(oldName, newName, isNewFile) { |
|
|
|
replace:function(oldName, newName, isNewFile) { |
|
|
|
// Finish any existing actions
|
|
|
|
// Finish any existing actions
|
|
|
|
$('tr').filterAttr('data-file', oldName).hide(); |
|
|
|
$('tr[data-file="'+oldName+'"]').hide(); |
|
|
|
$('tr').filterAttr('data-file', newName).hide(); |
|
|
|
$('tr[data-file="'+newName+'"]').hide(); |
|
|
|
var tr = $('tr').filterAttr('data-file', oldName).clone(); |
|
|
|
var tr = $('tr[data-file="'+oldName+'"]').clone(); |
|
|
|
tr.attr('data-replace', 'true'); |
|
|
|
tr.attr('data-replace', 'true'); |
|
|
|
tr.attr('data-file', newName); |
|
|
|
tr.attr('data-file', newName); |
|
|
|
var td = tr.children('td.filename'); |
|
|
|
var td = tr.children('td.filename'); |
|
|
@ -491,8 +511,8 @@ var FileList={ |
|
|
|
finishReplace:function() { |
|
|
|
finishReplace:function() { |
|
|
|
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) { |
|
|
|
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) { |
|
|
|
$.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) { |
|
|
|
$.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) { |
|
|
|
if (result && result.status == 'success') { |
|
|
|
if (result && result.status === 'success') { |
|
|
|
$('tr').filterAttr('data-replace', 'true').removeAttr('data-replace'); |
|
|
|
$('tr[data-replace="true"').removeAttr('data-replace'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
OC.dialogs.alert(result.data.message, 'Error moving file'); |
|
|
|
OC.dialogs.alert(result.data.message, 'Error moving file'); |
|
|
|
} |
|
|
|
} |
|
|
@ -503,12 +523,12 @@ var FileList={ |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
do_delete:function(files){ |
|
|
|
do_delete:function(files) { |
|
|
|
if(files.substr){ |
|
|
|
if (files.substr) { |
|
|
|
files=[files]; |
|
|
|
files=[files]; |
|
|
|
} |
|
|
|
} |
|
|
|
for (var i=0; i<files.length; i++) { |
|
|
|
for (var i=0; i<files.length; i++) { |
|
|
|
var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date").children(".action.delete"); |
|
|
|
var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); |
|
|
|
deleteAction.removeClass('delete-icon').addClass('progress-icon'); |
|
|
|
deleteAction.removeClass('delete-icon').addClass('progress-icon'); |
|
|
|
} |
|
|
|
} |
|
|
|
// Finish any existing actions
|
|
|
|
// Finish any existing actions
|
|
|
@ -519,10 +539,10 @@ var FileList={ |
|
|
|
var fileNames = JSON.stringify(files); |
|
|
|
var fileNames = JSON.stringify(files); |
|
|
|
$.post(OC.filePath('files', 'ajax', 'delete.php'), |
|
|
|
$.post(OC.filePath('files', 'ajax', 'delete.php'), |
|
|
|
{dir:$('#dir').val(),files:fileNames}, |
|
|
|
{dir:$('#dir').val(),files:fileNames}, |
|
|
|
function(result){ |
|
|
|
function(result) { |
|
|
|
if (result.status == 'success') { |
|
|
|
if (result.status === 'success') { |
|
|
|
$.each(files,function(index,file){ |
|
|
|
$.each(files,function(index,file) { |
|
|
|
var files = $('tr').filterAttr('data-file',file); |
|
|
|
var files = $('tr[data-file="'+file+'"]'); |
|
|
|
files.remove(); |
|
|
|
files.remove(); |
|
|
|
files.find('input[type="checkbox"]').removeAttr('checked'); |
|
|
|
files.find('input[type="checkbox"]').removeAttr('checked'); |
|
|
|
files.removeClass('selected'); |
|
|
|
files.removeClass('selected'); |
|
|
@ -533,14 +553,14 @@ var FileList={ |
|
|
|
FileList.updateEmptyContent(); |
|
|
|
FileList.updateEmptyContent(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$.each(files,function(index,file) { |
|
|
|
$.each(files,function(index,file) { |
|
|
|
var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date").children(".action.delete"); |
|
|
|
var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); |
|
|
|
deleteAction.removeClass('progress-icon').addClass('delete-icon'); |
|
|
|
deleteAction.removeClass('progress-icon').addClass('delete-icon'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
createFileSummary: function() { |
|
|
|
createFileSummary: function() { |
|
|
|
if( $('#fileList tr').length > 0 ) { |
|
|
|
if ( $('#fileList tr').exists() ) { |
|
|
|
var totalDirs = 0; |
|
|
|
var totalDirs = 0; |
|
|
|
var totalFiles = 0; |
|
|
|
var totalFiles = 0; |
|
|
|
var totalSize = 0; |
|
|
|
var totalSize = 0; |
|
|
@ -562,7 +582,7 @@ var FileList={ |
|
|
|
var infoVars = { |
|
|
|
var infoVars = { |
|
|
|
dirs: '<span class="dirinfo">'+directoryInfo+'</span><span class="connector">', |
|
|
|
dirs: '<span class="dirinfo">'+directoryInfo+'</span><span class="connector">', |
|
|
|
files: '</span><span class="fileinfo">'+fileInfo+'</span>' |
|
|
|
files: '</span><span class="fileinfo">'+fileInfo+'</span>' |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var info = t('files', '{dirs} and {files}', infoVars); |
|
|
|
var info = t('files', '{dirs} and {files}', infoVars); |
|
|
|
|
|
|
|
|
|
|
@ -644,17 +664,17 @@ var FileList={ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
updateEmptyContent: function(){ |
|
|
|
updateEmptyContent: function() { |
|
|
|
var $fileList = $('#fileList'); |
|
|
|
var $fileList = $('#fileList'); |
|
|
|
var permissions = $('#permissions').val(); |
|
|
|
var permissions = $('#permissions').val(); |
|
|
|
var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; |
|
|
|
var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; |
|
|
|
$('#emptycontent').toggleClass('hidden', !isCreatable || $fileList.find('tr').length > 0); |
|
|
|
$('#emptycontent').toggleClass('hidden', !isCreatable || $fileList.find('tr').exists()); |
|
|
|
$('#filestable th').toggleClass('hidden', $fileList.find('tr').length === 0); |
|
|
|
$('#filestable th').toggleClass('hidden', $fileList.find('tr').exists() === false); |
|
|
|
}, |
|
|
|
}, |
|
|
|
showMask: function(){ |
|
|
|
showMask: function() { |
|
|
|
// in case one was shown before
|
|
|
|
// in case one was shown before
|
|
|
|
var $mask = $('#content .mask'); |
|
|
|
var $mask = $('#content .mask'); |
|
|
|
if ($mask.length){ |
|
|
|
if ($mask.exists()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -665,31 +685,31 @@ var FileList={ |
|
|
|
$('#content').append($mask); |
|
|
|
$('#content').append($mask); |
|
|
|
|
|
|
|
|
|
|
|
// block UI, but only make visible in case loading takes longer
|
|
|
|
// block UI, but only make visible in case loading takes longer
|
|
|
|
FileList._maskTimeout = window.setTimeout(function(){ |
|
|
|
FileList._maskTimeout = window.setTimeout(function() { |
|
|
|
// reset opacity
|
|
|
|
// reset opacity
|
|
|
|
$mask.removeClass('transparent'); |
|
|
|
$mask.removeClass('transparent'); |
|
|
|
}, 250); |
|
|
|
}, 250); |
|
|
|
}, |
|
|
|
}, |
|
|
|
hideMask: function(){ |
|
|
|
hideMask: function() { |
|
|
|
var $mask = $('#content .mask').remove(); |
|
|
|
var $mask = $('#content .mask').remove(); |
|
|
|
if (FileList._maskTimeout){ |
|
|
|
if (FileList._maskTimeout) { |
|
|
|
window.clearTimeout(FileList._maskTimeout); |
|
|
|
window.clearTimeout(FileList._maskTimeout); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
scrollTo:function(file) { |
|
|
|
scrollTo:function(file) { |
|
|
|
//scroll to and highlight preselected file
|
|
|
|
//scroll to and highlight preselected file
|
|
|
|
var scrolltorow = $('tr[data-file="'+file+'"]'); |
|
|
|
var $scrolltorow = $('tr[data-file="'+file+'"]'); |
|
|
|
if (scrolltorow.length > 0) { |
|
|
|
if ($scrolltorow.exists()) { |
|
|
|
scrolltorow.addClass('searchresult'); |
|
|
|
$scrolltorow.addClass('searchresult'); |
|
|
|
$(window).scrollTop(scrolltorow.position().top); |
|
|
|
$(window).scrollTop($scrolltorow.position().top); |
|
|
|
//remove highlight when hovered over
|
|
|
|
//remove highlight when hovered over
|
|
|
|
scrolltorow.one('hover', function(){ |
|
|
|
$scrolltorow.one('hover', function() { |
|
|
|
scrolltorow.removeClass('searchresult'); |
|
|
|
$scrolltorow.removeClass('searchresult'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
filter:function(query){ |
|
|
|
filter:function(query) { |
|
|
|
$('#fileList tr:not(.summary)').each(function(i,e){ |
|
|
|
$('#fileList tr:not(.summary)').each(function(i,e) { |
|
|
|
if ($(e).data('file').toLowerCase().indexOf(query.toLowerCase()) !== -1) { |
|
|
|
if ($(e).data('file').toLowerCase().indexOf(query.toLowerCase()) !== -1) { |
|
|
|
$(e).addClass("searchresult"); |
|
|
|
$(e).addClass("searchresult"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -698,18 +718,18 @@ var FileList={ |
|
|
|
}); |
|
|
|
}); |
|
|
|
//do not use scrollto to prevent removing searchresult css class
|
|
|
|
//do not use scrollto to prevent removing searchresult css class
|
|
|
|
var first = $('#fileList tr.searchresult').first(); |
|
|
|
var first = $('#fileList tr.searchresult').first(); |
|
|
|
if (first.length !== 0) { |
|
|
|
if (first.exists()) { |
|
|
|
$(window).scrollTop(first.position().top); |
|
|
|
$(window).scrollTop(first.position().top); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
unfilter:function(){ |
|
|
|
unfilter:function() { |
|
|
|
$('#fileList tr.searchresult').each(function(i,e){ |
|
|
|
$('#fileList tr.searchresult').each(function(i,e) { |
|
|
|
$(e).removeClass("searchresult"); |
|
|
|
$(e).removeClass("searchresult"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function(){ |
|
|
|
$(document).ready(function() { |
|
|
|
var isPublic = !!$('#isPublic').val(); |
|
|
|
var isPublic = !!$('#isPublic').val(); |
|
|
|
|
|
|
|
|
|
|
|
// handle upload events
|
|
|
|
// handle upload events
|
|
|
@ -719,16 +739,16 @@ $(document).ready(function(){ |
|
|
|
OC.Upload.log('filelist handle fileuploaddrop', e, data); |
|
|
|
OC.Upload.log('filelist handle fileuploaddrop', e, data); |
|
|
|
|
|
|
|
|
|
|
|
var dropTarget = $(e.originalEvent.target).closest('tr, .crumb'); |
|
|
|
var dropTarget = $(e.originalEvent.target).closest('tr, .crumb'); |
|
|
|
if(dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder
|
|
|
|
if (dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder
|
|
|
|
|
|
|
|
|
|
|
|
// remember as context
|
|
|
|
// remember as context
|
|
|
|
data.context = dropTarget; |
|
|
|
data.context = dropTarget; |
|
|
|
|
|
|
|
|
|
|
|
var dir = dropTarget.data('file'); |
|
|
|
var dir = dropTarget.data('file'); |
|
|
|
// if from file list, need to prepend parent dir
|
|
|
|
// if from file list, need to prepend parent dir
|
|
|
|
if (dir){ |
|
|
|
if (dir) { |
|
|
|
var parentDir = $('#dir').val() || '/'; |
|
|
|
var parentDir = $('#dir').val() || '/'; |
|
|
|
if (parentDir[parentDir.length - 1] != '/'){ |
|
|
|
if (parentDir[parentDir.length - 1] !== '/') { |
|
|
|
parentDir += '/'; |
|
|
|
parentDir += '/'; |
|
|
|
} |
|
|
|
} |
|
|
|
dir = parentDir + dir; |
|
|
|
dir = parentDir + dir; |
|
|
@ -752,12 +772,12 @@ $(document).ready(function(){ |
|
|
|
OC.Upload.log('filelist handle fileuploadadd', e, data); |
|
|
|
OC.Upload.log('filelist handle fileuploadadd', e, data); |
|
|
|
|
|
|
|
|
|
|
|
//finish delete if we are uploading a deleted file
|
|
|
|
//finish delete if we are uploading a deleted file
|
|
|
|
if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1){ |
|
|
|
if (FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1) { |
|
|
|
FileList.finishDelete(null, true); //delete file before continuing
|
|
|
|
FileList.finishDelete(null, true); //delete file before continuing
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// add ui visualization to existing folder
|
|
|
|
// add ui visualization to existing folder
|
|
|
|
if(data.context && data.context.data('type') === 'dir') { |
|
|
|
if (data.context && data.context.data('type') === 'dir') { |
|
|
|
// add to existing folder
|
|
|
|
// add to existing folder
|
|
|
|
|
|
|
|
|
|
|
|
// update upload counter ui
|
|
|
|
// update upload counter ui
|
|
|
@ -767,7 +787,7 @@ $(document).ready(function(){ |
|
|
|
uploadtext.attr('currentUploads', currentUploads); |
|
|
|
uploadtext.attr('currentUploads', currentUploads); |
|
|
|
|
|
|
|
|
|
|
|
var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); |
|
|
|
var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); |
|
|
|
if(currentUploads === 1) { |
|
|
|
if (currentUploads === 1) { |
|
|
|
var img = OC.imagePath('core', 'loading.gif'); |
|
|
|
var img = OC.imagePath('core', 'loading.gif'); |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+img+')'); |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+img+')'); |
|
|
|
uploadtext.text(translatedText); |
|
|
|
uploadtext.text(translatedText); |
|
|
@ -794,7 +814,7 @@ $(document).ready(function(){ |
|
|
|
} |
|
|
|
} |
|
|
|
var result=$.parseJSON(response); |
|
|
|
var result=$.parseJSON(response); |
|
|
|
|
|
|
|
|
|
|
|
if(typeof result[0] !== 'undefined' && result[0].status === 'success') { |
|
|
|
if (typeof result[0] !== 'undefined' && result[0].status === 'success') { |
|
|
|
var file = result[0]; |
|
|
|
var file = result[0]; |
|
|
|
|
|
|
|
|
|
|
|
if (data.context && data.context.data('type') === 'dir') { |
|
|
|
if (data.context && data.context.data('type') === 'dir') { |
|
|
@ -805,7 +825,7 @@ $(document).ready(function(){ |
|
|
|
currentUploads -= 1; |
|
|
|
currentUploads -= 1; |
|
|
|
uploadtext.attr('currentUploads', currentUploads); |
|
|
|
uploadtext.attr('currentUploads', currentUploads); |
|
|
|
var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); |
|
|
|
var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); |
|
|
|
if(currentUploads === 0) { |
|
|
|
if (currentUploads === 0) { |
|
|
|
var img = OC.imagePath('core', 'filetypes/folder.png'); |
|
|
|
var img = OC.imagePath('core', 'filetypes/folder.png'); |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+img+')'); |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+img+')'); |
|
|
|
uploadtext.text(translatedText); |
|
|
|
uploadtext.text(translatedText); |
|
|
@ -822,18 +842,18 @@ $(document).ready(function(){ |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// only append new file if dragged onto current dir's crumb (last)
|
|
|
|
// only append new file if dragged onto current dir's crumb (last)
|
|
|
|
if (data.context && data.context.hasClass('crumb') && !data.context.hasClass('last')){ |
|
|
|
if (data.context && data.context.hasClass('crumb') && !data.context.hasClass('last')) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// add as stand-alone row to filelist
|
|
|
|
// add as stand-alone row to filelist
|
|
|
|
var size=t('files', 'Pending'); |
|
|
|
var size=t('files', 'Pending'); |
|
|
|
if (data.files[0].size>=0){ |
|
|
|
if (data.files[0].size>=0) { |
|
|
|
size=data.files[0].size; |
|
|
|
size=data.files[0].size; |
|
|
|
} |
|
|
|
} |
|
|
|
var date=new Date(); |
|
|
|
var date=new Date(); |
|
|
|
var param = {}; |
|
|
|
var param = {}; |
|
|
|
if ($('#publicUploadRequestToken').length) { |
|
|
|
if ($('#publicUploadRequestToken').exists()) { |
|
|
|
param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + file.name; |
|
|
|
param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + file.name; |
|
|
|
} |
|
|
|
} |
|
|
|
//should the file exist in the list remove it
|
|
|
|
//should the file exist in the list remove it
|
|
|
@ -846,14 +866,14 @@ $(document).ready(function(){ |
|
|
|
data.context.attr('data-mime',file.mime).attr('data-id',file.id); |
|
|
|
data.context.attr('data-mime',file.mime).attr('data-id',file.id); |
|
|
|
|
|
|
|
|
|
|
|
var permissions = data.context.data('permissions'); |
|
|
|
var permissions = data.context.data('permissions'); |
|
|
|
if(permissions !== file.permissions) { |
|
|
|
if (permissions !== file.permissions) { |
|
|
|
data.context.attr('data-permissions', file.permissions); |
|
|
|
data.context.attr('data-permissions', file.permissions); |
|
|
|
data.context.data('permissions', file.permissions); |
|
|
|
data.context.data('permissions', file.permissions); |
|
|
|
} |
|
|
|
} |
|
|
|
FileActions.display(data.context.find('td.filename'), true); |
|
|
|
FileActions.display(data.context.find('td.filename'), true); |
|
|
|
|
|
|
|
|
|
|
|
var path = getPathForPreview(file.name); |
|
|
|
var path = getPathForPreview(file.name); |
|
|
|
lazyLoadPreview(path, file.mime, function(previewpath){ |
|
|
|
lazyLoadPreview(path, file.mime, function(previewpath) { |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+previewpath+')'); |
|
|
|
data.context.find('td.filename').attr('style','background-image:url('+previewpath+')'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -887,10 +907,10 @@ $(document).ready(function(){ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$('#notification').hide(); |
|
|
|
$('#notification').hide(); |
|
|
|
$('#notification').on('click', '.undo', function(){ |
|
|
|
$('#notification').on('click', '.undo', function() { |
|
|
|
if (FileList.deleteFiles) { |
|
|
|
if (FileList.deleteFiles) { |
|
|
|
$.each(FileList.deleteFiles,function(index,file){ |
|
|
|
$.each(FileList.deleteFiles,function(index,file) { |
|
|
|
$('tr').filterAttr('data-file',file).show(); |
|
|
|
$('tr[data-file="'+file+'"]').show(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
FileList.deleteCanceled=true; |
|
|
|
FileList.deleteCanceled=true; |
|
|
|
FileList.deleteFiles=null; |
|
|
|
FileList.deleteFiles=null; |
|
|
@ -900,10 +920,10 @@ $(document).ready(function(){ |
|
|
|
FileList.deleteCanceled = false; |
|
|
|
FileList.deleteCanceled = false; |
|
|
|
FileList.deleteFiles = [FileList.replaceOldName]; |
|
|
|
FileList.deleteFiles = [FileList.replaceOldName]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$('tr').filterAttr('data-file', FileList.replaceOldName).show(); |
|
|
|
$('tr[data-file="'+FileList.replaceOldName+'"]').show(); |
|
|
|
} |
|
|
|
} |
|
|
|
$('tr').filterAttr('data-replace', 'true').remove(); |
|
|
|
$('tr[data-replace="true"').remove(); |
|
|
|
$('tr').filterAttr('data-file', FileList.replaceNewName).show(); |
|
|
|
$('tr[data-file="'+FileList.replaceNewName+'"]').show(); |
|
|
|
FileList.replaceCanceled = true; |
|
|
|
FileList.replaceCanceled = true; |
|
|
|
FileList.replaceOldName = null; |
|
|
|
FileList.replaceOldName = null; |
|
|
|
FileList.replaceNewName = null; |
|
|
|
FileList.replaceNewName = null; |
|
|
@ -918,7 +938,7 @@ $(document).ready(function(){ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#notification:first-child').on('click', '.suggest', function() { |
|
|
|
$('#notification:first-child').on('click', '.suggest', function() { |
|
|
|
$('tr').filterAttr('data-file', $('#notification > span').attr('data-oldName')).show(); |
|
|
|
$('tr[data-file="'+$('#notification > span').attr('data-oldName')+'"]').show(); |
|
|
|
OC.Notification.hide(); |
|
|
|
OC.Notification.hide(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#notification:first-child').on('click', '.cancel', function() { |
|
|
|
$('#notification:first-child').on('click', '.cancel', function() { |
|
|
@ -928,67 +948,67 @@ $(document).ready(function(){ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
FileList.useUndo=(window.onbeforeunload)?true:false; |
|
|
|
FileList.useUndo=(window.onbeforeunload)?true:false; |
|
|
|
$(window).bind('beforeunload', function (){ |
|
|
|
$(window).bind('beforeunload', function () { |
|
|
|
if (FileList.lastAction) { |
|
|
|
if (FileList.lastAction) { |
|
|
|
FileList.lastAction(); |
|
|
|
FileList.lastAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
$(window).unload(function (){ |
|
|
|
$(window).unload(function () { |
|
|
|
$(window).trigger('beforeunload'); |
|
|
|
$(window).trigger('beforeunload'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function decodeQuery(query){ |
|
|
|
function decodeQuery(query) { |
|
|
|
return query.replace(/\+/g, ' '); |
|
|
|
return query.replace(/\+/g, ' '); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parseHashQuery(){ |
|
|
|
function parseHashQuery() { |
|
|
|
var hash = window.location.hash, |
|
|
|
var hash = window.location.hash, |
|
|
|
pos = hash.indexOf('?'), |
|
|
|
pos = hash.indexOf('?'), |
|
|
|
query; |
|
|
|
query; |
|
|
|
if (pos >= 0){ |
|
|
|
if (pos >= 0) { |
|
|
|
return hash.substr(pos + 1); |
|
|
|
return hash.substr(pos + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
return ''; |
|
|
|
return ''; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parseCurrentDirFromUrl(){ |
|
|
|
function parseCurrentDirFromUrl() { |
|
|
|
var query = parseHashQuery(), |
|
|
|
var query = parseHashQuery(), |
|
|
|
params, |
|
|
|
params, |
|
|
|
dir = '/'; |
|
|
|
dir = '/'; |
|
|
|
// try and parse from URL hash first
|
|
|
|
// try and parse from URL hash first
|
|
|
|
if (query){ |
|
|
|
if (query) { |
|
|
|
params = OC.parseQueryString(decodeQuery(query)); |
|
|
|
params = OC.parseQueryString(decodeQuery(query)); |
|
|
|
} |
|
|
|
} |
|
|
|
// else read from query attributes
|
|
|
|
// else read from query attributes
|
|
|
|
if (!params){ |
|
|
|
if (!params) { |
|
|
|
params = OC.parseQueryString(decodeQuery(location.search)); |
|
|
|
params = OC.parseQueryString(decodeQuery(location.search)); |
|
|
|
} |
|
|
|
} |
|
|
|
return (params && params.dir) || '/'; |
|
|
|
return (params && params.dir) || '/'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// disable ajax/history API for public app (TODO: until it gets ported)
|
|
|
|
// disable ajax/history API for public app (TODO: until it gets ported)
|
|
|
|
if (!isPublic){ |
|
|
|
if (!isPublic) { |
|
|
|
// fallback to hashchange when no history support
|
|
|
|
// fallback to hashchange when no history support
|
|
|
|
if (!window.history.pushState){ |
|
|
|
if (!window.history.pushState) { |
|
|
|
$(window).on('hashchange', function(){ |
|
|
|
$(window).on('hashchange', function() { |
|
|
|
FileList.changeDirectory(parseCurrentDirFromUrl(), false); |
|
|
|
FileList.changeDirectory(parseCurrentDirFromUrl(), false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
window.onpopstate = function(e){ |
|
|
|
window.onpopstate = function(e) { |
|
|
|
var targetDir; |
|
|
|
var targetDir; |
|
|
|
if (e.state && e.state.dir){ |
|
|
|
if (e.state && e.state.dir) { |
|
|
|
targetDir = e.state.dir; |
|
|
|
targetDir = e.state.dir; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
// read from URL
|
|
|
|
// read from URL
|
|
|
|
targetDir = parseCurrentDirFromUrl(); |
|
|
|
targetDir = parseCurrentDirFromUrl(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (targetDir){ |
|
|
|
if (targetDir) { |
|
|
|
FileList.changeDirectory(targetDir, false); |
|
|
|
FileList.changeDirectory(targetDir, false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (parseInt($('#ajaxLoad').val(), 10) === 1){ |
|
|
|
if (parseInt($('#ajaxLoad').val(), 10) === 1) { |
|
|
|
// need to initially switch the dir to the one from the hash (IE8)
|
|
|
|
// need to initially switch the dir to the one from the hash (IE8)
|
|
|
|
FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); |
|
|
|
FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); |
|
|
|
} |
|
|
|
} |
|
|
|