diff options
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 034045ee40b..ae38511ec05 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -116,7 +116,7 @@ ownerDisplayName = $('#ownerDisplayName').val(); if (usedSpacePercent > 98) { if (owner !== oc_current_user) { - OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', + OC.Notification.showTemporary(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', { owner: ownerDisplayName })); return; } @@ -125,7 +125,7 @@ } if (usedSpacePercent > 90) { if (owner !== oc_current_user) { - OC.Notification.show(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)', + OC.Notification.showTemporary(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)', { usedSpacePercent: usedSpacePercent, owner: ownerDisplayName })); return; } @@ -234,7 +234,6 @@ // display storage warnings setTimeout(Files.displayStorageWarnings, 100); - OC.Notification.setDefault(Files.displayStorageWarnings); // only possible at the moment if user is logged in or the files app is loaded if (OC.currentUser && OCA.Files.App) { @@ -247,12 +246,12 @@ // Use jquery-visibility to de-/re-activate file stats sync if ($.support.pageVisibility) { $(document).on({ - 'show.visibility': function() { + 'show': function() { if (!updateStorageStatisticsIntervalId) { updateStorageStatisticsIntervalId = setInterval(func, updateStorageStatisticsInterval); } }, - 'hide.visibility': function() { + 'hide': function() { clearInterval(updateStorageStatisticsIntervalId); updateStorageStatisticsIntervalId = 0; } @@ -265,14 +264,46 @@ $('#webdavurl').select(); }); + $('#upload').tooltip({placement:'right'}); + //FIXME scroll to and highlight preselected file /* if (getURLParameter('scrollto')) { FileList.scrollTo(getURLParameter('scrollto')); } */ + }, + + /** + * Handles the download and calls the callback function once the download has started + * - browser sends download request and adds parameter with a token + * - server notices this token and adds a set cookie to the download response + * - browser now adds this cookie for the domain + * - JS periodically checks for this cookie and then knows when the download has started to call the callback + * + * @param {string} url download URL + * @param {function} callback function to call once the download has started + */ + handleDownload: function(url, callback) { + var randomToken = Math.random().toString(36).substring(2), + checkForDownloadCookie = function() { + if (!OC.Util.isCookieSetToValue('ocDownloadStarted', randomToken)){ + return false; + } else { + callback(); + return true; + } + }; + + if (url.indexOf('?') >= 0) { + url += '&'; + } else { + url += '?'; + } + OC.redirect(url + 'downloadStartSecret=' + randomToken); + OC.Util.waitFor(checkForDownloadCookie, 500); } - } + }; Files._updateStorageStatisticsDebounced = _.debounce(Files._updateStorageStatistics, 250); OCA.Files.Files = Files; @@ -307,6 +338,9 @@ function scanFiles(force, dir, users) { scannerEventSource.listen('folder',function(path) { console.log('now scanning ' + path); }); + scannerEventSource.listen('error',function(message) { + console.error('Scanner error: ', message); + }); scannerEventSource.listen('done',function(count) { scanFiles.scanning=false; console.log('done after ' + count + ' files'); @@ -327,7 +361,7 @@ var createDragShadow = function(event) { var isDragSelected = $(event.target).parents('tr').find('td input:first').prop('checked'); if (!isDragSelected) { //select dragged file - FileList._selectFileEl($(event.target).parents('tr:first'), true); + FileList._selectFileEl($(event.target).parents('tr:first'), true, false); } // do not show drag shadow for too many files @@ -336,7 +370,7 @@ var createDragShadow = function(event) { if (!isDragSelected && selectedFiles.length === 1) { //revert the selection - FileList._selectFileEl($(event.target).parents('tr:first'), false); + FileList._selectFileEl($(event.target).parents('tr:first'), false, false); } // build dragshadow @@ -384,22 +418,17 @@ var dragOptions={ cursor: 'move', start: function(event, ui){ var $selectedFiles = $('td.filename input:checkbox:checked'); - if($selectedFiles.length > 1){ - $selectedFiles.parents('tr').fadeTo(250, 0.2); - } - else{ - $(this).fadeTo(250, 0.2); + if (!$selectedFiles.length) { + $selectedFiles = $(this); } + $selectedFiles.closest('tr').fadeTo(250, 0.2).addClass('dragging'); }, stop: function(event, ui) { var $selectedFiles = $('td.filename input:checkbox:checked'); - if($selectedFiles.length > 1){ - $selectedFiles.parents('tr').fadeTo(250, 1); - } - else{ - $(this).fadeTo(250, 1); + if (!$selectedFiles.length) { + $selectedFiles = $(this); } - $('#fileList tr td.filename').addClass('ui-draggable'); + $selectedFiles.closest('tr').fadeTo(250, 1).removeClass('dragging'); } }; // sane browsers support using the distance option @@ -427,7 +456,9 @@ var folderDropOptions = { var files = FileList.getSelectedFiles(); if (files.length === 0) { // single one selected without checkbox? - files = _.map(ui.helper.find('tr'), FileList.elementToFile); + files = _.map(ui.helper.find('tr'), function(el) { + return FileList.elementToFile($(el)); + }); } FileList.move(_.pluck(files, 'name'), targetPath); |