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.
This commit is contained in:
parent
48c7bed59b
commit
48f6dccdb7
|
@ -195,15 +195,14 @@ var FileList={
|
||||||
},
|
},
|
||||||
checkName:function(oldName, newName, isNewFile) {
|
checkName:function(oldName, newName, isNewFile) {
|
||||||
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
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('oldName', oldName);
|
||||||
$('#notification').data('newName', newName);
|
$('#notification').data('newName', newName);
|
||||||
$('#notification').data('isNewFile', isNewFile);
|
$('#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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -245,11 +244,10 @@ var FileList={
|
||||||
FileList.finishReplace();
|
FileList.finishReplace();
|
||||||
};
|
};
|
||||||
if (isNewFile) {
|
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 {
|
} 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() {
|
finishReplace:function() {
|
||||||
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
|
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
|
||||||
|
@ -279,11 +277,10 @@ var FileList={
|
||||||
} else {
|
} else {
|
||||||
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
||||||
if ($('#dir').val() == '/Shared') {
|
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 {
|
} 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){
|
finishDelete:function(ready,sync){
|
||||||
|
@ -296,7 +293,7 @@ var FileList={
|
||||||
data: {dir:$('#dir').val(),files:fileNames},
|
data: {dir:$('#dir').val(),files:fileNames},
|
||||||
complete: function(data){
|
complete: function(data){
|
||||||
boolOperationFinished(data, function(){
|
boolOperationFinished(data, function(){
|
||||||
$('#notification').fadeOut('400');
|
Files.hideNotification();
|
||||||
$.each(FileList.deleteFiles,function(index,file){
|
$.each(FileList.deleteFiles,function(index,file){
|
||||||
FileList.remove(file);
|
FileList.remove(file);
|
||||||
});
|
});
|
||||||
|
@ -356,16 +353,16 @@ $(document).ready(function(){
|
||||||
FileList.replaceIsNewFile = null;
|
FileList.replaceIsNewFile = null;
|
||||||
}
|
}
|
||||||
FileList.lastAction = null;
|
FileList.lastAction = null;
|
||||||
$('#notification').fadeOut('400');
|
Files.hideNotification();
|
||||||
});
|
});
|
||||||
$('#notification .replace').live('click', function() {
|
$('#notification .replace').live('click', function() {
|
||||||
$('#notification').fadeOut('400', function() {
|
Files.hideNotification(function() {
|
||||||
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#notification .suggest').live('click', function() {
|
$('#notification .suggest').live('click', function() {
|
||||||
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
||||||
$('#notification').fadeOut('400');
|
Files.hideNotification();
|
||||||
});
|
});
|
||||||
$('#notification .cancel').live('click', function() {
|
$('#notification .cancel').live('click', function() {
|
||||||
if ($('#notification').data('isNewFile')) {
|
if ($('#notification').data('isNewFile')) {
|
||||||
|
|
|
@ -30,14 +30,45 @@ Files={
|
||||||
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
||||||
for (var i = 0; i < invalid_characters.length; i++) {
|
for (var i = 0; i < invalid_characters.length; i++) {
|
||||||
if (name.indexOf(invalid_characters[i]) != -1) {
|
if (name.indexOf(invalid_characters[i]) != -1) {
|
||||||
$('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
|
Files.showNotification(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#notification').fadeOut();
|
Files.hideNotification();
|
||||||
return false;
|
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() {
|
$(document).ready(function() {
|
||||||
Files.bindKeyboardShortcuts(document, jQuery);
|
Files.bindKeyboardShortcuts(document, jQuery);
|
||||||
|
@ -171,8 +202,7 @@ $(document).ready(function() {
|
||||||
$('.download').click('click',function(event) {
|
$('.download').click('click',function(event) {
|
||||||
var files=getSelectedFiles('name').join(';');
|
var files=getSelectedFiles('name').join(';');
|
||||||
var dir=$('#dir').val()||'/';
|
var dir=$('#dir').val()||'/';
|
||||||
$('#notification').text(t('files','generating ZIP-file, it may take some time.'));
|
Files.showNotification(t('files','generating ZIP-file, it may take some time.'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
// use special download URL if provided, e.g. for public shared files
|
// use special download URL if provided, e.g. for public shared files
|
||||||
if ( (downloadURL = document.getElementById("downloadURL")) ) {
|
if ( (downloadURL = document.getElementById("downloadURL")) ) {
|
||||||
window.location=downloadURL.value+"&download&files="+files;
|
window.location=downloadURL.value+"&download&files="+files;
|
||||||
|
@ -301,8 +331,7 @@ $(document).ready(function() {
|
||||||
var response;
|
var response;
|
||||||
response=jQuery.parseJSON(result);
|
response=jQuery.parseJSON(result);
|
||||||
if(response[0] == undefined || response[0].status != 'success') {
|
if(response[0] == undefined || response[0].status != 'success') {
|
||||||
$('#notification').text(t('files', response.data.message));
|
Files.showNotification(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
var file=response[0];
|
var file=response[0];
|
||||||
// TODO: this doesn't work if the file name has been changed server side
|
// TODO: this doesn't work if the file name has been changed server side
|
||||||
|
@ -339,9 +368,7 @@ $(document).ready(function() {
|
||||||
} else {
|
} else {
|
||||||
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
|
uploadtext.text(t('files', '{count} files uploading', {count: currentUploads}));
|
||||||
}
|
}
|
||||||
$('#notification').hide();
|
Files.showNotification(t('files', 'Upload cancelled.'));
|
||||||
$('#notification').text(t('files', 'Upload cancelled.'));
|
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//TODO test with filenames containing slashes
|
//TODO test with filenames containing slashes
|
||||||
|
@ -364,17 +391,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
FileList.loadingDone(file.name, file.id);
|
FileList.loadingDone(file.name, file.id);
|
||||||
} else {
|
} else {
|
||||||
$('#notification').text(t('files', response.data.message));
|
Files.showNotification(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
$('#fileList > tr').not('[data-mime]').fadeOut();
|
$('#fileList > tr').not('[data-mime]').fadeOut();
|
||||||
$('#fileList > tr').not('[data-mime]').remove();
|
$('#fileList > tr').not('[data-mime]').remove();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function(jqXHR, textStatus, errorThrown) {
|
.error(function(jqXHR, textStatus, errorThrown) {
|
||||||
if(errorThrown === 'abort') {
|
if(errorThrown === 'abort') {
|
||||||
$('#notification').hide();
|
Files.showNotification(t('files', 'Upload cancelled.'));
|
||||||
$('#notification').text(t('files', 'Upload cancelled.'));
|
|
||||||
$('#notification').fadeIn();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uploadingFiles[uniqueName] = jqXHR;
|
uploadingFiles[uniqueName] = jqXHR;
|
||||||
|
@ -394,8 +418,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
FileList.loadingDone(file.name, file.id);
|
FileList.loadingDone(file.name, file.id);
|
||||||
} else {
|
} else {
|
||||||
$('#notification').text(t('files', response.data.message));
|
Files.showNotification(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
|
||||||
$('#fileList > tr').not('[data-mime]').fadeOut();
|
$('#fileList > tr').not('[data-mime]').fadeOut();
|
||||||
$('#fileList > tr').not('[data-mime]').remove();
|
$('#fileList > tr').not('[data-mime]').remove();
|
||||||
}
|
}
|
||||||
|
@ -512,8 +535,7 @@ $(document).ready(function() {
|
||||||
if (type != 'web' && Files.containsInvalidCharacters($(this).val())) {
|
if (type != 'web' && Files.containsInvalidCharacters($(this).val())) {
|
||||||
return;
|
return;
|
||||||
} else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') {
|
} else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') {
|
||||||
$('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud'));
|
Files.showNotification(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud'));
|
||||||
$('#notification').fadeIn();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (FileList.lastAction) {
|
if (FileList.lastAction) {
|
||||||
|
@ -683,6 +705,9 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
resizeBreadcrumbs(true);
|
resizeBreadcrumbs(true);
|
||||||
|
|
||||||
|
// display storage warnings
|
||||||
|
setTimeout ( "Files.displayStorageWarnings()", 100 );
|
||||||
});
|
});
|
||||||
|
|
||||||
function scanFiles(force,dir){
|
function scanFiles(force,dir){
|
||||||
|
|
Loading…
Reference in New Issue