From 929cf988a1a1c4ff5d81868997e022b4b258853a Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Wed, 17 Aug 2011 13:23:17 +0000 Subject: [PATCH] don't reload groups when changing list view or list sort --- static/js/pandora/URL.js | 26 +++++++++++++++++++++++--- static/js/pandora/pandora.js | 2 +- static/js/pandora/ui/list.js | 5 ++++- static/js/pandora/ui/sortSelect.js | 21 ++++++++++----------- static/js/pandora/ui/toolbar.js | 1 + static/js/pandora/ui/viewSelect.js | 3 ++- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 7f63533..e79a017 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -78,7 +78,6 @@ pandora.URL = (function() { url = '/' + url; } history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url); - oldUserUI = Ox.clone(pandora.user.ui); this.update(); }, @@ -97,18 +96,39 @@ pandora.URL = (function() { }); }, + push: function(title, url) { + if (arguments.length == 1) { // fixme: remove later + url = title; + } + if (url[0] != '/') { + url = '/' + url; + } + history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url); + }, + update: function() { + var oldUserUI = Ox.clone(pandora.user.ui); this.parse(); if (pandora.user.ui.section != oldUserUI.section) { pandora.$ui.appPanel.replaceElement(1, pandora.$ui.mainPanel = pandora.ui.mainPanel()); } else if (pandora.user.ui.sitePage != oldUserUI.sitePage) { pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); + } else if (!pandora.user.ui.item && !oldUserUI.item) { + // list to list + // fixme: isEqual doesn't work here + if (Ox.isEqual(pandora.user.ui.findQuery, oldUserUI.findQuery) && false) { + Ox.print('EQUAL', pandora.user.ui.findQuery, oldUserUI.findQuery) + pandora.$ui.contentPanel.replaceElement(1, pandora.ui.list()); + } else { + pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); + pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); + } } else if (!pandora.user.ui.item || !oldUserUI.item) { - // list to list, list to item, item to list + // list to item or item to list pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); } else { - // item to items + // item to item pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item()); } diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 4b7a150..0fd2541 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -130,7 +130,7 @@ pandora.reloadGroups = function(i) { }); } }); - history.pushState({}, '', pandora.Query.toString()); + pandora.URL.push(pandora.Query.toString()); }; pandora.getListData = function() { diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 44ae094..4355eff 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -47,6 +47,7 @@ pandora.ui.list = function() { // fixme: remove view argument }), callback); }, scrollbarVisible: true, + selected: pandora.user.ui.lists[pandora.user.ui.list].selected, sort: pandora.user.ui.lists[pandora.user.ui.list].sort }) .bindEvent({ @@ -413,7 +414,8 @@ pandora.ui.list = function() { // fixme: remove view argument }, select: function(event, data) { var $still, $timeline; - pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids; + pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids); + //pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids; if (data.ids.length) { pandora.$ui.mainMenu.enableItem('copy'); pandora.$ui.mainMenu.enableItem('openmovie'); @@ -438,6 +440,7 @@ pandora.ui.list = function() { // fixme: remove view argument }); }, sort: function(event, data) { + Ox.print('--SORT--', pandora.user.ui.sort[0].key) /* some magic has already set user.ui.sort Ox.print(':', user.ui.sort[0]) if (data.key != user.ui.sort[0].key) { diff --git a/static/js/pandora/ui/sortSelect.js b/static/js/pandora/ui/sortSelect.js index 9d6be32..dd31909 100644 --- a/static/js/pandora/ui/sortSelect.js +++ b/static/js/pandora/ui/sortSelect.js @@ -17,18 +17,17 @@ pandora.ui.sortSelect = function() { }) .bindEvent({ change: function(event, data) { - var id = data.selected[0].id, - operator = pandora.getSortOperator(id); - /* - pandora.user.ui.lists[pandora.user.ui.list].sort[0] = { - key: id, - operator: operator - }; - */ - pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + id); + var key = data.selected[0].id, + operator = pandora.getSortOperator(key); + pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key); pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending')); - pandora.$ui.list.sortList(id, operator); - pandora.URL.set(pandora.Query.toString()); + pandora.$ui.list.options({ + sort: [{key: key, operator: operator}] + }); + // fixme: why does this not work?? + //pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: key, operator: operator}]); + pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator}; + pandora.URL.push(pandora.Query.toString()); } }); return that; diff --git a/static/js/pandora/ui/toolbar.js b/static/js/pandora/ui/toolbar.js index 6b7ef58..5d248a4 100644 --- a/static/js/pandora/ui/toolbar.js +++ b/static/js/pandora/ui/toolbar.js @@ -1,4 +1,5 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript + pandora.ui.toolbar = function() { var that = Ox.Bar({ size: 24 diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index a6aa358..39cc6cd 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -26,7 +26,8 @@ pandora.ui.viewSelect = function() { var id = data.selected[0].id; pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + id); pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), id); - pandora.URL.set(pandora.Query.toString()); + pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list()); + pandora.URL.push(pandora.Query.toString()); } : function(event, data) { var id = data.selected[0].id; //pandora.UI.set({itemView: id});