summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-01-02 15:09:40 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-01-02 15:09:40 +0100
commit48f6dccdb768126ae71a1e4de4eca184891a6115 (patch)
treef6f4e0f00b030e93c3108a6003a93aefba8ec3ca /apps
parent48c7bed59bce35eb5904dc7c7c80f99ba4126892 (diff)
downloadnextcloud-server-48f6dccdb768126ae71a1e4de4eca184891a6115.tar.gz
nextcloud-server-48f6dccdb768126ae71a1e4de4eca184891a6115.zip
notifications are now shown/hidden using the js functions hideNotification and showNotification.
storage warnings are displayed in a notification. as soon as a notification is hidden the storage warning will come back.
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js33
-rw-r--r--apps/files/js/files.js65
2 files changed, 60 insertions, 38 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 96dd0323d29..031c58e724c 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -195,15 +195,14 @@ var FileList={
},
checkName:function(oldName, newName, isNewFile) {
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
- if (isNewFile) {
- $('#notification').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 {
- $('#notification').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>');
- }
$('#notification').data('oldName', oldName);
$('#notification').data('newName', newName);
$('#notification').data('isNewFile', isNewFile);
- $('#notification').fadeIn();
+ if (isNewFile) {
+ Files.showHtmlNotification(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 {
+ Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
+ }
return true;
} else {
return false;
@@ -245,11 +244,10 @@ var FileList={
FileList.finishReplace();
};
if (isNewFile) {
- $('#notification').html(t('files', 'replaced {new_name}', {new_name: newName})+'<span class="undo">'+t('files', 'undo')+'</span>');
+ Files.showHtmlNotification(t('files', 'replaced {new_name}', {new_name: newName})+'<span class="undo">'+t('files', 'undo')+'</span>');
} else {
- $('#notification').html(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
+ Files.showHtmlNotification(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
}
- $('#notification').fadeIn();
},
finishReplace:function() {
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
@@ -279,11 +277,10 @@ var FileList={
} else {
// 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}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
+ Files.showHtmlNotification(t('files', 'unshared {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
} else {
- $('#notification').html(t('files', 'deleted {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
+ Files.showHtmlNotification(t('files', 'deleted {files}', {'files': escapeHTML(files)})+'<span class="undo">'+t('files', 'undo')+'</span>');
}
- $('#notification').fadeIn();
}
},
finishDelete:function(ready,sync){
@@ -296,7 +293,7 @@ var FileList={
data: {dir:$('#dir').val(),files:fileNames},
complete: function(data){
boolOperationFinished(data, function(){
- $('#notification').fadeOut('400');
+ Files.hideNotification();
$.each(FileList.deleteFiles,function(index,file){
FileList.remove(file);
});
@@ -356,16 +353,16 @@ $(document).ready(function(){
FileList.replaceIsNewFile = null;
}
FileList.lastAction = null;
- $('#notification').fadeOut('400');
+ Files.hideNotification();
});
$('#notification .replace').live('click', function() {
- $('#notification').fadeOut('400', function() {
- FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
- });
+ Files.hideNotification(function() {
+ FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
+ });
});
$('#notification .suggest').live('click', function() {
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
- $('#notification').fadeOut('400');
+ Files.hideNotification();
});
$('#notification .cancel').live('click', function() {
if ($('#notification').data('isNewFile')) {
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){