1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Added keyboard shortcuts

This commit is contained in:
Hillel Coren 2016-12-06 23:39:10 +02:00
parent 4821908521
commit 98a237b5ad
7 changed files with 171 additions and 35 deletions

View File

@ -33,7 +33,8 @@
"bootstrap-daterangepicker": "~2.1.24",
"sweetalert2": "^5.3.8",
"jSignature": "brinley/jSignature#^2.1.0",
"select2": "select2-dist#^4.0.3"
"select2": "select2-dist#^4.0.3",
"mousetrap": "^1.6.0"
},
"resolutions": {
"jquery": "~1.11"

View File

@ -126,6 +126,7 @@ elixir(function(mix) {
bowerDir + '/sweetalert2/dist/sweetalert2.js',
//bowerDir + '/sweetalert/dist/sweetalert-dev.js',
bowerDir + '/nouislider/distribute/nouislider.js',
bowerDir + '/mousetrap/mousetrap.js',
bowerDir + '/fuse.js/src/fuse.js',
'bootstrap-combobox.js',
'script.js',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2259,6 +2259,10 @@ $LANG = array(
'redirect_url_help' => 'Optionally specify a URL to redirect to after a payment is made entered.',
'save_draft' => 'Save Draft',
'refunded_credit_payment' => 'Refunded credit payment',
'keyboard_shortcuts' => 'Keyboard Shortcuts',
'toggle_menu' => 'Toggle Menu',
'new_...' => 'New ...',
'list_...' => 'List ...',
);

View File

@ -4,7 +4,6 @@
@section('head')
<link href="{{ asset('css/built.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/>
<style type="text/css">
@if (Auth::check() && Auth::user()->dark_mode)
body {
@ -288,12 +287,59 @@
$('#search').focusin(onSearchFocus);
$('#search').blur(onSearchBlur);
$('body').keypress(function(event) {
/*
$(document).keypress(function (event) {
console.log(event);
if (event.which == 47 && !$('*:focus').length) {
event.preventDefault();
$('#search').focus();
}
});
*/
Mousetrap.bind('?', function(e) {
console.log('heree');
$('#helpModal').modal('show');
});
Mousetrap.bind('/', function(e) {
event.preventDefault();
$('#search').focus();
});
Mousetrap.bind('d', function(e) {
location.href = "{{ url('/dashboard') }}";
});
Mousetrap.bind('s', function(e) {
location.href = "{{ url('/settings/company_details') }}";
});
Mousetrap.bind('h', function(e) {
$('#right-menu-toggle').trigger('click');
});
Mousetrap.bind('m', function(e) {
$('#left-menu-toggle').trigger('click');
});
@foreach([
'i' => ENTITY_INVOICE,
'p' => ENTITY_PAYMENT,
'e' => ENTITY_EXPENSE,
't' => ENTITY_TASK,
'c' => ENTITY_CLIENT,
'q' => ENTITY_QUOTE,
'v' => ENTITY_VENDOR,
'r' => ENTITY_RECURRING_INVOICE,
] as $key => $value)
Mousetrap.bind('n {{ $key }}', function(e) {
location.href = "{{ url($value . 's/create') }}";
});
Mousetrap.bind('l {{ $key }}', function(e) {
location.href = "{{ url($value . 's') }}";
});
@endforeach
// manage sidebar state
function setupSidebar(side) {
@ -735,6 +781,90 @@
</div>
@endif
<div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel" aria-hidden="true">
<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>
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.keyboard_shortcuts') }}</h4>
</div>
<style type="text/css">
.help-panel {
margin-left: 14px;
margin-right: 14px;
}
.help-panel .col-md-2 div,
.help-panel .col-md-3 div {
background-color:#777;
color:#fff;
width:28px;
text-align:center;
padding-top:4px;
padding-bottom:4px;
font-weight:bold;
font-size: 18px;
float: left;
margin-right: 12px;
margin-top: 4px;
margin-bottom: 4px;
}
.help-panel .key-label {
padding-top: 12px;
}
</style>
<div class="panel-body help-panel">
<div class="row">
<div class="col-md-2"><div>?</div></div>
<div class="col-md-4 key-label">{{ trans('texts.help') }}</div>
<div class="col-md-3"><div>N</div><div>C</div></div>
<div class="col-md-3 key-label">{{ trans('texts.new_client') }}</div>
</div>
<div class="row">
<div class="col-md-2"><div>/</div></div>
<div class="col-md-4 key-label">{{ trans('texts.search') }}</div>
<div class="col-md-3"><div>N</div><div>I</div></div>
<div class="col-md-3 key-label">{{ trans('texts.new_invoice') }}</div>
</div>
<div class="row">
<div class="col-md-2"><div>D</div></div>
<div class="col-md-4 key-label">{{ trans('texts.dashboard') }}</div>
<div class="col-md-3"><div>N</div><div>...</div></div>
<div class="col-md-3 key-label">{{ trans('texts.new_...') }}</div>
</div>
<div class="row">
<div class="col-md-2"><div>S</div></div>
<div class="col-md-4 key-label">{{ trans('texts.settings') }}</div>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-4"></div>
<div class="col-md-3"><div>L</div><div>C</div></div>
<div class="col-md-3 key-label">{{ trans('texts.list_clients') }}</div>
</div>
<div class="row">
<div class="col-md-2"><div>M</div></div>
<div class="col-md-4 key-label">{{ trans('texts.toggle_menu') }}</div>
<div class="col-md-3"><div>L</div><div>I</div></div>
<div class="col-md-3 key-label">{{ trans('texts.list_invoices') }}</div>
</div>
<div class="row">
<div class="col-md-2"><div>H</div></div>
<div class="col-md-4 key-label">{{ trans('texts.toggle_history') }}</div>
<div class="col-md-3"><div>L</div><div>...</div></div>
<div class="col-md-3 key-label">{{ trans('texts.list_...') }}</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }}</button>
</div>
</div>
</div>
</div>
</div>
<p>&nbsp;</p>

View File

@ -432,7 +432,7 @@
@if (!$task && !$clientPublicId)
$('.client-select input.form-control').focus();
@else
$('#amount').focus();
$('#description').focus();
@endif
$('input[type=radio]').change(function(event) {
@ -566,7 +566,7 @@
});
$projectSelect.combobox();
if (projectId) {
var project = projectMap[projectId];
setComboboxValue($('.project-select'), project.public_id, project.name);