2012-09-04 19:27:04 +00:00
|
|
|
var FileList={
|
2012-04-15 13:48:02 +00:00
|
|
|
useUndo:true,
|
2011-06-04 16:44:14 +00:00
|
|
|
update:function(fileListHtml) {
|
|
|
|
$('#fileList').empty().html(fileListHtml);
|
|
|
|
},
|
2012-09-05 04:12:11 +00:00
|
|
|
addFile:function(name,size,lastModified,loading,hidden){
|
2011-10-07 16:09:49 +00:00
|
|
|
var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png');
|
2012-09-06 01:46:59 +00:00
|
|
|
var html='<tr data-type="file" data-size="'+size+'" data-permissions="'+$('#permissions').val()+'">';
|
2011-07-28 21:52:49 +00:00
|
|
|
if(name.indexOf('.')!=-1){
|
2011-08-28 19:39:17 +00:00
|
|
|
var basename=name.substr(0,name.lastIndexOf('.'));
|
2012-04-15 11:32:45 +00:00
|
|
|
var extension=name.substr(name.lastIndexOf('.'));
|
2011-07-28 21:52:49 +00:00
|
|
|
}else{
|
|
|
|
var basename=name;
|
2012-04-15 11:32:45 +00:00
|
|
|
var extension=false;
|
2011-07-28 21:52:49 +00:00
|
|
|
}
|
2011-08-02 01:17:26 +00:00
|
|
|
html+='<td class="filename" style="background-image:url('+img+')"><input type="checkbox" />';
|
2012-09-04 19:27:04 +00:00
|
|
|
html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '<').replace(/>/, '>')+'/'+name+'"><span class="nametext">'+basename;
|
2012-04-15 11:32:45 +00:00
|
|
|
if(extension){
|
|
|
|
html+='<span class="extension">'+extension+'</span>';
|
2011-07-28 21:52:49 +00:00
|
|
|
}
|
|
|
|
html+='</span></a></td>';
|
|
|
|
if(size!='Pending'){
|
|
|
|
simpleSize=simpleFileSize(size);
|
|
|
|
}else{
|
|
|
|
simpleSize='Pending';
|
|
|
|
}
|
2011-07-30 13:42:34 +00:00
|
|
|
sizeColor = Math.round(200-size/(1024*1024)*2);
|
2011-07-28 23:10:08 +00:00
|
|
|
lastModifiedTime=Math.round(lastModified.getTime() / 1000);
|
2011-07-30 13:31:11 +00:00
|
|
|
modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*14);
|
2011-07-28 21:52:49 +00:00
|
|
|
html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
|
2011-09-25 18:18:33 +00:00
|
|
|
html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>';
|
2011-06-04 16:44:14 +00:00
|
|
|
html+='</tr>';
|
2011-11-01 21:35:13 +00:00
|
|
|
FileList.insertElement(name,'file',$(html).attr('data-file',name));
|
2011-07-19 18:57:40 +00:00
|
|
|
if(loading){
|
2011-11-01 21:35:13 +00:00
|
|
|
$('tr').filterAttr('data-file',name).data('loading',true);
|
2011-07-19 18:57:40 +00:00
|
|
|
}else{
|
2011-11-01 21:35:13 +00:00
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
|
2011-07-19 18:57:40 +00:00
|
|
|
}
|
2012-09-05 04:12:11 +00:00
|
|
|
if (hidden) {
|
|
|
|
$('tr').filterAttr('data-file', name).hide();
|
|
|
|
}
|
2011-06-04 16:44:14 +00:00
|
|
|
},
|
2012-09-05 04:12:11 +00:00
|
|
|
addDir:function(name,size,lastModified,hidden){
|
2012-09-06 01:46:59 +00:00
|
|
|
html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name, "data-permissions": $('#permissions').val()});
|
2011-11-01 21:35:13 +00:00
|
|
|
td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' });
|
|
|
|
td.append('<input type="checkbox" />');
|
2012-05-31 17:46:32 +00:00
|
|
|
var link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') });
|
2011-11-01 21:35:13 +00:00
|
|
|
link_elem.append($('<span></span>').addClass('nametext').text(name));
|
2012-03-27 19:38:55 +00:00
|
|
|
link_elem.append($('<span></span>').attr({'class': 'uploadtext', 'currentUploads': 0}));
|
2011-11-01 21:35:13 +00:00
|
|
|
td.append(link_elem);
|
|
|
|
html.append(td);
|
2011-07-28 23:10:08 +00:00
|
|
|
if(size!='Pending'){
|
|
|
|
simpleSize=simpleFileSize(size);
|
|
|
|
}else{
|
|
|
|
simpleSize='Pending';
|
|
|
|
}
|
|
|
|
sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
|
|
|
|
lastModifiedTime=Math.round(lastModified.getTime() / 1000);
|
|
|
|
modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
|
2011-11-01 21:35:13 +00:00
|
|
|
td = $('<td></td>').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize);
|
|
|
|
html.append(td);
|
2012-05-31 17:46:32 +00:00
|
|
|
|
2011-11-01 21:35:13 +00:00
|
|
|
td = $('<td></td>').attr({ "class": "date" });
|
|
|
|
td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) ));
|
|
|
|
html.append(td);
|
|
|
|
FileList.insertElement(name,'dir',html);
|
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
|
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').droppable(folderDropOptions);
|
2012-09-05 04:12:11 +00:00
|
|
|
if (hidden) {
|
|
|
|
$('tr').filterAttr('data-file', name).hide();
|
|
|
|
}
|
2011-06-04 16:44:14 +00:00
|
|
|
},
|
|
|
|
refresh:function(data) {
|
|
|
|
result = jQuery.parseJSON(data.responseText);
|
|
|
|
if(typeof(result.data.breadcrumb) != 'undefined'){
|
|
|
|
updateBreadcrumb(result.data.breadcrumb);
|
|
|
|
}
|
|
|
|
FileList.update(result.data.files);
|
|
|
|
resetFileActionPanel();
|
|
|
|
},
|
|
|
|
remove:function(name){
|
2011-11-01 21:35:13 +00:00
|
|
|
$('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
|
|
|
|
$('tr').filterAttr('data-file',name).remove();
|
2011-07-30 12:42:58 +00:00
|
|
|
if($('tr[data-file]').length==0){
|
|
|
|
$('#emptyfolder').show();
|
|
|
|
$('.file_upload_filename').addClass('highlight');
|
|
|
|
}
|
2011-06-04 16:44:14 +00:00
|
|
|
},
|
|
|
|
insertElement:function(name,type,element){
|
|
|
|
//find the correct spot to insert the file or folder
|
2012-09-05 04:12:11 +00:00
|
|
|
var fileElements=$('tr[data-file][data-type="'+type+'"]:visible');
|
2011-06-04 16:44:14 +00:00
|
|
|
var pos;
|
|
|
|
if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){
|
2011-07-26 14:55:28 +00:00
|
|
|
pos=-1;
|
2011-06-04 16:44:14 +00:00
|
|
|
}else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){
|
|
|
|
pos=fileElements.length-1;
|
|
|
|
}else{
|
2011-07-26 14:55:28 +00:00
|
|
|
for(var pos=0;pos<fileElements.length-1;pos++){
|
2011-06-04 16:44:14 +00:00
|
|
|
if(name.localeCompare($(fileElements[pos]).attr('data-file'))>0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-04 19:46:20 +00:00
|
|
|
if(fileElements.length){
|
2011-07-26 14:55:28 +00:00
|
|
|
if(pos==-1){
|
|
|
|
$(fileElements[0]).before(element);
|
|
|
|
}else{
|
|
|
|
$(fileElements[pos]).after(element);
|
|
|
|
}
|
|
|
|
}else if(type=='dir' && $('tr[data-file]').length>0){
|
|
|
|
$('tr[data-file]').first().before(element);
|
2011-07-04 19:46:20 +00:00
|
|
|
}else{
|
|
|
|
$('#fileList').append(element);
|
|
|
|
}
|
2011-07-30 12:42:58 +00:00
|
|
|
$('#emptyfolder').hide();
|
|
|
|
$('.file_upload_filename').removeClass('highlight');
|
2011-07-19 18:57:40 +00:00
|
|
|
},
|
|
|
|
loadingDone:function(name){
|
2011-11-01 21:35:13 +00:00
|
|
|
var tr=$('tr').filterAttr('data-file',name);
|
2011-10-08 19:18:47 +00:00
|
|
|
tr.data('loading',false);
|
|
|
|
var mime=tr.data('mime');
|
|
|
|
tr.attr('data-mime',mime);
|
|
|
|
getMimeIcon(mime,function(path){
|
|
|
|
tr.find('td.filename').attr('style','background-image:url('+path+')');
|
|
|
|
});
|
|
|
|
tr.find('td.filename').draggable(dragOptions);
|
2011-07-19 18:57:40 +00:00
|
|
|
},
|
|
|
|
isLoading:function(name){
|
2011-11-01 21:35:13 +00:00
|
|
|
return $('tr').filterAttr('data-file',name).data('loading');
|
2011-07-28 21:04:34 +00:00
|
|
|
},
|
|
|
|
rename:function(name){
|
2011-11-01 21:35:13 +00:00
|
|
|
var tr=$('tr').filterAttr('data-file',name);
|
2011-07-29 00:26:20 +00:00
|
|
|
tr.data('renaming',true);
|
2011-07-28 21:04:34 +00:00
|
|
|
var td=tr.children('td.filename');
|
2011-11-01 21:35:13 +00:00
|
|
|
var input=$('<input class="filename"></input>').val(name);
|
2011-12-05 22:51:44 +00:00
|
|
|
var form=$('<form></form>')
|
2011-07-28 21:04:34 +00:00
|
|
|
form.append(input);
|
|
|
|
td.children('a.name').text('');
|
|
|
|
td.children('a.name').append(form)
|
|
|
|
input.focus();
|
|
|
|
form.submit(function(event){
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
2011-07-29 15:51:17 +00:00
|
|
|
var newname=input.val();
|
2012-07-30 16:21:58 +00:00
|
|
|
if (newname != name) {
|
2012-09-05 04:12:11 +00:00
|
|
|
if (FileList.checkName(name, newname, false)) {
|
2012-07-30 16:21:58 +00:00
|
|
|
newname = name;
|
|
|
|
} else {
|
|
|
|
$.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(result) {
|
|
|
|
if (!result || result.status == 'error') {
|
|
|
|
OC.dialogs.alert(result.data.message, 'Error moving file');
|
|
|
|
newname = name;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tr.attr('data-file', newname);
|
2011-12-28 17:47:27 +00:00
|
|
|
var path = td.children('a.name').attr('href');
|
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
|
2012-09-18 22:08:34 +00:00
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
|
2012-07-30 16:21:58 +00:00
|
|
|
var basename=newname.substr(0,newname.lastIndexOf('.'));
|
|
|
|
} else {
|
|
|
|
var basename=newname;
|
2011-07-29 00:17:40 +00:00
|
|
|
}
|
2012-07-30 16:21:58 +00:00
|
|
|
td.children('a.name').empty();
|
2011-07-29 15:51:17 +00:00
|
|
|
var span=$('<span class="nametext"></span>');
|
|
|
|
span.text(basename);
|
|
|
|
td.children('a.name').append(span);
|
2012-09-18 22:08:34 +00:00
|
|
|
if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
|
2012-04-15 11:32:45 +00:00
|
|
|
span.append($('<span class="extension">'+newname.substr(newname.lastIndexOf('.'))+'</span>'));
|
2011-07-29 00:17:40 +00:00
|
|
|
}
|
2012-07-30 16:21:58 +00:00
|
|
|
tr.data('renaming',false);
|
2011-12-05 22:51:44 +00:00
|
|
|
return false;
|
2011-07-28 21:04:34 +00:00
|
|
|
});
|
2011-12-05 22:51:44 +00:00
|
|
|
input.click(function(event){
|
2011-07-28 21:04:34 +00:00
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
input.blur(function(){
|
2011-07-29 15:51:17 +00:00
|
|
|
form.trigger('submit');
|
2011-07-28 21:04:34 +00:00
|
|
|
});
|
2011-08-03 22:22:44 +00:00
|
|
|
},
|
2012-09-05 04:12:11 +00:00
|
|
|
checkName:function(oldName, newName, isNewFile) {
|
|
|
|
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
|
|
|
if (isNewFile) {
|
|
|
|
$('#notification').html(newName+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
|
|
|
} else {
|
|
|
|
$('#notification').html(newName+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
|
|
|
}
|
|
|
|
$('#notification').data('oldName', oldName);
|
|
|
|
$('#notification').data('newName', newName);
|
|
|
|
$('#notification').data('isNewFile', isNewFile);
|
|
|
|
$('#notification').fadeIn();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
replace:function(oldName, newName, isNewFile) {
|
2012-07-30 16:21:58 +00:00
|
|
|
// Finish any existing actions
|
|
|
|
if (FileList.lastAction || !FileList.useUndo) {
|
|
|
|
FileList.lastAction();
|
|
|
|
}
|
2012-09-05 04:12:11 +00:00
|
|
|
$('tr').filterAttr('data-file', oldName).hide();
|
|
|
|
$('tr').filterAttr('data-file', newName).hide();
|
|
|
|
var tr = $('tr').filterAttr('data-file', oldName).clone();
|
|
|
|
tr.attr('data-replace', 'true');
|
|
|
|
tr.attr('data-file', newName);
|
|
|
|
var td = tr.children('td.filename');
|
|
|
|
td.children('a.name .span').text(newName);
|
|
|
|
var path = td.children('a.name').attr('href');
|
|
|
|
td.children('a.name').attr('href', path.replace(encodeURIComponent(oldName), encodeURIComponent(newName)));
|
|
|
|
if (newName.indexOf('.') > 0) {
|
|
|
|
var basename = newName.substr(0, newName.lastIndexOf('.'));
|
|
|
|
} else {
|
|
|
|
var basename = newName;
|
|
|
|
}
|
|
|
|
td.children('a.name').empty();
|
|
|
|
var span = $('<span class="nametext"></span>');
|
|
|
|
span.text(basename);
|
|
|
|
td.children('a.name').append(span);
|
|
|
|
if (newName.indexOf('.') > 0) {
|
|
|
|
span.append($('<span class="extension">'+newName.substr(newName.lastIndexOf('.'))+'</span>'));
|
|
|
|
}
|
|
|
|
FileList.insertElement(newName, tr.data('type'), tr);
|
|
|
|
tr.show();
|
2012-07-30 16:21:58 +00:00
|
|
|
FileList.replaceCanceled = false;
|
|
|
|
FileList.replaceOldName = oldName;
|
|
|
|
FileList.replaceNewName = newName;
|
2012-09-05 04:12:11 +00:00
|
|
|
FileList.replaceIsNewFile = isNewFile;
|
2012-08-20 15:24:10 +00:00
|
|
|
FileList.lastAction = function() {
|
2012-07-30 16:21:58 +00:00
|
|
|
FileList.finishReplace();
|
|
|
|
};
|
2012-09-05 04:12:11 +00:00
|
|
|
if (isNewFile) {
|
|
|
|
$('#notification').html(t('files', 'replaced')+' '+newName+'<span class="undo">'+t('files', 'undo')+'</span>');
|
|
|
|
} else {
|
|
|
|
$('#notification').html(t('files', 'replaced')+' '+newName+' '+t('files', 'with')+' '+oldName+'<span class="undo">'+t('files', 'undo')+'</span>');
|
|
|
|
}
|
2012-07-30 16:21:58 +00:00
|
|
|
$('#notification').fadeIn();
|
|
|
|
},
|
|
|
|
finishReplace:function() {
|
|
|
|
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
|
2012-09-06 02:13:50 +00:00
|
|
|
$.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') {
|
|
|
|
$('tr').filterAttr('data-replace', 'true').removeAttr('data-replace');
|
|
|
|
} else {
|
|
|
|
OC.dialogs.alert(result.data.message, 'Error moving file');
|
|
|
|
}
|
|
|
|
FileList.replaceCanceled = true;
|
|
|
|
FileList.replaceOldName = null;
|
|
|
|
FileList.replaceNewName = null;
|
|
|
|
FileList.lastAction = null;
|
|
|
|
}});
|
2012-07-30 16:21:58 +00:00
|
|
|
}
|
|
|
|
},
|
2011-08-27 23:32:48 +00:00
|
|
|
do_delete:function(files){
|
2012-07-30 16:21:58 +00:00
|
|
|
// Finish any existing actions
|
|
|
|
if (FileList.lastAction || !FileList.useUndo) {
|
2012-08-20 15:24:10 +00:00
|
|
|
if(!FileList.deleteFiles) {
|
|
|
|
FileList.prepareDeletion(files);
|
|
|
|
}
|
2012-07-30 16:21:58 +00:00
|
|
|
FileList.lastAction();
|
2011-08-03 22:22:44 +00:00
|
|
|
}
|
2012-08-20 15:24:10 +00:00
|
|
|
FileList.prepareDeletion(files);
|
2012-09-07 04:01:52 +00:00
|
|
|
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
|
|
|
if ($('#dir').val() == '/Shared') {
|
|
|
|
$('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
|
|
|
} else {
|
|
|
|
$('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
|
|
|
}
|
2011-08-05 05:37:08 +00:00
|
|
|
$('#notification').fadeIn();
|
2011-08-03 22:22:44 +00:00
|
|
|
},
|
|
|
|
finishDelete:function(ready,sync){
|
|
|
|
if(!FileList.deleteCanceled && FileList.deleteFiles){
|
|
|
|
var fileNames=FileList.deleteFiles.join(';');
|
|
|
|
$.ajax({
|
2012-04-29 14:09:41 +00:00
|
|
|
url: OC.filePath('files', 'ajax', 'delete.php'),
|
2011-08-03 22:22:44 +00:00
|
|
|
async:!sync,
|
2012-04-29 14:09:41 +00:00
|
|
|
data: {dir:$('#dir').val(),files:fileNames},
|
2011-08-03 22:22:44 +00:00
|
|
|
complete: function(data){
|
|
|
|
boolOperationFinished(data, function(){
|
2012-09-05 04:12:11 +00:00
|
|
|
$('#notification').fadeOut('400');
|
2011-08-03 22:22:44 +00:00
|
|
|
$.each(FileList.deleteFiles,function(index,file){
|
|
|
|
FileList.remove(file);
|
|
|
|
});
|
|
|
|
FileList.deleteCanceled=true;
|
|
|
|
FileList.deleteFiles=null;
|
2012-07-30 16:21:58 +00:00
|
|
|
FileList.lastAction = null;
|
2011-08-03 22:22:44 +00:00
|
|
|
if(ready){
|
|
|
|
ready();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2012-08-20 15:24:10 +00:00
|
|
|
},
|
|
|
|
prepareDeletion:function(files){
|
|
|
|
if(files.substr){
|
|
|
|
files=[files];
|
|
|
|
}
|
|
|
|
$.each(files,function(index,file){
|
|
|
|
var files = $('tr').filterAttr('data-file',file);
|
|
|
|
files.hide();
|
|
|
|
files.find('input[type="checkbox"]').removeAttr('checked');
|
|
|
|
files.removeClass('selected');
|
|
|
|
});
|
|
|
|
procesSelection();
|
|
|
|
FileList.deleteCanceled=false;
|
|
|
|
FileList.deleteFiles=files;
|
|
|
|
FileList.lastAction = function() {
|
|
|
|
FileList.finishDelete(null, true);
|
|
|
|
};
|
2011-06-04 16:44:14 +00:00
|
|
|
}
|
2011-07-04 19:46:20 +00:00
|
|
|
}
|
2011-08-03 22:22:44 +00:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2011-08-05 05:37:08 +00:00
|
|
|
$('#notification').hide();
|
2012-07-29 20:00:46 +00:00
|
|
|
$('#notification .undo').live('click', function(){
|
2012-07-30 16:21:58 +00:00
|
|
|
if (FileList.deleteFiles) {
|
2011-10-17 18:39:01 +00:00
|
|
|
$.each(FileList.deleteFiles,function(index,file){
|
2011-11-01 21:35:13 +00:00
|
|
|
$('tr').filterAttr('data-file',file).show();
|
2011-10-17 18:39:01 +00:00
|
|
|
});
|
|
|
|
FileList.deleteCanceled=true;
|
|
|
|
FileList.deleteFiles=null;
|
2012-07-30 16:21:58 +00:00
|
|
|
} else if (FileList.replaceOldName && FileList.replaceNewName) {
|
2012-09-05 04:12:11 +00:00
|
|
|
if (FileList.replaceIsNewFile) {
|
|
|
|
// Delete the new uploaded file
|
|
|
|
FileList.deleteCanceled = false;
|
|
|
|
FileList.deleteFiles = [FileList.replaceOldName];
|
|
|
|
FileList.finishDelete(null, true);
|
|
|
|
} else {
|
|
|
|
$('tr').filterAttr('data-file', FileList.replaceOldName).show();
|
|
|
|
}
|
|
|
|
$('tr').filterAttr('data-replace', 'true').remove();
|
|
|
|
$('tr').filterAttr('data-file', FileList.replaceNewName).show();
|
2012-07-30 16:21:58 +00:00
|
|
|
FileList.replaceCanceled = true;
|
|
|
|
FileList.replaceOldName = null;
|
|
|
|
FileList.replaceNewName = null;
|
2012-09-05 04:12:11 +00:00
|
|
|
FileList.replaceIsNewFile = null;
|
2011-10-17 18:39:01 +00:00
|
|
|
}
|
2012-08-22 21:08:10 +00:00
|
|
|
FileList.lastAction = null;
|
2012-09-05 04:12:11 +00:00
|
|
|
$('#notification').fadeOut('400');
|
2011-08-03 22:22:44 +00:00
|
|
|
});
|
2012-07-30 16:21:58 +00:00
|
|
|
$('#notification .replace').live('click', function() {
|
|
|
|
$('#notification').fadeOut('400', function() {
|
2012-09-05 04:12:11 +00:00
|
|
|
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
2012-07-30 16:21:58 +00:00
|
|
|
});
|
|
|
|
});
|
2012-09-05 04:12:11 +00:00
|
|
|
$('#notification .suggest').live('click', function() {
|
|
|
|
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
|
|
|
$('#notification').fadeOut('400');
|
|
|
|
});
|
2012-07-30 16:21:58 +00:00
|
|
|
$('#notification .cancel').live('click', function() {
|
2012-09-05 04:12:11 +00:00
|
|
|
if ($('#notification').data('isNewFile')) {
|
|
|
|
FileList.deleteCanceled = false;
|
|
|
|
FileList.deleteFiles = [$('#notification').data('oldName')];
|
|
|
|
FileList.finishDelete(null, true);
|
|
|
|
}
|
2012-07-30 16:21:58 +00:00
|
|
|
});
|
2012-04-15 13:48:02 +00:00
|
|
|
FileList.useUndo=('onbeforeunload' in window)
|
2011-08-03 22:22:44 +00:00
|
|
|
$(window).bind('beforeunload', function (){
|
2012-07-30 16:21:58 +00:00
|
|
|
if (FileList.lastAction) {
|
|
|
|
FileList.lastAction();
|
|
|
|
}
|
2011-08-03 22:22:44 +00:00
|
|
|
});
|
|
|
|
});
|