Merge pull request #29 from finnlabs/feature/fix-rate-form-enter-keypress
Feature/fix rate form enter keypresspull/6827/head
commit
9e32a4420d
@ -1,30 +1,29 @@ |
|||||||
function addRate(date_field) { |
function addRate(date_field){ |
||||||
var my_date = date_field.value; |
RatesForm.add_on_top(); |
||||||
var date_elements = $(RatesForm.parentElement).select('input.date'); |
|
||||||
|
|
||||||
var highest_date = null; |
var newRateRow = $(RatesForm.parentElement).down("tr"); |
||||||
for (var e in date_elements) { |
var validFromField = newRateRow.down('input.date') |
||||||
if (e.value > my_date) { |
validFromField.value = jQuery.datepicker.formatDate('yy-mm-dd', new Date()); |
||||||
highest_date = e; |
newRateRow.down('td.currency').down('input').select(); |
||||||
} else { |
} |
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
switch (highest_date) { |
function disableEnterKey(event){ |
||||||
case null: |
if (event.keyCode == 13) event.preventDefault(); |
||||||
RatesForm.add_on_top() |
} |
||||||
var e = $(RatesForm.parentElement).down("tr"); |
|
||||||
break; |
|
||||||
default: |
|
||||||
var after = highest_date.up('tr'); |
|
||||||
RatesForm.add_after(after); |
|
||||||
var e = after.next(); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
var new_date_field = e.down('input.date') |
function deleteRow(image){ |
||||||
new_date_field.value = date_field.value; |
var row = image.up("tr") |
||||||
date_field.value = ""; |
var parent=row.up(); |
||||||
e.down('td.currency').down('input').select(); |
row.remove(); |
||||||
|
recalculate_even_odd(parent); |
||||||
} |
} |
||||||
|
|
||||||
|
jQuery(function(jQuery){ |
||||||
|
jQuery(document).on("keydown", "body.action-edit input", function(event){ |
||||||
|
disableEnterKey(event); |
||||||
|
}); |
||||||
|
|
||||||
|
jQuery(document).on("click", "body.action-edit img.delete", function(){ |
||||||
|
deleteRow(this); |
||||||
|
}); |
||||||
|
}); |
||||||
|
Loading…
Reference in new issue