filelist.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. var FileList={
  2. useUndo:true,
  3. update:function(fileListHtml) {
  4. $('#fileList').empty().html(fileListHtml);
  5. },
  6. createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions){
  7. var td, simpleSize, basename, extension;
  8. //containing tr
  9. var tr = $('<tr></tr>').attr({
  10. "data-type": type,
  11. "data-size": size,
  12. "data-file": name,
  13. "data-permissions": permissions
  14. });
  15. // filename td
  16. td = $('<td></td>').attr({
  17. "class": "filename",
  18. "style": 'background-image:url('+iconurl+')'
  19. });
  20. td.append('<input type="checkbox" />');
  21. var link_elem = $('<a></a>').attr({
  22. "class": "name",
  23. "href": linktarget
  24. });
  25. //split extension from filename for non dirs
  26. if (type != 'dir' && name.indexOf('.')!=-1) {
  27. basename=name.substr(0,name.lastIndexOf('.'));
  28. extension=name.substr(name.lastIndexOf('.'));
  29. } else {
  30. basename=name;
  31. extension=false;
  32. }
  33. var name_span=$('<span></span>').addClass('nametext').text(basename);
  34. link_elem.append(name_span);
  35. if(extension){
  36. name_span.append($('<span></span>').addClass('extension').text(extension));
  37. }
  38. //dirs can show the number of uploaded files
  39. if (type == 'dir') {
  40. link_elem.append($('<span></span>').attr({
  41. 'class': 'uploadtext',
  42. 'currentUploads': 0
  43. }));
  44. }
  45. td.append(link_elem);
  46. tr.append(td);
  47. //size column
  48. if(size!=t('files', 'Pending')){
  49. simpleSize = humanFileSize(size);
  50. }else{
  51. simpleSize=t('files', 'Pending');
  52. }
  53. var sizeColor = Math.round(160-Math.pow((size/(1024*1024)),2));
  54. var lastModifiedTime = Math.round(lastModified.getTime() / 1000);
  55. td = $('<td></td>').attr({
  56. "class": "filesize",
  57. "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'
  58. }).text(simpleSize);
  59. tr.append(td);
  60. // date column
  61. var modifiedColor = Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
  62. td = $('<td></td>').attr({ "class": "date" });
  63. td.append($('<span></span>').attr({
  64. "class": "modified",
  65. "title": formatDate(lastModified),
  66. "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')'
  67. }).text( relative_modified_date(lastModified.getTime() / 1000) ));
  68. tr.append(td);
  69. return tr;
  70. },
  71. addFile:function(name,size,lastModified,loading,hidden,param){
  72. var imgurl;
  73. if (!param) {
  74. param = {};
  75. }
  76. var download_url = null;
  77. if (!param.download_url) {
  78. download_url = OC.Router.generate('download', { file: $('#dir').val()+'/'+name });
  79. } else {
  80. download_url = param.download_url;
  81. }
  82. if (loading) {
  83. imgurl = OC.imagePath('core', 'loading.gif');
  84. } else {
  85. imgurl = OC.imagePath('core', 'filetypes/file.png');
  86. }
  87. var tr = this.createRow(
  88. 'file',
  89. name,
  90. imgurl,
  91. download_url,
  92. size,
  93. lastModified,
  94. $('#permissions').val()
  95. );
  96. FileList.insertElement(name, 'file', tr);
  97. if(loading){
  98. tr.data('loading',true);
  99. }else{
  100. tr.find('td.filename').draggable(dragOptions);
  101. }
  102. if (hidden) {
  103. tr.hide();
  104. }
  105. FileActions.display(tr.find('td.filename'));
  106. return tr;
  107. },
  108. addDir:function(name,size,lastModified,hidden){
  109. var tr = this.createRow(
  110. 'dir',
  111. name,
  112. OC.imagePath('core', 'filetypes/folder.png'),
  113. OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/'),
  114. size,
  115. lastModified,
  116. $('#permissions').val()
  117. );
  118. FileList.insertElement(name,'dir',tr);
  119. var td = tr.find('td.filename');
  120. td.draggable(dragOptions);
  121. td.droppable(folderDropOptions);
  122. if (hidden) {
  123. tr.hide();
  124. }
  125. FileActions.display(tr.find('td.filename'));
  126. return tr;
  127. },
  128. refresh:function(data) {
  129. var result = jQuery.parseJSON(data.responseText);
  130. if(typeof(result.data.breadcrumb) != 'undefined'){
  131. updateBreadcrumb(result.data.breadcrumb);
  132. }
  133. FileList.update(result.data.files);
  134. resetFileActionPanel();
  135. },
  136. remove:function(name){
  137. $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
  138. $('tr').filterAttr('data-file',name).remove();
  139. if($('tr[data-file]').length==0){
  140. $('#emptyfolder').show();
  141. }
  142. },
  143. insertElement:function(name,type,element){
  144. //find the correct spot to insert the file or folder
  145. var pos, fileElements=$('tr[data-file][data-type="'+type+'"]:visible');
  146. if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){
  147. pos=-1;
  148. }else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){
  149. pos=fileElements.length-1;
  150. }else{
  151. for(pos=0;pos<fileElements.length-1;pos++){
  152. if(name.localeCompare($(fileElements[pos]).attr('data-file'))>0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){
  153. break;
  154. }
  155. }
  156. }
  157. if(fileElements.length){
  158. if(pos==-1){
  159. $(fileElements[0]).before(element);
  160. }else{
  161. $(fileElements[pos]).after(element);
  162. }
  163. }else if(type=='dir' && $('tr[data-file]').length>0){
  164. $('tr[data-file]').first().before(element);
  165. } else if(type=='file' && $('tr[data-file]').length>0) {
  166. $('tr[data-file]').last().before(element);
  167. }else{
  168. $('#fileList').append(element);
  169. }
  170. $('#emptyfolder').hide();
  171. },
  172. loadingDone:function(name, id){
  173. var mime, tr=$('tr').filterAttr('data-file',name);
  174. tr.data('loading',false);
  175. mime=tr.data('mime');
  176. tr.attr('data-mime',mime);
  177. if (id != null) {
  178. tr.attr('data-id', id);
  179. }
  180. getMimeIcon(mime,function(path){
  181. tr.find('td.filename').attr('style','background-image:url('+path+')');
  182. });
  183. tr.find('td.filename').draggable(dragOptions);
  184. },
  185. isLoading:function(name){
  186. return $('tr').filterAttr('data-file',name).data('loading');
  187. },
  188. rename:function(name){
  189. var tr, td, input, form;
  190. tr=$('tr').filterAttr('data-file',name);
  191. tr.data('renaming',true);
  192. td=tr.children('td.filename');
  193. input=$('<input class="filename"/>').val(name);
  194. form=$('<form></form>');
  195. form.append(input);
  196. td.children('a.name').hide();
  197. td.append(form);
  198. input.focus();
  199. //preselect input
  200. var len = input.val().lastIndexOf('.');
  201. if (len === -1) {
  202. len = input.val().length;
  203. }
  204. input.selectRange(0,len);
  205. form.submit(function(event){
  206. event.stopPropagation();
  207. event.preventDefault();
  208. var newname=input.val();
  209. if (!Files.isFileNameValid(newname)) {
  210. return false;
  211. } else if (newname != name) {
  212. if (FileList.checkName(name, newname, false)) {
  213. newname = name;
  214. } else {
  215. // save background image, because it's replaced by a spinner while async request
  216. var oldBackgroundImage = td.css('background-image');
  217. // mark as loading
  218. td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')');
  219. $.ajax({
  220. url: OC.filePath('files','ajax','rename.php'),
  221. data: {
  222. dir : $('#dir').val(),
  223. newname: newname,
  224. file: name
  225. },
  226. success: function(result) {
  227. if (!result || result.status === 'error') {
  228. OC.Notification.show(result.data.message);
  229. newname = name;
  230. // revert changes
  231. tr.attr('data-file', newname);
  232. var path = td.children('a.name').attr('href');
  233. td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
  234. if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') {
  235. var basename=newname.substr(0,newname.lastIndexOf('.'));
  236. } else {
  237. var basename=newname;
  238. }
  239. td.find('a.name span.nametext').text(basename);
  240. if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') {
  241. if (td.find('a.name span.extension').length === 0 ) {
  242. td.find('a.name span.nametext').append('<span class="extension"></span>');
  243. }
  244. td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.')));
  245. }
  246. tr.find('.fileactions').effect('highlight', {}, 5000);
  247. tr.effect('highlight', {}, 5000);
  248. }
  249. // remove loading mark and recover old image
  250. td.css('background-image', oldBackgroundImage);
  251. }
  252. });
  253. }
  254. }
  255. tr.data('renaming',false);
  256. tr.attr('data-file', newname);
  257. var path = td.children('a.name').attr('href');
  258. td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
  259. if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
  260. var basename=newname.substr(0,newname.lastIndexOf('.'));
  261. } else {
  262. var basename=newname;
  263. }
  264. td.find('a.name span.nametext').text(basename);
  265. if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
  266. if (td.find('a.name span.extension').length == 0 ) {
  267. td.find('a.name span.nametext').append('<span class="extension"></span>');
  268. }
  269. td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.')));
  270. }
  271. form.remove();
  272. td.children('a.name').show();
  273. return false;
  274. });
  275. input.keyup(function(event){
  276. if (event.keyCode == 27) {
  277. tr.data('renaming',false);
  278. form.remove();
  279. td.children('a.name').show();
  280. }
  281. });
  282. input.click(function(event){
  283. event.stopPropagation();
  284. event.preventDefault();
  285. });
  286. input.blur(function(){
  287. form.trigger('submit');
  288. });
  289. },
  290. checkName:function(oldName, newName, isNewFile) {
  291. if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
  292. var html;
  293. if(isNewFile){
  294. 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>&nbsp;<span class="cancel">'+t('files', 'cancel')+'</span>';
  295. }else{
  296. 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>';
  297. }
  298. html = $('<span>' + html + '</span>');
  299. html.attr('data-oldName', oldName);
  300. html.attr('data-newName', newName);
  301. html.attr('data-isNewFile', isNewFile);
  302. OC.Notification.showHtml(html);
  303. return true;
  304. } else {
  305. return false;
  306. }
  307. },
  308. replace:function(oldName, newName, isNewFile) {
  309. // Finish any existing actions
  310. $('tr').filterAttr('data-file', oldName).hide();
  311. $('tr').filterAttr('data-file', newName).hide();
  312. var tr = $('tr').filterAttr('data-file', oldName).clone();
  313. tr.attr('data-replace', 'true');
  314. tr.attr('data-file', newName);
  315. var td = tr.children('td.filename');
  316. td.children('a.name .span').text(newName);
  317. var path = td.children('a.name').attr('href');
  318. td.children('a.name').attr('href', path.replace(encodeURIComponent(oldName), encodeURIComponent(newName)));
  319. if (newName.indexOf('.') > 0) {
  320. var basename = newName.substr(0, newName.lastIndexOf('.'));
  321. } else {
  322. var basename = newName;
  323. }
  324. td.children('a.name').empty();
  325. var span = $('<span class="nametext"></span>');
  326. span.text(basename);
  327. td.children('a.name').append(span);
  328. if (newName.indexOf('.') > 0) {
  329. span.append($('<span class="extension">'+newName.substr(newName.lastIndexOf('.'))+'</span>'));
  330. }
  331. FileList.insertElement(newName, tr.data('type'), tr);
  332. tr.show();
  333. FileList.replaceCanceled = false;
  334. FileList.replaceOldName = oldName;
  335. FileList.replaceNewName = newName;
  336. FileList.replaceIsNewFile = isNewFile;
  337. FileList.lastAction = function() {
  338. FileList.finishReplace();
  339. };
  340. if (!isNewFile) {
  341. OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
  342. }
  343. },
  344. finishReplace:function() {
  345. if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
  346. $.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) {
  347. if (result && result.status == 'success') {
  348. $('tr').filterAttr('data-replace', 'true').removeAttr('data-replace');
  349. } else {
  350. OC.dialogs.alert(result.data.message, 'Error moving file');
  351. }
  352. FileList.replaceCanceled = true;
  353. FileList.replaceOldName = null;
  354. FileList.replaceNewName = null;
  355. FileList.lastAction = null;
  356. }});
  357. }
  358. },
  359. do_delete:function(files){
  360. if(files.substr){
  361. files=[files];
  362. }
  363. for (var i=0; i<files.length; i++) {
  364. var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date").children(".action.delete");
  365. var oldHTML = deleteAction.html();
  366. var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'perform delete operation')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
  367. deleteAction.html(newHTML);
  368. }
  369. // Finish any existing actions
  370. if (FileList.lastAction) {
  371. FileList.lastAction();
  372. }
  373. var fileNames = JSON.stringify(files);
  374. $.post(OC.filePath('files', 'ajax', 'delete.php'),
  375. {dir:$('#dir').val(),files:fileNames},
  376. function(result){
  377. if (result.status == 'success') {
  378. $.each(files,function(index,file){
  379. var files = $('tr').filterAttr('data-file',file);
  380. files.remove();
  381. files.find('input[type="checkbox"]').removeAttr('checked');
  382. files.removeClass('selected');
  383. });
  384. procesSelection();
  385. checkTrashStatus();
  386. } else {
  387. $.each(files,function(index,file) {
  388. var deleteAction = $('tr').filterAttr('data-file',file).children("td.date").children(".move2trash");
  389. deleteAction.html(oldHTML);
  390. });
  391. }
  392. });
  393. }
  394. };
  395. $(document).ready(function(){
  396. // handle upload events
  397. var file_upload_start = $('#file_upload_start');
  398. file_upload_start.on('fileuploaddrop', function(e, data) {
  399. // only handle drop to dir if fileList exists
  400. if ($('#fileList').length > 0) {
  401. var dropTarget = $(e.originalEvent.target).closest('tr');
  402. if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
  403. var dirName = dropTarget.data('file');
  404. // update folder in form
  405. data.formData = function(form) {
  406. var formArray = form.serializeArray();
  407. // array index 0 contains the max files size
  408. // array index 1 contains the request token
  409. // array index 2 contains the directory
  410. var parentDir = formArray[2]['value'];
  411. if (parentDir === '/') {
  412. formArray[2]['value'] += dirName;
  413. } else {
  414. formArray[2]['value'] += '/'+dirName;
  415. }
  416. return formArray;
  417. }
  418. }
  419. }
  420. });
  421. file_upload_start.on('fileuploadadd', function(e, data) {
  422. // only add to fileList if it exists
  423. if ($('#fileList').length > 0) {
  424. if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!=-1){//finish delete if we are uploading a deleted file
  425. FileList.finishDelete(null, true); //delete file before continuing
  426. }
  427. // add ui visualization to existing folder or as new stand-alone file?
  428. var dropTarget = $(e.originalEvent.target).closest('tr');
  429. if(dropTarget && dropTarget.data('type') === 'dir') {
  430. // add to existing folder
  431. var dirName = dropTarget.data('file');
  432. // set dir context
  433. data.context = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName);
  434. // update upload counter ui
  435. var uploadtext = data.context.find('.uploadtext');
  436. var currentUploads = parseInt(uploadtext.attr('currentUploads'));
  437. currentUploads += 1;
  438. uploadtext.attr('currentUploads', currentUploads);
  439. var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads);
  440. if(currentUploads === 1) {
  441. var img = OC.imagePath('core', 'loading.gif');
  442. data.context.find('td.filename').attr('style','background-image:url('+img+')');
  443. uploadtext.text(translatedText);
  444. uploadtext.show();
  445. } else {
  446. uploadtext.text(translatedText);
  447. }
  448. } else {
  449. // add as stand-alone row to filelist
  450. var uniqueName = getUniqueName(data.files[0].name);
  451. var size=t('files','Pending');
  452. if(data.files[0].size>=0){
  453. size=data.files[0].size;
  454. }
  455. var date=new Date();
  456. var param = {};
  457. if ($('#publicUploadRequestToken').length) {
  458. param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + uniqueName;
  459. }
  460. // create new file context
  461. data.context = FileList.addFile(uniqueName,size,date,true,false,param);
  462. }
  463. }
  464. });
  465. file_upload_start.on('fileuploaddone', function(e, data) {
  466. // only update the fileList if it exists
  467. if ($('#fileList').length > 0) {
  468. var response;
  469. if (typeof data.result === 'string') {
  470. response = data.result;
  471. } else {
  472. // fetch response from iframe
  473. response = data.result[0].body.innerText;
  474. }
  475. var result=$.parseJSON(response);
  476. if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
  477. var file = result[0];
  478. if (data.context.data('type') === 'file') {
  479. // update file data
  480. data.context.attr('data-mime',file.mime).attr('data-id',file.id);
  481. var size = data.context.data('size');
  482. if(size!=file.size){
  483. data.context.attr('data-size', file.size);
  484. data.context.find('td.filesize').text(humanFileSize(file.size));
  485. }
  486. if (FileList.loadingDone) {
  487. FileList.loadingDone(file.name, file.id);
  488. }
  489. } else {
  490. // update upload counter ui
  491. var uploadtext = data.context.find('.uploadtext');
  492. var currentUploads = parseInt(uploadtext.attr('currentUploads'));
  493. currentUploads -= 1;
  494. uploadtext.attr('currentUploads', currentUploads);
  495. if(currentUploads === 0) {
  496. var img = OC.imagePath('core', 'filetypes/folder.png');
  497. data.context.find('td.filename').attr('style','background-image:url('+img+')');
  498. uploadtext.text('');
  499. uploadtext.hide();
  500. } else {
  501. uploadtext.text(currentUploads + ' ' + t('files', 'files uploading'));
  502. }
  503. // update folder size
  504. var size = parseInt(data.context.data('size'));
  505. size += parseInt(file.size) ;
  506. data.context.attr('data-size', size);
  507. data.context.find('td.filesize').text(humanFileSize(size));
  508. }
  509. }
  510. }
  511. });
  512. file_upload_start.on('fileuploadfail', function(e, data) {
  513. // only update the fileList if it exists
  514. // cleanup files, error notification has been shown by fileupload code
  515. var tr = data.context;
  516. if (typeof tr === 'undefined') {
  517. tr = $('tr').filterAttr('data-file', data.files[0].name);
  518. }
  519. if (tr.attr('data-type') === 'dir') {
  520. //cleanup uploading to a dir
  521. var uploadtext = tr.find('.uploadtext');
  522. var img = OC.imagePath('core', 'filetypes/folder.png');
  523. tr.find('td.filename').attr('style','background-image:url('+img+')');
  524. uploadtext.text('');
  525. uploadtext.hide(); //TODO really hide already
  526. } else {
  527. //remove file
  528. tr.fadeOut();
  529. tr.remove();
  530. }
  531. });
  532. $('#notification').hide();
  533. $('#notification').on('click', '.undo', function(){
  534. if (FileList.deleteFiles) {
  535. $.each(FileList.deleteFiles,function(index,file){
  536. $('tr').filterAttr('data-file',file).show();
  537. });
  538. FileList.deleteCanceled=true;
  539. FileList.deleteFiles=null;
  540. } else if (FileList.replaceOldName && FileList.replaceNewName) {
  541. if (FileList.replaceIsNewFile) {
  542. // Delete the new uploaded file
  543. FileList.deleteCanceled = false;
  544. FileList.deleteFiles = [FileList.replaceOldName];
  545. } else {
  546. $('tr').filterAttr('data-file', FileList.replaceOldName).show();
  547. }
  548. $('tr').filterAttr('data-replace', 'true').remove();
  549. $('tr').filterAttr('data-file', FileList.replaceNewName).show();
  550. FileList.replaceCanceled = true;
  551. FileList.replaceOldName = null;
  552. FileList.replaceNewName = null;
  553. FileList.replaceIsNewFile = null;
  554. }
  555. FileList.lastAction = null;
  556. OC.Notification.hide();
  557. });
  558. $('#notification:first-child').on('click', '.replace', function() {
  559. OC.Notification.hide(function() {
  560. FileList.replace($('#notification > span').attr('data-oldName'), $('#notification > span').attr('data-newName'), $('#notification > span').attr('data-isNewFile'));
  561. });
  562. });
  563. $('#notification:first-child').on('click', '.suggest', function() {
  564. $('tr').filterAttr('data-file', $('#notification > span').attr('data-oldName')).show();
  565. OC.Notification.hide();
  566. });
  567. $('#notification:first-child').on('click', '.cancel', function() {
  568. if ($('#notification > span').attr('data-isNewFile')) {
  569. FileList.deleteCanceled = false;
  570. FileList.deleteFiles = [$('#notification > span').attr('data-oldName')];
  571. }
  572. });
  573. FileList.useUndo=(window.onbeforeunload)?true:false;
  574. $(window).bind('beforeunload', function (){
  575. if (FileList.lastAction) {
  576. FileList.lastAction();
  577. }
  578. });
  579. $(window).unload(function (){
  580. $(window).trigger('beforeunload');
  581. });
  582. });