update sort menu and select if navigating to or from clip view

This commit is contained in:
rolux 2011-09-17 20:47:50 +00:00
parent 412a5d2bbe
commit eac4160fbb
7 changed files with 91 additions and 58 deletions

View file

@ -6,13 +6,13 @@
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
},
"clipKeys": [
{"id": "value", "title": "Text"},
{"id": "in", "title": "Position"},
{"id": "duration", "title": "Duration"},
{"id": "hue", "title": "Hue"},
{"id": "saturation", "title": "Saturation"},
{"id": "lightness", "title": "Lightness"},
{"id": "volume", "title": "Volume"}
{"id": "clip:value", "title": "Clip Text", "type": "string"},
{"id": "clip:position", "title": "Clip Position", "type": "float"},
{"id": "clip:duration", "title": "Clip Duration", "type": "float"},
{"id": "clip:hue", "title": "Clip Hue", "type": "hue"},
{"id": "clip:saturation", "title": "Clip Saturation", "type": "float"},
{"id": "clip:lightness", "title": "Clip Lightness", "type": "float"},
{"id": "clip:volume", "title": "Clip Volume", "type": "float"}
],
"groups": [
{"id": "director", "title": "Director"},

View file

@ -142,6 +142,7 @@ pandora.Query = (function() {
ret.list = ret.query.conditions[index].value;
}
}
ret.groups = getGroupsData(ret.query);
// find is populated if exactly one condition in an & query
// has a findKey as key and "" as operator
// (and all other conditions are either list or groups)
@ -179,7 +180,6 @@ pandora.Query = (function() {
}
}
}
ret.groups = getGroupsData(ret.query);
return ret;
}

View file

@ -72,6 +72,7 @@ pandora.enableDragAndDrop = function($list, canMove) {
!pandora.user.ui.showFolder.items[title] && $bar.trigger('dblclick');
}
if (!scrollInterval) {
//Ox.print('AT TOP', isAtListsTop(event), 'AT BOTTOM', isAtListsBottom(event))
scroll = isAtListsTop(event) ? -16
: isAtListsBottom(event) ? 16 : 0
if (scroll) {
@ -321,8 +322,38 @@ pandora.getListData = function() {
return data;
};
pandora.getSortMenu = function() {
var list = pandora.user.ui.lists[pandora.user.ui.list];
return { id: 'sortMenu', title: 'Sort', items: [
{ id: 'sortmovies', title: 'Sort ' + (list.listView == 'clip' ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
{ group: 'sortmovies', min: 1, max: 1, items: Ox.merge(list.listView == 'clip' ? Ox.merge(pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), {
checked: list.sort[0].key == key.id
});
}), {}) : [], pandora.site.sortKeys.map(function(key) {
return Ox.extend({
checked: list.sort[0].key == key.id
}, key);
})) }
] },
{ id: 'ordermovies', title: 'Order ' + (list.listView == 'clip' ? 'Clips' : pandora.site.itemName.plural), items: [
{ group: 'ordermovies', min: 1, max: 1, items: [
{ id: 'ascending', title: 'Ascending', checked: (list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)) == '+' },
{ id: 'descending', title: 'Descending', checked: (list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)) == '-' }
]}
] },
{ id: 'advancedsort', title: 'Advanced Sort...', keyboard: 'shift control s' },
{},
{ id: 'groupsstuff', title: 'Groups Stuff' }
] };
};
pandora.getSortOperator = function(key) { // fixme: make static
var type = Ox.getObjectById(pandora.site.itemKeys, key).type;
Ox.print('getSortOperator', key)
var type = Ox.getObjectById(
/^clip:/.test(key) ? pandora.site.clipKeys : pandora.site.itemKeys,
key
).type;
return ['hue', 'string', 'text'].indexOf(
Ox.isArray(type) ? type[0] : type
) > -1 ? '+' : '-';

View file

@ -165,6 +165,9 @@ pandora.ui.group = function(id) {
replaceGroup(i, id_);
replaceGroup(i_, id);
}
// fixme: there is an obscure special case not yet covered:
// switching to a new group may change find from advanced to not advanced
// if part of the existing query works as a group selection in the new group
function replaceGroup(i, id, query) {
// if query is passed, selected items will be derived from it
var isOuter = i % 4 == 0;

View file

@ -1,6 +1,7 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.mainMenu = function() {
var isGuest = pandora.user.level == 'guest',
list = pandora.user.ui.lists[pandora.user.ui.list],
that = Ox.MainMenu({
extras: [
$('<div>').html('beta').css({marginRight: '8px', color: 'rgb(128, 128, 128)'}),
@ -69,7 +70,7 @@ pandora.ui.mainMenu = function() {
{ id: 'movies', title: 'View ' + pandora.site.itemName.plural, items: [
{ group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) {
return Ox.extend({
checked: pandora.user.ui.lists[pandora.user.ui.list].listView == view.id,
checked: list.listView == view.id,
}, view);
}) },
]},
@ -112,24 +113,7 @@ pandora.ui.mainMenu = function() {
]}
] }
]},
{ id: 'sortMenu', title: 'Sort', items: [
{ id: 'sortmovies', title: 'Sort ' + pandora.site.itemName.plural + ' by', items: [
{ group: 'sortmovies', min: 1, max: 1, items: pandora.site.sortKeys.map(function(key) {
return Ox.extend({
checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id
}, key);
}) }
] },
{ id: 'ordermovies', title: 'Order ' + pandora.site.itemName.plural, items: [
{ group: 'ordermovies', min: 1, max: 1, items: [
{ id: 'ascending', title: 'Ascending', checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].operator == '+' },
{ id: 'descending', title: 'Descending', checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].operator == '-' }
]}
] },
{ id: 'advancedsort', title: 'Advanced Sort...', keyboard: 'shift control s' },
{},
{ id: 'groupsstuff', title: 'Groups Stuff' }
] },
pandora.getSortMenu(),
{ id: 'findMenu', title: 'Find', items: [
{ id: 'find', title: 'Find', items: [
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {

View file

@ -1,14 +1,24 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.sortSelect = function() {
var that = Ox.Select({
id: 'sortSelect',
items: pandora.site.sortKeys.map(function(key) {
//Ox.print('????', pandora.user.ui.lists[pandora.user.ui.list].sort.key, key.id)
return Ox.extend(Ox.extend({}, key), {
checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id,
var list = pandora.user.ui.lists[pandora.user.ui.list],
items = pandora.site.sortKeys.map(function(key) {
return Ox.extend(Ox.clone(key), {
checked: list.sort[0].key == key.id,
title: 'Sort by ' + key.title
});
}),
that;
if (list.listView == 'clip') {
items = Ox.merge(pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), {
checked: list.sort[0].key == key.id,
title: 'Sort by ' + key.title
});
}), {}, items);
}
that = Ox.Select({
id: 'sortSelect',
items: items,
width: 144
})
.css({
@ -20,7 +30,7 @@ pandora.ui.sortSelect = function() {
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.mainMenu.checkItem('sortMenu_ordermovies_' + (operator == '+' ? 'ascending' : 'descending'));
pandora.$ui.list.options({
sort: [{key: key, operator: operator}]
});

View file

@ -21,9 +21,14 @@ pandora.ui.viewSelect = function() {
})
.bindEvent({
change: !pandora.user.ui.item ? function(data) {
var view = data.selected[0].id;
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view);
var view = data.selected[0].id,
wasClipView = pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip';
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), view);
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view);
if (view == 'clip' || wasClipView) {
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
}
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
pandora.URL.push('/' + view + '/' + document.location.search);
// pandora.URL.set('/' + view + '/' + document.location.search);