From 48f6dccdb768126ae71a1e4de4eca184891a6115 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 2 Jan 2013 15:09:40 +0100 Subject: 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. --- apps/files/js/filelist.js | 33 +++++++++++------------- apps/files/js/files.js | 65 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 38 deletions(-) (limited to 'apps/files/js') 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)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); - } else { - $('#notification').html(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); - } $('#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)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); + } else { + Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); + } 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})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); } else { - $('#notification').html(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); } - $('#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)})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } else { - $('#notification').html(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } - $('#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){ -- cgit v1.2.3 From ba475d486258c0b7ea86cd766814053df6c69170 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 4 Jan 2013 23:34:09 +0100 Subject: javascript notification functions have been moved to js.js for common use --- apps/files/js/filelist.js | 20 ++++++++++---------- apps/files/js/files.js | 45 ++++++++++++--------------------------------- core/js/js.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 43 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 031c58e724c..33f35eee6c5 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -199,9 +199,9 @@ var FileList={ $('#notification').data('newName', newName); $('#notification').data('isNewFile', isNewFile); if (isNewFile) { - Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); + OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); } else { - Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); + OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); } return true; } else { @@ -244,9 +244,9 @@ var FileList={ FileList.finishReplace(); }; if (isNewFile) { - Files.showHtmlNotification(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); } else { - Files.showHtmlNotification(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); } }, finishReplace:function() { @@ -277,9 +277,9 @@ var FileList={ } else { // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder if ($('#dir').val() == '/Shared') { - Files.showHtmlNotification(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } else { - Files.showHtmlNotification(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } } }, @@ -293,7 +293,7 @@ var FileList={ data: {dir:$('#dir').val(),files:fileNames}, complete: function(data){ boolOperationFinished(data, function(){ - Files.hideNotification(); + OC.Notification.hide(); $.each(FileList.deleteFiles,function(index,file){ FileList.remove(file); }); @@ -353,16 +353,16 @@ $(document).ready(function(){ FileList.replaceIsNewFile = null; } FileList.lastAction = null; - Files.hideNotification(); + OC.Notification.hide(); }); $('#notification .replace').live('click', function() { - Files.hideNotification(function() { + OC.Notification.hide(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(); - Files.hideNotification(); + OC.Notification.hide(); }); $('#notification .cancel').live('click', function() { if ($('#notification').data('isNewFile')) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6023cf78e79..6166b240e83 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -30,45 +30,23 @@ Files={ var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { - Files.showNotification(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); + OC.Notification.show(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); return true; } } - Files.hideNotification(); + OC.Notification.hide(); 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!')); + OC.Notification.show(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})); + OC.Notification.show(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); @@ -202,7 +180,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - Files.showNotification(t('files','generating ZIP-file, it may take some time.')); + OC.Notification.show(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; @@ -331,7 +309,7 @@ $(document).ready(function() { var response; response=jQuery.parseJSON(result); if(response[0] == undefined || response[0].status != 'success') { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); } var file=response[0]; // TODO: this doesn't work if the file name has been changed server side @@ -368,7 +346,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } - Files.showNotification(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -391,14 +369,14 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(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') { - Files.showNotification(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -418,7 +396,7 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -535,7 +513,7 @@ $(document).ready(function() { if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - Files.showNotification(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); + OC.Notification.show(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); return; } if (FileList.lastAction) { @@ -708,6 +686,7 @@ $(document).ready(function() { // display storage warnings setTimeout ( "Files.displayStorageWarnings()", 100 ); + OC.Notification.setDefault(Files.displayStorageWarnings); }); function scanFiles(force,dir){ diff --git a/core/js/js.js b/core/js/js.js index 7d967321d93..b57603b7b2f 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -289,6 +289,36 @@ OC.search.lastResults={}; OC.addStyle.loaded=[]; OC.addScript.loaded=[]; +OC.Notification={ + getDefaultNotificationFunction: null, + setDefault: function(callback) { + OC.Notification.getDefaultNotificationFunction = callback; + }, + hide: function(callback) { + $("#notification").text(''); + $('#notification').fadeOut('400', function(){ + if ($("#notification").text() === '') { + if (OC.Notification.getDefaultNotificationFunction) { + OC.Notification.getDefaultNotificationFunction.call(); + } + } + if (callback) { + callback.call(); + } + }); + }, + showHtml: function(html) { + $('#notification').hide(); + $('#notification').html(html); + $('#notification').fadeIn(); + }, + show: function(text) { + $('#notification').hide(); + $('#notification').text(text); + $('#notification').fadeIn(); + } +}; + OC.Breadcrumb={ container:null, crumbs:[], -- cgit v1.2.3 From 9afdc14d4050917bf4e0f8cbe7e97d922213a487 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 14:55:49 +0100 Subject: adding accidentally removed line - THX @bartv2 --- apps/files/js/files.js | 1 + 1 file changed, 1 insertion(+) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 81f596d6647..c1c88d1c72b 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -359,6 +359,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } + delete uploadingFiles[dirName][fileName]; OC.Notification.show(t('files', 'Upload cancelled.')); } }); -- cgit v1.2.3 From 3d33e8f8453f49c15d539cce3448465f330cf9c0 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 15:02:34 +0100 Subject: fixing indent - sorryy wrong setting on the IDE :-( replace missing calls to OC.Notification.show --- apps/files/js/files.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index c1c88d1c72b..426f91c7928 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -28,13 +28,11 @@ Files={ }, isFileNameValid:function (name) { if (name === '.') { - $('#notification').text(t('files', '\'.\' is an invalid file name.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', '\'.\' is an invalid file name.')); return false; } if (name.length == 0) { - $('#notification').text(t('files', 'File name cannot be empty.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', 'File name cannot be empty.')); return false; } @@ -46,17 +44,17 @@ Files={ return false; } } - OC.Notification.hide(); + OC.Notification.hide(); return true; }, displayStorageWarnings: function() { var usedSpacePercent = $('#usedSpacePercent').val(); if (usedSpacePercent > 98) { - OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); - return; + OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + return; } if (usedSpacePercent > 90) { - OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); } } }; @@ -192,7 +190,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - OC.Notification.show(t('files','generating ZIP-file, it may take some time.')); + OC.Notification.show(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; @@ -360,7 +358,7 @@ $(document).ready(function() { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } delete uploadingFiles[dirName][fileName]; - OC.Notification.show(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -385,7 +383,7 @@ $(document).ready(function() { FileList.loadingDone(file.name, file.id); } else { Files.cancelUpload(this.files[0].name); - OC.Notification.show(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -393,7 +391,7 @@ $(document).ready(function() { .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { Files.cancelUpload(this.files[0].name); - OC.Notification.show(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -415,7 +413,7 @@ $(document).ready(function() { FileList.loadingDone(file.name, file.id); } else { //TODO Files.cancelUpload(/*where do we get the filename*/); - OC.Notification.show(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -541,7 +539,7 @@ $(document).ready(function() { } else if (type != 'web' && !Files.isFileNameValid(newname)) { return false; } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { - OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); + OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); return false; } if (FileList.lastAction) { @@ -712,9 +710,9 @@ $(document).ready(function() { resizeBreadcrumbs(true); - // display storage warnings - setTimeout ( "Files.displayStorageWarnings()", 100 ); - OC.Notification.setDefault(Files.displayStorageWarnings); + // display storage warnings + setTimeout ( "Files.displayStorageWarnings()", 100 ); + OC.Notification.setDefault(Files.displayStorageWarnings); }); function scanFiles(force,dir){ -- cgit v1.2.3 From 1dd70ac506982d230d18059ba3626ef2a92664fd Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 19 Jan 2013 00:31:49 +0100 Subject: update used space percent after each ajax call and display the notification --- apps/files/js/files.js | 12 ++++++++++-- core/js/js.js | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index f4d572b6954..843c6e3fc4a 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -32,14 +32,18 @@ Files={ } if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { $('#max_upload').val(response.data.uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + $('#upload.button').attr('original-title', response.data.maxHumanFilesize); + $('#usedSpacePercent').val(response.data.usedSpacePercent); + Files.displayStorageWarnings(); } if(response[0] == undefined) { return; } if(response[0].uploadMaxFilesize !== undefined) { $('#max_upload').val(response[0].uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + $('#upload.button').attr('original-title', response[0].maxHumanFilesize); + $('#usedSpacePercent').val(response[0].usedSpacePercent); + Files.displayStorageWarnings(); } }, @@ -65,6 +69,10 @@ Files={ return true; }, displayStorageWarnings: function() { + if (!OC.Notification.isHidden()) { + return; + } + var usedSpacePercent = $('#usedSpacePercent').val(); if (usedSpacePercent > 98) { OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); diff --git a/core/js/js.js b/core/js/js.js index 3160159e287..2daf63af9d8 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -297,7 +297,7 @@ OC.Notification={ hide: function(callback) { $("#notification").text(''); $('#notification').fadeOut('400', function(){ - if ($("#notification").text() === '') { + if (OC.Notification.isHidden()) { if (OC.Notification.getDefaultNotificationFunction) { OC.Notification.getDefaultNotificationFunction.call(); } @@ -318,7 +318,10 @@ OC.Notification={ notification.hide(); notification.text(text); notification.fadeIn().css("display","inline"); - } + }, + isHidden: function() { + return ($("#notification").text() === ''); + } }; OC.Breadcrumb={ -- cgit v1.2.3 From 5d6c1d52bdb5aa3addc26d1e105749a8eda35301 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 19 Jan 2013 21:37:05 +0100 Subject: replace #notification with OC.Notification call --- apps/files/js/files.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index ce5a8096bf9..6486468eafd 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -563,8 +563,7 @@ $(document).ready(function() { event.preventDefault(); var newname=input.val(); if(type == 'web' && newname.length == 0) { - $('#notification').text(t('files', 'URL cannot be empty.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', 'URL cannot be empty.')); return false; } else if (type != 'web' && !Files.isFileNameValid(newname)) { return false; -- cgit v1.2.3 From 0d02caa684a4ecad8d69e74007c3f9893303f428 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 21 Jan 2013 20:34:28 +0100 Subject: No inline JS in apps --- apps/files/appinfo/routes.php | 5 ++++- apps/files/js/publiclistview.php | 21 +++++++++++++++++++++ apps/files/templates/part.list.php | 8 +------- 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 apps/files/js/publiclistview.php (limited to 'apps/files/js') diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 043782a9c04..307a4d0320d 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -8,4 +8,7 @@ $this->create('download', 'download{file}') ->requirements(array('file' => '.*')) - ->actionInclude('files/download.php'); \ No newline at end of file + ->actionInclude('files/download.php'); +// oC JS config +$this->create('publicListView', 'js/publiclistview.js') + ->actionInclude('files/js/publiclistview.php'); \ No newline at end of file diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php new file mode 100644 index 00000000000..95e23a9b2b3 --- /dev/null +++ b/apps/files/js/publiclistview.php @@ -0,0 +1,21 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// Set the content type to Javascript +header("Content-type: text/javascript"); + +// Disallow caching +header("Cache-Control: no-cache, must-revalidate"); +header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); + +if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true ) { + echo "var publicListView = true;"; +} else { + echo "var publicListView = false;"; +} +?> diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index dfac43d1b12..78f91467c7a 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,10 +1,4 @@ - + Date: Mon, 21 Jan 2013 22:29:27 +0100 Subject: Remove closing tag --- apps/files/js/publiclistview.php | 1 - 1 file changed, 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php index 95e23a9b2b3..8652dabc420 100644 --- a/apps/files/js/publiclistview.php +++ b/apps/files/js/publiclistview.php @@ -18,4 +18,3 @@ if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true ) { } else { echo "var publicListView = false;"; } -?> -- cgit v1.2.3 From 367aadb3b7fcb3c1d3dda0b6cdc463dfce8879a4 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Tue, 22 Jan 2013 18:34:59 +0100 Subject: rename 'publicListView' switch to 'disableSharing' because this is not only used for the public list view --- apps/files/js/publiclistview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php index 8652dabc420..f1c67aabb48 100644 --- a/apps/files/js/publiclistview.php +++ b/apps/files/js/publiclistview.php @@ -13,8 +13,8 @@ header("Content-type: text/javascript"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); -if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true ) { - echo "var publicListView = true;"; +if ( array_key_exists('disableSharing', $_) && $_['disableSharing'] == true ) { + echo "var disableSharing = true;"; } else { - echo "var publicListView = false;"; + echo "var disableSharing = false;"; } -- cgit v1.2.3 From 2e42c6f54f85c5ac5b339625d04685535ac69d40 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 26 Jan 2013 14:07:35 +0100 Subject: Use HTML5 data attribute + fix undefined variable --- apps/files/appinfo/routes.php | 5 +---- apps/files/index.php | 1 + apps/files/js/publiclistview.php | 20 -------------------- apps/files/templates/part.list.php | 2 +- apps/files_sharing/js/share.js | 2 ++ apps/files_sharing/templates/public.php | 2 -- 6 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 apps/files/js/publiclistview.php (limited to 'apps/files/js') diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 307a4d0320d..043782a9c04 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -8,7 +8,4 @@ $this->create('download', 'download{file}') ->requirements(array('file' => '.*')) - ->actionInclude('files/download.php'); -// oC JS config -$this->create('publicListView', 'js/publiclistview.js') - ->actionInclude('files/js/publiclistview.php'); \ No newline at end of file + ->actionInclude('files/download.php'); \ No newline at end of file diff --git a/apps/files/index.php b/apps/files/index.php index 2c6b689b0c9..378f5e02e62 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -76,6 +76,7 @@ $list = new OCP\Template('files', 'part.list', ''); $list->assign('files', $files, false); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false); $list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false); +$list->assign('disableSharing', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false); diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php deleted file mode 100644 index f1c67aabb48..00000000000 --- a/apps/files/js/publiclistview.php +++ /dev/null @@ -1,20 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -// Set the content type to Javascript -header("Content-type: text/javascript"); - -// Disallow caching -header("Cache-Control: no-cache, must-revalidate"); -header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); - -if ( array_key_exists('disableSharing', $_) && $_['disableSharing'] == true ) { - echo "var disableSharing = true;"; -} else { - echo "var disableSharing = false;"; -} diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 78f91467c7a..f3f06d61d66 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,4 +1,4 @@ - + "> - -- cgit v1.2.3