add page titles; various bugfixes related to urls

This commit is contained in:
rolux 2011-10-08 14:52:00 +00:00
parent f031041dcf
commit c14effdf9c
5 changed files with 27 additions and 23 deletions

View file

@ -34,7 +34,7 @@ pandora.UI = (function() {
Ox.print('UI SET', args)
self.previousUI = Ox.clone(pandora.user.ui, true);
Ox.forEach(args, function(val, key) {
if (key == 'find') {
if (key == 'find' && !Ox.isEqual(val, pandora.user.ui.find)) {
// the challenge here is that find may change list,
// and list may then change listSort and listView,
// which we don't want to trigger, since find triggers

View file

@ -326,6 +326,7 @@ pandora.URL = (function() {
self.isPopState = true;
if (!Ox.isEmpty(e.state)) {
Ox.print('E.STATE', e.state)
document.title = e.state.title;
setState(e.state);
} else {
that.parse();
@ -357,7 +358,7 @@ pandora.URL = (function() {
// pushes a new URL (as string or from state)
that.push = function(url) {
if (url) {
self.URL.push(null, '', url, setState);
self.URL.push(null, pandora.getPageTitle(), url, setState);
} else {
// fixme
//alert('DO YOU REALLY WANT TO CALL PUSH WITHOUT URL?')
@ -369,7 +370,7 @@ pandora.URL = (function() {
// replaces the current URL (as string or from state)
that.replace = function(url) {
if (url) {
self.URL.replace(null, '', url, setState)
self.URL.replace(null, pandora.getPageTitle(), url, setState)
} else {
self.URL.replace(getState());
}
@ -396,11 +397,11 @@ pandora.URL = (function() {
return /^videoPoints/.test(key);
})
) {
action = 'replace'
action = 'replace';
} else {
action = 'push'
action = 'push';
}
self.URL[action](getState(), 'title', getState(keys));
self.URL[action](getState(), pandora.getPageTitle(), getState(keys));
}
};

View file

@ -10,8 +10,7 @@ pandora.ui.item = function() {
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
if (result.status.code == 200) {
// fixme: probably does not belong here
document.title = '0xDB - ' + Ox.stripTags(result.data.title);
document.title = pandora.getPageTitle(result.data.title);
}
/*if (result.status.code != 200) {

View file

@ -2,21 +2,7 @@
pandora.ui.rightPanel = function() {
var that;
if (pandora.user.ui.section == 'site') {
if (pandora.user.ui.sitePage == 'home') {
that = pandora.ui.homePage()
.bindEvent({
resize: function(data) {
that.resize();
}
});
} else {
that = Ox.Element().css({padding: '8px'});
pandora.api.getPage(pandora.user.ui.sitePage, function(result) {
that.html(result.data.body).css({overflowY: 'auto'});
});
}
} else if (pandora.user.ui.section == 'items') {
if (pandora.user.ui.section == 'items') {
that = Ox.SplitPanel({
elements: [
{

View file

@ -562,6 +562,24 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
}
};
(function() {
var itemTitles = {};
pandora.getPageTitle = function(itemTitle) {
if (itemTitle) {
itemTitles[pandora.user.ui.item] = itemTitle
}
var parts = [pandora.site.site.name];
if (!pandora.user.ui.item) {
pandora.user.ui._list && parts.push('List ' + pandora.user.ui._list);
parts.push(Ox.toTitleCase(pandora.user.ui.listView) + ' View');
} else {
parts.push(itemTitles[pandora.user.ui.item] || pandora.user.ui.item);
parts.push(Ox.toTitleCase(pandora.user.ui.itemView) + ' View');
}
return parts.join(' - ');
};
}());
pandora._getSortOperator = function(type) {
return ['hue', 'string', 'text'].indexOf(
Ox.isArray(type) ? type[0] : type