web: add form: drop unneeded C-minus/C-plus keys & related help text

This commit is contained in:
Simon Michael 2020-04-06 18:18:01 -07:00
parent 3178a860f2
commit ca4fc4a421
2 changed files with 9 additions and 18 deletions

View File

@ -33,7 +33,7 @@ $(document).ready(function() {
$('body').bind('keydown', 'a', function(){ addformShow(); return false; }); $('body').bind('keydown', 'a', function(){ addformShow(); return false; });
$('body').bind('keydown', 'n', function(){ addformShow(); return false; }); $('body').bind('keydown', 'n', function(){ addformShow(); return false; });
$('body').bind('keydown', 'f', function(){ $('#searchform input').focus(); return false; }); $('body').bind('keydown', 'f', function(){ $('#searchform input').focus(); return false; });
addformBindKeys(); lastAmountBindKey();
// highlight the entry from the url hash // highlight the entry from the url hash
if (window.location.hash && $(window.location.hash)[0]) { if (window.location.hash && $(window.location.hash)[0]) {
@ -48,14 +48,8 @@ $(document).ready(function() {
}); });
}); });
// Set up keybindings affecting the add form, everywhere they should be // Add the add-new-row-on-keypress handler to the current last amount field.
// (body, each add form input, and one more on the last amount input). function lastAmountBindKey() {
// Called on page load and again each time an add form row is added.
function addformBindKeys() {
$('body, #addform input, #addform select').bind('keydown', 'ctrl++', addformAddPosting);
$('body, #addform input, #addform select').bind('keydown', 'ctrl+shift+=', addformAddPosting);
$('body, #addform input, #addform select').bind('keydown', 'ctrl+=', addformAddPosting);
$('body, #addform input, #addform select').bind('keydown', 'ctrl+-', addformDeletePosting);
$('.amount-input:last').keypress(addformAddPosting); $('.amount-input:last').keypress(addformAddPosting);
} }
@ -175,7 +169,7 @@ function addformAddPosting() {
return; return;
} }
// Remove the add-new-row-on-keypress handler from the old last amount field // Remove the keypress handler from the old last amount field
$('.amount-input:last').off('keypress'); $('.amount-input:last').off('keypress');
// Clone the old last row to make a new last row // Clone the old last row to make a new last row
@ -184,8 +178,9 @@ function addformAddPosting() {
var n = $('#addform .account-group').length; var n = $('#addform .account-group').length;
$('.account-input:last').prop('placeholder', 'Account '+n).val(''); $('.account-input:last').prop('placeholder', 'Account '+n).val('');
$('.amount-input:last').prop('placeholder','Amount '+n).val(''); // XXX Enable typehead on dynamically created inputs $('.amount-input:last').prop('placeholder','Amount '+n).val(''); // XXX Enable typehead on dynamically created inputs
// and ensure they have the proper keybindings
addformBindKeys(); // and add the keypress handler to the new last amount field
lastAmountBindKey();
} }
// Remove the add form's last posting row, if empty, keeping at least two. // Remove the add form's last posting row, if empty, keeping at least two.
@ -202,8 +197,8 @@ function addformDeletePosting() {
if (focuslost) { if (focuslost) {
focus($('.account-input:last')); focus($('.account-input:last'));
} }
// Rebind keypress
$('.amount-input:last').keypress(addformAddPosting); lastAmountBindKey();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -65,7 +65,3 @@ $if length journals > 1
$forall p <- journals $forall p <- journals
<option value=#{p}>#{p} <option value=#{p}>#{p}
<span .small style="padding-left:2em;"> <span .small style="padding-left:2em;">
Enter a value in the last field for #
<a href="#" onclick="addformAddPosting(); return false;">
more
\ (or ctrl +, ctrl -)