prepare public api
This commit is contained in:
parent
507b6fed3e
commit
dd0e22a979
18 changed files with 237 additions and 94 deletions
|
|
@ -7,7 +7,9 @@ oml.ui.mainMenu = function() {
|
|||
fromMenu = false,
|
||||
|
||||
that = Ox.MainMenu({
|
||||
extras: [
|
||||
extras: oml.readOnly ? [
|
||||
oml.$ui.loadingIcon = oml.ui.loadingIcon()
|
||||
] : [
|
||||
oml.$ui.updateButton = oml.ui.updateButton(),
|
||||
oml.$ui.transferButton = oml.ui.transferButton(),
|
||||
oml.$ui.peersButton = oml.ui.peersButton(),
|
||||
|
|
@ -39,6 +41,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'contact',
|
||||
title: Ox._('Send Feedback')
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'update',
|
||||
|
|
@ -50,7 +53,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Quit Open Media Library'),
|
||||
keyboard: 'control q'
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
{
|
||||
id: 'userMenu',
|
||||
|
|
@ -61,6 +64,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Preferences...'),
|
||||
keyboard: 'control ,'
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'peers',
|
||||
|
|
@ -70,7 +74,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'transfers',
|
||||
title: Ox._('Transfers...')
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
getListMenu(),
|
||||
getEditMenu(),
|
||||
|
|
@ -295,6 +299,7 @@ oml.ui.mainMenu = function() {
|
|||
keyboard: 'shift control s',
|
||||
disabled: true
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'sorttitles',
|
||||
|
|
@ -304,7 +309,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'sortnames',
|
||||
title: Ox._('Sort Names...')
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
getFindMenu(),
|
||||
{
|
||||
|
|
@ -477,15 +482,19 @@ oml.ui.mainMenu = function() {
|
|||
} else if (id == 'invertselection') {
|
||||
oml.$ui.list.invertSelection();
|
||||
} else if (id == 'download') {
|
||||
oml.api.addListItems({
|
||||
items: ui.listSelection.filter(function(id) {
|
||||
return oml.$ui.list.value(id, 'mediastate') == 'unavailable';
|
||||
}),
|
||||
list: ':'
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache();
|
||||
// FIXME: reload?
|
||||
});
|
||||
if (oml.readOnly) {
|
||||
document.location.href = '/' + ui.listSelection[0] + '/get/'
|
||||
} else {
|
||||
oml.api.addListItems({
|
||||
items: ui.listSelection.filter(function(id) {
|
||||
return oml.$ui.list.value(id, 'mediastate') == 'unavailable';
|
||||
}),
|
||||
list: ':'
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache();
|
||||
// FIXME: reload?
|
||||
});
|
||||
}
|
||||
} else if (Ox.contains(['cut', 'cutadd'], id)) {
|
||||
var action = data.id == 'cut' ? 'copy' : 'add';
|
||||
fromMenu = true;
|
||||
|
|
@ -741,7 +750,7 @@ oml.ui.mainMenu = function() {
|
|||
clipboardItems > 1 ? Ox.formatNumber(clipboardItems) + ' ' : ''
|
||||
) + Ox._(clipboardItems == 1 ? 'Book' : 'Books'),
|
||||
canSelect = !ui.item,
|
||||
canDownload = !!unavailableItems,
|
||||
canDownload = !!unavailableItems || (oml.readOnly && selectionItems == 1),
|
||||
canCopy = canSelect && selectionItems,
|
||||
canCut = canCopy && listData.editable,
|
||||
canPaste = listData.editable && clipboardItems,
|
||||
|
|
@ -757,7 +766,7 @@ oml.ui.mainMenu = function() {
|
|||
return {
|
||||
id: 'editMenu',
|
||||
title: Ox._('Edit'),
|
||||
items: [
|
||||
items: [].concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'import',
|
||||
title: Ox._(oml.user.importing ? 'Importing Books...' : 'Import Books...') // FIXME
|
||||
|
|
@ -767,6 +776,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._(oml.user.exporting ? 'Exporting Books...' : 'Export Books...') // FIXME
|
||||
},
|
||||
{},
|
||||
]).concat([
|
||||
{
|
||||
id: 'selectall',
|
||||
title: Ox._('Select All'),
|
||||
|
|
@ -792,6 +802,7 @@ oml.ui.mainMenu = function() {
|
|||
disabled: !canDownload,
|
||||
keyboard: 'control d'
|
||||
},
|
||||
]).concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'cut',
|
||||
title: Ox._('Cut {0}', [selectionItemName]),
|
||||
|
|
@ -865,7 +876,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Clear History'),
|
||||
disabled: !historyItems,
|
||||
}
|
||||
]
|
||||
])
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -930,6 +941,14 @@ oml.ui.mainMenu = function() {
|
|||
isLibrary = Ox.endsWith(ui._list, ':'),
|
||||
isList = !isLibraries && !isLibrary,
|
||||
isOwnList = ui._list[0] == ':';
|
||||
|
||||
if (oml.readOnly) {
|
||||
return {
|
||||
id: 'listMenu',
|
||||
title: Ox._('List'),
|
||||
items: []
|
||||
};
|
||||
}
|
||||
return {
|
||||
id: 'listMenu',
|
||||
title: Ox._('List'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue