From c14effdf9ce4b74342c38ac21eb6c39c59296ba2 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 8 Oct 2011 14:52:00 +0000 Subject: [PATCH] add page titles; various bugfixes related to urls --- static/js/pandora/UI.js | 2 +- static/js/pandora/URL.js | 11 ++++++----- static/js/pandora/ui/item.js | 3 +-- static/js/pandora/ui/rightPanel.js | 16 +--------------- static/js/pandora/utils.js | 18 ++++++++++++++++++ 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 47d00c3a4..b96e91e83 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -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 diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index f7043b408..3e40923e1 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -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)); } }; diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index fbba0ce80..9bd8a2716 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -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) { diff --git a/static/js/pandora/ui/rightPanel.js b/static/js/pandora/ui/rightPanel.js index fea39f556..347c21922 100644 --- a/static/js/pandora/ui/rightPanel.js +++ b/static/js/pandora/ui/rightPanel.js @@ -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: [ { diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 859decdf9..89b655b98 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -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