1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Keyboard shortcut legend

New: Show keybaord shortcuts with '?'
New: ctrl+s will save settings
This commit is contained in:
Mark McDowall 2014-07-29 00:10:07 -07:00
parent 7fc3b971f6
commit e71de9cc29
10 changed files with 141 additions and 14 deletions

View File

@ -7,6 +7,7 @@ define(
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
},
Keys : {
DefaultProfileId : 'DefaultProfileId',
DefaultRootFolderId : 'DefaultRootFolderId',

View File

@ -16,6 +16,7 @@
@import "../Rename/rename";
@import "typeahead";
@import "utilities";
@import "../Hotkeys/hotkeys";
.main-region {
@media (min-width: @screen-lg-min) {
@ -239,3 +240,10 @@ body {
padding-top: 10px;
}
}
.modal-header {
h3 {
margin-top : 0px;
margin-bottom : 0px;
}
}

37
src/UI/Hotkeys/Hotkeys.js Normal file
View File

@ -0,0 +1,37 @@
'use strict';
define(
[
'jquery',
'vent',
'Hotkeys/HotkeysView'
], function ($, vent, HotkeysView) {
$(document).on('keydown', function (e) {
if (e.ctrlKey && e.keyCode === 83) {
vent.trigger(vent.Hotkeys.SaveSettings);
e.preventDefault();
return;
}
if (e.shiftKey && e.keyCode === 191) {
vent.trigger(vent.Commands.OpenModalCommand, new HotkeysView());
// vent.trigger(vent.Hotkeys.ShowHotkeys);
e.preventDefault();
return;
}
if ($(e.target).is('input') || $(e.target).is('textarea')) {
return;
}
if (e.ctrlKey || e.metaKey || e.altKey) {
return;
}
if (e.keyCode === 84) {
vent.trigger(vent.Hotkeys.NavbarSearch);
e.preventDefault();
}
});
});

View File

@ -0,0 +1,11 @@
'use strict';
define(
[
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Hotkeys/HotkeysViewTemplate'
});
});

View File

@ -0,0 +1,47 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Keyboard Shortcuts</h3>
</div>
<div class="modal-body hotkeys-modal">
<div class="row hotkey-group">
<div class="col-md-12">
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>Focus Search Box</h3>
</div>
<div class="col-md-3">
<kbd class="hotkey">t</kbd>
</div>
</div>
<div class="row">
<div class="col-md-11 col-md-offset-1">
Pressing 't' puts the cursor in the search box below the navigation links
</div>
</div>
</div>
</div>
<div class="row hotkey-group">
<div class="col-md-12">
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>Save Settings</h3>
</div>
<div class="col-md-3">
<kbd class="hotkey">ctrl + s</kbd>
</div>
</div>
<div class="row">
<div class="col-md-11 col-md-offset-1">
Pressing ctrl + 's' saves your settings (only in settings)
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">close</button>
</div>
</div>
</div>

View File

@ -0,0 +1,23 @@
.hotkeys-modal {
h3 {
margin-top : 0px;
margin-botton : 0px;
}
.hotkey-group {
&:first-of-type {
margin-top : 0px;
}
&:last-of-type {
margin-bottom : 0px;
}
margin-top : 25px;
margin-bottom : 25px;
.hotkey {
font-size : 22px;
}
}
}

View File

@ -3,23 +3,14 @@ define(
[
'underscore',
'jquery',
'vent',
'backbone',
'Series/SeriesCollection',
'typeahead'
], function (_, $, Backbone, SeriesCollection) {
$(document).on('keydown', function (e) {
if ($(e.target).is('input') || $(e.target).is('textarea')) {
return;
}
], function (_, $, vent, Backbone, SeriesCollection) {
if (e.ctrlKey || e.metaKey || e.altKey) {
return;
}
if (e.keyCode === 84) {
$('.x-series-search').focus();
e.preventDefault();
}
vent.on(vent.Hotkeys.NavbarSearch, function () {
$('.x-series-search').focus();
});
$.fn.bindSearch = function () {

View File

@ -89,6 +89,8 @@ define(
if (options.action) {
this.action = options.action.toLowerCase();
}
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
},
onRender: function () {

View File

@ -245,7 +245,8 @@ define(
'System/StatusModel',
'Shared/Tooltip',
'Instrumentation/StringFormat',
'LifeCycle'
'LifeCycle',
'Hotkeys/Hotkeys'
], function ($, Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController, ControlPanelController, serverStatusModel, Tooltip) {
new SeriesController();

View File

@ -30,5 +30,11 @@ define(
CloseControlPanelCommand : 'CloseControlPanelCommand'
};
vent.Hotkeys = {
NavbarSearch : 'navbar:search',
SaveSettings : 'settings:save',
ShowHotkeys : 'hotkeys:show'
};
return vent;
});