forked from 0x2620/pandora
update sort menu and select if navigating to or from clip view
This commit is contained in:
parent
412a5d2bbe
commit
eac4160fbb
7 changed files with 91 additions and 58 deletions
|
@ -6,13 +6,13 @@
|
||||||
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
|
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
|
||||||
},
|
},
|
||||||
"clipKeys": [
|
"clipKeys": [
|
||||||
{"id": "value", "title": "Text"},
|
{"id": "clip:value", "title": "Clip Text", "type": "string"},
|
||||||
{"id": "in", "title": "Position"},
|
{"id": "clip:position", "title": "Clip Position", "type": "float"},
|
||||||
{"id": "duration", "title": "Duration"},
|
{"id": "clip:duration", "title": "Clip Duration", "type": "float"},
|
||||||
{"id": "hue", "title": "Hue"},
|
{"id": "clip:hue", "title": "Clip Hue", "type": "hue"},
|
||||||
{"id": "saturation", "title": "Saturation"},
|
{"id": "clip:saturation", "title": "Clip Saturation", "type": "float"},
|
||||||
{"id": "lightness", "title": "Lightness"},
|
{"id": "clip:lightness", "title": "Clip Lightness", "type": "float"},
|
||||||
{"id": "volume", "title": "Volume"}
|
{"id": "clip:volume", "title": "Clip Volume", "type": "float"}
|
||||||
],
|
],
|
||||||
"groups": [
|
"groups": [
|
||||||
{"id": "director", "title": "Director"},
|
{"id": "director", "title": "Director"},
|
||||||
|
|
|
@ -142,6 +142,7 @@ pandora.Query = (function() {
|
||||||
ret.list = ret.query.conditions[index].value;
|
ret.list = ret.query.conditions[index].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret.groups = getGroupsData(ret.query);
|
||||||
// find is populated if exactly one condition in an & query
|
// find is populated if exactly one condition in an & query
|
||||||
// has a findKey as key and "" as operator
|
// has a findKey as key and "" as operator
|
||||||
// (and all other conditions are either list or groups)
|
// (and all other conditions are either list or groups)
|
||||||
|
@ -179,7 +180,6 @@ pandora.Query = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret.groups = getGroupsData(ret.query);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ pandora.enableDragAndDrop = function($list, canMove) {
|
||||||
!pandora.user.ui.showFolder.items[title] && $bar.trigger('dblclick');
|
!pandora.user.ui.showFolder.items[title] && $bar.trigger('dblclick');
|
||||||
}
|
}
|
||||||
if (!scrollInterval) {
|
if (!scrollInterval) {
|
||||||
|
//Ox.print('AT TOP', isAtListsTop(event), 'AT BOTTOM', isAtListsBottom(event))
|
||||||
scroll = isAtListsTop(event) ? -16
|
scroll = isAtListsTop(event) ? -16
|
||||||
: isAtListsBottom(event) ? 16 : 0
|
: isAtListsBottom(event) ? 16 : 0
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
|
@ -321,8 +322,38 @@ pandora.getListData = function() {
|
||||||
return data;
|
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
|
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(
|
return ['hue', 'string', 'text'].indexOf(
|
||||||
Ox.isArray(type) ? type[0] : type
|
Ox.isArray(type) ? type[0] : type
|
||||||
) > -1 ? '+' : '-';
|
) > -1 ? '+' : '-';
|
||||||
|
|
|
@ -165,6 +165,9 @@ pandora.ui.group = function(id) {
|
||||||
replaceGroup(i, id_);
|
replaceGroup(i, 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) {
|
function replaceGroup(i, id, query) {
|
||||||
// if query is passed, selected items will be derived from it
|
// if query is passed, selected items will be derived from it
|
||||||
var isOuter = i % 4 == 0;
|
var isOuter = i % 4 == 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||||
pandora.ui.mainMenu = function() {
|
pandora.ui.mainMenu = function() {
|
||||||
var isGuest = pandora.user.level == 'guest',
|
var isGuest = pandora.user.level == 'guest',
|
||||||
|
list = pandora.user.ui.lists[pandora.user.ui.list],
|
||||||
that = Ox.MainMenu({
|
that = Ox.MainMenu({
|
||||||
extras: [
|
extras: [
|
||||||
$('<div>').html('beta').css({marginRight: '8px', color: 'rgb(128, 128, 128)'}),
|
$('<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: [
|
{ id: 'movies', title: 'View ' + pandora.site.itemName.plural, items: [
|
||||||
{ group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) {
|
{ group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) {
|
||||||
return Ox.extend({
|
return Ox.extend({
|
||||||
checked: pandora.user.ui.lists[pandora.user.ui.list].listView == view.id,
|
checked: list.listView == view.id,
|
||||||
}, view);
|
}, view);
|
||||||
}) },
|
}) },
|
||||||
]},
|
]},
|
||||||
|
@ -112,24 +113,7 @@ pandora.ui.mainMenu = function() {
|
||||||
]}
|
]}
|
||||||
] }
|
] }
|
||||||
]},
|
]},
|
||||||
{ id: 'sortMenu', title: 'Sort', items: [
|
pandora.getSortMenu(),
|
||||||
{ 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' }
|
|
||||||
] },
|
|
||||||
{ id: 'findMenu', title: 'Find', items: [
|
{ id: 'findMenu', title: 'Find', items: [
|
||||||
{ id: 'find', title: 'Find', items: [
|
{ id: 'find', title: 'Find', items: [
|
||||||
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {
|
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {
|
||||||
|
|
|
@ -1,33 +1,43 @@
|
||||||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||||
pandora.ui.sortSelect = function() {
|
pandora.ui.sortSelect = function() {
|
||||||
var that = Ox.Select({
|
var list = pandora.user.ui.lists[pandora.user.ui.list],
|
||||||
id: 'sortSelect',
|
items = pandora.site.sortKeys.map(function(key) {
|
||||||
items: pandora.site.sortKeys.map(function(key) {
|
return Ox.extend(Ox.clone(key), {
|
||||||
//Ox.print('????', pandora.user.ui.lists[pandora.user.ui.list].sort.key, key.id)
|
checked: list.sort[0].key == key.id,
|
||||||
return Ox.extend(Ox.extend({}, key), {
|
title: 'Sort by ' + key.title
|
||||||
checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id,
|
});
|
||||||
title: 'Sort by ' + key.title
|
}),
|
||||||
});
|
that;
|
||||||
}),
|
if (list.listView == 'clip') {
|
||||||
width: 144
|
items = Ox.merge(pandora.site.clipKeys.map(function(key) {
|
||||||
})
|
return Ox.extend(Ox.clone(key), {
|
||||||
.css({
|
checked: list.sort[0].key == key.id,
|
||||||
float: 'left',
|
title: 'Sort by ' + key.title
|
||||||
margin: '4px 0 0 4px'
|
});
|
||||||
})
|
}), {}, items);
|
||||||
.bindEvent({
|
}
|
||||||
change: function(data) {
|
that = Ox.Select({
|
||||||
var key = data.selected[0].id,
|
id: 'sortSelect',
|
||||||
operator = pandora.getSortOperator(key);
|
items: items,
|
||||||
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key);
|
width: 144
|
||||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
|
})
|
||||||
pandora.$ui.list.options({
|
.css({
|
||||||
sort: [{key: key, operator: operator}]
|
float: 'left',
|
||||||
});
|
margin: '4px 0 0 4px'
|
||||||
pandora.UI.set('lists|' + pandora.user.ui.list + '|sort', [{key: key, operator: operator}]);
|
})
|
||||||
pandora.URL.push(pandora.Query.toString());
|
.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());
|
||||||
|
}
|
||||||
|
});
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,14 @@ 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;
|
var view = data.selected[0].id,
|
||||||
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view);
|
wasClipView = pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip';
|
||||||
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), view);
|
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.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||||
pandora.URL.push('/' + view + '/' + document.location.search);
|
pandora.URL.push('/' + view + '/' + document.location.search);
|
||||||
// pandora.URL.set('/' + view + '/' + document.location.search);
|
// pandora.URL.set('/' + view + '/' + document.location.search);
|
||||||
|
|
Loading…
Reference in a new issue