Медицинский информационный портал
';
if (jQuery.inArray(jQuery(this).val(), ['adate']) === -1)
strout += '
';
strout += '
';
} else {
strout = '
';
}
jQuery(this).parents('li').after('
' +
''+
'
' + jQuery(this).find('option:selected').html() + ' ' +
strout+
'
Delete
'+
'
'+
' ');
}
// if auto_filter we submit form.
$('jak2filter-form-214').fireEvent('submit');
});
function resetChildren($current, $next) {
if ($next) {
$data = $jak2depend[parseInt($next.data('exfield'))][$current.val()];
if ($data != undefined && $data != 'undefined') {
$next.html('');
$next.append('
'+$next.data('extitle')+' ');
for (i=0;i'+$data[i][1]+'');
}
$next.chosen("destroy").chosen();
} else {
$next.html('');
$next.append('
'+$next.data('extitle')+' ');
$next.chosen("destroy").chosen();
}
$_next = '#K2ExtraField_'+$next.data('exfield')+'_'+(parseInt($next.data('dependlv'))+1);
if (jQuery($_next).length) resetChildren($next, jQuery($_next));
}
}
jQuery('#jak2filter214 .jak2depend').unbind().off().change(function() {
$next = '#K2ExtraField_'+jQuery(this).data('exfield')+'_'+(parseInt(jQuery(this).data('dependlv'))+1);
if (jQuery($next).length) resetChildren(jQuery(this), jQuery($next));
jQuery('#xf_'+parseInt(jQuery(this).data('exfield'))+'_array').val('');
jQuery('#jak2filter214 .jak2depend').each(function(){
$ar = jQuery('#xf_'+parseInt(jQuery(this).data('exfield'))+'_array').val();
if (jQuery(this).val() != '')
$ar += jQuery(this).val()+',';
jQuery('#xf_'+parseInt(jQuery(this).data('exfield'))+'_array').val($ar);
});
jQuery('#xf_'+parseInt(jQuery(this).data('exfield'))+'_txt').val(jQuery(this).val());
if (jQuery(this).val() == '') { // get the prev value if choose no value at current.
$prev = '#K2ExtraField_'+jQuery(this).data('exfield')+'_'+(parseInt(jQuery(this).data('dependlv'))-1);
if (jQuery($prev).length) {
jQuery('#xf_'+parseInt(jQuery(this).data('exfield'))+'_txt').val(jQuery($prev).val());
}
}
if (jQuery(this).data('autofield') == 'all') $('jak2filter-form-214').fireEvent('submit'); // always submit form if all defined.
if (parseInt(jQuery(this).data('dependlv')) === parseInt(jQuery(this).data('autofield'))) // submit form at number defined
$('jak2filter-form-214').fireEvent('submit');
if (!jQuery($next).length) {
// if auto_filter and the last one choose we submit form.
$('jak2filter-form-214').fireEvent('submit');
}
});
jQuery('#btnSubmit214').on('click', function(){
jQuery(this).preventDefault();
return false;
});
setTimeout(function(){
if (jQuery('#ja-extra-field-accordion-214').find('.ui-accordion-disabled.ui-state-disabled').length)
jQuery('#ja-extra-field-accordion-214').find('.ui-accordion-disabled.ui-state-disabled').each(function(){
if (jQuery(this).next().find('.chzn-container.chzn-container-single').length)
jQuery(this).next().find('.chzn-container.chzn-container-single').attr('style', 'width:auto;');
});
}, 1000);
});
window.addEvent('load', function () {
if ($('jak2filter214').getElement('#category_id')) {
jak2DisplayExtraFields(214, $('jak2filter214').getElement('#category_id'), 0);
}
var f = $('jak2filter-form-214');
f.getElements('input').each(function (el) {
el.addEvent('change', function () {
if (this.id == 'sdate_214' || this.id == 'edate_214') {
var sDate = $('jak2filter214').getElement('#sdate_214').get('value');
var eDate = $('jak2filter214').getElement('#edate_214').get('value');
if (sDate != '' && eDate != '') {
if (isDate(sDate) && isDate(eDate)) {
this.removeClass('date-error');
$('jak2filter-form-214').fireEvent('submit');
}
else {
this.addClass('date-error');
}
}
}
else {
$('jak2filter-form-214').fireEvent('submit');
}
});
});
f.getElements('select').each(function (el) {
el.addEvent('change', function () {
if (el.getAttribute("class").search('jak2depend') !== -1) // remove event from jak2depenf field.
return;
if (this.id == 'dtrange' && this.value == 'range') {
var sDate = $('jak2filter214').getElement('#sdate_214');
var eDate = $('jak2filter214').getElement('#edate_214');
if (sDate.get('value') != '' && eDate.get('value') != '') {
var isStartDate = isDate(sDate.get('value'));
var isEndDate = isDate(eDate.get('value'));
if (isStartDate && isEndDate) {
$('jak2filter-form-214').fireEvent('submit');
}
else {
if (!isStartDate)
sDate.addClass('date-error');
if (!isEndDate)
eDate.addClass('date-error');
}
}
}
else {
$('jak2filter-form-214').fireEvent('submit');
}
});
jQuery("#"+el.id).chosen().change( function() {
if (jQuery(this).hasClass('jak2depend')) // remove event from jak2depend field.
return false;
else
$('jak2filter-form-214').fireEvent('submit');
});
});
f.getElements('textarea').each(function (el) {
el.addEvent('change', function () {
$('jak2filter-form-214').fireEvent('submit');
});
});
$('jak2filter-form-214').addEvent('submit', function () { // mootools
$check = checkrequired($required_fields214, "jak2filter-form-214");
if ($check == true) {
$('jak2filter-form-214').submit();
} else {
jQuery("html, body").scrollTop(jQuery('#jak2filter-form-214').find('.jak2-error').first().offset().top-jQuery('#jak2filter-form-214').find('.jak2-error').first().parents('.subclass').height());
return false;
}
});
});
/*]]>*/