From 9752b2e332b798a1099e5cbb1012476fca6447ad Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 9 Nov 2011 15:01:23 +0000 Subject: [PATCH 1/3] clear contact dialog after sending a message --- pandora/0xdb.jsonc | 2 +- static/js/pandora/contactForm.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index fedfade3..5673bad6 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -569,7 +569,7 @@ "sitePages": [ {"id": "about", "title": "About"}, {"id": "news", "title": "News"}, - {"id": "tour", "title": "Take a Tour"}, + // {"id": "tour", "title": "Take a Tour"}, {"id": "faq", "title": "Frequently Asked Questions"}, {"id": "terms", "title": "Terms of Service"}, {"id": "rights", "title": "Rights Management"}, diff --git a/static/js/pandora/contactForm.js b/static/js/pandora/contactForm.js index df8f03ba..410a4763 100644 --- a/static/js/pandora/contactForm.js +++ b/static/js/pandora/contactForm.js @@ -115,6 +115,7 @@ pandora.ui.contactForm = function() { }).bindEvent({ click: function() { $dialog.close(); + $form.values({subject: '', message: ''}); } }) ], From f93fd49bd7ef51f9a04be5d051d6768723d6c88d Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 9 Nov 2011 17:37:44 +0000 Subject: [PATCH 2/3] fix bugs with dialogs that represent multiple URLs, and history --- static/js/pandora/URL.js | 38 ++++++++++++++++++++------------- static/js/pandora/account.js | 28 +++++++++++++----------- static/js/pandora/helpDialog.js | 6 ++---- static/js/pandora/listDialog.js | 3 ++- static/js/pandora/siteDialog.js | 34 +++++++++++++---------------- static/js/pandora/utils.js | 9 +------- 6 files changed, 58 insertions(+), 60 deletions(-) diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 092ccb8e..1ed860ae 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -75,7 +75,7 @@ pandora.URL = (function() { Ox.getPositionById(pandora.site.sitePages, state.page) > -1 || state.page == 'software' ) { - if (pandora.$ui.siteDialog) { + if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) { pandora.$ui.siteDialog.select(state.page); } else { pandora.$ui.siteDialog = pandora.ui.siteDialog(state.page).open(); @@ -84,7 +84,11 @@ pandora.URL = (function() { pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); } else if (['signup', 'signin'].indexOf(state.page) > -1) { if (pandora.user.level == 'guest') { - pandora.$ui.accountDialog = pandora.ui.accountDialog(state.page).open(); + if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) { + pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(state.page)); + } else { + pandora.$ui.accountDialog = pandora.ui.accountDialog(state.page).open(); + } } else { pandora.URL.replace('/'); } @@ -270,15 +274,17 @@ pandora.URL = (function() { Ox.Request.cancel(); self.isPopState = true; $('.OxDialog:visible').each(function() { - Ox.UI.elements[$(this).data('oxid')].close().remove(); + Ox.UI.elements[$(this).data('oxid')].close(); }); if ( pandora.user.ui.item && pandora.user.ui.itemView == 'video' + && pandora.$ui.player && pandora.$ui.player.options('fullscreen') ) { + pandora.$ui.player.remove(); //pandora.$ui.player.options({fullscreen: false}); - $('body > .OxVideoPlayer').remove(); + //$('body > .OxVideoPlayer').remove(); } if (!Ox.isEmpty(e.state)) { Ox.Log('', 'E.STATE', e.state) @@ -311,24 +317,26 @@ pandora.URL = (function() { }; // pushes a new URL (as string or from state) - that.push = function(url) { - if (url) { - self.URL.push(null, pandora.getPageTitle(), url, setState); + that.push = function(stateOrURL) { + var state, title = pandora.getPageTitle(), url; + if (Ox.isObject(stateOrURL)) { + state = stateOrURL; } else { - // fixme - //alert('DO YOU REALLY WANT TO CALL PUSH WITHOUT URL?') - //self.URL.push(getState()); + url = stateOrURL; } + self.URL.push(state, title, url, setState); return that; }; // replaces the current URL (as string or from state) - that.replace = function(url) { - if (url) { - self.URL.replace(null, pandora.getPageTitle(), url, setState) + that.replace = function(stateOrURL) { + var state, title = pandora.getPageTitle(), url; + if (Ox.isObject(stateOrURL)) { + state = stateOrURL; } else { - self.URL.replace(getState()); + url = stateOrURL; } + self.URL.replace(state, title, url, setState); return that; }; @@ -360,7 +368,7 @@ pandora.URL = (function() { action = 'push'; } state = getState(); - self.URL[action](state, pandora.getPageTitle(), state); + self.URL[action](state, pandora.getPageTitle(), ''); } }; diff --git a/static/js/pandora/account.js b/static/js/pandora/account.js index 0ac81fc0..a60dfda6 100644 --- a/static/js/pandora/account.js +++ b/static/js/pandora/account.js @@ -7,6 +7,7 @@ pandora.ui.accountDialog = function(action) { fixedSize: true, height: 192, id: 'accountDialog', + removeOnClose: true, width: 432 }, pandora.ui.accountDialogOptions(action))) .bindEvent({ @@ -56,7 +57,7 @@ pandora.ui.accountDialogOptions = function(action, value) { id: 'cancel' + Ox.toTitleCase(action), title: 'Cancel' }).bindEvent('click', function() { - pandora.$ui.accountDialog.close().remove(); + pandora.$ui.accountDialog.close(); pandora.URL.update(); }); } else if (type == 'submit') { @@ -72,13 +73,12 @@ pandora.ui.accountDialogOptions = function(action, value) { id: type, title: buttonTitle[type] + '...' }).bindEvent('click', function() { - pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(type)); - pandora.$ui.accountForm.find('input')[0].focus(); if (['signin', 'signup'].indexOf(type) > -1) { - // fixme: similar problem as in siteDialog, - // the URL controller should handle this - history.replaceState({}, '', '/' + type); + pandora.URL.replace({page: type}); + } else { + pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(type)); } + pandora.$ui.accountForm.find('input.OxInput')[0].focus(); }); } } @@ -147,7 +147,7 @@ pandora.ui.accountForm = function(action, value) { if (action == 'signin') { pandora.api.signin(data, function(result) { if (!result.data.errors) { - pandora.$ui.accountDialog.close().remove(); + pandora.$ui.accountDialog.close(); pandora.signin(result.data); } else { pandora.$ui.accountDialog.enableButtons(); @@ -157,7 +157,7 @@ pandora.ui.accountForm = function(action, value) { } else if (action == 'signup') { pandora.api.signup(data, function(result) { if (!result.data.errors) { - pandora.$ui.accountDialog.close().remove(); + pandora.$ui.accountDialog.close(); pandora.signin(result.data); pandora.ui.accountWelcomeDialog().open(); } else { @@ -181,7 +181,7 @@ pandora.ui.accountForm = function(action, value) { } else if (action == 'resetAndSignin') { pandora.api.resetPassword(data, function(result) { if (!result.data.errors) { - pandora.$ui.accountDialog.close().remove(); + pandora.$ui.accountDialog.close(); pandora.signin(result.data); } else { pandora.$ui.accountDialog.enableButtons(); @@ -318,14 +318,14 @@ pandora.ui.accountSignoutDialog = function() { id: 'stay', title: 'Stay Signed In' }).bindEvent('click', function() { - that.close().remove(); + that.close(); pandora.URL.update(); }), Ox.Button({ id: 'signout', title: 'Sign Out' }).bindEvent('click', function() { - that.close().remove(); + that.close(); pandora.api.signout({}, function(result) { pandora.signout(result.data); }); @@ -345,6 +345,7 @@ pandora.ui.accountSignoutDialog = function() { fixedSize: true, height: 128, keys: {enter: 'signout', escape: 'stay'}, + removeOnClose: true, title: 'Sign Out', width: 304 }); @@ -358,7 +359,7 @@ pandora.ui.accountWelcomeDialog = function() { id: 'preferences', title: 'Preferences...' }).bindEvent('click', function() { - that.close().remove(); + that.close(); pandora.$ui.preferencesDialog = pandora.ui.preferencesDialog().open(); }), {}, @@ -366,7 +367,7 @@ pandora.ui.accountWelcomeDialog = function() { id: 'close', title: 'Close' }).bindEvent('click', function() { - that.close().remove(); + that.close(); }) ], content: Ox.Element() @@ -383,6 +384,7 @@ pandora.ui.accountWelcomeDialog = function() { fixedSize: true, height: 128, keys: {enter: 'close', escape: 'close'}, + removeOnClose: true, title: 'Welcome to ' + pandora.site.site.name, width: 304 }); diff --git a/static/js/pandora/helpDialog.js b/static/js/pandora/helpDialog.js index 07c80299..c74d2a12 100644 --- a/static/js/pandora/helpDialog.js +++ b/static/js/pandora/helpDialog.js @@ -9,10 +9,8 @@ pandora.ui.helpDialog = function() { title: 'Close' }).bindEvent({ click: function() { - that.close().remove(); - //fixme: this should be using URL.push / UI.set - //but that currenlty causes a reload - history.pushState({}, '', '/'); + that.close(); + pandora.URL.update(); } }) ], diff --git a/static/js/pandora/listDialog.js b/static/js/pandora/listDialog.js index cb4b9157..61d63b54 100644 --- a/static/js/pandora/listDialog.js +++ b/static/js/pandora/listDialog.js @@ -94,7 +94,7 @@ pandora.ui.listDialog = function(section) { }) .bindEvent({ click: function() { - $dialog.close().remove(); + $dialog.close(); } }) ], @@ -104,6 +104,7 @@ pandora.ui.listDialog = function(section) { minWidth: width, height: 312, // keys: {enter: 'save', escape: 'cancel'}, + removeOnClose: true, title: 'List - ' + listData.name, width: width }); diff --git a/static/js/pandora/siteDialog.js b/static/js/pandora/siteDialog.js index f635546e..ff454090 100644 --- a/static/js/pandora/siteDialog.js +++ b/static/js/pandora/siteDialog.js @@ -5,12 +5,10 @@ pandora.ui.siteDialog = function(section) { var tabs = Ox.merge( - Ox.clone(pandora.site.sitePages), + Ox.clone(pandora.site.sitePages, true), [{id: 'software', title: 'Software'}] ); - //Ox.getObjectById(tabs, section).selected = true; - tabs[Ox.getPositionById(tabs, section)].selected = true; - //Ox.print('SITE DIALOG', section, Ox.getObjectById(tabs, section), Ox.getObjectById(tabs, section).selected) + Ox.getObjectById(tabs, section).selected = true; var $tabPanel = Ox.TabPanel({ content: function(id) { var $content = Ox.Element().css({padding: '16px', overflowY: 'auto'}); @@ -82,8 +80,6 @@ pandora.ui.siteDialog = function(section) { + 'Legal Action' ) .appendTo($column); - }) - pandora.site.rightsLevels.forEach(function(rightsLevel) { }); } }); @@ -113,34 +109,34 @@ pandora.ui.siteDialog = function(section) { }) .bindEvent({ change: function(data) { - $dialog.options({ + that.options({ title: Ox.getObjectById(tabs, data.selected).title }); - //pandora.URL.replace('/' + data.selected); - //fixme: this should be using URL.push / UI.set - //but that currenlty causes another dialog to be opened - history.pushState({/*page: data.selected*/}, '', '/' + data.selected); + pandora.URL.push({page: data.selected}); + //history.pushState({page: data.selected}, '', '/' + data.selected); } }); - var $dialog = Ox.Dialog({ + + var that = Ox.Dialog({ buttons: [ Ox.Button({ id: 'close', title: 'Close' }).bindEvent({ click: function() { - $dialog.close().remove(); + that.close(); pandora.URL.update(); } }) ], - //closeButton: true, + closeButton: true, content: $tabPanel, height: Math.round((window.innerHeight - 24) * 0.75), - //maximizeButton: true, + maximizeButton: true, minHeight: 256, minWidth: 688, // 16 + 256 + 16 + 384 + 16 - title: 'About', + removeOnClose: true, + title: Ox.getObjectById(tabs, section).title, width: Math.round(window.innerWidth * 0.75), }) .bindEvent({ @@ -151,11 +147,11 @@ pandora.ui.siteDialog = function(section) { } }); - $dialog.select = function(id) { + that.select = function(id) { $tabPanel.select(id); - return $dialog; + return that; }; - return $dialog; + return that; }; diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index d44273ad..b2537b6f 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -856,15 +856,9 @@ pandora.resizeFolders = function() { }; pandora.resizeWindow = function() { + // FIXME: a lot of this throws errors on load pandora.$ui.leftPanel.size(2, pandora.getInfoHeight(true)); pandora.resizeFolders(); - /* - var infoHeight = pandora.getInfoHeight(true); - pandora.$ui.leftPanel.size(2, infoHeight); - !pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoHeight}); - pandora.resizeFolders(); - pandora.$ui.info.resizeInfo(); - */ if (!pandora.user.ui.item) { pandora.resizeFilters(pandora.$ui.rightPanel.width()); if (pandora.user.ui.listView == 'clips') { @@ -893,7 +887,6 @@ pandora.resizeWindow = function() { pandora.$ui.list.size(); } } else { - //Ox.Log('', 'pandora.$ui.window.resize'); pandora.$ui.browser.scrollToSelection(); if (pandora.user.ui.itemView == 'info') { pandora.$ui.item.resize(); From 8a6f29cd313a6460ff90f179881a8219d610f501 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 9 Nov 2011 22:32:54 +0000 Subject: [PATCH 3/3] rewrite history, again --- pandora/0xdb.jsonc | 1 + pandora/urls.py | 1 + static/js/pandora/URL.js | 75 ++++++++++++--------------------- static/js/pandora/account.js | 6 +-- static/js/pandora/appPanel.js | 43 +++++++++++++++++++ static/js/pandora/helpDialog.js | 50 ++++++++++++---------- static/js/pandora/home.js | 10 ++--- static/js/pandora/item.js | 6 ++- static/js/pandora/menu.js | 2 +- static/js/pandora/siteDialog.js | 7 +-- static/js/pandora/utils.js | 57 +++++++++++++++++-------- 11 files changed, 155 insertions(+), 103 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 5673bad6..2b4a64ff 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -617,6 +617,7 @@ "lists": {}, "mapFind": "", "mapSelection": "", + "page": "", "section": "items", "showAnnotations": true, "showBrowser": true, diff --git a/pandora/urls.py b/pandora/urls.py index eb275a1c..770063b9 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -24,6 +24,7 @@ urlpatterns = patterns('', (r'^api/upload/$', 'archive.views.firefogg_upload'), (r'^url=(?P.*)$', 'app.views.redirect_url'), (r'^file/(?P.*)$', 'archive.views.lookup_file'), + (r'^api$', include('api.urls')), (r'^api/$', include('api.urls')), (r'^resetUI$', 'user.views.reset_ui'), (r'', include('item.urls')), diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 1ed860ae..e5ba9ec3 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -6,9 +6,13 @@ pandora.URL = (function() { var self = {}, that = {}; - function getState(keys) { + function getState() { - Ox.Log('GET STATE, UI', pandora.user.ui) + Ox.Log('', 'GET STATE, UI', pandora.user.ui) + + if (pandora.user.ui.page) { + return {page: pandora.user.ui.page}; + } var state = {}; @@ -45,7 +49,7 @@ pandora.URL = (function() { ); } - Ox.Log('URL', 'STATE ...', state) + Ox.Log('', 'URL', 'STATE ...', state) return state; @@ -66,43 +70,7 @@ pandora.URL = (function() { } else if (state.page) { - if (state.page == 'home') { - // if we're on page load, show screen immediately - pandora.$ui.home = pandora.ui.home()[ - !pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen' - ](); - } else if ( - Ox.getPositionById(pandora.site.sitePages, state.page) > -1 - || state.page == 'software' - ) { - if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) { - pandora.$ui.siteDialog.select(state.page); - } else { - pandora.$ui.siteDialog = pandora.ui.siteDialog(state.page).open(); - } - } else if (state.page == 'help') { - pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); - } else if (['signup', 'signin'].indexOf(state.page) > -1) { - if (pandora.user.level == 'guest') { - if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) { - pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(state.page)); - } else { - pandora.$ui.accountDialog = pandora.ui.accountDialog(state.page).open(); - } - } else { - pandora.URL.replace('/'); - } - } else if (['preferences', 'signout'].indexOf(state.page) > -1) { - if (pandora.user.level == 'guest') { - pandora.URL.replace('/'); - } else if (state.page == 'preferences') { - pandora.ui.preferencesDialog().open(); - } else { - pandora.ui.accountSignoutDialog().open(); - } - } else if (state.page == 'api') { - document.location.href = '/api/'; - } + pandora.UI.set(state); callback && callback(); } else { @@ -276,6 +244,10 @@ pandora.URL = (function() { $('.OxDialog:visible').each(function() { Ox.UI.elements[$(this).data('oxid')].close(); }); + if (pandora.$ui.home) { + pandora.UI.set({page: ''}); + pandora.$ui.home.fadeOutScreen(); + } if ( pandora.user.ui.item && pandora.user.ui.itemView == 'video' @@ -283,10 +255,8 @@ pandora.URL = (function() { && pandora.$ui.player.options('fullscreen') ) { pandora.$ui.player.remove(); - //pandora.$ui.player.options({fullscreen: false}); - //$('body > .OxVideoPlayer').remove(); } - if (!Ox.isEmpty(e.state)) { + if (e.state && !Ox.isEmpty(e.state)) { Ox.Log('', 'E.STATE', e.state) document.title = e.state.title; setState(e.state); @@ -313,12 +283,15 @@ pandora.URL = (function() { // sets the URL to the previous URL that.pop = function() { - self.URL.pop(); + self.URL.pop() || that.update(); }; // pushes a new URL (as string or from state) that.push = function(stateOrURL) { - var state, title = pandora.getPageTitle(), url; + var state, + title = pandora.getPageTitle(stateOrURL) + || pandora.getDocumentTitle(), + url; if (Ox.isObject(stateOrURL)) { state = stateOrURL; } else { @@ -329,8 +302,11 @@ pandora.URL = (function() { }; // replaces the current URL (as string or from state) - that.replace = function(stateOrURL) { - var state, title = pandora.getPageTitle(), url; + that.replace = function(stateOrURL, title) { + var state, + title = pandora.getPageTitle(stateOrURL) + || pandora.getDocumentTitle(), + url; if (Ox.isObject(stateOrURL)) { state = stateOrURL; } else { @@ -368,7 +344,10 @@ pandora.URL = (function() { action = 'push'; } state = getState(); - self.URL[action](state, pandora.getPageTitle(), ''); + self.URL[action]( + state, + pandora.getPageTitle(state) || pandora.getDocumentTitle() + ); } }; diff --git a/static/js/pandora/account.js b/static/js/pandora/account.js index a60dfda6..2fa32001 100644 --- a/static/js/pandora/account.js +++ b/static/js/pandora/account.js @@ -58,7 +58,7 @@ pandora.ui.accountDialogOptions = function(action, value) { title: 'Cancel' }).bindEvent('click', function() { pandora.$ui.accountDialog.close(); - pandora.URL.update(); + pandora.UI.set({page: ''}); }); } else if (type == 'submit') { return Ox.Button({ @@ -74,7 +74,7 @@ pandora.ui.accountDialogOptions = function(action, value) { title: buttonTitle[type] + '...' }).bindEvent('click', function() { if (['signin', 'signup'].indexOf(type) > -1) { - pandora.URL.replace({page: type}); + pandora.UI.set({page: type}); } else { pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(type)); } @@ -319,7 +319,7 @@ pandora.ui.accountSignoutDialog = function() { title: 'Stay Signed In' }).bindEvent('click', function() { that.close(); - pandora.URL.update(); + pandora.UI({page: ''}); }), Ox.Button({ id: 'signout', diff --git a/static/js/pandora/appPanel.js b/static/js/pandora/appPanel.js index 17c7e433..00381225 100644 --- a/static/js/pandora/appPanel.js +++ b/static/js/pandora/appPanel.js @@ -13,6 +13,7 @@ pandora.ui.appPanel = function() { ], orientation: 'vertical' }); + setPage(pandora.user.ui.page); that.display = function() { // fixme: move animation into Ox.App var animate = $('.OxScreen').length == 0; @@ -27,6 +28,48 @@ pandora.ui.appPanel = function() { pandora.$ui.appPanel = pandora.ui.appPanel().appendTo(pandora.$ui.body); return that; } + that.bindEvent({ + pandora_page: function(data) { + setPage(data.value); + } + }); + function setPage(page) { + if (page == 'home') { + // if we're on page load, show screen immediately + pandora.$ui.home = pandora.ui.home()[ + !pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen' + ](); + } else if ( + Ox.getPositionById(pandora.site.sitePages, page) > -1 + || page == 'software' + ) { + if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) { + pandora.$ui.siteDialog.select(page); + } else { + pandora.$ui.siteDialog = pandora.ui.siteDialog(page).open(); + } + } else if (page == 'help') { + pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); + } else if (['signup', 'signin'].indexOf(page) > -1) { + if (pandora.user.level == 'guest') { + if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) { + pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(page)); + } else { + pandora.$ui.accountDialog = pandora.ui.accountDialog(page).open(); + } + } else { + pandora.URL.replace('/'); + } + } else if (['preferences', 'signout'].indexOf(page) > -1) { + if (pandora.user.level == 'guest') { + pandora.URL.replace('/'); + } else if (page == 'preferences') { + pandora.ui.preferencesDialog().open(); + } else { + pandora.ui.accountSignoutDialog().open(); + } + } + } return that; }; diff --git a/static/js/pandora/helpDialog.js b/static/js/pandora/helpDialog.js index c74d2a12..3c8e85ee 100644 --- a/static/js/pandora/helpDialog.js +++ b/static/js/pandora/helpDialog.js @@ -3,29 +3,33 @@ pandora.ui.helpDialog = function() { var content = Ox.Element().css({margin: '16px'}), that = Ox.Dialog({ - buttons: [ - Ox.Button({ - id: 'close', - title: 'Close' - }).bindEvent({ - click: function() { - that.close(); - pandora.URL.update(); - } - }) - ], - //closeButton: true, - content: content, - height: Math.round((window.innerHeight - 24) * 0.75), - keys: { - 'escape': 'close' - }, - //maximizeButton: true, - minHeight: 256, - minWidth: 640, - title: 'Help', - width: Math.round(window.innerWidth * 0.75) - }); + buttons: [ + Ox.Button({ + id: 'close', + title: 'Close' + }).bindEvent({ + click: function() { + that.close(); + } + }) + ], + closeButton: true, + content: content, + height: Math.round((window.innerHeight - 24) * 0.75), + keys: { + 'escape': 'close' + }, + maximizeButton: true, + minHeight: 256, + minWidth: 640, + title: 'Help', + width: Math.round(window.innerWidth * 0.75) + }) + .bindEvent({ + close: function(data) { + pandora.UI.set({page: ''}); + } + }); pandora.api.getPage({name: 'help'}, function(result) { //content.html(response.data.body); content.html('Help is coming soon...') diff --git a/static/js/pandora/home.js b/static/js/pandora/home.js index 7583a5b7..328d0925 100644 --- a/static/js/pandora/home.js +++ b/static/js/pandora/home.js @@ -134,7 +134,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.update(); + pandora.UI.set({page: ''}); that.fadeOutScreen(); } }) @@ -154,7 +154,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.push('/signup'); + pandora.UI.set({page: 'signup'}); that.fadeOutScreen(); } }), @@ -173,7 +173,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.push('/signin'); + pandora.UI.set({page :'signin'}); that.fadeOutScreen(); } }), @@ -192,7 +192,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.push('/preferences'); + pandora.UI.set({page: 'preferences'}); that.fadeOutScreen(); } }), @@ -211,7 +211,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.push('/about'); + pandora.UI.set({page: 'about'}); that.fadeOutScreen(); } }) diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 71d2b2c5..97e46d9e 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -11,8 +11,10 @@ pandora.ui.item = function() { }, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) { if (result.status.code == 200) { - // fixme: can the history state title get updated too? - document.title = pandora.getPageTitle(result.data.title); + // we want to cache the title in any way, so that after closing + // a dialog and getting to this item, the title is correct + var documentTitle = pandora.getDocumentTitle(result.data.title); + document.title = pandora.getPageTitle(document.location.pathname) || documentTitle; } /*if (result.status.code != 200) { diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js index f3fb853e..6b58c2c4 100644 --- a/static/js/pandora/menu.js +++ b/static/js/pandora/menu.js @@ -230,7 +230,7 @@ pandora.ui.mainMenu = function() { 'home', 'about', 'news', 'tour', 'faq', 'terms', 'rights', 'contact', 'software', 'signup', 'signin', 'signout', 'preferences', 'help' ].indexOf(data.id) > -1) { - pandora.URL.push('/' + data.id); + pandora.UI.set({page: data.id}); } else if ([ 'newlist', 'newlistfromselection', 'newsmartlist', 'newsmartlistfromresults' ].indexOf(data.id) > -1) { diff --git a/static/js/pandora/siteDialog.js b/static/js/pandora/siteDialog.js index ff454090..e0d36ada 100644 --- a/static/js/pandora/siteDialog.js +++ b/static/js/pandora/siteDialog.js @@ -112,8 +112,7 @@ pandora.ui.siteDialog = function(section) { that.options({ title: Ox.getObjectById(tabs, data.selected).title }); - pandora.URL.push({page: data.selected}); - //history.pushState({page: data.selected}, '', '/' + data.selected); + pandora.UI.set({page: data.selected}); } }); @@ -125,7 +124,6 @@ pandora.ui.siteDialog = function(section) { }).bindEvent({ click: function() { that.close(); - pandora.URL.update(); } }) ], @@ -140,6 +138,9 @@ pandora.ui.siteDialog = function(section) { width: Math.round(window.innerWidth * 0.75), }) .bindEvent({ + close: function(data) { + pandora.UI.set({page: ''}); + }, resize: function(data) { if ($tabPanel.selected() == 'contact') { pandora.$ui.contactForm.resize(); diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index b2537b6f..afccc6b6 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -492,6 +492,25 @@ pandora.getClipsQuery = function() { return clipsQuery; }; +(function() { + var itemTitles = {}; + pandora.getDocumentTitle = function(itemTitle) { + Ox.Log('', 'ITEM TITLES', itemTitles) + 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.getFilterSizes = function() { return Ox.divideInt( window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1, 5 @@ -664,24 +683,26 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) { } }; -(function() { - var itemTitles = {}; - pandora.getPageTitle = function(itemTitle) { - Ox.Log('', 'ITEM TITLES', itemTitles) - 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.getPageTitle = function(stateOrURL) { + var pages = Ox.merge([ + {id: '', title: ''}, + {id: 'help', title: 'Help'}, + {id: 'home', title: ''}, + {id: 'preferences', title: 'Preferences'}, + {id: 'signin', title: 'Sign In'}, + {id: 'signout', title: 'Sign Out'}, + {id: 'signup', title: 'Sign Up'}, + {id: 'software', title: 'Software'} + ], pandora.site.sitePages), + page = Ox.getObjectById( + pages, + Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.substr(1) + ); + return page + ? pandora.site.site.name + + (page.title ? ' - ' + page.title : '') + : null; +}; pandora.getSortKeyData = function(key) { return Ox.getObjectById(pandora.site.itemKeys, key)