%PDF- %PDF-
Direktori : /home/bitrix/www/local/components/UB/casting.edit/templates/.default/ |
Current File : //home/bitrix/www/local/components/UB/casting.edit/templates/.default/script.js |
function setCurrency(s) { /* re = /\((\W)\)/; found = s.html().match(re); $('#label_curency').html(found[1]+' <span class="caret"></span>'); */ $('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').attr('value',s.attr('data-currency')); $('#label_curency').html(s.html()+' <span class="caret"></span>'); } $(document).ready(function(){ modelID = 7; // Модели eduID = 799; // Обучение eduCompensationTypeID = 210; // ID Компенсация (тип) для Обучения datetimepickerParams = { timepicker:false, lang:'ru', format:'d.m.Y', yearStart:'2014', yearEnd:'2020', mask:true } function showErrorAlert(s) { $('#alert-danger > span').html(s); $('#alert-danger').show(); } // Отображение превью и ошибок (если есть) $('#confirm-buttom-submit').click(function(){ // Проверка обязательных полей errorMsg = ''; if ($('input[name="CASTING[NAME]"]').val().length<3) errorMsg += LC_MESS["AD_TITLE_IS_NOT_SPECIFIED"]; if (!$('select[name="CASTING_PROPS[CITY]"]').val()) errorMsg += LC_MESS["THE_CITY_IS_NOT_SPECIFIED"]; if ($('textarea[name="CASTING_PROPS[CASTING_TEXT]"]').val().length<10) errorMsg += LC_MESS["AD_TEXT_IS_NOT_SPECIFIED"]; if ($('input[name="CASTING_PROPS[CONTACT_NAME]"]').val().length<3) errorMsg += LC_MESS["CONTACT_NAME_IS_NOT_SPECIFIED"]; if ($('input[name="CASTING_PROPS[CONTACT_EMAIL]"]').val().length<5) errorMsg += LC_MESS["EMAIL_IS_NOT_SPECIFIED"]; if ($('input#cb_tfp:checked').val()!='Y' && $('input[name="CASTING_PROPS[COMPENSATION]"]').val().length==0) errorMsg += LC_MESS["COMPENSATION_SUM_IS_NOT_SPECIFIED"]; if ($('input[name="CASTING_PROPS[JOB_DATE]"]').val()=="__.__.____") errorMsg += LC_MESS["START_DATE_IS_NOT_SPECIFIED"]; if (errorMsg.length>0) { showErrorAlert(errorMsg); return; } $('#alert-danger').hide(); // Формирование превью $('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():'-'; $('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[COMPENSATION_CURRENCY]"]').html( $('a.sel_curency[data-currency="'+$('input[name="CASTING_PROPS[COMPENSATION_CURRENCY]"]').val()+'"]').html() ); $('#sel_section > option:selected').each(function(){ $('#model-more').html( LC_MESS["SEX_JS"]+$("select#sel_sex > option:selected").html()+ LC_MESS["NUDE_JS"]+$("select#sel_nudity > option:selected").html() ); }); $('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'); }); $('#save-image-btn').click(function(){ $('#casting-form').submit(); }); $('#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'); } }); $('#cb_tfp').trigger('change'); $('#DATE_FROM').datetimepicker(datetimepickerParams); $('#DATE_TO').datetimepicker(datetimepickerParams); $('#JOB_DATE').datetimepicker(datetimepickerParams); $('form.register-page').find('select').each(function() { $(this).chosen({disable_search_threshold: 10}); }); $('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#sel_section').chosen().change(function (){ if ($('select#sel_section > option:selected').attr('value')==modelID) { $("select#sel_sex").prop('disabled',false); $("select#sel_sex").trigger('chosen:updated'); $("select#sel_nudity").prop('disabled',false); $("select#sel_nudity").trigger('chosen:updated'); $("input#DATE_FROM").prop('disabled',false); $("input#DATE_TO").prop('disabled',false); $('#casting-period').show(); $('#casting-sex').show(); $('#casting-ny').show(); } else { $("select#sel_sex").prop('disabled',true); $("select#sel_sex").trigger('chosen:updated'); $("select#sel_nudity").prop('disabled',true); $("select#sel_nudity").trigger('chosen:updated'); $("input#DATE_FROM").prop('disabled',true); $("input#DATE_TO").prop('disabled',true); $('#casting-period').hide(); $('#casting-sex').hide(); $('#casting-ny').hide(); } if ($('select#sel_section > option:selected').attr('value')==eduID) { $('#casting-tfp').hide(); $('#casting-job-date').html(LC_MESS["DATE_OF_TRAINING_START"]); $('select#sel_comp_type > option').prop("disabled", true); $('select#sel_comp_type > option[value="'+eduCompensationTypeID+'"]').prop("disabled", false); $('select#sel_comp_type > option[value="'+eduCompensationTypeID+'"]').attr("selected", "selected"); $('select#sel_comp_type').trigger('chosen:updated'); } else { $('#casting-tfp').show(); $('#casting-job-date').html(LC_MESS["DATE_OF_WORK_START"]); $('select#sel_comp_type > option').prop("disabled", false); $('select#sel_comp_type > option[value="'+eduCompensationTypeID+'"]').prop("disabled", true); $('select#sel_comp_type > option:first').attr("selected", "selected"); $('select#sel_comp_type').trigger('chosen:updated'); } }); $("select#sel_section").trigger('change'); $("select#CASTING_STATE").change(function () { sid = $(this).val(); $.ajax({ url: 'load_ref.php', type: "GET", data: {REF: 'CITY', SID: sid}, dataType: "html", success: function(html){ $('#CASTING_CITY').html(html); if ($('input#CASTING_CITY_PRE').attr('value')>0) $('#CASTING_CITY option[value="'+$('input#CASTING_CITY_PRE').attr('value')+'"]').prop("selected", true); $("#CASTING_CITY").trigger('chosen:updated'); } }); }); $('select#CASTING_COUNTRY').chosen().change(function () { sid = $(this).val(); $("#CASTING_CITY").html(''); $("#CASTING_STATE").html(''); $("#CASTING_STATE").prop('disabled',true); $("#CASTING_CITY").prop('disabled',true); $("#CASTING_CITY").trigger('chosen:updated'); $("#CASTING_STATE").trigger('chosen:updated'); $.ajax({ url: 'load_ref.php', type: "GET", data: {REF: 'STATE', SID: sid}, dataType: "html", success: function(html){ if (html!='<option value=""></option>'/*html.length>0*/) { // Если регионы для страны определены $("#CASTING_STATE").html(html); if ($('input#CASTING_STATE_PRE').attr('value')>0) $('#CASTING_STATE option[value="'+$('input#CASTING_STATE_PRE').attr('value')+'"]').prop("selected", true); else $('#CASTING_STATE :first').remove(); $("#CASTING_STATE").prop('disabled',false); $("#CASTING_CITY").prop('disabled',false); $("#CASTING_STATE").trigger('chosen:updated'); $("#CASTING_STATE").trigger('change'); } else { $.ajax({ url: 'load_ref.php', type: "GET", data: {REF: 'CITY', SID: sid}, dataType: "html", success: function(html){ $("#CASTING_CITY").html(html); if ($('input#CASTING_CITY_PRE').attr('value')>0) $('#CASTING_CITY option[value="'+$('input#CASTING_CITY_PRE').attr('value')+'"]').prop("selected", true); $("#CASTING_CITY").prop('disabled',false); $("#CASTING_CITY").trigger('chosen:updated'); } }); } } }); }); //if($("#CASTING_COUNTRY").val()>0) $("#CASTING_COUNTRY").trigger('change'); });