%PDF- %PDF-
Direktori : /proc/self/root/home/bitrix/www/local/components/UB/adbase.offer.edit/templates/job/ |
Current File : //proc/self/root/home/bitrix/www/local/components/UB/adbase.offer.edit/templates/job/script.js |
function setCurrency(s) { $('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').attr('value',s.attr('data-currency')); $('#label_curency').html(s.html()+' <span class="caret"></span>'); } $(document).ready(function(){ var new_image = ''; modelID = 7; // Модели $('#DATE_FROM').datetimepicker(datetimepickerParams); $('#DATE_TO').datetimepicker(datetimepickerParams); $('#JOB_DATE').datetimepicker(datetimepickerParams); $('#image-cropper').cropit({ imageBackground: true, width:650, height:450 }); $('#select-image-btn').click(function() { $('.cropit-image-input').click(); }); $('#save-image-btn').click(function() { // Сохранение изображения в поле формы // закрываем окно $('#imageloader').modal('hide'); // загружаем картинку в форму new_image = $('#image-cropper').cropit('export',{type:'image/jpeg',quality:.9,originalSize:false}); $('#new_image_preview > div').html('<img src="'+new_image+'" width="140" height="97" />'); $('#confirm-submit-body .portfolio-item > div').html('<img src="'+new_image+'" width="140" height="97" />'); $('#new_image_content').attr('value',new_image); }); function showErrorAlert(s) { $('#alert-danger > span').html(s); $('#alert-danger').show(); } $('input[name="CASTING_PROPS[COMPENSATION]"]').bind("change keyup input click", function() { if (this.value.match(/[^0-9]/g)) { this.value = this.value.replace(/[^0-9]/g, ''); } }); // Отображение превью и ошибок (если есть) $('#confirm-buttom-submit').click(function(){ // Проверка обязательных полей errorMsg = ''; if ($('select#sel_section option:selected').attr('value')==0) errorMsg += LA_MESS["AD_CATEGORY_IS_NOT_SELECTED"]; if ($('input[name="CASTING[NAME]"]').val().length<3) errorMsg += LA_MESS["AD_TITLE_IS_NOT_SPECIFIED"]; if (!$('select[name="CASTING_PROPS[CITY]"]').val()) errorMsg += LA_MESS["THE_CITY_IS_NOT_SPECIFIED"]; if ($('textarea[name="CASTING_PROPS[CASTING_TEXT]"]').val().length<10) errorMsg += LA_MESS["AD_TEXT_IS_NOT_SPECIFIED"]; if ($('input#cb_tfp:checked').val()!='Y' && $('input[name="CASTING_PROPS[COMPENSATION]"]').val().length==0) errorMsg += LA_MESS["COMPENSATION_SUM_IS_NOT_SPECIFIED"]; if ($('input[name="CASTING_PROPS[JOB_DATE]"]').val()=="__.__.____" | $('input[name="CASTING_PROPS[JOB_DATE]"]').val()=="__/__/____") errorMsg += LA_MESS["START_DATE_IS_NOT_SPECIFIED"]; if (errorMsg.length>0) { showErrorAlert(errorMsg); return false; } $('#alert-danger').hide(); // Формирование превью $('div#confirm-submit-body ul > li > span').html(''); $('form#casting-form').find('input[type="text"],textarea').each(function() { value = $(this).val().length>0?$(this).val():'-'; $('div#confirm-submit-body ul > li > span[data-id="'+$(this).attr('name')+'"]').html(value.replace(/([^])\n/g,'$1<br/>')); }); $('form#casting-form').find('select > option:selected').each(function() { value = $(this).text().length>0?$(this).text():'-'; old_value = $('div#confirm-submit-body ul > li > span[data-id="'+$(this).parent().attr('name')+'"]').html(); if (old_value.length>0) value = old_value+', '+value; $('div#confirm-submit-body ul > li > span[data-id="'+$(this).parent().attr('name')+'"]').html(value); }); $('div#confirm-submit-body ul > li > span[data-id="CASTING_PROPS[CITY]"]').html( $('#CASTING_CITY_chosen .chosen-single span').text() ); $('div#confirm-submit-body ul > li > span[data-id="CASTING_PROPS[COMPENSATION_CURRENCY]"]').html( $('a.sel_curency[data-currency="'+$('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').val()+'"]').html() ); $('#sel_section > option:selected[value='+modelID+']').each(function(){ var lengcheck = $("input.sel_sex:checked").length; var sex = $("input.sel_sex:checked:eq(0)").data('value'); if (lengcheck > 1){ sex += " " + $("input.sel_sex:checked:eq(1)").data('value'); }; $('#model-more').html( (sex===undefined?'':LA_MESS["SEX_JS"]+sex)+ ($("input#sel_nudity").prop('checked')?LA_MESS["NUDE_JS"]:'') ); }); $('input#cb_tfp:checked').each(function(){ $('div#confirm-submit-body ul > li > span[data-id="CASTING_PROPS[COMPENSATION]"]').html('TFP'); $('div#confirm-submit-body ul > li > span[data-id="CASTING_PROPS[COMPENSATION_CURRENCY]"]').html(''); $('div#confirm-submit-body ul > li > span[data-id="CASTING_PROPS[COMPENSATION_TYPE]"]').html(''); }); $('#confirm-submit').modal('show'); }); $('input.sel_sex').change(function(){ state = $(this).prop('checked'); $('input.sel_sex').each(function(){ /*$(this).prop('checked',false);*/ }); $(this).prop('checked',state); }); $('#cb_tfp').change(function(){ if ($('#cb_tfp').prop('checked')) { $('input[name="CASTING_PROPS[COMPENSATION]"]').attr('value',0); $('input[name="CASTING_PROPS[COMPENSATION]"]').prop('disabled',true); $('#label_curency').prop('disabled',true); $('select#sel_comp_type').prop('disabled',true); $('select#sel_comp_type').trigger('chosen:updated'); } else { $('input[name="CASTING_PROPS[COMPENSATION]"]').prop('disabled',false); $('#label_curency').prop('disabled',false); $('select#sel_comp_type').prop('disabled',false); $('select#sel_comp_type').trigger('chosen:updated'); } }); $('#sel_comp_type').change(function(){ if ($('select#sel_comp_type').val() == 392 || $('select#sel_comp_type').val() == 452) { $('input[name="CASTING_PROPS[COMPENSATION]"]').attr('value',0); $('input[name="CASTING_PROPS[COMPENSATION]"]').prop('disabled',true); $('#label_curency').prop('disabled',true); $('#cb_tfp').prop('disabled',true); $('select#sel_comp_type').trigger('chosen:updated'); } else { $('input[name="CASTING_PROPS[COMPENSATION]"]').prop('disabled',false); $('#label_curency').prop('disabled',false); $('#cb_tfp').prop('disabled',false); $('select#sel_comp_type').trigger('chosen:updated'); } }); $('#cb_tfp').trigger('change'); $('#post-offer-btn').click(function(){ $('#casting-form').submit(); }); $('form.register-page').find('select').each(function() { $(this).chosen({disable_search_threshold: ($(this).attr('id')=='CASTING_CITY')?0:10}); }); $('select#sel_section').chosen().change(function (){ if ($('select#sel_section > option:selected').attr('value')==modelID) $('div.casting-model').show(); else $('div.casting-model').hide(); }); $('#START_DATE').datetimepicker(datetimepickerParams); $('a.sel_curency').click(function(){ setCurrency($(this)); }); if ($('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').val().length==0) { $("a.sel_curency:first").each(function(){ setCurrency($(this)); }); } else { $('a.sel_curency[data-currency="'+$('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').attr('value')+'"]').click(); } $('select#CASTING_CITY').ajaxChosen( { type: 'GET', url: 'load_ref.php', dataType: 'json' }, function (data) { return data; } ); $("select#sel_section").trigger('change'); addRegionToCity = function() { $('#CASTING_CITY_chosen .chosen-single span').text( $('select#CASTING_CITY option:selected').parent()[0].label+', '+ $('#CASTING_CITY_chosen .chosen-single span').text() ); } $('select#CASTING_CITY').chosen().change(function(){ addRegionToCity(); }); initCityList = function() { sid = $('input#CASTING_CITY_PRE').val(); $.ajax({ url: 'load_ref.php', type: "GET", data: {REF: 'CITY', SID: sid }, dataType: "html", success: function(html){ $('select#CASTING_CITY').html(html); if ($('input#CASTING_CITY_PRE').attr('value')>0) $('select#CASTING_CITY option[value="'+$('input#CASTING_CITY_PRE').attr('value')+'"]').prop("selected", true); $("select#CASTING_CITY").trigger('chosen:updated'); addRegionToCity(); } }); } initCityList(); });