forked from 0x2620/pandora
make advanced find work; put more logic into the url controller
This commit is contained in:
parent
62a952b8b0
commit
4f34613d80
7 changed files with 125 additions and 75 deletions
|
@ -1,12 +1,17 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.UI = (function() {
|
||||
// fixme: why do we use '|', and not '.', as a separator?
|
||||
var previousUI = {};
|
||||
return {
|
||||
// sets pandora.user.ui.key to val
|
||||
// key foo|bar|baz sets pandora.user.ui.foo.bar.baz
|
||||
// val null removes a key
|
||||
getPrevious: function() {
|
||||
return previousUI;
|
||||
},
|
||||
set: function(/*{key: val} or key, val*/) {
|
||||
var obj = Ox.makeObject(arguments);
|
||||
previousUI = Ox.clone(pandora.user.ui, true);
|
||||
Ox.forEach(obj, function(val, key) {
|
||||
Ox.print('key', key, 'val', val);
|
||||
var i = 0,
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
pandora.URL = (function() {
|
||||
|
||||
var previousURL = '',
|
||||
var previousUI = {},
|
||||
previousURL = '',
|
||||
regexps = {
|
||||
'^$': function(pathname, search) {
|
||||
if (/^\?url=/.test(search)) {
|
||||
|
@ -179,7 +180,7 @@ pandora.URL = (function() {
|
|||
url = '/' + url;
|
||||
}
|
||||
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
|
||||
this.update();
|
||||
this._update();
|
||||
},
|
||||
|
||||
replace: function(title, url) {
|
||||
|
@ -194,56 +195,76 @@ pandora.URL = (function() {
|
|||
},
|
||||
|
||||
update: function() {
|
||||
var oldUserUI = Ox.clone(pandora.user.ui);
|
||||
this.set(pandora.Query.toString());
|
||||
},
|
||||
|
||||
_update: function() {
|
||||
// fixme: make this method private
|
||||
var previousUI = pandora.UI.getPrevious();
|
||||
Ox.print('now', pandora.user.ui, 'previously', previousUI)
|
||||
Ox.Request.cancel();
|
||||
$('video').each(function() {
|
||||
$(this).trigger('stop');
|
||||
});
|
||||
this.parse();
|
||||
if (pandora.user.ui.section != oldUserUI.section) {
|
||||
if (pandora.user.ui.section != previousUI.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) {
|
||||
} else if (!pandora.user.ui.item && !previousUI.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 {
|
||||
if (pandora.isClipView()) {
|
||||
var isClipView = pandora.isClipView(),
|
||||
list = pandora.user.ui.lists[pandora.user.ui.list],
|
||||
previousList = previousUI.lists[previousUI.list],
|
||||
wasClipView = pandora.isClipView(previousList.listView);
|
||||
if (list.listView != previousList.listView) {
|
||||
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + list.listView);
|
||||
pandora.$ui.viewSelect.options({value: list.listView});
|
||||
Ox.print('is', isClipView, 'was', wasClipView);
|
||||
if (isClipView != wasClipView) {
|
||||
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
|
||||
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
|
||||
if (isClipView && !wasClipView) {
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', []);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Ox.isEqual(list.sort, previousList.sort)) {
|
||||
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + list.sort[0].key);
|
||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (
|
||||
list.sort[0].operator == '' ? pandora.getSortOperator(list.sort[0].key)
|
||||
: list.sort[0].operator == '+' ? 'ascending' : 'descending'
|
||||
));
|
||||
pandora.$ui.sortSelect.options({value: list.sort[0].key});
|
||||
}
|
||||
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
||||
if (pandora.user.ui.list == oldUserUI.list) {
|
||||
Ox.print('EQUAL?', pandora.user.ui.query, previousUI.query, Ox.isEqual(pandora.user.ui.query, previousUI.query))
|
||||
if (Ox.isEqual(pandora.user.ui.query, previousUI.query)) {
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||
} else {
|
||||
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
||||
}
|
||||
}
|
||||
// fixme: should list selection and deselection happen here?
|
||||
// (home and menu may cause a list switch)
|
||||
} else if (!pandora.user.ui.item || !oldUserUI.item) {
|
||||
} else if (!pandora.user.ui.item || !previousUI.item) {
|
||||
// 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 item
|
||||
if (pandora.user.ui.item != oldUserUI.item) {
|
||||
if (pandora.user.ui.item != previousUI.item) {
|
||||
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
||||
}
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
|
||||
}
|
||||
// fixme: should be 'video', not 'player'
|
||||
if (
|
||||
oldUserUI.item &&
|
||||
['player', 'timeline'].indexOf(oldUserUI.itemView) > -1
|
||||
previousUI.item &&
|
||||
['player', 'timeline'].indexOf(previousUI.itemView) > -1
|
||||
) {
|
||||
var $item = pandora.$ui[
|
||||
oldUserUI.itemView == 'player' ? 'player' : 'editor'
|
||||
previousUI.itemView == 'player' ? 'player' : 'editor'
|
||||
];
|
||||
$item && pandora.UI.set(
|
||||
'videoPoints|' + oldUserUI.item + '|position',
|
||||
'videoPoints|' + previousUI.item + '|position',
|
||||
$item.options('position')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ pandora.ui.filter = function(list) {
|
|||
title: 'List',
|
||||
type: 'list'
|
||||
}),
|
||||
list: list ? null : {
|
||||
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
||||
view: pandora.user.ui.lists[pandora.user.ui.list].listView
|
||||
},
|
||||
query: list ? list.query : pandora.user.ui.query,
|
||||
sortKeys: pandora.site.sortKeys,
|
||||
viewKeys: pandora.site.listViews
|
||||
|
@ -30,14 +34,12 @@ pandora.ui.filter = function(list) {
|
|||
query: data.query
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache(list.id);
|
||||
//Ox.Request.clearCache();
|
||||
pandora.$ui.groups.forEach(function($group) {
|
||||
$group.reloadList();
|
||||
});
|
||||
pandora.$ui.list
|
||||
.bindEventOnce({
|
||||
init: function(data) {
|
||||
Ox.print('NUMBER OF ITEMS:', data.items);
|
||||
pandora.$ui.folderList[
|
||||
pandora.getListData().folder
|
||||
].value(list.id, 'items', data.items);
|
||||
|
@ -45,6 +47,10 @@ pandora.ui.filter = function(list) {
|
|||
})
|
||||
.reloadList();
|
||||
});
|
||||
} else {
|
||||
pandora.user.ui.query = data.query;
|
||||
pandora.URL.update();
|
||||
//reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -188,8 +188,50 @@ pandora.ui.listIconPanel = function(list) {
|
|||
),
|
||||
size: 288
|
||||
},
|
||||
{
|
||||
element: Ox.SplitPanel({
|
||||
elements: [
|
||||
{
|
||||
element: Ox.Bar({size: 24}).append(
|
||||
Ox.FormElementGroup({
|
||||
elements: [
|
||||
pandora.$ui.findIconItemSelect = Ox.Select({
|
||||
items: pandora.site.findKeys,
|
||||
overlap: 'right',
|
||||
type: 'image'
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
|
||||
}
|
||||
}),
|
||||
pandora.$ui.findIconItemInput = Ox.Input({
|
||||
changeOnKeypress: true,
|
||||
clear: true,
|
||||
placeholder: 'Find: Foo',
|
||||
width: 120
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
|
||||
}
|
||||
})
|
||||
],
|
||||
})
|
||||
.css({
|
||||
float: 'right',
|
||||
margin: '4px',
|
||||
align: 'right'
|
||||
})
|
||||
),
|
||||
size: 24
|
||||
},
|
||||
{
|
||||
element: $list
|
||||
}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
})
|
||||
},
|
||||
{
|
||||
element: $preview,
|
||||
|
|
|
@ -194,17 +194,11 @@ pandora.ui.mainMenu = function() {
|
|||
groups[position].sort[0].key = key;
|
||||
pandora.UI.set({groups: groups});
|
||||
} else if (data.id == 'sortmovies') {
|
||||
var key = value,
|
||||
operator = pandora.getSortOperator(key);
|
||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator == '+' ? 'ascending' : 'descending'));
|
||||
pandora.$ui.sortSelect.options({value: key});
|
||||
pandora.$ui.list.options({
|
||||
sort: [{key: key, operator: operator}]
|
||||
});
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|sort', [{key: key, operator: operator}]);
|
||||
//pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator};
|
||||
pandora.URL.push(pandora.Query.toString());
|
||||
|
||||
pandora.UI.set(
|
||||
'lists|' + pandora.user.ui.list + '|sort',
|
||||
[{key: value, operator: ''}]
|
||||
);
|
||||
pandora.URL.update();
|
||||
} else if (data.id == 'viewicons') {
|
||||
var $list;
|
||||
pandora.UI.set({icons: value});
|
||||
|
@ -221,19 +215,11 @@ pandora.ui.mainMenu = function() {
|
|||
defaultRatio: value == 'posters' ? 5/8 : 1
|
||||
}).reloadList(true);
|
||||
} else if (data.id == 'viewmovies') {
|
||||
var isClipView = pandora.isClipView(value),
|
||||
wasClipView = pandora.isClipView(pandora.user.ui.lists[pandora.user.ui.list].listView);
|
||||
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), value);
|
||||
if (isClipView != wasClipView) {
|
||||
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
|
||||
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
|
||||
}
|
||||
pandora.$ui.viewSelect.options({value: value});
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||
pandora.URL.push('/' + value + '/' + document.location.search);
|
||||
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(data.id) > -1) {
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', value);
|
||||
pandora.URL.update();
|
||||
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) {
|
||||
pandora.URL.set(
|
||||
data.checked[0] ? '?find=list:' + data.checked[0].id.substr(8) : ''
|
||||
data.checked[0] ? '?find=list:' + value.substr(8) : ''
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -27,15 +27,14 @@ pandora.ui.sortSelect = function() {
|
|||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
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.options({
|
||||
sort: [{key: key, operator: operator}]
|
||||
});
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|sort', [{key: key, operator: operator}]);
|
||||
pandora.URL.push(pandora.Query.toString());
|
||||
//var query = Ox.unserialize(document.location.search);
|
||||
//query.sort = data.selected.id;
|
||||
//pandora.URL.set('/' + pandora.user.ui.lists[pandora.user.ui.list].listView + '/?' + Ox.serialize(query));
|
||||
pandora.UI.set(
|
||||
'lists|' + pandora.user.ui.list + '|sort',
|
||||
[{key: data.selected[0].id, operator: ''}]
|
||||
);
|
||||
pandora.URL.update();
|
||||
}
|
||||
});
|
||||
return that;
|
||||
|
|
|
@ -21,21 +21,12 @@ pandora.ui.viewSelect = function() {
|
|||
})
|
||||
.bindEvent({
|
||||
change: !pandora.user.ui.item ? function(data) {
|
||||
var view = data.selected[0].id,
|
||||
isClipView = pandora.isClipView(view),
|
||||
wasClipView = pandora.isClipView();
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', view);
|
||||
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view);
|
||||
if (isClipView != wasClipView) {
|
||||
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
|
||||
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
|
||||
}
|
||||
pandora.URL.set(view + '/' + document.location.search);
|
||||
// pandora.URL.set('/' + view + '/' + document.location.search);
|
||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', data.selected[0].id);
|
||||
pandora.URL.update();
|
||||
//pandora.URL.set('/' + data.selected[0].id + '/' + document.location.search);
|
||||
} : function(data) {
|
||||
var view = data.selected[0].id;
|
||||
//pandora.UI.set({itemView: id});
|
||||
pandora.URL.set(pandora.user.ui.item + '/' + view);
|
||||
pandora.UI.set({itemView: data.selected[0].id});
|
||||
pandora.URL.update();
|
||||
// pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue