Merge pull request #7320 from owncloud/GuillaumeAmat-patch-1

Update page title when navigating through directories (local)
This commit is contained in:
Morris Jobke 2014-02-24 13:34:07 +01:00
commit 8d17f6d675
4 changed files with 79 additions and 3 deletions

View File

@ -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() {
@ -18,6 +19,21 @@ window.FileList={
$(this).attr('data-file',decodeURIComponent($(this).attr('data-file')));
});
},
/**
* Sets a new page title
*/
setPageTitle: function(title){
if (title) {
title += ' - ';
} else {
title = '';
}
title += FileList.appName;
// Sets the page title with the " - ownCloud" suffix as in templates
window.document.title = title + ' - ' + oc_defaults.title;
return true;
},
/**
* Returns the tr element for a given file name
*/
@ -204,7 +220,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) {
@ -847,7 +872,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');
@ -1132,5 +1158,7 @@ $(document).ready(function() {
}
}
FileList.setCurrentDir(parseCurrentDirFromUrl(), false);
FileList.createFileSummary();
});

View File

@ -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, '/');

View File

@ -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) {
@ -61,6 +64,20 @@ $array = array(
'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')),
'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()
)
)
);

View File

@ -63,6 +63,7 @@ window.oc_config = {
session_lifetime: 600 * 1000,
session_keepalive: false
};
window.oc_defaults = {};
// global setup for all tests
(function setupTests() {