2014-05-04 17:26:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
oml.ui.mainMenu = function() {
|
|
|
|
|
|
|
|
var ui = oml.user.ui,
|
|
|
|
findState = oml.getFindState(ui.find),
|
2014-05-12 23:43:27 +00:00
|
|
|
fromMenu = false,
|
2014-05-04 17:26:43 +00:00
|
|
|
appItems = Ox.getObjectById(oml.config.pages, 'app').parts,
|
|
|
|
|
|
|
|
that = Ox.MainMenu({
|
|
|
|
extras: [
|
|
|
|
oml.$ui.connectionButton = oml.ui.connectionButton(),
|
2014-09-01 12:01:41 +00:00
|
|
|
oml.$ui.updateButton = oml.ui.updateButton(),
|
2014-05-04 17:26:43 +00:00
|
|
|
oml.$ui.notificationsButton = oml.ui.notificationsButton(),
|
|
|
|
oml.$ui.loadingIcon = oml.ui.loadingIcon()
|
|
|
|
],
|
|
|
|
menus: [
|
|
|
|
{
|
|
|
|
id: 'appMenu',
|
|
|
|
title: '<img src="/static/png/oml.png" style="width: 14px; height: 14px">',
|
|
|
|
items: [
|
|
|
|
appItems[0],
|
|
|
|
{}
|
|
|
|
].concat(
|
|
|
|
appItems.slice(1, -1)
|
|
|
|
).concat([
|
|
|
|
{},
|
|
|
|
Ox.last(appItems)
|
|
|
|
])
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'userMenu',
|
|
|
|
title: Ox._('User'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'preferences',
|
|
|
|
title: Ox._('Preferences...'),
|
|
|
|
keyboard: 'control ,'
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'users',
|
|
|
|
title: Ox._('Users...')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'devices',
|
|
|
|
title: Ox._('Devices...')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2014-05-12 12:57:47 +00:00
|
|
|
getListMenu(),
|
|
|
|
getEditMenu(),
|
2014-05-04 17:26:43 +00:00
|
|
|
{
|
|
|
|
id: 'viewMenu',
|
|
|
|
title: Ox._('View'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'section',
|
|
|
|
title: Ox._('Section'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'section',
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'books',
|
|
|
|
title: Ox._('Books'),
|
|
|
|
checked: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'music',
|
|
|
|
title: Ox._('Music'),
|
|
|
|
disabled: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'movies',
|
|
|
|
title: Ox._('Movies'),
|
|
|
|
disabled: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2014-05-21 00:02:39 +00:00
|
|
|
id: 'iconsSubmenu',
|
2014-05-04 17:26:43 +00:00
|
|
|
title: 'Icons',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'icons',
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'cover',
|
|
|
|
title: Ox._('Cover'),
|
|
|
|
checked: ui.icons == 'cover'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'preview',
|
|
|
|
title: Ox._('Preview'),
|
|
|
|
checked: ui.icons == 'preview'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2014-05-21 00:02:39 +00:00
|
|
|
id: 'showiconinfo',
|
|
|
|
title: 'Show Icon Info',
|
|
|
|
checked: ui.showIconInfo
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2014-05-21 00:02:39 +00:00
|
|
|
group: 'iconinfo',
|
2014-05-04 17:26:43 +00:00
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'extension',
|
|
|
|
title: Ox._('Show Extension'),
|
2014-05-21 00:02:39 +00:00
|
|
|
checked: ui.iconInfo == 'extension',
|
|
|
|
disabled: !ui.showIconInfo
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'size',
|
|
|
|
title: Ox._('Show Size'),
|
2014-05-21 00:02:39 +00:00
|
|
|
checked: ui.iconInfo == 'size',
|
|
|
|
disabled: !ui.showIconInfo
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'showsidebar',
|
|
|
|
title: Ox._((ui.showSidebar ? 'Hide' : 'Show') + ' Sidebar'),
|
|
|
|
keyboard: 'shift s'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'showinfo',
|
|
|
|
title: Ox._((ui.showInfo ? 'Hide' : 'Show') + ' Info'),
|
|
|
|
keyboard: 'shift i',
|
|
|
|
disabled: !ui.showSidebar
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'showfilters',
|
|
|
|
title: Ox._((ui.showFilters ? 'Hide' : 'Show') + ' Filters'),
|
|
|
|
keyboard: 'shift f',
|
|
|
|
disabled: !!ui.item
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'showbrowser',
|
|
|
|
title: Ox._((ui.showBrowser ? 'Hide': 'Show') + ' Browser'),
|
|
|
|
keyboard: 'shift b',
|
|
|
|
disabled: !ui.item
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'notifications',
|
|
|
|
title: Ox._('Notifications...')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'transfers',
|
|
|
|
title: Ox._('Transfers...')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'activity',
|
|
|
|
title: Ox._('Activity...')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'sortMenu',
|
|
|
|
title: Ox._('Sort'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'sortitems',
|
|
|
|
title: Ox._('Sort Books by'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'sort',
|
|
|
|
title: Ox._('Sort Books by'),
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: oml.config.sortKeys.map(function(key) {
|
|
|
|
return {
|
|
|
|
id: key.id,
|
|
|
|
title: Ox._(key.title),
|
|
|
|
checked: key.id == ui.listSort[0].key
|
|
|
|
};
|
|
|
|
})
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'orderitems',
|
|
|
|
title: Ox._('Order Books'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'order',
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'ascending',
|
|
|
|
title: Ox._('Ascending'),
|
|
|
|
checked: ui.listSort[0].operator == '+'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'descending',
|
|
|
|
title: Ox._('Descending'),
|
|
|
|
checked: ui.listSort[0].operator == '-'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'advancedsort',
|
|
|
|
title: Ox._('Advanced Sort'),
|
|
|
|
keyboard: 'shift control s',
|
|
|
|
disabled: true
|
2014-05-25 12:16:04 +00:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'sorttitles',
|
|
|
|
title: Ox._('Sort Titles...')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'sortnames',
|
|
|
|
title: Ox._('Sort Names...')
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2014-05-17 14:42:46 +00:00
|
|
|
getFindMenu(),
|
2014-05-04 17:26:43 +00:00
|
|
|
{
|
|
|
|
id: 'helpMenu',
|
|
|
|
title: Ox._('Help'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'gettingstarted',
|
|
|
|
title: 'Getting Started...'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'help',
|
|
|
|
title: Ox._('{0} Help...', ['Open Media Library']),
|
|
|
|
keyboard: 'control ?'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'documentation',
|
|
|
|
title: Ox._('Documentation...'),
|
|
|
|
keyboard: 'shift control ?'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'debugMenu',
|
|
|
|
title: Ox._('Debug'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'debugmode',
|
|
|
|
title: Ox._((
|
|
|
|
oml.localStorage('enableDebugMode')
|
|
|
|
? 'Disable' : 'Enable'
|
|
|
|
) + ' Debug Mode'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'eventlogging',
|
|
|
|
title: Ox._((
|
|
|
|
oml.localStorage('enableEventLogging')
|
|
|
|
? 'Disable' : 'Enable'
|
|
|
|
) + ' Event Logging'),
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'changelog',
|
|
|
|
title: Ox._('Change Log...')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'errorlog',
|
|
|
|
title: Ox._('Error Log...')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
var id = data.id,
|
|
|
|
value = Ox.isBoolean(data.checked)
|
|
|
|
? data.checked : data.checked[0].id;
|
|
|
|
if (id == 'icons') {
|
|
|
|
oml.UI.set({icons: value});
|
2014-05-21 00:02:39 +00:00
|
|
|
} else if (id == 'icons') {
|
|
|
|
oml.UI.set({icons: value});
|
|
|
|
} else if (id == 'showiconinfo') {
|
|
|
|
oml.UI.set({showIconInfo: value});
|
|
|
|
} else if (id == 'iconinfo') {
|
|
|
|
oml.UI.set({iconInfo: value});
|
2014-05-17 11:45:57 +00:00
|
|
|
} else if (id == 'sort') {
|
|
|
|
oml.UI.set({
|
|
|
|
listSort: [{
|
|
|
|
key: value,
|
|
|
|
operator: oml.getSortOperator(value)
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
} else if (id == 'order') {
|
|
|
|
oml.UI.set({
|
|
|
|
listSort: [{
|
|
|
|
key: ui.listSort[0].key,
|
|
|
|
operator: value == 'ascending' ? '+' : '-'
|
|
|
|
}]
|
|
|
|
});
|
2014-05-17 14:42:46 +00:00
|
|
|
} else if (id == 'findin') {
|
|
|
|
oml.$ui.findInSelect.value(value);
|
|
|
|
if (ui._findState.key == 'advanced') {
|
|
|
|
// ...
|
|
|
|
} else {
|
|
|
|
oml.$ui.findInput.focusInput(true);
|
|
|
|
}
|
2014-05-17 11:45:57 +00:00
|
|
|
} else if (id == 'find') {
|
|
|
|
if (value) {
|
|
|
|
oml.$ui.findSelect.value(value);
|
|
|
|
if (ui._findState.key == 'advanced') {
|
|
|
|
// fixme: autocomplete function doesn't get updated
|
2014-05-17 14:42:46 +00:00
|
|
|
oml.$ui.findInput.options({placeholder: ''});
|
|
|
|
} else {
|
|
|
|
oml.$ui.findInput.focusInput(true);
|
2014-05-17 11:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
} else {
|
2014-05-17 11:45:57 +00:00
|
|
|
Ox.print('MAIN MENU DOES NOT YET HANDLE', id, data);
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
click: function(data) {
|
|
|
|
var id = data.id;
|
|
|
|
if (Ox.contains([
|
|
|
|
'about', 'faq', 'terms',
|
|
|
|
'development', 'contact', 'update'
|
|
|
|
], id)) {
|
|
|
|
oml.UI.set({'part.app': id});
|
|
|
|
oml.UI.set({page: 'app'});
|
|
|
|
} else if (id == 'preferences') {
|
|
|
|
oml.UI.set({page: 'preferences'});
|
|
|
|
} else if (id == 'users') {
|
|
|
|
oml.UI.set({page: 'users'});
|
2014-05-12 23:43:27 +00:00
|
|
|
} else if (id == 'alllibraries') {
|
|
|
|
if (!ui._list) {
|
|
|
|
oml.UI.set({item: ''});
|
|
|
|
} else {
|
|
|
|
oml.UI.set({find: {
|
|
|
|
conditions: [],
|
|
|
|
operator: '&'
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
} else if (id == 'thislibrary') {
|
|
|
|
if (Ox.endsWith(ui._list, ':')) {
|
|
|
|
oml.UI.set({item: ''});
|
|
|
|
} else {
|
|
|
|
oml.UI.set({find: {
|
|
|
|
conditions: [{
|
|
|
|
key: 'list',
|
|
|
|
operator: '==',
|
|
|
|
value: ui._list.split(':')[0] + ':'
|
|
|
|
}],
|
|
|
|
operator: '&'
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
} else if (id == 'thislist') {
|
|
|
|
oml.UI.set({item: ''});
|
2014-05-04 17:26:43 +00:00
|
|
|
} else if (Ox.contains([
|
|
|
|
'newlist', 'newlistfromselection',
|
|
|
|
'newsmartlist', 'newsmartlistfromresults'
|
|
|
|
], id)) {
|
|
|
|
oml.addList(Ox.contains(id, 'smart'), Ox.contains(id, 'from'));
|
|
|
|
} else if (id == 'duplicatelist') {
|
|
|
|
oml.addList(ui._list);
|
2015-02-27 12:28:01 +00:00
|
|
|
} else if (id == 'delete') {
|
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.editable && listData.type == 'static') {
|
|
|
|
oml.doHistory('delete', ui.listSelection, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
|
|
|
oml.$ui.folders.updateItems();
|
|
|
|
oml.$ui.list.updateElement();
|
|
|
|
});
|
|
|
|
}
|
2015-02-27 11:03:20 +00:00
|
|
|
} else if (id == 'deletefromlibrary') {
|
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.own) {
|
|
|
|
oml.ui.deleteItemsDialog().open();
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
} else if (id == 'editlist') {
|
|
|
|
oml.ui.listDialog.open();
|
|
|
|
} else if (id == 'deletelist') {
|
2014-05-12 23:43:27 +00:00
|
|
|
oml.ui.deleteListDialog().open();
|
2014-05-16 14:30:16 +00:00
|
|
|
} else if (id == 'import') {
|
2014-05-17 08:17:34 +00:00
|
|
|
oml.UI.set({page: 'import'});
|
|
|
|
} else if (id == 'export') {
|
|
|
|
oml.UI.set({page: 'export'});
|
2014-05-12 23:43:27 +00:00
|
|
|
} else if (id == 'selectall') {
|
|
|
|
oml.$ui.list.selectAll();
|
|
|
|
} else if (id == 'selectnone') {
|
|
|
|
oml.UI.set({listSelection: []});
|
|
|
|
} else if (id == 'invertselection') {
|
|
|
|
oml.$ui.list.invertSelection();
|
2014-05-19 15:00:33 +00:00
|
|
|
} else if (Ox.contains(['cut', 'cutadd'], id)) {
|
|
|
|
var action = data.id == 'cut' ? 'copy' : 'add';
|
|
|
|
fromMenu = true;
|
|
|
|
oml.clipboard[action](ui.listSelection, 'item');
|
|
|
|
oml.doHistory('cut', ui.listSelection, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
|
|
|
oml.reloadList();
|
|
|
|
});
|
|
|
|
} else if (Ox.contains(['copy', 'copyadd'], id)) {
|
|
|
|
var action = data.id == 'copy' ? 'copy' : 'add';
|
|
|
|
fromMenu = true;
|
|
|
|
oml.clipboard[action](ui.listSelection, 'item');
|
|
|
|
} else if (id == 'paste') {
|
|
|
|
var items = oml.clipboard.paste();
|
|
|
|
oml.doHistory('paste', items, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: items});
|
|
|
|
oml.reloadList();
|
|
|
|
});
|
2014-05-12 23:43:27 +00:00
|
|
|
} else if (data.id == 'clearclipboard') {
|
|
|
|
oml.clipboard.clear();
|
|
|
|
} else if (data.id == 'delete') {
|
|
|
|
oml.doHistory('delete', ui.listSelection, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
|
|
|
oml.reloadList();
|
|
|
|
});
|
|
|
|
} else if (data.id == 'undo') {
|
|
|
|
fromMenu = true;
|
|
|
|
oml.undoHistory();
|
|
|
|
} else if (data.id == 'redo') {
|
|
|
|
fromMenu = true;
|
|
|
|
oml.redoHistory();
|
|
|
|
} else if (id == 'clearhistory') {
|
|
|
|
fromMenu = true;
|
|
|
|
oml.history.clear();
|
2014-05-04 17:26:43 +00:00
|
|
|
} else if (id == 'showsidebar') {
|
|
|
|
oml.UI.set({showSidebar: !ui.showSidebar});
|
|
|
|
} else if (id == 'showinfo') {
|
|
|
|
oml.UI.set({showInfo: !ui.showInfo});
|
|
|
|
} else if (id == 'showfilters') {
|
|
|
|
oml.UI.set({showFilters: !ui.showFilters});
|
|
|
|
} else if (id == 'showbrowser') {
|
|
|
|
oml.UI.set({showBrowser: !ui.showBrowser});
|
|
|
|
} else if (id == 'transfers') {
|
|
|
|
oml.UI.set({page: 'transfers'});
|
2014-05-12 23:43:27 +00:00
|
|
|
} else if (id == 'debugmode') {
|
|
|
|
if (oml.localStorage('enableDebugMode')) {
|
|
|
|
oml.localStorage['delete']('enableDebugMode');
|
|
|
|
} else {
|
|
|
|
oml.localStorage('enableDebugMode', true);
|
|
|
|
}
|
|
|
|
window.location.reload();
|
2015-05-14 11:03:49 +00:00
|
|
|
} else if (id == 'sortnames') {
|
|
|
|
(oml.$ui.namesDialog || (
|
|
|
|
oml.$ui.namesDialog = oml.ui.namesDialog()
|
|
|
|
)).open();
|
|
|
|
} else if (id == 'sorttitles') {
|
|
|
|
(oml.$ui.titlesDialog || (
|
|
|
|
oml.$ui.titlesDialog = oml.ui.titlesDialog()
|
|
|
|
)).open();
|
2015-05-14 11:08:16 +00:00
|
|
|
} else if (id == 'download') {
|
|
|
|
document.location.href = '/' + oml.user.ui.item + '/get/';
|
2014-05-04 17:26:43 +00:00
|
|
|
} else {
|
|
|
|
Ox.print('MAIN MENU DOES NOT YET HANDLE', id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oml_find: function() {
|
2014-05-12 12:57:47 +00:00
|
|
|
that.replaceMenu('listMenu', getListMenu());
|
|
|
|
that.replaceMenu('editMenu', getEditMenu());
|
2014-05-17 14:42:46 +00:00
|
|
|
that.replaceMenu('findMenu', getFindMenu());
|
2014-05-12 12:57:47 +00:00
|
|
|
/*
|
2014-05-04 17:26:43 +00:00
|
|
|
var action = Ox.startsWith(ui._list, ':') && ui._list != ':'
|
|
|
|
? 'enableItem' : 'disableItem';
|
|
|
|
that[
|
|
|
|
ui._list && !Ox.endsWith(ui._list, ':')
|
|
|
|
? 'enableItem' : 'disableItem'
|
|
|
|
]('duplicatelist');
|
|
|
|
that[action]('editlist');
|
|
|
|
that[action]('deletelist');
|
2014-05-12 12:57:47 +00:00
|
|
|
*/
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
2014-05-21 00:02:39 +00:00
|
|
|
oml_iconinfo: function(data) {
|
|
|
|
// ...
|
|
|
|
},
|
|
|
|
oml_icons: function(data) {
|
|
|
|
that.checkItem('viewMenu_iconsSubmenu_' + data.value);
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
oml_item: function(data) {
|
|
|
|
if (!!data.value != !!data.previousValue) {
|
|
|
|
that[data.value ? 'disableItem' : 'enableItem']('showfilters');
|
|
|
|
that[data.value ? 'enableItem' : 'disableItem']('showbrowser');
|
|
|
|
}
|
|
|
|
},
|
2014-05-12 12:57:47 +00:00
|
|
|
oml_listselection: function(data) {
|
|
|
|
that.replaceMenu('editMenu', getEditMenu());
|
|
|
|
},
|
2014-05-12 23:43:27 +00:00
|
|
|
oml_listsort: function(data) {
|
|
|
|
that.checkItem('sortMenu_sortitems_' + data.value[0].key);
|
|
|
|
that.checkItem('sortMenu_orderitems_' + (
|
|
|
|
data.value[0].operator == '+' ? 'ascending' : 'descending')
|
|
|
|
);
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
oml_showbrowser: function(data) {
|
|
|
|
that.setItemTitle('showbrowser', Ox._((data.value ? 'Hide' : 'Show') + ' Browser'));
|
|
|
|
},
|
|
|
|
oml_showfilters: function(data) {
|
|
|
|
that.setItemTitle('showfilters', Ox._((data.value ? 'Hide' : 'Show') + ' Filters'));
|
|
|
|
},
|
2014-05-21 00:02:39 +00:00
|
|
|
oml_showiconinfo: function(data) {
|
|
|
|
var action = data.value ? 'enableItem' : 'disableItem';
|
|
|
|
that[action]('viewMenu_iconsSubmenu_extension');
|
|
|
|
that[action]('viewMenu_iconsSubmenu_size');
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
oml_showinfo: function(data) {
|
|
|
|
that.setItemTitle('showinfo', Ox._((data.value ? 'Hide' : 'Show') + ' Info'));
|
|
|
|
},
|
|
|
|
oml_showsidebar: function(data) {
|
|
|
|
that.setItemTitle('showsidebar', Ox._((data.value ? 'Hide' : 'Show') + ' Sidebar'));
|
|
|
|
that[data.value ? 'enableItem' : 'disableItem']('showinfo');
|
|
|
|
},
|
|
|
|
});
|
2014-09-25 11:32:04 +00:00
|
|
|
Ox.Event.bind({
|
|
|
|
key_backtick: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
changeFocus(1);
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_comma: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen()) {
|
|
|
|
oml.UI.set({page: 'preferences'});
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_f: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen()) {
|
|
|
|
if (ui._findState.key != 'advanced') {
|
|
|
|
setTimeout(function() {
|
|
|
|
oml.$ui.findInput.focusInput(true);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
oml.$ui.filterDialog = oml.ui.filterDialog().open();
|
|
|
|
}
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_m: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen() && !that.isSelected()) {
|
|
|
|
that.options('menus')[0].element.trigger('click');
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_shift_f: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
Ox.print('FIXME: NOT IMPLEMENTED')
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_shift_w: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen()) {
|
|
|
|
oml.UI.set({
|
|
|
|
find: oml.config.user.ui.find,
|
|
|
|
item: ''
|
|
|
|
});
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_shift_z: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
oml.redoHistory();
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_slash: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen()) {
|
|
|
|
oml.UI.set({page: 'help'});
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_w: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
if (!oml.hasDialogOrScreen()) {
|
|
|
|
oml.UI.set({item: ''});
|
|
|
|
}
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_control_z: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
oml.undoHistory();
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_shift_b: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
ui.item && oml.UI.set({showBrowser: !ui.showBrowser});
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_shift_f: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
!ui.item && oml.UI.set({showFilters: !ui.showFilters});
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_shift_i: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
ui.showSidebar && oml.UI.set({showInfo: !ui.showInfo});
|
2014-09-25 11:32:04 +00:00
|
|
|
},
|
|
|
|
key_shift_s: function() {
|
2014-09-24 13:30:23 +00:00
|
|
|
oml.UI.set({showSidebar: !ui.showSidebar});
|
|
|
|
}
|
|
|
|
});
|
2015-05-14 11:40:29 +00:00
|
|
|
setTimeout(oml.updateDebugMenu);
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2014-05-12 12:57:47 +00:00
|
|
|
function getEditMenu() {
|
|
|
|
var listData = oml.getListData(),
|
|
|
|
username = oml.user.preferences.username,
|
|
|
|
selectionItems = ui.listSelection.length,
|
|
|
|
selectionItemName = (
|
|
|
|
selectionItems > 1 ? Ox.formatNumber(selectionItems) + ' ' : ''
|
2014-05-12 23:43:27 +00:00
|
|
|
) + Ox._(selectionItems == 1 ? 'Book' : 'Books'),
|
2014-05-12 12:57:47 +00:00
|
|
|
clipboardItems = oml.clipboard.items(),
|
|
|
|
clipboardType = oml.clipboard.type(),
|
|
|
|
clipboardItemName = !clipboardItems ? ''
|
|
|
|
: (
|
|
|
|
clipboardItems > 1 ? Ox.formatNumber(clipboardItems) + ' ' : ''
|
|
|
|
) + Ox._(clipboardItems == 1 ? 'Book' : 'Books'),
|
|
|
|
canSelect = !ui.item,
|
2014-05-12 23:43:27 +00:00
|
|
|
canDownload = listData.user != username && selectionItems,
|
2014-05-12 12:57:47 +00:00
|
|
|
canCopy = canSelect && selectionItems,
|
|
|
|
canCut = canCopy && listData.editable,
|
|
|
|
canPaste = listData.editable && clipboardItems,
|
2014-05-19 15:00:33 +00:00
|
|
|
canAdd = canCopy && clipboardItems && clipboardType == 'book',
|
2015-02-27 06:15:24 +00:00
|
|
|
canDelete = listData.user == '' && selectionItems,
|
2014-05-12 12:57:47 +00:00
|
|
|
historyItems = oml.history.items(),
|
|
|
|
undoText = oml.history.undoText(),
|
|
|
|
redoText = oml.history.redoText();
|
|
|
|
return {
|
|
|
|
id: 'editMenu',
|
|
|
|
title: Ox._('Edit'),
|
|
|
|
items: [
|
|
|
|
{
|
2014-05-16 14:30:16 +00:00
|
|
|
id: 'import',
|
2014-05-17 08:17:34 +00:00
|
|
|
title: Ox._(oml.user.importing ? 'Importing Books...' : 'Import Books...') // FIXME
|
2014-05-12 12:57:47 +00:00
|
|
|
},
|
|
|
|
{
|
2014-05-16 14:30:16 +00:00
|
|
|
id: 'export',
|
2014-05-17 08:17:34 +00:00
|
|
|
title: Ox._(oml.user.exporting ? 'Exporting Books...' : 'Export Books...') // FIXME
|
2014-05-12 12:57:47 +00:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'selectall',
|
|
|
|
title: Ox._('Select All'),
|
|
|
|
disabled: !canSelect,
|
|
|
|
keyboard: 'control a'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'selectnone',
|
|
|
|
title: Ox._('Select None'),
|
|
|
|
disabled: !canSelect,
|
|
|
|
keyboard: 'shift control a'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'invertselection',
|
|
|
|
title: Ox._('Invert Selection'),
|
|
|
|
disabled: !canSelect,
|
|
|
|
keyboard: 'alt control a'
|
|
|
|
},
|
|
|
|
{},
|
2014-05-12 23:43:27 +00:00
|
|
|
{
|
|
|
|
id: 'download',
|
|
|
|
title: Ox._('Download {0}', [selectionItemName]),
|
|
|
|
disabled: !canDownload,
|
|
|
|
keyboard: 'control d'
|
|
|
|
},
|
2014-05-12 12:57:47 +00:00
|
|
|
{
|
|
|
|
id: 'cut',
|
|
|
|
title: Ox._('Cut {0}', [selectionItemName]),
|
|
|
|
disabled: !canCut,
|
|
|
|
keyboard: 'control x'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'cutadd',
|
|
|
|
title: Ox._('Cut and Add to Clipboard'),
|
|
|
|
disabled: !canCut || !canAdd,
|
|
|
|
keyboard: 'shift control x'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'copy',
|
|
|
|
title: Ox._('Copy {0}', [selectionItemName]),
|
|
|
|
disabled: !canCopy,
|
|
|
|
keyboard: 'control c'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'copyadd',
|
|
|
|
title: Ox._('Copy and Add to Clipboard'),
|
|
|
|
disabled: !canCopy || !canAdd,
|
|
|
|
keyboard: 'shift control c'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'paste',
|
|
|
|
title: !clipboardItems ? Ox._('Paste') : Ox._('Paste {0}', [clipboardItemName]),
|
|
|
|
disabled: !canPaste,
|
|
|
|
keyboard: 'control v'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'clearclipboard',
|
|
|
|
title: Ox._('Clear Clipboard'),
|
|
|
|
disabled: !clipboardItems
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'delete',
|
|
|
|
title: Ox._('Delete {0} from List', [selectionItemName]),
|
|
|
|
disabled: !canCut,
|
|
|
|
keyboard: 'delete'
|
|
|
|
},
|
2014-05-12 23:43:27 +00:00
|
|
|
{
|
|
|
|
id: 'deletefromlibrary',
|
|
|
|
title: Ox._('Delete {0} from Library...', [selectionItemName]),
|
|
|
|
disabled: !canDelete,
|
2014-05-17 11:45:57 +00:00
|
|
|
keyboard: 'control delete'
|
2014-05-12 23:43:27 +00:00
|
|
|
},
|
2014-05-12 12:57:47 +00:00
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'undo',
|
|
|
|
title: undoText ? Ox._('Undo {0}', [undoText]) : Ox._('Undo'),
|
|
|
|
disabled: !undoText,
|
|
|
|
keyboard: 'control z'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'redo',
|
|
|
|
title: redoText ? Ox._('Redo {0}', [redoText]) : Ox._('Redo'),
|
|
|
|
disabled: !redoText,
|
|
|
|
keyboard: 'shift control z'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'clearhistory',
|
|
|
|
title: Ox._('Clear History'),
|
|
|
|
disabled: !historyItems,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-05-12 23:43:27 +00:00
|
|
|
function getFindMenu() {
|
2014-05-17 14:42:46 +00:00
|
|
|
var isLibraries = !ui._list,
|
|
|
|
isLibrary = Ox.endsWith(ui._list, ':'),
|
|
|
|
isList = !isLibraries && !isLibrary;
|
|
|
|
return {
|
|
|
|
id: 'findMenu',
|
|
|
|
title: Ox._('Find'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'findlists',
|
|
|
|
title: Ox._('Find In'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'findin',
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: [
|
|
|
|
{id: 'all', title: Ox._('All Libraries'), checked: isLibraries}
|
|
|
|
].concat(!isLibraries ? [
|
|
|
|
{id: 'user', title: Ox._('This Library'), checked: isLibrary}
|
|
|
|
] : []).concat(isList ? [
|
|
|
|
{id: 'list', title: Ox._('This List'), checked: isList}
|
|
|
|
] : [])
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'finditems',
|
|
|
|
title: Ox._('Find'),
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
group: 'find',
|
|
|
|
min: 1,
|
|
|
|
max: 1,
|
|
|
|
items: oml.config.findKeys.map(function(key) {
|
|
|
|
var checked = key.id == findState.key;
|
|
|
|
return {
|
|
|
|
id: key.id,
|
|
|
|
title: Ox._(key.title),
|
|
|
|
checked: checked,
|
|
|
|
keyboard: checked ? 'control f' : ''
|
|
|
|
};
|
|
|
|
})
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'advancedfind',
|
|
|
|
title: Ox._('Advanced Find'),
|
|
|
|
keyboard: 'shift control f'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2014-05-12 23:43:27 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 12:57:47 +00:00
|
|
|
function getListMenu() {
|
|
|
|
var isLibraries = !ui._list,
|
|
|
|
isLibrary = Ox.endsWith(ui._list, ':'),
|
|
|
|
isList = !isLibraries && !isLibrary,
|
|
|
|
isOwnList = ui._list[0] == ':';
|
|
|
|
return {
|
|
|
|
id: 'listMenu',
|
|
|
|
title: Ox._('List'),
|
2014-05-12 23:43:27 +00:00
|
|
|
items: [].concat(!isLibraries || ui.item ? [
|
2014-05-12 12:57:47 +00:00
|
|
|
{
|
2014-05-12 23:43:27 +00:00
|
|
|
id: 'alllibraries',
|
2014-05-12 12:57:47 +00:00
|
|
|
title: Ox._('All Libraries'),
|
|
|
|
keyboard: 'shift control w'
|
2014-05-12 23:43:27 +00:00
|
|
|
}
|
|
|
|
] : []).concat(isList || (isLibrary && ui.item) ? [
|
2014-05-12 12:57:47 +00:00
|
|
|
{
|
2014-05-12 23:43:27 +00:00
|
|
|
id: 'thislibrary',
|
2014-05-12 12:57:47 +00:00
|
|
|
title: Ox._('This Library'),
|
|
|
|
keyboard: isLibrary ? 'control w' : ''
|
2014-05-12 23:43:27 +00:00
|
|
|
}
|
|
|
|
] : []).concat(isList && ui.item ? [
|
2014-05-12 12:57:47 +00:00
|
|
|
{
|
2014-05-12 23:43:27 +00:00
|
|
|
id: 'thislist',
|
2014-05-12 12:57:47 +00:00
|
|
|
title: Ox._('This List'),
|
2014-05-12 23:43:27 +00:00
|
|
|
keyboard: isList ? 'control w' : ''
|
|
|
|
}
|
|
|
|
] : []).concat(!isLibraries || ui.item ? [
|
2014-05-12 12:57:47 +00:00
|
|
|
{},
|
2014-05-12 23:43:27 +00:00
|
|
|
] : []).concat([
|
2014-05-12 12:57:47 +00:00
|
|
|
{
|
|
|
|
id: 'newlist',
|
2014-05-12 23:43:27 +00:00
|
|
|
title: Ox._('New List...'),
|
2014-05-12 12:57:47 +00:00
|
|
|
keyboard: 'control n'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'newlistfromselection',
|
2014-05-12 23:43:27 +00:00
|
|
|
title: Ox._('New List from Selection...'),
|
2014-05-12 12:57:47 +00:00
|
|
|
keyboard: 'shift control n',
|
|
|
|
disabled: !ui.listSelection.length
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'newsmartlist',
|
2014-05-12 23:43:27 +00:00
|
|
|
title: Ox._('New Smart List...'),
|
2014-05-12 12:57:47 +00:00
|
|
|
keyboard: 'alt control n'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'newsmartlistfromresults',
|
2014-05-12 23:43:27 +00:00
|
|
|
title: Ox._('New Smart List from Results...'),
|
2014-05-12 12:57:47 +00:00
|
|
|
keyboard: 'shift alt control n'
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'duplicatelist',
|
2014-05-12 23:43:27 +00:00
|
|
|
title: Ox._('Duplicate List...'),
|
2014-05-12 12:57:47 +00:00
|
|
|
disabled: !isList
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'editlist',
|
|
|
|
title: Ox._('Edit List...'),
|
|
|
|
keyboard: 'return',
|
2014-05-17 11:45:57 +00:00
|
|
|
disabled: !isList || !isOwnList
|
2014-05-12 12:57:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'deletelist',
|
|
|
|
title: Ox._('Delete List...'),
|
|
|
|
keyboard: 'delete',
|
2014-05-17 11:45:57 +00:00
|
|
|
disabled: !isList || !isOwnList
|
2014-05-12 12:57:47 +00:00
|
|
|
}
|
2014-05-12 23:43:27 +00:00
|
|
|
])
|
2014-05-12 12:57:47 +00:00
|
|
|
};
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.clipboard.bindEvent(function(data, event) {
|
|
|
|
if (Ox.contains(['add', 'copy', 'clear'], event)) {
|
|
|
|
that.replaceMenu('editMenu', getEditMenu());
|
|
|
|
}
|
|
|
|
if (Ox.contains(['add', 'copy', 'paste'], event) && !fromMenu) {
|
|
|
|
that.highlightMenu('editMenu');
|
|
|
|
}
|
|
|
|
fromMenu = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
oml.history.bindEvent(function(data, event) {
|
|
|
|
that.replaceMenu('editMenu', getEditMenu());
|
|
|
|
if (Ox.contains(['undo', 'redo'], event) && !fromMenu) {
|
|
|
|
that.highlightMenu('editMenu');
|
|
|
|
}
|
|
|
|
fromMenu = false;
|
|
|
|
});
|
|
|
|
|
2014-05-17 11:45:57 +00:00
|
|
|
that.updateElement = function(menu) {
|
2014-05-12 23:43:27 +00:00
|
|
|
(
|
2014-05-17 14:42:46 +00:00
|
|
|
menu ? Ox.makeArray(menu) : ['listMenu', 'editMenu', 'findMenu']
|
2014-05-12 23:43:27 +00:00
|
|
|
).forEach(function(menu) {
|
|
|
|
that.updateMenu(
|
|
|
|
menu,
|
2014-05-17 14:42:46 +00:00
|
|
|
menu == 'listMenu' ? getListMenu()
|
|
|
|
: menu == 'editMenu' ? getEditMenu()
|
|
|
|
: getFindMenu()
|
2014-05-12 23:43:27 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
return that;
|
2014-05-12 12:57:47 +00:00
|
|
|
};
|
|
|
|
|
2014-05-04 17:26:43 +00:00
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|