From a62b393d02fdfc49334b5ad4b1e847a711de741d Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Wed, 12 Feb 2014 00:54:35 +0100 Subject: Update page title when navigating through directories --- apps/files/js/filelist.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a855d6cbe59..7691135e620 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -18,6 +18,15 @@ window.FileList={ $(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); }); }, + /** + * Sets a new page title + */ + setPageTitle: function(title){ + // Sets the page title with the " - ownCloud" suffix as in templates + window.document.title = title + ' - ownCloud'; + + return true; + }, /** * Returns the tr element for a given file name */ @@ -186,12 +195,22 @@ window.FileList={ changeDirectory: function(targetDir, changeUrl, force) { var $dir = $('#dir'), url, - currentDir = $dir.val() || '/'; + currentDir = $dir.val() || '/', + baseDir = targetDir.split('/').pop(), targetDir = targetDir || '/'; if (!force && currentDir === targetDir) { return; } + + if (baseDir !== '') { + FileList.setPageTitle(baseDir); + } + else { + FileList.setPageTitle(t('files', 'Files')); + } + FileList.setCurrentDir(targetDir, changeUrl); + $('#fileList').trigger( jQuery.Event('changeDirectory', { dir: targetDir, @@ -811,7 +830,8 @@ window.FileList={ }; $(document).ready(function() { - var isPublic = !!$('#isPublic').val(); + var baseDir, + isPublic = !!$('#isPublic').val(); // handle upload events var file_upload_start = $('#file_upload_start'); @@ -1095,6 +1115,14 @@ $(document).ready(function() { FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); } } - + + + baseDir = parseCurrentDirFromUrl().split('/').pop(); + + if (baseDir !== '') { + FileList.setPageTitle(baseDir); + } + + FileList.createFileSummary(); }); -- cgit v1.2.3 From 01dc7c5482e6b7486695fdba865a1c88ab05358d Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Thu, 13 Feb 2014 10:48:01 +0100 Subject: Gets the page title from oc_defaults in Files app --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 7691135e620..14f03121ff6 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -23,7 +23,7 @@ window.FileList={ */ setPageTitle: function(title){ // Sets the page title with the " - ownCloud" suffix as in templates - window.document.title = title + ' - ownCloud'; + window.document.title = title + ' - ' + oc_defaults.title; return true; }, -- cgit v1.2.3 From 609a91a9b1bbee423a6bda2420dc4010b46757f6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 19 Feb 2014 14:47:29 +0100 Subject: Show svg mime icons when no preview is available --- apps/files/js/filelist.js | 10 +++++----- apps/files/js/files.js | 9 +++++++-- apps/files/lib/helper.php | 14 ++++++++------ core/ajax/preview.php | 30 +++++++++++++++++------------- 4 files changed, 37 insertions(+), 26 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a855d6cbe59..b2de0161aa8 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -129,7 +129,7 @@ window.FileList={ if (loading) { imgurl = OC.imagePath('core', 'loading.gif'); } else { - imgurl = OC.imagePath('core', 'filetypes/file.png'); + imgurl = OC.imagePath('core', 'filetypes/file'); } var tr = this.createRow( 'file', @@ -157,7 +157,7 @@ window.FileList={ var tr = this.createRow( 'dir', name, - OC.imagePath('core', 'filetypes/folder.png'), + OC.imagePath('core', 'filetypes/folder'), OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/'), size, lastModified, @@ -907,7 +907,7 @@ $(document).ready(function() { uploadtext.attr('currentUploads', currentUploads); var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); if (currentUploads === 0) { - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); data.context.find('td.filename').attr('style','background-image:url('+img+')'); uploadtext.text(translatedText); uploadtext.hide(); @@ -967,7 +967,7 @@ $(document).ready(function() { if (data.errorThrown === 'abort') { //cleanup uploading to a dir var uploadtext = $('tr .uploadtext'); - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); uploadtext.parents('td.filename').attr('style','background-image:url('+img+')'); uploadtext.fadeOut(); uploadtext.attr('currentUploads', 0); @@ -980,7 +980,7 @@ $(document).ready(function() { if (data.errorThrown === 'abort') { //cleanup uploading to a dir var uploadtext = $('tr .uploadtext'); - var img = OC.imagePath('core', 'filetypes/folder.png'); + var img = OC.imagePath('core', 'filetypes/folder'); uploadtext.parents('td.filename').attr('style','background-image:url('+img+')'); uploadtext.fadeOut(); uploadtext.attr('currentUploads', 0); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 1ec4c4ec7ab..dab060229e6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -731,6 +731,9 @@ Files.getMimeIcon = function(mime, ready) { ready(Files.getMimeIcon.cache[mime]); } else { $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) { + if(SVGSupport()){ + path = path.substr(0, path.length-4) + '.svg'; + } Files.getMimeIcon.cache[mime]=path; ready(Files.getMimeIcon.cache[mime]); }); @@ -785,8 +788,10 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { // this will make the browser cache the image var img = new Image(); img.onload = function(){ - //set preview thumbnail URL - ready(previewURL); + // if loading the preview image failed (no preview for the mimetype) then img.width will < 5 + if (img.width > 5) { + ready(previewURL); + } } img.src = previewURL; }); diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index ac8a2ad3200..fec1297b180 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -36,14 +36,16 @@ class Helper } } } - return \OC_Helper::mimetypeIcon('dir'); + $icon = \OC_Helper::mimetypeIcon('dir'); + }else{ + if($file['isPreviewAvailable']) { + $pathForPreview = $file['directory'] . '/' . $file['name']; + return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag']; + } + $icon = \OC_Helper::mimetypeIcon($file['mimetype']); } - if($file['isPreviewAvailable']) { - $pathForPreview = $file['directory'] . '/' . $file['name']; - return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag']; - } - return \OC_Helper::mimetypeIcon($file['mimetype']); + return substr($icon, 0, -3) . 'svg'; } /** diff --git a/core/ajax/preview.php b/core/ajax/preview.php index a1267d6f5cf..5c6d5ce25ab 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -7,34 +7,38 @@ */ \OC_Util::checkLoggedIn(); -$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : ''; -$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; -$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; -$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; +$file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : ''; +$maxX = array_key_exists('x', $_GET) ? (int)$_GET['x'] : '36'; +$maxY = array_key_exists('y', $_GET) ? (int)$_GET['y'] : '36'; +$scalingUp = array_key_exists('scalingup', $_GET) ? (bool)$_GET['scalingup'] : true; -if($file === '') { +if ($file === '') { //400 Bad Request \OC_Response::setStatus(400); \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); exit; } -if($maxX === 0 || $maxY === 0) { +if ($maxX === 0 || $maxY === 0) { //400 Bad Request \OC_Response::setStatus(400); \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); exit; } -try{ +try { $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingUp); + if (!$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { + \OC_Response::setStatus(404); + } else { + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + } $preview->show(); -}catch(\Exception $e) { +} catch (\Exception $e) { \OC_Response::setStatus(500); \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); -} \ No newline at end of file +} -- cgit v1.2.3 From 577559458dd7aa74e32ab62216a22bbc75009866 Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Wed, 19 Feb 2014 22:50:49 +0100 Subject: Uses OC.basename instead of custom code --- apps/files/js/filelist.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 14f03121ff6..7d0818ef1ee 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -196,7 +196,7 @@ window.FileList={ var $dir = $('#dir'), url, currentDir = $dir.val() || '/', - baseDir = targetDir.split('/').pop(), + baseDir = OC.basename(targetDir), targetDir = targetDir || '/'; if (!force && currentDir === targetDir) { return; @@ -1117,7 +1117,7 @@ $(document).ready(function() { } - baseDir = parseCurrentDirFromUrl().split('/').pop(); + baseDir = OC.basename(parseCurrentDirFromUrl()); if (baseDir !== '') { FileList.setPageTitle(baseDir); -- cgit v1.2.3 From 476444ab1a6f925b87ca6f6382953633fd060283 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 20 Feb 2014 14:56:28 +0100 Subject: Fixed title format --- apps/files/js/filelist.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 6bf134eed3b..3fd3c406b2f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -22,6 +22,13 @@ window.FileList={ * Sets a new page title */ setPageTitle: function(title){ + if (title) { + title += ' - '; + } + else { + title = ''; + } + title += t('files', 'Files'); // Sets the page title with the " - ownCloud" suffix as in templates window.document.title = title + ' - ' + oc_defaults.title; @@ -206,7 +213,7 @@ window.FileList={ FileList.setPageTitle(baseDir); } else { - FileList.setPageTitle(t('files', 'Files')); + FileList.setPageTitle(); } FileList.setCurrentDir(targetDir, changeUrl); -- cgit v1.2.3 From 44441b56d63783a0be5c9b24f5b1ee9264509bef Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 20 Feb 2014 15:16:45 +0100 Subject: Fixed trashbin title --- apps/files/js/filelist.js | 36 +++++++++++++++--------------------- apps/files_trashbin/js/filelist.js | 32 +++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 22 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3fd3c406b2f..edcc5519b20 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -11,6 +11,7 @@ /* global OC, t, n, FileList, FileActions, Files */ /* global procesSelection, dragOptions, SVGSupport, replaceSVG */ window.FileList={ + appName: t('files', 'Files'), useUndo:true, postProcessList: function() { $('#fileList tr').each(function() { @@ -28,7 +29,7 @@ window.FileList={ else { title = ''; } - title += t('files', 'Files'); + title += FileList.appName; // Sets the page title with the " - ownCloud" suffix as in templates window.document.title = title + ' - ' + oc_defaults.title; @@ -202,22 +203,12 @@ window.FileList={ changeDirectory: function(targetDir, changeUrl, force) { var $dir = $('#dir'), url, - currentDir = $dir.val() || '/', - baseDir = OC.basename(targetDir), + currentDir = $dir.val() || '/'; targetDir = targetDir || '/'; if (!force && currentDir === targetDir) { return; } - - if (baseDir !== '') { - FileList.setPageTitle(baseDir); - } - else { - FileList.setPageTitle(); - } - FileList.setCurrentDir(targetDir, changeUrl); - $('#fileList').trigger( jQuery.Event('changeDirectory', { dir: targetDir, @@ -230,7 +221,16 @@ window.FileList={ return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); }, setCurrentDir: function(targetDir, changeUrl) { - var url; + var url, + baseDir = OC.basename(targetDir); + + if (baseDir !== '') { + FileList.setPageTitle(baseDir); + } + else { + FileList.setPageTitle(); + } + $('#dir').val(targetDir); if (changeUrl !== false) { if (window.history.pushState && changeUrl !== false) { @@ -1158,14 +1158,8 @@ $(document).ready(function() { FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); } } - - - baseDir = OC.basename(parseCurrentDirFromUrl()); - - if (baseDir !== '') { - FileList.setPageTitle(baseDir); - } - + + FileList.setCurrentDir(parseCurrentDirFromUrl(), false); FileList.createFileSummary(); }); diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js index f42abb6d029..a88459b0a9a 100644 --- a/apps/files_trashbin/js/filelist.js +++ b/apps/files_trashbin/js/filelist.js @@ -1,3 +1,4 @@ +/* globals OC, FileList, t */ // override reload with own ajax call FileList.reload = function(){ FileList.showMask(); @@ -17,7 +18,36 @@ FileList.reload = function(){ FileList.reloadCallback(result); } }); -} +}; + +FileList.appName = t('files_trashbin', 'Deleted files'); + +FileList._deletedRegExp = new RegExp(/^(.+)\.d[0-9]+$/); + +/** + * Convert a file name in the format filename.d12345 to the real file name. + * This will use basename. + * The name will not be changed if it has no ".d12345" suffix. + * @param name file name + * @return converted file name + */ +FileList.getDeletedFileName = function(name) { + name = OC.basename(name); + var match = FileList._deletedRegExp.exec(name); + if (match && match.length > 1) { + name = match[1]; + } + return name; +}; +var oldSetCurrentDir = FileList.setCurrentDir; +FileList.setCurrentDir = function(targetDir) { + oldSetCurrentDir.apply(this, arguments); + + var baseDir = OC.basename(targetDir); + if (baseDir !== '') { + FileList.setPageTitle(FileList.getDeletedFileName(baseDir)); + } +}; FileList.linkTo = function(dir){ return OC.linkTo('files_trashbin', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); -- cgit v1.2.3 From 658758c3f7e0f18a37c00ce107c8d3b4917183e0 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 20 Feb 2014 15:36:52 +0100 Subject: fix intendation --- apps/files/js/filelist.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index edcc5519b20..2dacabaa9d6 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -32,7 +32,7 @@ window.FileList={ title += FileList.appName; // Sets the page title with the " - ownCloud" suffix as in templates window.document.title = title + ' - ' + oc_defaults.title; - + return true; }, /** @@ -874,7 +874,7 @@ window.FileList={ $(document).ready(function() { var baseDir, - isPublic = !!$('#isPublic').val(); + isPublic = !!$('#isPublic').val(); // handle upload events var file_upload_start = $('#file_upload_start'); @@ -1160,6 +1160,6 @@ $(document).ready(function() { } FileList.setCurrentDir(parseCurrentDirFromUrl(), false); - + FileList.createFileSummary(); }); -- cgit v1.2.3 From b22d82f941d29157d659ec29689c75a8b53a530c Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 21 Feb 2014 09:42:19 +0100 Subject: code style: else on same line --- apps/files/js/filelist.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 2dacabaa9d6..35fbdeecd39 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -25,8 +25,7 @@ window.FileList={ setPageTitle: function(title){ if (title) { title += ' - '; - } - else { + } else { title = ''; } title += FileList.appName; -- cgit v1.2.3 From 4715fb12c8001b8642c2e6dcef57ac216ef92c3d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 21 Feb 2014 14:06:15 +0100 Subject: Add url parameter to control whether previews should return 404 when the mimetype is unsupported --- apps/files/js/files.js | 1 + core/ajax/preview.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8b252e69a1d..1f4bd6794f3 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -786,6 +786,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { } previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); + previewURL += '&always=0'; // preload image to prevent delay // this will make the browser cache the image diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 5c6d5ce25ab..285af3a8a76 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -11,6 +11,7 @@ $file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : ''; $maxX = array_key_exists('x', $_GET) ? (int)$_GET['x'] : '36'; $maxY = array_key_exists('y', $_GET) ? (int)$_GET['y'] : '36'; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool)$_GET['scalingup'] : true; +$always = array_key_exists('always', $_GET) ? (bool)$_GET['always'] : true; if ($file === '') { //400 Bad Request @@ -28,7 +29,7 @@ if ($maxX === 0 || $maxY === 0) { try { $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - if (!$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { + if (!$always and !$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) { \OC_Response::setStatus(404); } else { $preview->setFile($file); -- cgit v1.2.3 From 7c4f81bd78b0933928056f6f59020837e1291525 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 24 Feb 2014 13:24:10 +0100 Subject: rename url parameter --- apps/files/js/files.js | 2 +- core/ajax/preview.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 1f4bd6794f3..f4546120702 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -786,7 +786,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { } previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); - previewURL += '&always=0'; + previewURL += '&forceIcon=0'; // preload image to prevent delay // this will make the browser cache the image diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 285af3a8a76..526719e8a1b 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -11,7 +11,7 @@ $file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : ''; $maxX = array_key_exists('x', $_GET) ? (int)$_GET['x'] : '36'; $maxY = array_key_exists('y', $_GET) ? (int)$_GET['y'] : '36'; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool)$_GET['scalingup'] : true; -$always = array_key_exists('always', $_GET) ? (bool)$_GET['always'] : true; +$always = array_key_exists('forceIcon', $_GET) ? (bool)$_GET['forceIcon'] : true; if ($file === '') { //400 Bad Request -- cgit v1.2.3 From 2b423e5a445718928b6f75e9acc33bfa339dc6ef Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Wed, 26 Feb 2014 10:16:54 +0100 Subject: coding style fixes, cut long lines, comments not on same lines, curly braces --- apps/files/js/admin.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/admin.js b/apps/files/js/admin.js index f735079fcbe..842b73c0cae 100644 --- a/apps/files/js/admin.js +++ b/apps/files/js/admin.js @@ -8,19 +8,22 @@ * */ -function switchPublicFolder() -{ +function switchPublicFolder() { var publicEnable = $('#publicEnable').is(':checked'); - var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group + // find all radiobuttons of that group + var sharingaimGroup = $('input:radio[name=sharingaim]'); $.each(sharingaimGroup, function(index, sharingaimItem) { - sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state + // set all buttons to the correct state + sharingaimItem.disabled = !publicEnable; }); } -$(document).ready(function(){ - switchPublicFolder(); // Execute the function after loading DOM tree - $('#publicEnable').click(function(){ - switchPublicFolder(); // To get rid of onClick() +$(document).ready(function() { + // Execute the function after loading DOM tree + switchPublicFolder(); + $('#publicEnable').click(function() { + // To get rid of onClick() + switchPublicFolder(); }); $('#allowZipDownload').bind('change', function() { -- cgit v1.2.3