From a62b393d02fdfc49334b5ad4b1e847a711de741d Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Wed, 12 Feb 2014 00:54:35 +0100 Subject: [PATCH 1/4] Update page title when navigating through directories --- apps/files/js/filelist.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) 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(); }); From 01dee35ebe1f3ab0e8a7f986015a9fa43a80b061 Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Thu, 13 Feb 2014 10:47:03 +0100 Subject: [PATCH 2/4] Adds OC_Defaults values in javascript config --- core/js/config.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/js/config.php b/core/js/config.php index 517ea1615a8..7ec0904ec3d 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -16,6 +16,9 @@ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Enable l10n support $l = OC_L10N::get('core'); +// Enable OC_Defaults support +$defaults = new OC_Defaults(); + // Get the config $apps_paths = array(); foreach(OC_App::getEnabledApps() as $app) { @@ -60,6 +63,20 @@ $array = array( 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', 60 * 60 * 24), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true) ) + ), + "oc_defaults" => json_encode( + array( + 'entity' => $defaults->getEntity(), + 'name' => $defaults->getName(), + 'title' => $defaults->getTitle(), + 'baseUrl' => $defaults->getBaseUrl(), + 'syncClientUrl' => $defaults->getSyncClientUrl(), + 'docBaseUrl' => $defaults->getDocBaseUrl(), + 'slogan' => $defaults->getSlogan(), + 'logoClaim' => $defaults->getLogoClaim(), + 'shortFooter' => $defaults->getShortFooter(), + 'longFooter' => $defaults->getLongFooter() + ) ) ); From 01dc7c5482e6b7486695fdba865a1c88ab05358d Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Thu, 13 Feb 2014 10:48:01 +0100 Subject: [PATCH 3/4] Gets the page title from oc_defaults in Files app --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }, From 577559458dd7aa74e32ab62216a22bbc75009866 Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Wed, 19 Feb 2014 22:50:49 +0100 Subject: [PATCH 4/4] Uses OC.basename instead of custom code --- apps/files/js/filelist.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);