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) { |
||||
var my_date = date_field.value; |
||||
var date_elements = $(RatesForm.parentElement).select('input.date'); |
||||
|
||||
var highest_date = null; |
||||
for (var e in date_elements) { |
||||
if (e.value > my_date) { |
||||
highest_date = e; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
switch (highest_date) { |
||||
case null: |
||||
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') |
||||
new_date_field.value = date_field.value; |
||||
date_field.value = ""; |
||||
e.down('td.currency').down('input').select(); |
||||
} |
||||
function addRate(date_field){ |
||||
RatesForm.add_on_top(); |
||||
|
||||
var newRateRow = $(RatesForm.parentElement).down("tr"); |
||||
var validFromField = newRateRow.down('input.date') |
||||
validFromField.value = jQuery.datepicker.formatDate('yy-mm-dd', new Date()); |
||||
newRateRow.down('td.currency').down('input').select(); |
||||
} |
||||
|
||||
function disableEnterKey(event){ |
||||
if (event.keyCode == 13) event.preventDefault(); |
||||
} |
||||
|
||||
function deleteRow(image){ |
||||
var row = image.up("tr") |
||||
var parent=row.up(); |
||||
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