diff options
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..6023cf78e79 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -30,14 +30,45 @@ Files={ var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { - $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); - $('#notification').fadeIn(); + Files.showNotification(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); return true; } } - $('#notification').fadeOut(); + Files.hideNotification(); return false; - } + }, + displayStorageWarnings: function() { + var usedSpacePercent = $('#usedSpacePercent').val(); + if (usedSpacePercent > 98) { + Files.showNotification(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + return; + } + if (usedSpacePercent > 90) { + Files.showNotification(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + } + }, + hideNotification: function(callback) { + $("#notification").text(''); + $('#notification').fadeOut('400', function(){ + if ($("#notification").text() === '') { + Files.displayStorageWarnings(); + } + if (callback) { + callback.call(); + } + }); + }, + showHtmlNotification: function(html) { + $('#notification').hide(); + $("#notification").html(html); + $("#notification").fadeIn(); + }, + showNotification: function(text) { + $('#notification').hide(); + $("#notification").text(text); + $("#notification").fadeIn(); + } + }; $(document).ready(function() { Files.bindKeyboardShortcuts(document, jQuery); @@ -171,8 +202,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - $('#notification').text(t('files','generating ZIP-file, it may take some time.')); - $('#notification').fadeIn(); + Files.showNotification(t('files','generating ZIP-file, it may take some time.')); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { window.location=downloadURL.value+"&download&files="+files; @@ -301,8 +331,7 @@ $(document).ready(function() { var response; response=jQuery.parseJSON(result); if(response[0] == undefined || response[0].status != 'success') { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); } var file=response[0]; // TODO: this doesn't work if the file name has been changed server side @@ -339,9 +368,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } - $('#notification').hide(); - $('#notification').text(t('files', 'Upload cancelled.')); - $('#notification').fadeIn(); + Files.showNotification(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -364,17 +391,14 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { - $('#notification').hide(); - $('#notification').text(t('files', 'Upload cancelled.')); - $('#notification').fadeIn(); + Files.showNotification(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -394,8 +418,7 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -512,8 +535,7 @@ $(document).ready(function() { if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); - $('#notification').fadeIn(); + Files.showNotification(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); return; } if (FileList.lastAction) { @@ -683,6 +705,9 @@ $(document).ready(function() { }); resizeBreadcrumbs(true); + + // display storage warnings + setTimeout ( "Files.displayStorageWarnings()", 100 ); }); function scanFiles(force,dir){ |