46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
$(document).ready(removeDitto());//Remove 'ditto' in first row.
|
|
|
|
$(document).on('click', '.chosen-with-drop', function()
|
|
{
|
|
var select = $(this).prev('select');
|
|
if($(select).val() == 'ditto')
|
|
{
|
|
var index = $(select).closest('td').index();
|
|
var row = $(select).closest('tr').index();
|
|
var table = $(select).closest('tr').parent();
|
|
var value = '';
|
|
for(i = row - 1; i >= 0; i--)
|
|
{
|
|
value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val();
|
|
if(value != 'ditto') break;
|
|
}
|
|
$(select).val(value);
|
|
$(select).trigger("chosen:updated");
|
|
}
|
|
});
|
|
$(document).on('mousedown', 'select', function()
|
|
{
|
|
if($(this).val() == 'ditto')
|
|
{
|
|
var index = $(this).closest('td').index();
|
|
var row = $(this).closest('tr').index();
|
|
var table = $(this).closest('tr').parent();
|
|
var value = '';
|
|
for(i = row - 1; i >= 0; i--)
|
|
{
|
|
value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val();
|
|
if(value != 'ditto') break;
|
|
}
|
|
$(this).val(value);
|
|
}
|
|
})
|
|
|
|
if(navigator.userAgent.indexOf("Firefox") < 0)
|
|
{
|
|
$(document).on('input keyup paste change', 'textarea.autosize', function()
|
|
{
|
|
this.style.height = 'auto';
|
|
this.style.height = (this.scrollHeight + 2) + "px";
|
|
});
|
|
}
|