And try to clarify a bit. 67af073c was the relevant commit.
This commit is contained in:
parent
3cc79a67f2
commit
ef5db595f9
@ -33,11 +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; });
|
||||||
$('body, #addform input, #addform select').bind('keydown', 'ctrl++', addformAddPosting);
|
addformBindKeys();
|
||||||
$('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);
|
|
||||||
|
|
||||||
// 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]) {
|
||||||
@ -52,6 +48,17 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set up keybindings affecting the add form, everywhere they should be
|
||||||
|
// (body, each add form input, and one more on the last amount input).
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// REGISTER CHART
|
// REGISTER CHART
|
||||||
|
|
||||||
@ -168,27 +175,17 @@ function addformAddPosting() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var prevLastRow = $('#addform .account-group:last');
|
// Remove the add-new-row-on-keypress handler from the old last amount field
|
||||||
prevLastRow.off('keypress');
|
$('.amount-input:last').off('keypress');
|
||||||
|
|
||||||
// Clone the currently last row
|
// Clone the old last row to make a new last row
|
||||||
$('#addform .account-postings').append(prevLastRow.clone());
|
$('#addform .account-postings').append( $('#addform .account-group:last').clone() );
|
||||||
var num = $('#addform .account-group').length;
|
// renumber and clear the new last account and amount fields
|
||||||
|
var n = $('#addform .account-group').length;
|
||||||
// clear and renumber the field, add keybindings
|
$('.account-input:last').prop('placeholder', 'Account '+n).val('');
|
||||||
// XXX Enable typehead on dynamically created inputs
|
$('.amount-input:last').prop('placeholder','Amount '+n).val(''); // XXX Enable typehead on dynamically created inputs
|
||||||
$('.amount-input:last')
|
// and ensure they have the proper keybindings
|
||||||
.val('')
|
addformBindKeys();
|
||||||
.prop('placeholder','Amount ' + num)
|
|
||||||
.keypress(addformAddPosting);
|
|
||||||
|
|
||||||
$('.account-input:last')
|
|
||||||
.val('')
|
|
||||||
.prop('placeholder', 'Account ' + num)
|
|
||||||
.bind('keydown', 'ctrl++', addformAddPosting)
|
|
||||||
.bind('keydown', 'ctrl+shift+=', addformAddPosting)
|
|
||||||
.bind('keydown', 'ctrl+=', addformAddPosting)
|
|
||||||
.bind('keydown', 'ctrl+-', addformDeletePosting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user