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
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||||
pandora.UI = (function() {
|
pandora.UI = (function() {
|
||||||
// fixme: why do we use '|', and not '.', as a separator?
|
// fixme: why do we use '|', and not '.', as a separator?
|
||||||
|
var previousUI = {};
|
||||||
return {
|
return {
|
||||||
// sets pandora.user.ui.key to val
|
// sets pandora.user.ui.key to val
|
||||||
// key foo|bar|baz sets pandora.user.ui.foo.bar.baz
|
// key foo|bar|baz sets pandora.user.ui.foo.bar.baz
|
||||||
// val null removes a key
|
// val null removes a key
|
||||||
|
getPrevious: function() {
|
||||||
|
return previousUI;
|
||||||
|
},
|
||||||
set: function(/*{key: val} or key, val*/) {
|
set: function(/*{key: val} or key, val*/) {
|
||||||
var obj = Ox.makeObject(arguments);
|
var obj = Ox.makeObject(arguments);
|
||||||
|
previousUI = Ox.clone(pandora.user.ui, true);
|
||||||
Ox.forEach(obj, function(val, key) {
|
Ox.forEach(obj, function(val, key) {
|
||||||
Ox.print('key', key, 'val', val);
|
Ox.print('key', key, 'val', val);
|
||||||
var i = 0,
|
var i = 0,
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
pandora.URL = (function() {
|
pandora.URL = (function() {
|
||||||
|
|
||||||
var previousURL = '',
|
var previousUI = {},
|
||||||
|
previousURL = '',
|
||||||
regexps = {
|
regexps = {
|
||||||
'^$': function(pathname, search) {
|
'^$': function(pathname, search) {
|
||||||
if (/^\?url=/.test(search)) {
|
if (/^\?url=/.test(search)) {
|
||||||
|
@ -179,7 +180,7 @@ pandora.URL = (function() {
|
||||||
url = '/' + url;
|
url = '/' + url;
|
||||||
}
|
}
|
||||||
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
|
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
|
||||||
this.update();
|
this._update();
|
||||||
},
|
},
|
||||||
|
|
||||||
replace: function(title, url) {
|
replace: function(title, url) {
|
||||||
|
@ -194,56 +195,76 @@ pandora.URL = (function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
update: 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();
|
Ox.Request.cancel();
|
||||||
$('video').each(function() {
|
$('video').each(function() {
|
||||||
$(this).trigger('stop');
|
$(this).trigger('stop');
|
||||||
});
|
});
|
||||||
this.parse();
|
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());
|
pandora.$ui.appPanel.replaceElement(1, pandora.$ui.mainPanel = pandora.ui.mainPanel());
|
||||||
} else if (pandora.user.ui.sitePage != oldUserUI.sitePage) {
|
} else if (!pandora.user.ui.item && !previousUI.item) {
|
||||||
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
|
||||||
} else if (!pandora.user.ui.item && !oldUserUI.item) {
|
|
||||||
// list to list
|
// list to list
|
||||||
// fixme: isEqual doesn't work here
|
var isClipView = pandora.isClipView(),
|
||||||
if (Ox.isEqual(pandora.user.ui.findQuery, oldUserUI.findQuery) && false) {
|
list = pandora.user.ui.lists[pandora.user.ui.list],
|
||||||
Ox.print('EQUAL', pandora.user.ui.findQuery, oldUserUI.findQuery)
|
previousList = previousUI.lists[previousUI.list],
|
||||||
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.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());
|
||||||
|
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 {
|
} else {
|
||||||
if (pandora.isClipView()) {
|
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
||||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', []);
|
|
||||||
}
|
|
||||||
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
|
||||||
if (pandora.user.ui.list == oldUserUI.list) {
|
|
||||||
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?
|
// fixme: should list selection and deselection happen here?
|
||||||
// (home and menu may cause a list switch)
|
// (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
|
// list to item or item to list
|
||||||
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
||||||
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
||||||
} else {
|
} else {
|
||||||
// item to item
|
// 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.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
||||||
}
|
}
|
||||||
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
|
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
|
||||||
}
|
}
|
||||||
// fixme: should be 'video', not 'player'
|
// fixme: should be 'video', not 'player'
|
||||||
if (
|
if (
|
||||||
oldUserUI.item &&
|
previousUI.item &&
|
||||||
['player', 'timeline'].indexOf(oldUserUI.itemView) > -1
|
['player', 'timeline'].indexOf(previousUI.itemView) > -1
|
||||||
) {
|
) {
|
||||||
var $item = pandora.$ui[
|
var $item = pandora.$ui[
|
||||||
oldUserUI.itemView == 'player' ? 'player' : 'editor'
|
previousUI.itemView == 'player' ? 'player' : 'editor'
|
||||||
];
|
];
|
||||||
$item && pandora.UI.set(
|
$item && pandora.UI.set(
|
||||||
'videoPoints|' + oldUserUI.item + '|position',
|
'videoPoints|' + previousUI.item + '|position',
|
||||||
$item.options('position')
|
$item.options('position')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ pandora.ui.filter = function(list) {
|
||||||
title: 'List',
|
title: 'List',
|
||||||
type: '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,
|
query: list ? list.query : pandora.user.ui.query,
|
||||||
sortKeys: pandora.site.sortKeys,
|
sortKeys: pandora.site.sortKeys,
|
||||||
viewKeys: pandora.site.listViews
|
viewKeys: pandora.site.listViews
|
||||||
|
@ -30,14 +34,12 @@ pandora.ui.filter = function(list) {
|
||||||
query: data.query
|
query: data.query
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
Ox.Request.clearCache(list.id);
|
Ox.Request.clearCache(list.id);
|
||||||
//Ox.Request.clearCache();
|
|
||||||
pandora.$ui.groups.forEach(function($group) {
|
pandora.$ui.groups.forEach(function($group) {
|
||||||
$group.reloadList();
|
$group.reloadList();
|
||||||
});
|
});
|
||||||
pandora.$ui.list
|
pandora.$ui.list
|
||||||
.bindEventOnce({
|
.bindEventOnce({
|
||||||
init: function(data) {
|
init: function(data) {
|
||||||
Ox.print('NUMBER OF ITEMS:', data.items);
|
|
||||||
pandora.$ui.folderList[
|
pandora.$ui.folderList[
|
||||||
pandora.getListData().folder
|
pandora.getListData().folder
|
||||||
].value(list.id, 'items', data.items);
|
].value(list.id, 'items', data.items);
|
||||||
|
@ -45,6 +47,10 @@ pandora.ui.filter = function(list) {
|
||||||
})
|
})
|
||||||
.reloadList();
|
.reloadList();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
pandora.user.ui.query = data.query;
|
||||||
|
pandora.URL.update();
|
||||||
|
//reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -189,7 +189,49 @@ pandora.ui.listIconPanel = function(list) {
|
||||||
size: 288
|
size: 288
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
element: $list
|
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,
|
element: $preview,
|
||||||
|
|
|
@ -194,17 +194,11 @@ pandora.ui.mainMenu = function() {
|
||||||
groups[position].sort[0].key = key;
|
groups[position].sort[0].key = key;
|
||||||
pandora.UI.set({groups: groups});
|
pandora.UI.set({groups: groups});
|
||||||
} else if (data.id == 'sortmovies') {
|
} else if (data.id == 'sortmovies') {
|
||||||
var key = value,
|
pandora.UI.set(
|
||||||
operator = pandora.getSortOperator(key);
|
'lists|' + pandora.user.ui.list + '|sort',
|
||||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator == '+' ? 'ascending' : 'descending'));
|
[{key: value, operator: ''}]
|
||||||
pandora.$ui.sortSelect.options({value: key});
|
);
|
||||||
pandora.$ui.list.options({
|
pandora.URL.update();
|
||||||
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());
|
|
||||||
|
|
||||||
} else if (data.id == 'viewicons') {
|
} else if (data.id == 'viewicons') {
|
||||||
var $list;
|
var $list;
|
||||||
pandora.UI.set({icons: value});
|
pandora.UI.set({icons: value});
|
||||||
|
@ -221,19 +215,11 @@ pandora.ui.mainMenu = function() {
|
||||||
defaultRatio: value == 'posters' ? 5/8 : 1
|
defaultRatio: value == 'posters' ? 5/8 : 1
|
||||||
}).reloadList(true);
|
}).reloadList(true);
|
||||||
} else if (data.id == 'viewmovies') {
|
} else if (data.id == 'viewmovies') {
|
||||||
var isClipView = pandora.isClipView(value),
|
pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', value);
|
||||||
wasClipView = pandora.isClipView(pandora.user.ui.lists[pandora.user.ui.list].listView);
|
pandora.URL.update();
|
||||||
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), value);
|
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) {
|
||||||
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.URL.set(
|
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({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
var key = data.selected[0].id,
|
//var query = Ox.unserialize(document.location.search);
|
||||||
operator = pandora.getSortOperator(key);
|
//query.sort = data.selected.id;
|
||||||
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key);
|
//pandora.URL.set('/' + pandora.user.ui.lists[pandora.user.ui.list].listView + '/?' + Ox.serialize(query));
|
||||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator == '+' ? 'ascending' : 'descending'));
|
pandora.UI.set(
|
||||||
pandora.$ui.list.options({
|
'lists|' + pandora.user.ui.list + '|sort',
|
||||||
sort: [{key: key, operator: operator}]
|
[{key: data.selected[0].id, operator: ''}]
|
||||||
});
|
);
|
||||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|sort', [{key: key, operator: operator}]);
|
pandora.URL.update();
|
||||||
pandora.URL.push(pandora.Query.toString());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -21,21 +21,12 @@ pandora.ui.viewSelect = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: !pandora.user.ui.item ? function(data) {
|
change: !pandora.user.ui.item ? function(data) {
|
||||||
var view = data.selected[0].id,
|
pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', data.selected[0].id);
|
||||||
isClipView = pandora.isClipView(view),
|
pandora.URL.update();
|
||||||
wasClipView = pandora.isClipView();
|
//pandora.URL.set('/' + data.selected[0].id + '/' + document.location.search);
|
||||||
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);
|
|
||||||
} : function(data) {
|
} : function(data) {
|
||||||
var view = data.selected[0].id;
|
pandora.UI.set({itemView: data.selected[0].id});
|
||||||
//pandora.UI.set({itemView: id});
|
pandora.URL.update();
|
||||||
pandora.URL.set(pandora.user.ui.item + '/' + view);
|
|
||||||
// pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
// pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue