fix keyboard shortcut to switch document views

This commit is contained in:
j 2016-11-27 19:43:28 +01:00
parent cc00510f5d
commit 03b5937a4d

View file

@ -4,6 +4,7 @@
pandora.ui.mainMenu = function() { pandora.ui.mainMenu = function() {
var isGuest = pandora.user.level == 'guest', var isGuest = pandora.user.level == 'guest',
documentViewKey = 1,
itemViewKey = 1, itemViewKey = 1,
listViewKey = 1, listViewKey = 1,
ui = pandora.user.ui, ui = pandora.user.ui,
@ -134,6 +135,18 @@ pandora.ui.mainMenu = function() {
return {id: view, title: Ox._(Ox.toTitleCase(view)), checked: ui.videoView == view}; return {id: view, title: Ox._(Ox.toTitleCase(view)), checked: ui.videoView == view};
}) } }) }
] }, ] },
{ id: 'documents', title: Ox._('Open Documents'), items: [
{ group: 'documentview', min: 1, max: 1, items: ['info', 'view'].map(function(id) {
return {
id: id,
checked: ui.documentView == id,
keyboard: documentViewKey <= 10
? 'shift ' + (documentViewKey++%10)
: void 0,
title: Ox._(Ox.toTitleCase(id))
}
}) }
] },
{}, {},
{ {
id: 'showsidebar', id: 'showsidebar',
@ -306,6 +319,8 @@ pandora.ui.mainMenu = function() {
set.listSort = pandora.site.user.ui.listSort; set.listSort = pandora.site.user.ui.listSort;
} }
pandora.UI.set(set); pandora.UI.set(set);
} else if (data.id == 'documentview') {
pandora.UI.set({documentView: value});
} else if (Ox.startsWith(data.id, 'orderfilter')) { } else if (Ox.startsWith(data.id, 'orderfilter')) {
var filters = Ox.clone(ui.filters), var filters = Ox.clone(ui.filters),
id = data.id.replace('orderfilter', ''), id = data.id.replace('orderfilter', ''),
@ -979,6 +994,7 @@ pandora.ui.mainMenu = function() {
Ox.range(10).forEach(function(i) { Ox.range(10).forEach(function(i) {
Ox.Event.bind('key_shift_' + (i + 1) % 10, function() { Ox.Event.bind('key_shift_' + (i + 1) % 10, function() {
var view; var view;
if (ui.section == 'items') {
if (ui.item) { if (ui.item) {
view = pandora.site.itemViews[i]; view = pandora.site.itemViews[i];
if (view && (view.id != 'data' && view.id != 'media' || if (view && (view.id != 'data' && view.id != 'media' ||
@ -991,6 +1007,17 @@ pandora.ui.mainMenu = function() {
pandora.UI.set({listView: view.id}); pandora.UI.set({listView: view.id});
} }
} }
} else if (ui.section == 'edits') {
if (ui.edit && i < 3) {
pandora.UI.set({editView: ['list', 'grid', 'annotations'][i]});
}
} else if (ui.section == 'documents') {
if (ui.document && i < 2) {
pandora.UI.set({documentView: ['info', 'view'][i]});
} else if (i < 2) {
pandora.UI.set({collectionView: ['list', 'grid'][i]});
}
}
}); });
}); });