2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.mainMenu = function() {
|
2011-09-27 14:14:40 +00:00
|
|
|
|
2011-10-06 15:38:29 +00:00
|
|
|
var isAdmin = pandora.user.level == 'admin',
|
|
|
|
isGuest = pandora.user.level == 'guest',
|
2011-09-23 10:44:54 +00:00
|
|
|
ui = pandora.user.ui,
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.MainMenu({
|
2011-05-25 19:42:45 +00:00
|
|
|
extras: [
|
|
|
|
$('<div>').html('beta').css({marginRight: '8px', color: 'rgb(128, 128, 128)'}),
|
2011-06-19 17:49:25 +00:00
|
|
|
pandora.$ui.loadingIcon = Ox.LoadingIcon({
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 'medium'
|
|
|
|
})
|
|
|
|
],
|
|
|
|
id: 'mainMenu',
|
|
|
|
menus: [
|
2011-06-06 15:48:11 +00:00
|
|
|
{ id: pandora.site.site.id + 'Menu', title: pandora.site.site.name, items: [
|
2011-05-25 19:42:45 +00:00
|
|
|
{ id: 'home', title: 'Home' },
|
|
|
|
{},
|
2011-06-06 15:48:11 +00:00
|
|
|
{ id: 'about', title: 'About ' + pandora.site.site.name },
|
|
|
|
{ id: 'news', title: pandora.site.site.name + ' News' },
|
2011-05-25 19:42:45 +00:00
|
|
|
{ id: 'tour', title: 'Take a Tour' },
|
|
|
|
{ id: 'faq', title: 'Frequently Asked Questions' },
|
|
|
|
{ id: 'terms', title: 'Terms of Service' },
|
2011-08-16 17:03:14 +00:00
|
|
|
{ id: 'contact', title: 'Contact ' + pandora.site.site.name },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-08-16 17:03:14 +00:00
|
|
|
{ id: 'software', title: 'Software' }
|
2011-05-25 19:42:45 +00:00
|
|
|
] },
|
|
|
|
{ id: 'userMenu', title: 'User', items: [
|
2011-06-06 15:48:11 +00:00
|
|
|
{ id: 'username', title: 'User: ' + (isGuest ? 'not logged in' : pandora.user.username), disabled: true },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
|
|
|
{ id: 'preferences', title: 'Preferences...', disabled: isGuest, keyboard: 'control ,' },
|
2011-08-16 17:03:14 +00:00
|
|
|
{ id: 'archives', title: 'Archives...', disabled: isGuest },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-08-24 21:04:13 +00:00
|
|
|
{ id: 'signup', title: 'Sign Up...', disabled: !isGuest },
|
2011-09-23 10:44:54 +00:00
|
|
|
isGuest ? { id: 'signin', title: 'Sign In...' }
|
|
|
|
: { id: 'signout', title: 'Sign Out...'}
|
2011-05-25 19:42:45 +00:00
|
|
|
] },
|
2011-09-27 14:14:40 +00:00
|
|
|
getListMenu(),
|
2011-05-25 19:42:45 +00:00
|
|
|
{ id: 'editMenu', title: 'Edit', items: [
|
|
|
|
{ id: 'undo', title: 'Undo', disabled: true, keyboard: 'control z' },
|
|
|
|
{ id: 'redo', title: 'Redo', disabled: true, keyboard: 'shift control z' },
|
|
|
|
{},
|
|
|
|
{ id: 'cut', title: 'Cut', disabled: true, keyboard: 'control x' },
|
|
|
|
{ id: 'copy', title: 'Copy', disabled: true, keyboard: 'control c' },
|
|
|
|
{ id: 'paste', title: 'Paste', disabled: true, keyboard: 'control v' },
|
|
|
|
{ id: 'delete', title: 'Delete', disabled: true, keyboard: 'delete' },
|
|
|
|
{},
|
|
|
|
{ id: 'selectall', title: 'Select All', disabled: true, keyboard: 'control a' },
|
|
|
|
{ id: 'selectnone', title: 'Select None', disabled: true, keyboard: 'shift control a' },
|
|
|
|
{ id: 'invertselection', title: 'Invert Selection', disabled: true, keyboard: 'alt control a' }
|
|
|
|
] },
|
|
|
|
{ id: 'viewMenu', title: 'View', items: [
|
2011-06-06 15:48:11 +00:00
|
|
|
{ id: 'movies', title: 'View ' + pandora.site.itemName.plural, items: [
|
2011-09-17 18:36:30 +00:00
|
|
|
{ group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) {
|
2011-08-16 13:41:43 +00:00
|
|
|
return Ox.extend({
|
2011-09-23 10:44:54 +00:00
|
|
|
checked: ui.listView == view.id,
|
2011-05-25 19:42:45 +00:00
|
|
|
}, view);
|
|
|
|
}) },
|
|
|
|
]},
|
|
|
|
{ id: 'icons', title: 'Icons', items: [
|
2011-08-06 18:00:15 +00:00
|
|
|
{ group: 'viewicons', min: 1, max: 1, items: ['posters', 'frames'].map(function(icons) {
|
2011-09-23 10:44:54 +00:00
|
|
|
return {id: icons, title: Ox.toTitleCase(icons), checked: ui.icons == icons};
|
2011-08-21 08:17:10 +00:00
|
|
|
}) },
|
|
|
|
{},
|
2011-09-23 10:44:54 +00:00
|
|
|
{ id: 'showsiteposter', title: 'Always Show ' + pandora.site.site.name + ' Poster', checked: ui.showSitePoster }
|
2011-05-25 19:42:45 +00:00
|
|
|
] },
|
2011-09-04 22:06:14 +00:00
|
|
|
{ id: 'columns', title: 'Columns', items: [
|
|
|
|
{ id: 'loadcolumns', title: 'Load Layout...' },
|
|
|
|
{ id: 'savecolumns', title: 'Save Layout...' },
|
2011-09-04 21:15:53 +00:00
|
|
|
{},
|
2011-09-18 00:31:41 +00:00
|
|
|
{ id: 'resetcolumns', title: 'Reset Layout' }
|
2011-09-04 21:15:53 +00:00
|
|
|
]},
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-08-19 06:40:19 +00:00
|
|
|
{ id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [
|
2011-09-26 19:17:39 +00:00
|
|
|
{ group: 'itemview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) {
|
2011-08-16 13:41:43 +00:00
|
|
|
return Ox.extend({
|
2011-09-23 10:44:54 +00:00
|
|
|
checked: ui.itemView == view.id,
|
2011-05-25 19:42:45 +00:00
|
|
|
}, view);
|
|
|
|
}) },
|
|
|
|
]},
|
2011-08-19 06:40:19 +00:00
|
|
|
{ id: 'openvideo', title: 'Open Video Links', items: [
|
|
|
|
{ group: 'videoview', min: 1, max: 1, items: ['player', 'editor'].map(function(view) {
|
2011-09-23 10:44:54 +00:00
|
|
|
return {id: view, title: Ox.toTitleCase(view), checked: ui.videoView == view};
|
2011-08-19 06:40:19 +00:00
|
|
|
}) }
|
|
|
|
] },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-09-17 23:24:53 +00:00
|
|
|
{ id: 'groups', title: 'Groups', items: [
|
|
|
|
{ group: 'groups', min: 5, max: 5, items: pandora.site.groups.map(function(group) {
|
|
|
|
return Ox.extend({
|
2011-09-23 10:44:54 +00:00
|
|
|
checked: Ox.getPositionById(ui.groups, group.id) > -1
|
2011-09-17 23:24:53 +00:00
|
|
|
}, group);
|
2011-09-18 00:31:41 +00:00
|
|
|
}) },
|
|
|
|
{},
|
|
|
|
{ id: 'resetgroups', title: 'Reset Groups' }
|
2011-09-17 23:24:53 +00:00
|
|
|
] },
|
|
|
|
{},
|
2011-10-06 15:38:29 +00:00
|
|
|
{
|
|
|
|
id: 'togglelists',
|
|
|
|
title: Ox.map([pandora.user.ui.showSidebar? 'Hide': 'Show',
|
|
|
|
pandora.user.ui.showSidebar? 'Show': 'Hide' ],
|
|
|
|
function(t) { return t + ' Lists'; } ),
|
|
|
|
keyboard: 'shift l'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'toggleinfo',
|
|
|
|
title: Ox.map([pandora.user.ui.showInfo? 'Hide': 'Show',
|
|
|
|
pandora.user.ui.showInfo? 'Show': 'Hide' ],
|
|
|
|
function(t) { return t + ' Info'; } ),
|
|
|
|
keyboard: 'shift i'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'togglegroups',
|
|
|
|
title: Ox.map([pandora.user.ui.showGroups? 'Hide': 'Show',
|
|
|
|
pandora.user.ui.showGroups? 'Show': 'Hide' ],
|
|
|
|
function(t) { return t + ' Groups'; } ),
|
|
|
|
keyboard: 'shift g'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'movies', title:
|
|
|
|
'Hide ' + pandora.site.itemName.plural,
|
|
|
|
disabled: true,
|
|
|
|
keyboard: 'shift m'
|
|
|
|
},
|
2011-09-09 12:09:05 +00:00
|
|
|
{},
|
|
|
|
{ id: 'theme', title: 'Theme', items: [
|
|
|
|
{ group: 'settheme', min: 1, max: 1, items: [
|
2011-09-23 10:44:54 +00:00
|
|
|
{ id: 'classic', title: 'Classic', checked: ui.theme == 'classic'},
|
|
|
|
{ id: 'modern', title: 'Modern', checked: ui.theme == 'modern' }
|
2011-09-09 12:09:05 +00:00
|
|
|
]}
|
|
|
|
] }
|
2011-05-25 19:42:45 +00:00
|
|
|
]},
|
2011-09-27 14:14:40 +00:00
|
|
|
getSortMenu(),
|
2011-05-25 19:42:45 +00:00
|
|
|
{ id: 'findMenu', title: 'Find', items: [
|
|
|
|
{ id: 'find', title: 'Find', items: [
|
2011-08-18 07:54:46 +00:00
|
|
|
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {
|
2011-09-23 10:44:54 +00:00
|
|
|
var index = ui._findState.index;
|
2011-08-16 13:41:43 +00:00
|
|
|
return Ox.extend({
|
2011-09-23 10:44:54 +00:00
|
|
|
checked: index > -1 && ui.find.conditions[index].key
|
|
|
|
? ui.find.conditions[index].key == key.id
|
2011-08-24 06:19:34 +00:00
|
|
|
: key.id == 'all'
|
2011-08-18 07:54:46 +00:00
|
|
|
}, key);
|
2011-05-25 19:42:45 +00:00
|
|
|
}) }
|
|
|
|
] },
|
|
|
|
{ id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' }
|
|
|
|
] },
|
|
|
|
{ id: 'dataMenu', title: 'Data', items: [
|
2011-10-06 15:38:29 +00:00
|
|
|
{ id: 'titles', title: 'Manage Titles...', disabled: !isAdmin },
|
|
|
|
{ id: 'names', title: 'Manage Names...', disabled: !isAdmin },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-10-06 15:38:29 +00:00
|
|
|
{ id: 'places', title: 'Manage Places...', disabled: isGuest },
|
|
|
|
{ id: 'events', title: 'Manage Events...', disabled: isGuest },
|
2011-05-25 19:42:45 +00:00
|
|
|
{},
|
2011-10-11 16:01:33 +00:00
|
|
|
{ id: 'users', title: 'Manage Users...', disabled: !isAdmin }/*,
|
2011-10-06 15:38:29 +00:00
|
|
|
{ id: 'lists', title: 'Manage Lists...', disabled: !isAdmin },
|
2011-08-28 19:50:38 +00:00
|
|
|
{},
|
2011-10-06 15:38:29 +00:00
|
|
|
{ id: 'news', title: 'Manage News...', disabled: !isAdmin },
|
2011-10-11 16:01:33 +00:00
|
|
|
{ id: 'tour', title: 'Manage Tour...', disabled: !isAdmin }*/
|
2011-05-25 19:42:45 +00:00
|
|
|
] },
|
|
|
|
{ id: 'helpMenu', title: 'Help', items: [
|
2011-06-06 15:48:11 +00:00
|
|
|
{ id: 'help', title: pandora.site.site.name + ' Help', keyboard: 'shift ?' }
|
2011-05-25 19:42:45 +00:00
|
|
|
] },
|
|
|
|
{ id: 'debugMenu', title: 'Debug', items: [
|
2011-09-17 23:24:53 +00:00
|
|
|
{ id: 'clearcache', title: 'Clear cache'},
|
2011-10-01 13:51:18 +00:00
|
|
|
{ id: 'resetui', title: 'Reset UI Settings'}
|
2011-05-25 19:42:45 +00:00
|
|
|
] }
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-09-17 17:40:15 +00:00
|
|
|
change: function(data) {
|
2011-09-18 01:52:43 +00:00
|
|
|
var value = data.checked[0] ? data.checked[0].id : null;
|
2011-05-25 19:42:45 +00:00
|
|
|
if (data.id == 'find') {
|
2011-09-17 07:07:59 +00:00
|
|
|
pandora.$ui.findSelect.options({value: value});
|
2011-09-26 19:17:39 +00:00
|
|
|
} else if (data.id == 'itemview') {
|
|
|
|
pandora.UI.set({itemView: value});
|
2011-09-17 23:24:53 +00:00
|
|
|
} else if (Ox.startsWith(data.id, 'ordergroup')) {
|
|
|
|
var groups = Ox.clone(pandora.user.ui.groups),
|
|
|
|
id = data.id.replace('ordergroup', ''),
|
|
|
|
position = Ox.getPositionById(groups, id),
|
|
|
|
key = groups[position].sort[0].key,
|
|
|
|
operator = value == 'ascending' ? '+' : '-';
|
|
|
|
pandora.$ui.groups[position].options({
|
|
|
|
sort: [{key: key, operator: operator}]
|
|
|
|
});
|
|
|
|
groups[position].sort[0].operator = operator;
|
|
|
|
pandora.UI.set({groups: groups});
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.id == 'ordermovies') {
|
2011-09-23 10:44:54 +00:00
|
|
|
var key = pandora.user.ui.listSort[0].key,
|
2011-08-18 07:54:46 +00:00
|
|
|
operator = value == 'ascending' ? '+' : '-';
|
2011-09-23 10:44:54 +00:00
|
|
|
pandora.UI.set({listSort: [{key: key, operator: operator}]});
|
2011-09-09 12:09:05 +00:00
|
|
|
} else if (data.id == 'settheme') {
|
|
|
|
Ox.Theme(value);
|
|
|
|
pandora.UI.set('theme', value);
|
2011-09-23 10:44:54 +00:00
|
|
|
} else if (data.id == 'showsiteposter') {
|
|
|
|
pandora.UI.set('showSitePoster', data.checked)
|
2011-09-17 23:24:53 +00:00
|
|
|
} else if (Ox.startsWith(data.id, 'sortgroup')) {
|
2011-09-23 10:44:54 +00:00
|
|
|
var groups = Ox.clone(ui.groups),
|
2011-09-17 23:24:53 +00:00
|
|
|
id = data.id.replace('sortgroup', ''),
|
|
|
|
position = Ox.getPositionById(groups, id),
|
2011-09-17 23:50:38 +00:00
|
|
|
type = Ox.getObjectById(pandora.site.groups, id).type,
|
2011-09-17 23:24:53 +00:00
|
|
|
key = value,
|
2011-09-17 23:50:38 +00:00
|
|
|
operator = key == 'name' && type == 'string' ? '+' : '-';
|
|
|
|
pandora.$ui.mainMenu.checkItem('sortMenu_ordergroups_ordergroup' + id + '_' + (operator == '+' ? 'ascending' : 'descending'))
|
2011-09-17 23:24:53 +00:00
|
|
|
pandora.$ui.groups[position].options({
|
|
|
|
sort: [{key: key, operator: operator}]
|
|
|
|
});
|
|
|
|
groups[position].sort[0].key = key;
|
|
|
|
pandora.UI.set({groups: groups});
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.id == 'sortmovies') {
|
2011-09-23 10:44:54 +00:00
|
|
|
pandora.UI.set({listSort: [{key: value, operator: ''}]});
|
2011-08-07 18:30:14 +00:00
|
|
|
} else if (data.id == 'viewicons') {
|
2011-08-07 20:25:33 +00:00
|
|
|
pandora.UI.set({icons: value});
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.id == 'viewmovies') {
|
2011-10-09 13:13:11 +00:00
|
|
|
var set = {listView: value};
|
|
|
|
if (
|
|
|
|
!pandora.isClipView(key, pandora.user.ui.item)
|
|
|
|
&& ['title', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1
|
|
|
|
) {
|
|
|
|
set.listSort = pandora.site.user.ui.listSort;
|
|
|
|
}
|
|
|
|
pandora.UI.set(set);
|
2011-09-20 00:10:35 +00:00
|
|
|
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) {
|
2011-09-23 10:44:54 +00:00
|
|
|
pandora.UI.set({list: value.substr(8)});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
click: function(data) {
|
2011-09-23 10:44:54 +00:00
|
|
|
if ([
|
|
|
|
'home', 'about', 'news', 'tour', 'faq', 'tos', 'contact', 'software',
|
|
|
|
'signup', 'signin', 'signout', 'preferences', 'help'
|
|
|
|
].indexOf(data.id) > -1) {
|
|
|
|
pandora.URL.push('/' + data.id);
|
2011-09-29 17:25:04 +00:00
|
|
|
} else if ([
|
|
|
|
'newlist', 'newlistfromselection', 'newsmartlist', 'newsmartlistfromresults'
|
|
|
|
].indexOf(data.id) > -1) {
|
|
|
|
pandora.addList(data.id.indexOf('smart') > -1, data.id.indexOf('from') > -1);
|
|
|
|
} else if (data.id == 'duplicatelist') {
|
|
|
|
pandora.addList(pandora.user.ui._list);
|
|
|
|
} else if (data.id == 'editlist') {
|
|
|
|
pandora.ui.listDialog().open();
|
|
|
|
} else if (data.id == 'deletelist') {
|
|
|
|
pandora.ui.deleteListDialog().open();
|
2011-08-04 14:49:16 +00:00
|
|
|
} else if (data.id == 'stills') {
|
|
|
|
var id = pandora.user.ui.item || pandora.user.ui.listItem;
|
|
|
|
pandora.$ui.postersDialog = pandora.ui.framesDialog(id).open();
|
2011-06-06 12:23:59 +00:00
|
|
|
} else if (data.id == 'posters') {
|
2011-08-01 16:55:18 +00:00
|
|
|
var id = pandora.user.ui.item || pandora.user.ui.listItem;
|
|
|
|
pandora.$ui.postersDialog = pandora.ui.postersDialog(id).open();
|
2011-10-11 11:29:05 +00:00
|
|
|
} else if (data.id == 'names') {
|
|
|
|
pandora.$ui.namesDialog = pandora.ui.namesDialog().open();
|
|
|
|
} else if (data.id == 'titles') {
|
|
|
|
pandora.$ui.titlesDialog = pandora.ui.titlesDialog().open();
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.id == 'places') {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.placesDialog = pandora.ui.placesDialog().open();
|
2011-09-24 23:09:48 +00:00
|
|
|
} else if (data.id == 'events') {
|
|
|
|
pandora.$ui.eventsDialog = pandora.ui.eventsDialog().open();
|
|
|
|
} else if (data.id == 'users') {
|
|
|
|
pandora.$ui.eventsDialog = pandora.ui.usersDialog().open();
|
|
|
|
} else if (data.id == 'lists') {
|
|
|
|
pandora.$ui.eventsDialog = pandora.ui.listsDialog().open();
|
2011-09-18 00:31:41 +00:00
|
|
|
} else if (data.id == 'resetgroups') {
|
|
|
|
pandora.UI.set({
|
|
|
|
groups: pandora.site.user.ui.groups
|
|
|
|
});
|
|
|
|
pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.id == 'resetui') {
|
|
|
|
pandora.api.resetUI({}, function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel.reload();
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-08-11 17:28:44 +00:00
|
|
|
} else if (data.id == 'clearcache') {
|
|
|
|
Ox.Request.clearCache();
|
2011-10-06 15:38:29 +00:00
|
|
|
} else if (data.id == 'togglegroups') {
|
2011-10-09 14:52:53 +00:00
|
|
|
that.getItem('viewMenu_togglegroups').toggleTitle();
|
2011-10-06 15:38:29 +00:00
|
|
|
pandora.$ui.contentPanel.toggle(0);
|
|
|
|
} else if (data.id == 'toggleinfo') {
|
2011-10-09 14:52:53 +00:00
|
|
|
that.getItem('viewMenu_toggleinfo').toggleTitle();
|
2011-10-06 15:38:29 +00:00
|
|
|
pandora.$ui.leftPanel.toggle(2);
|
|
|
|
} else if (data.id == 'togglelists') {
|
2011-10-09 14:52:53 +00:00
|
|
|
that.getItem('viewMenu_togglelists').toggleTitle();
|
2011-10-06 15:38:29 +00:00
|
|
|
pandora.$ui.mainPanel.toggle(0);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-09-27 23:30:13 +00:00
|
|
|
},
|
2011-09-29 17:25:04 +00:00
|
|
|
pandora_find: function() {
|
|
|
|
var action = ui._list
|
|
|
|
&& pandora.getListData(ui._list).user == pandora.user.username
|
|
|
|
? 'enableItem' : 'disableItem';
|
|
|
|
that[action]('editlist');
|
|
|
|
that[action]('duplicatelist');
|
|
|
|
that[action]('deletelist');
|
|
|
|
that[pandora.user.ui.listSelection.length ? 'enableItem' : 'disableItem']('newlistfromselection');
|
|
|
|
},
|
|
|
|
pandora_listselection: function(data) {
|
|
|
|
that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection');
|
|
|
|
},
|
|
|
|
pandora_listview: function(data) {
|
2011-10-09 13:13:11 +00:00
|
|
|
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + data.value);
|
2011-09-27 23:30:13 +00:00
|
|
|
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
|
|
|
|
that.replaceMenu('sortMenu', getSortMenu());
|
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
2011-09-18 01:52:43 +00:00
|
|
|
|
2011-09-27 14:14:40 +00:00
|
|
|
function getListMenu(lists) {
|
|
|
|
return { id: 'listMenu', title: 'List', items: Ox.merge(
|
|
|
|
['personal', 'favorite', 'featured'].map(function(folder) {
|
|
|
|
return {
|
|
|
|
id: folder + 'lists',
|
|
|
|
title: Ox.toTitleCase(folder) + ' Lists',
|
|
|
|
items: [{
|
|
|
|
group: folder + 'lists',
|
|
|
|
min: 0,
|
|
|
|
max: 1,
|
|
|
|
items: lists ? lists[folder].map(function(list) {
|
|
|
|
return {
|
|
|
|
id: 'viewlist' + list.id,
|
|
|
|
title: (folder == 'favorite' ? list.user + ': ' : '') + list.name,
|
2011-09-28 00:10:26 +00:00
|
|
|
checked: list.id == pandora.user.ui._list
|
2011-09-27 14:14:40 +00:00
|
|
|
};
|
|
|
|
}) : [{id: 'loading', title: 'Loading...', disabled: true}]
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
[
|
|
|
|
{},
|
2011-09-29 17:25:04 +00:00
|
|
|
{ id: 'newlist', title: 'New List', keyboard: 'control n' },
|
|
|
|
{ id: 'newlistfromselection', title: 'New List from Selection', disabled: ui.listSelection.length == 0, keyboard: 'shift control n' },
|
|
|
|
{ id: 'newsmartlist', title: 'New Smart List', keyboard: 'alt control n' },
|
|
|
|
{ id: 'newsmartlistfromresults', title: 'New Smart List from Results', keyboard: 'shift alt control n' },
|
2011-09-27 14:14:40 +00:00
|
|
|
{},
|
2011-09-29 17:25:04 +00:00
|
|
|
{ id: 'duplicatelist', title: 'Duplicate Selected List', disabled: !pandora.user.ui._list, keyboard: 'control d' },
|
|
|
|
{ id: 'editlist', title: 'Edit Selected List...', disabled: !pandora.user.ui._list, keyboard: 'control e' },
|
|
|
|
{ id: 'deletelist', title: 'Delete Selected List...', disabled: !pandora.user.ui._list, keyboard: 'delete' },
|
2011-09-27 14:14:40 +00:00
|
|
|
]
|
|
|
|
)};
|
|
|
|
};
|
|
|
|
|
|
|
|
function getSortMenu() {
|
|
|
|
var ui = pandora.user.ui,
|
|
|
|
isClipView = pandora.isClipView(ui.listView);
|
|
|
|
return { id: 'sortMenu', title: 'Sort', items: [
|
|
|
|
{ id: 'sortmovies', title: 'Sort ' + (isClipView ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
|
|
|
|
{ group: 'sortmovies', min: 1, max: 1, items: Ox.merge(isClipView ? Ox.merge(pandora.site.clipKeys.map(function(key) {
|
2011-09-27 22:12:37 +00:00
|
|
|
return Ox.extend(Ox.clone(key), {
|
|
|
|
checked: ui.listSort[0].key == key.id,
|
|
|
|
title: 'Clip ' + key.title
|
|
|
|
});
|
|
|
|
}), /*{}*/[]) : [], pandora.site.sortKeys.map(function(key) {
|
2011-09-27 14:14:40 +00:00
|
|
|
return Ox.extend({
|
|
|
|
checked: ui.listSort[0].key == key.id
|
|
|
|
}, key);
|
|
|
|
})) }
|
|
|
|
] },
|
|
|
|
{ id: 'ordermovies', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [
|
|
|
|
{ group: 'ordermovies', min: 1, max: 1, items: [
|
|
|
|
{ id: 'ascending', title: 'Ascending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '+' },
|
|
|
|
{ id: 'descending', title: 'Descending', checked: (ui.listSort[0].operator || pandora.getSortOperator(ui.listSort[0].key)) == '-' }
|
|
|
|
]}
|
|
|
|
] },
|
|
|
|
{ id: 'advancedsort', title: 'Advanced Sort...', keyboard: 'shift control s' },
|
|
|
|
{},
|
|
|
|
{ id: 'sortgroups', title: 'Sort Groups', items: pandora.user.ui.groups.map(function(group) {
|
|
|
|
return {
|
|
|
|
id: 'sortgroup' + group.id,
|
|
|
|
title: 'Sort ' + Ox.getObjectById(pandora.site.groups, group.id).title + ' Group by',
|
|
|
|
items: [
|
|
|
|
{ group: 'sortgroup' + group.id, min: 1, max: 1, items: [
|
|
|
|
{ id: 'name', title: 'Name', checked: group.sort[0].key == 'name' },
|
|
|
|
{ id: 'items', title: 'Items', checked: group.sort[0].key == 'items' }
|
|
|
|
] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}) },
|
|
|
|
{ id: 'ordergroups', title: 'Order Groups', items: pandora.user.ui.groups.map(function(group) {
|
|
|
|
return {
|
|
|
|
id: 'ordergroup' + group.id,
|
|
|
|
title: 'Order ' + Ox.getObjectById(pandora.site.groups, group.id).title + ' Group',
|
|
|
|
items: [
|
|
|
|
{ group: 'ordergroup' + group.id, min: 1, max: 1, items: [
|
|
|
|
{ id: 'ascending', title: 'Ascending', checked: group.sort[0].operator == '+' },
|
|
|
|
{ id: 'descending', title: 'Descending', checked: group.sort[0].operator == '-' }
|
|
|
|
] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}) }
|
|
|
|
] };
|
|
|
|
}
|
|
|
|
|
2011-09-18 01:52:43 +00:00
|
|
|
// fixme: the sidebar makes the same requests.
|
|
|
|
// is it ok to make them twice, or should the sidebar trigger the menu replace?
|
|
|
|
|
|
|
|
var counter = 0,
|
|
|
|
lists = {},
|
|
|
|
queries = {
|
|
|
|
// fixme: duplicated
|
|
|
|
personal: {conditions: [
|
2011-09-28 17:32:03 +00:00
|
|
|
{key: 'user', value: pandora.user.username, operator: '=='},
|
|
|
|
{key: 'status', value: 'featured', operator: '!='}
|
2011-09-18 01:52:43 +00:00
|
|
|
], operator: '&'},
|
|
|
|
favorite: {conditions: [
|
|
|
|
{key: 'subscribed', value: true, operator: '='},
|
2011-09-28 17:32:03 +00:00
|
|
|
{key: 'status', value: 'featured', operator: '!='},
|
2011-09-18 01:52:43 +00:00
|
|
|
], operator: '&'},
|
|
|
|
featured: {conditions: [
|
|
|
|
{key: 'status', value: 'featured', operator: '='}
|
|
|
|
], operator: '&'}
|
|
|
|
};
|
|
|
|
|
|
|
|
Ox.forEach(queries, function(query, folder) {
|
|
|
|
pandora.api.findLists({
|
|
|
|
query: query,
|
|
|
|
keys: ['id', 'name', 'user']
|
|
|
|
}, function(result) {
|
|
|
|
lists[folder] = result.data.items;
|
|
|
|
if (++counter == 3) {
|
|
|
|
Ox.print('--------------------------------------------', lists)
|
2011-09-27 14:14:40 +00:00
|
|
|
pandora.$ui.mainMenu.replaceMenu('listMenu', getListMenu(lists));
|
2011-09-18 01:52:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2011-09-27 22:12:37 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
|