From 2d36a20a1df4129608e9573cea3dcbb2e9de2d12 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 2 Jan 2013 14:35:45 +0100 Subject: [PATCH 01/18] moving storage calculation code to OC_Helper::getStorageInfo() --- lib/helper.php | 19 +++++++++++++++++++ settings/personal.php | 16 ++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/helper.php b/lib/helper.php index be4e4e5267..c870536eb5 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -758,4 +758,23 @@ class OC_Helper { } return $str; } + + /** + * Calculate the disc space + */ + public static function getStorageInfo() { + $rootInfo = OC_FileCache::get(''); + $used = $rootInfo['size']; + if ($used < 0) { + $used = 0; + } + $free = OC_Filesystem::free_space(); + $total = $free + $used; + if ($total == 0) { + $total = 1; // prevent division by zero + } + $relative = round(($used / $total) * 10000) / 100; + + return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative); + } } diff --git a/settings/personal.php b/settings/personal.php index 47dbcc53eb..4624bda839 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -15,15 +15,7 @@ OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); OC_Util::addStyle( '3rdparty', 'chosen' ); OC_App::setActiveNavigationEntry( 'personal' ); -// calculate the disc space -$rootInfo=OC_FileCache::get(''); -$sharedInfo=OC_FileCache::get('/Shared'); -$used=$rootInfo['size']; -if($used<0) $used=0; -$free=OC_Filesystem::free_space(); -$total=$free+$used; -if($total==0) $total=1; // prevent division by zero -$relative=round(($used/$total)*10000)/100; +$storageInfo=OC_Helper::getStorageInfo(); $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); @@ -50,9 +42,9 @@ foreach($languageCodes as $lang) { // Return template $tmpl = new OC_Template( 'settings', 'personal', 'user'); -$tmpl->assign('usage', OC_Helper::humanFileSize($used)); -$tmpl->assign('total_space', OC_Helper::humanFileSize($total)); -$tmpl->assign('usage_relative', $relative); +$tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used'])); +$tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total'])); +$tmpl->assign('usage_relative', $storageInfo['relative']); $tmpl->assign('email', $email); $tmpl->assign('languages', $languages); From 48c7bed59bce35eb5904dc7c7c80f99ba4126892 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 2 Jan 2013 15:06:49 +0100 Subject: [PATCH 02/18] make usedSpacePercent available in the files app --- apps/files/index.php | 4 ++++ apps/files/templates/index.php | 1 + 2 files changed, 5 insertions(+) diff --git a/apps/files/index.php b/apps/files/index.php index b64bde44cc..cdbedbba47 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -98,6 +98,9 @@ if (OC_Filesystem::isSharable($dir . '/')) { $permissions |= OCP\PERMISSION_SHARE; } +// information about storage capacities +$storageInfo=OC_Helper::getStorageInfo(); + $tmpl = new OCP\Template('files', 'index', 'user'); $tmpl->assign('fileList', $list->fetchPage(), false); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false); @@ -108,4 +111,5 @@ $tmpl->assign('files', $files); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); +$tmpl->assign('usedSpacePercent', $storageInfo['relative']); $tmpl->printPage(); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index edf048c7e1..5246ff1bea 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -117,3 +117,4 @@ + From 48f6dccdb768126ae71a1e4de4eca184891a6115 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 2 Jan 2013 15:09:40 +0100 Subject: [PATCH 03/18] 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(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 96dd0323d2..031c58e724 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 6a37d9e7f5..6023cf78e7 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){ From ba475d486258c0b7ea86cd766814053df6c69170 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 4 Jan 2013 23:34:09 +0100 Subject: [PATCH 04/18] 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(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 031c58e724..33f35eee6c 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 6023cf78e7..6166b240e8 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 7d967321d9..b57603b7b2 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:[], From 594d388ad9121c2c2808e83ca77513390853a355 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 4 Jan 2013 23:37:21 +0100 Subject: [PATCH 05/18] new javascript notification functions used within users.js --- settings/js/users.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/settings/js/users.js b/settings/js/users.js index b0e30feb80..a01b4cab95 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -26,9 +26,8 @@ var UserList = { UserList.deleteCanceled = false; // Provide user with option to undo - $('#notification').html(t('users', 'deleted') + ' ' + uid + '' + t('users', 'undo') + ''); $('#notification').data('deleteuser', true); - $('#notification').fadeIn(); + OC.Notification.showHtml(t('users', 'deleted') + ' ' + uid + '' + t('users', 'undo') + ''); }, /** @@ -53,7 +52,7 @@ var UserList = { success:function (result) { if (result.status == 'success') { // Remove undo option, & remove user from table - $('#notification').fadeOut(); + OC.Notification.hide(); $('tr').filterAttr('data-uid', UserList.deleteUid).remove(); UserList.deleteCanceled = true; if (ready) { @@ -401,13 +400,13 @@ $(document).ready(function () { ); }); // Handle undo notifications - $('#notification').hide(); + OC.Notification.hide(); $('#notification .undo').live('click', function () { if ($('#notification').data('deleteuser')) { $('tbody tr').filterAttr('data-uid', UserList.deleteUid).show(); UserList.deleteCanceled = true; } - $('#notification').fadeOut(); + OC.Notification.hide(); }); UserList.useUndo = ('onbeforeunload' in window) $(window).bind('beforeunload', function () { From b5d1dfcdc91e9192b50752714b5beeda49bbeadf Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 4 Jan 2013 23:38:07 +0100 Subject: [PATCH 06/18] javascript syntax error fixed on the way --- settings/js/users.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings/js/users.js b/settings/js/users.js index a01b4cab95..2ccb56ab0e 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -195,7 +195,7 @@ var UserList = { checked:checked, oncheck:checkHandeler, onuncheck:checkHandeler, - minWidth:100, + minWidth:100 }); } if ($(element).attr('class') == 'subadminsselect') { @@ -230,7 +230,7 @@ var UserList = { checked:checked, oncheck:checkHandeler, onuncheck:checkHandeler, - minWidth:100, + minWidth:100 }); } } @@ -387,7 +387,7 @@ $(document).ready(function () { { username:username, password:password, - groups:groups, + groups:groups }, function (result) { if (result.status != 'success') { From a867b36e7f99c648252ba2a1c04888ba21c1405f Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sun, 6 Jan 2013 10:41:07 +0100 Subject: [PATCH 07/18] js optimisations and style fixes --- core/js/js.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 4e35547c05..710ef416b6 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -37,14 +37,14 @@ function t(app,text, vars){ t.cache[app] = []; } } - var _build = function(text, vars) { - return text.replace(/{([^{}]*)}/g, - function (a, b) { - var r = vars[b]; - return typeof r === 'string' || typeof r === 'number' ? r : a; - } - ); - } + var _build = function (text, vars) { + return text.replace(/{([^{}]*)}/g, + function (a, b) { + var r = vars[b]; + return typeof r === 'string' || typeof r === 'number' ? r : a; + } + ); + }; if( typeof( t.cache[app][text] ) !== 'undefined' ){ if(typeof vars === 'object') { return _build(t.cache[app][text], vars); @@ -247,7 +247,6 @@ var OC={ var popup = $('#appsettings_popup'); if(popup.length == 0) { $('body').prepend(''); - popup = $('#appsettings_popup'); popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft'); } if(popup.is(':visible')) { @@ -308,14 +307,16 @@ OC.Notification={ }); }, showHtml: function(html) { - $('#notification').hide(); - $('#notification').html(html); - $('#notification').fadeIn(); + var notification = $('#notification'); + notification.hide(); + notification.html(html); + notification.fadeIn(); }, show: function(text) { - $('#notification').hide(); - $('#notification').text(text); - $('#notification').fadeIn(); + var notification = $('#notification'); + notification.hide(); + notification.text(text); + notification.fadeIn(); } }; From bfc55fef89089fc43c6a352de860374ca3fcfd53 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 8 Jan 2013 00:24:35 +0100 Subject: [PATCH 08/18] bring back L250 as spotted by @tanghus - THX --- core/js/js.js | 1 + 1 file changed, 1 insertion(+) diff --git a/core/js/js.js b/core/js/js.js index 710ef416b6..e2775fa722 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -247,6 +247,7 @@ var OC={ var popup = $('#appsettings_popup'); if(popup.length == 0) { $('body').prepend(''); + popup = $('#appsettings_popup'); popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft'); } if(popup.is(':visible')) { From 508b6a9fc79326bcf6d060f1daf42f5b67bfaeec Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 11:52:07 +0100 Subject: [PATCH 09/18] displaying notification now centered The notification div has been moved to the user templates. Correct display of the notification will only work with the use of OC.Notification.show() as on fadeIn() the css needs to be changed as this style required display: inline. --- apps/files/templates/index.php | 1 - core/css/styles.css | 3 ++- core/js/js.js | 4 ++-- core/templates/layout.user.php | 5 ++++- settings/templates/users.php | 2 -- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 77c06007da..b66b523ae3 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -50,7 +50,6 @@ -
t('Nothing in here. Upload something!')?>
diff --git a/core/css/styles.css b/core/css/styles.css index 496320561f..e7ad777f71 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -190,7 +190,8 @@ fieldset.warning legend { color:#b94a48 !important; } .bold { font-weight:bold; } .center { text-align:center; } -#notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } +#notification-container { position: absolute; top: 0px; width: 100%; text-align: center; z-index: 101; line-height: 1.2;} +#notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position: relative; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } #notification span { cursor:pointer; font-weight:bold; margin-left:1em; } tr .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; } diff --git a/core/js/js.js b/core/js/js.js index 10758a9072..e724be9c2d 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -311,13 +311,13 @@ OC.Notification={ var notification = $('#notification'); notification.hide(); notification.html(html); - notification.fadeIn(); + notification.fadeIn().css("display","inline"); }, show: function(text) { var notification = $('#notification'); notification.hide(); notification.text(text); - notification.fadeIn(); + notification.fadeIn().css("display","inline"); } }; diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index ba5053edec..be9eff8055 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -40,7 +40,10 @@ -