Files
EasySoft-ZenTaoPMS/module/task/js/batchedit.js
T

55 lines
1.7 KiB
JavaScript

$(function()
{
$firstTr = $('.table-form').find('tbody tr:first');
$firstTr.find('td select').each(function()
{
$(this).find("option[value='ditto']").remove();
$(this).trigger("chosen:updated");
});
})
$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();})
$(document).on('change', 'select', function()
{
if($(this).val() == 'ditto')
{
var index = $(this).closest('td').index();
var row = $(this).closest('tr').index();
var $tbody = $(this).closest('tr').parent();
var value = '';
for(i = row - 1; i >= 0; i--)
{
value = $tbody.children('tr').eq(i).find('td').eq(index).find('select').val();
if(value != 'ditto') break;
}
isModules = $(this).attr('name').indexOf('modules') != -1;
isAssignedTos = $(this).attr('name').indexOf('assignedTos') != -1;
isFinishedBys = $(this).attr('name').indexOf('finishedBys') != -1;
isClosedBys = $(this).attr('name').indexOf('closedBys') != -1;
if(isModules || isAssignedTos || isFinishedBys || isClosedBys)
{
var valueStr = ',' + $(this).find('option').map(function(){return $(this).val();}).get().join(',') + ',';
if(valueStr.indexOf(',' + value + ',') != -1)
{
$(this).val(value);
}
else
{
alert(dittoNotice);
$(this).val(oldValue);
}
}
else
{
$(this).val(value);
}
$(this).trigger("chosen:updated");
$(this).trigger("change");
}
})