diff --git a/pandora/0xdb.json b/pandora/0xdb.json
index a5fd8865..1fe05e75 100644
--- a/pandora/0xdb.json
+++ b/pandora/0xdb.json
@@ -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"},
diff --git a/static/js/pandora/Query.js b/static/js/pandora/Query.js
index 1d9dcd29..1e924217 100644
--- a/static/js/pandora/Query.js
+++ b/static/js/pandora/Query.js
@@ -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;
}
diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js
index 55bea5af..2bf57113 100644
--- a/static/js/pandora/pandora.js
+++ b/static/js/pandora/pandora.js
@@ -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 ? '+' : '-';
diff --git a/static/js/pandora/ui/group.js b/static/js/pandora/ui/group.js
index 6e2f75bf..e89535ba 100644
--- a/static/js/pandora/ui/group.js
+++ b/static/js/pandora/ui/group.js
@@ -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;
diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js
index d150d4d5..8bfd3c95 100644
--- a/static/js/pandora/ui/menu.js
+++ b/static/js/pandora/ui/menu.js
@@ -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: [
$('
').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) {
diff --git a/static/js/pandora/ui/sortSelect.js b/static/js/pandora/ui/sortSelect.js
index 72a08b38..7055426f 100644
--- a/static/js/pandora/ui/sortSelect.js
+++ b/static/js/pandora/ui/sortSelect.js
@@ -1,33 +1,43 @@
// 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,
- title: 'Sort by ' + key.title
- });
- }),
- width: 144
- })
- .css({
- float: 'left',
- margin: '4px 0 0 4px'
- })
- .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 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({
+ float: 'left',
+ margin: '4px 0 0 4px'
+ })
+ .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;
};
diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js
index 041b55eb..f0b0c79f 100644
--- a/static/js/pandora/ui/viewSelect.js
+++ b/static/js/pandora/ui/viewSelect.js
@@ -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);