Выбор офиса обслуживания
Воронеж (центральный склад)
Вход
+7 (473) 210-67-14 (новые запчасти)
+7 (920) 436-21-53 (б/у запчасти)
' + '' + '×' + ''; $partListTable.append(field).show(); $partInput.val(''); queryCount++; } showApproximateQueryPrice(); }; $('.part-item .remove').live('click', function(event) { $(this).closest('.part-item').remove(); if (!$partListTable.has('.part-item').length) { $partListTable.hide(); } queryCount--; showApproximateQueryPrice(); }); $('.add-part-button').click(function() { addPart(); }); var checkPartStringLength = function() { var trimmedPartText = $.trim($('.add-part-input').val()); if (trimmedPartText.length >= 50 || /[\.,:;\+]/.test(trimmedPartText)) { showPartInputTooltip(stockEnable ? lang_vinquLongPartStock : lang_vinquLongPart); } }; var $addPartInput = $('.add-part-input'); $addPartInput.on('paste', function(event) { setTimeout(checkPartStringLength, 50); }); var getKeyCode = function(event) { var keyCode; if (event.keyCode != null) { keyCode = event.keyCode; } if (!((keyCode != null) && (event.which != null))) { keyCode = event.which; } return keyCode; }; $addPartInput.keyup(function(event) { if (event.keyCode == 13) { addPart(); } else { var keyCode = getKeyCode(event); var checkedKeyCode = false; checkedKeyCode = checkedKeyCode || keyCode == 32; checkedKeyCode = checkedKeyCode || (keyCode >= 48 && keyCode = 65 && keyCode = 96 && keyCode = 186 && keyCode = 219 && keyCode = 2) { $.ajax({ url: '//admin.nodacdn.net/ajax/modules/vinqu/decode.vin.php?vin=' + $value, success: function(resp) { if (resp.status && $('.carbase-blocks.carbase-blocks-simple .carChoiceBlock').is(':visible')) { var $manufactorersSelect = $('[name=manufacturers]'); if (!!$manufactorersSelect.find('option[value="' + resp.brand + '"]').length) { $manufactorersSelect.value(resp.brand); } else { $manufactorersSelect.value(''); } } var modifId = $('.selected-car input[name=modifId]').val(); if (stockEnable && !modifId) { if (resp.bad) { var carbase_blocks = $('.carbase-blocks') carbase_blocks.removeClass('carbase-blocks-simple'); $('.carbase-block-toggle-wrapper').hide(); carbase_blocks.find('.carbase-block.carbase-block-extended').removeClass('carbase-block-hidden'); $('.error-bad-vehicle').show(); } else { $('.carbase-block-toggle-wrapper').show(); $('.error-bad-vehicle').hide(); } } }, method: 'GET', dataType: 'jsonp' }); } } $('.vinqu-block input[name=vin]').keyup(changeVin); $('.vinqu-block input[name=vin]').change(changeVin); $('.vinqu-block input[name=selectVinOrFrame]:radio').change(changeVinOrFrame); $('.add-to-garage-button').click(function() { var vin = $('.vinqu-block input[name=vin]').val(); var frame = $('.vinqu-block input[name=frame]').val(); var modifId = $('.selected-car input[name=modifId]').val(); if ((!vin && !frame) || !modifId) { return false; } $.ajax({ url: '/vinqu/?action=ajax_add_car_to_garage', data: { modifId: modifId, vin: vin, frame: frame }, success: function(resp) { if (!resp.status) { showError(lang_serverError); } else { $('.add-to-garage-button').hide(); $('.in-garage-button').show(); } }, method: 'POST', dataType: 'json' }); }); $( "#dialog-message" ).dialog({ modal: true, autoOpen: false, buttons: { Ok: function() { $( this ).dialog( "close" ); } } }); $('.carbase-block-toggle').click(function(event){ event.preventDefault(); var $carbaseBlocks = $(this).closest('.carbase-blocks'); $carbaseBlocks.toggleClass('carbase-blocks-simple'); $carbaseBlocks.find('.carbase-block.carbase-block-extended').removeClass('carbase-block-hidden'); return false; }); var attachLabelModify = function($attachInput) { var filename = $attachInput.val().split(/(\\|\/)/g).pop(); var $filename = $attachInput.parent().find('.attache-filename'); $filename.text(filename); var fileType = filename.split('.').pop(); var fileTypeClass = []; if (fileType) { fileTypeClass.push('fileicon'); switch (fileType) { case 'jpg': case 'jpeg': fileTypeClass.push('jpgfile'); break; case 'png': fileTypeClass.push('pngfile'); break; case 'gif': fileTypeClass.push('giffile'); break; default: } } $filename.removeClass(['jpgfile', 'pngfile', 'giffile', 'fileicon'].join(' ')); if (fileTypeClass.length) { $filename.addClass(fileTypeClass.join(' ')); } }; $('.vinqu-block input[type=file]').live('change', function(event) { var $this = $(this); var fileInput = $this.get(0); var $fileFieldForm = $this.closest('.query-attache-form'); var $fileFieldLabel = $fileFieldForm.find('label'); var rollbackField = function() { $this.val(''); $fileFieldLabel.text(lang_labelBrandFieldFile); $fileFieldForm.find('.brand-file-field-filename').removeClass(['jpgfile', 'pngfile', 'giffile', 'fileicon'].join(' ')).html(''); }; if ($this.val() && fileInput && fileInput.files && fileInput.files[0]) { if (fileInput.files[0].size '; item += '
' + field.descr + ' ?
'; var required = field.is_required ? 'required="required"' : ''; if (field.with_image == 1) { item += '
'; item += ''; item += '
'; item += ''; item += '
'; } else { if (field.length > 50) { item += ''; } else { item += ''; } } item += '
'; if ($vinquParamsBlock.html() == '') { $vinquParamsBlock.append($vinquBlock.find('.params-label').clone().show()); } $vinquParamsBlock.append(item); } } } }, method: 'GET', dataType: 'jsonp' }); }); var $fakeCommentField = $('.comment-field-fake'); var recalcTextarealHeight = function(resizeFunc, compareFunc, compareVal) { var height = $fakeCommentField.outerHeight(); height = compareFunc(height, compareVal); var $this = $(this); var oldHeight = $this.outerHeight(); if (oldHeight != height) { resizeFunc(oldHeight, height); } }; $('.comment-field').on('keydown keyup change', function(event) { var $this = $(this); var val = $(this).val(); $fakeCommentField.html(val ? val + '\n' : val); recalcTextarealHeight.apply(this, [function(oldVal, newVal) { $this.css({ height: newVal + 'px' }); }, Math.max, 108]); }); var $phone = $('[name="guestInfo[phone]"]'); $phone.change(function () { $phone.inputmasks(abcpMaskOpts); }); $phone.change(); }); var showApproximateQueryPrice = function() {}; function updateVinFrameBySelectedCar(car) { var vin = $.trim(car.find('input[name=vin]').val()); var frame = $.trim(car.find('input[name=frame]').val()); var brand = car.find('input[name=brand]').val(); var $vinquBlock = $('.vinqu-block'); var $vinquParamsBlock = $vinquBlock.find('.params'); $vinquParamsBlock.html(''); $.ajax({ url: '//admin.nodacdn.net/ajax/modules/vinqu/get.brand.info.php?brand=' + brand, success: function(resp) { blocked = false; $('.loader').hide(); $('.car-list-block').css('opacity', 1); if (!resp.status) { showError(lang_serverError); } else { if ($('.selected-car-block .selected-car').is(':not(:empty)')) { if (resp.brand && resp.brand.fields) { for (var k in resp.brand.fields) { var field = resp.brand.fields[k]; var item = '
'; item += '
' + field.descr + ' ?
'; var required = field.is_required ? 'required="required"' : ''; if (field.with_image == 1) { item += '
'; item += ''; item += '
'; item += ''; item += '
'; } else { if (field.length > 50) { item += ''; } else { item += ''; } } item += '
'; if ($vinquParamsBlock.html() == '') { $vinquParamsBlock.append($vinquBlock.find('.params-label').clone().show()); } $vinquParamsBlock.append(item); } } var $vinInput = $vinquBlock.find('input[name=vin]'); var $frameInput = $vinquBlock.find('input[name=frame]'); if (frame.length > 0) { $('#check-vin').prop('checked', false); $('#check-frame').prop('checked', true); $vinInput.prop('disabled', true); $frameInput.prop('disabled', false); $('.vin-field').hide(); $('.frame-field').show(); $vinInput.val(''); $frameInput.val(frame); } else if (vin.length > 0) { $('#check-vin').prop('checked', true); $('#check-frame').prop('checked', false); $vinInput.prop('disabled', false); $frameInput.prop('disabled', true); $('.vin-field').show(); $('.frame-field').hide(); $vinInput.val(vin); $frameInput.val(''); } else { $('#check-vin').prop('checked', true); $('#check-frame').prop('checked', false); $vinInput.prop('disabled', false); $frameInput.prop('disabled', true); $('.vin-field').show(); $('.frame-field').hide(); } $('.car-block').slideUp(); $('.add-to-garage-button').hide(); $('.selected-car-block').slideDown(); } } }, error: function(resp) { blocked = false; $('.loader').hide(); $('.car-list-block').css('opacity', 1); }, method: 'GET', dataType: 'jsonp' }); } function showError(msg) { $('#message').html(msg); $( "#dialog-message" ).dialog('open'); return false; } function showGarageCarListByClientId(clientId) { client_id = clientId; $.ajax({ url: '/ajax/vinqu/get.garage.car.list.php?clientId=' + clientId, data: {}, method: 'GET', dataType: 'jsonp', success: function(resp) { if (resp.carList) { $('.car-list-block').html(resp.carList); if (!$('.selected-car-block:visible').length) { $('.car-block').show(); $('.car-list-block').show(); $('.carChoiceBlock').hide(); } } else { if (!$('.selected-car-block:visible').length) { $('.car-block').hide(); $('.car-list-block').hide(); $('.carChoiceBlock').show(); } } } }); } function checkQuery() { var hasError = false; var $partInput = $('.add-part-input'); var part = $.trim($partInput.val()); if (queryCount 0)) { hasError = true; $('.error-empty-parts').show(); $('input[name="article[query][]"]').addClass('error-field'); $('.addPartLabel').addClass('error-text'); } else { $('.error-empty-parts').hide(); $('input[name="article[query][]"]').removeClass('error-field'); $('.addPartLabel').removeClass('error-text'); } var hasModifId = false; var brand = $('#choiceManufacturers').val(); var model = $('#choiceModels').val(); if (!model) { model = $('#newModel').val(); } else { model = $('#choiceModels option[value="' + model + '"]').html(); } var $modifId = $('.selected-car input[name=modifId], .choicedModification input[name=modifId]'); if ($modifId.length) { hasModifId = !!$modifId.val(); } else { // Случай когда вводится новая модель var $newModel = $('#newModel'); var $newModification = $('#newModification'); hasModifId = $newModel.is(':disabled') || !!$newModel.val() && $newModel.val() != $newModel.attr('placeholder'); hasModifId = hasModifId && $newModification.is(':not(:disabled)') && !!$newModification.val() && $newModification.val() != $newModification.attr('placeholder') } var $selectedBrand = $('.selected-car input[name=brand], .choicedModification input[name=brand]'); if (!$selectedBrand.length) { $selectedBrand = $('.carbase-blocks-simple .carbase-block-simple select[name=manufacturers], .carbase-blocks:not(.carbase-blocks-simple) .carbase-block-extended select[name=manufacturers]'); } var selectedBrand = $selectedBrand.val(); if ($selectedBrand.is('.carbase-block-extended select[name=manufacturers]')) { selectedBrand = selectedBrand ? $selectedBrand.find('option:selected').text() : null; } var brandDisabled = false; if (selectedBrand) { brandDisabled = true; $.each(enabledManufacturers, function(i, el) { return brandDisabled = el.name != selectedBrand; }); } if (brandDisabled) { hasError = true; $('.error-disabled-brand').show(); } else { $('.error-disabled-brand').hide(); } var isVin = $('input[name="selectVinOrFrame"]:checked').is('#check-vin'); var $vin = $('.vinqu-block input[name=vin]:not(:disabled)'); var vin = null; if ($vin.length) { vin = $.trim($vin.val()); if (vin == $vin.attr('placeholder')) { vin = null; } } var $frame = $('.vinqu-block input[name=frame]:not(:disabled)'); var frame = null; if ($frame.length) { frame = $.trim($frame.val()); if (frame == $frame.attr('placeholder')) { frame = null; } } var client_id = $('#client_id').val(); if (!$('.selected-car input[name=modifId]').length && $('.carbase-blocks').is('.carbase-blocks-simple')) { if ($('.simple-car-choice-select').val()) { $('.error-empty-car').hide(); if (!$('.simple-car-choice-select').is(':focus')) { $('.simple-car-choice-select').removeClass('error-field'); } } else { hasError = true; $('.error-empty-car').show(); if (!$('.simple-car-choice-select').is(':focus')) { $('.simple-car-choice-select').addClass('error-field'); } } } else { var $carSelectsAndInputsAll = $('#choiceYears, #choiceManufacturers, #choiceModels, #newModel, #choiceModifications, #newModification'); var needToSet = requiredFieldsCnt - requiredFields; if ((requiredFields === 0 && !hasModifId) || (requiredFields === 1 && !hasModifId && !model) || (requiredFields === 2 && !hasModifId && !model && !brand)) { hasError = true; var changeClassSelector = ':not(:disabled):lt(' + needToSet + '):has(option:selected[value=""]), :lt(' + needToSet + ')input[value=""]'; $carSelectsAndInputsAll.not(changeClassSelector).not(':focus').removeClass('error-field'); $carSelectsAndInputsAll.filter(changeClassSelector).not(':focus').addClass('error-field'); $('.error-empty-car').show(); } else { $carSelectsAndInputsAll.not(':focus').removeClass('error-field'); $('.error-empty-car').hide(); } } if (vin && vin != '' && isVin || !isVin && frame && frame != '') { $('.error-empty-vin').hide(); $('input[name="vin"]').removeClass('error-field'); $('input[name="frame"]').removeClass('error-field'); } else { hasError = true; $('.error-empty-vin').show(); $('input[name="vin"]').addClass('error-field'); $('input[name="frame"]').addClass('error-field'); } if (isVin && vin && vin != '' && !validateVin(vin)) { hasError = true; $('.error-incorrect-vin').show(); $('input[name="vin"]').addClass('error-field'); } else { $('.error-incorrect-vin').hide(); } var result = true; $('.vinqu-block .params input, .vinqu-block .params textarea').each(function() { var $this = $(this); if ($this.attr('required') && $this.val().length maxfileSize) { $this.closest('.param').addClass('error-field'); resultMaxSize = false; return false; } else { $this.closest('.param').removeClass('error-field'); } } } return true; }); if (!resultMaxSize) { hasError = true; $('.error-file-params-maxsize').show(); } else { $('.error-file-params-maxsize').hide(); } var resultAvailableType = true; $('.vinqu-block .params input[type=file]').each(function() { var $this = $(this); if ($this.attr('required') && $this.val().length) { var fileInput = $this.get(0); if (fileInput && fileInput.files && fileInput.files[0] && fileInput.files[0].name) { if (!availableType.test(fileInput.files[0].name)) { $this.closest('.param').addClass('error-field'); resultAvailableType = false; return false; } else { $this.closest('.param').removeClass('error-field'); } } } return true; }); if (!resultAvailableType) { hasError = true; $('.error-file-params-filetype').show(); } else { $('.error-file-params-filetype').hide(); } if (expertMode && !client_id) { hasError = true; } if (!expertMode && client_id == 0 && !is4mycar) { var $name = $('input[name="guestInfo[name]"]'); var name = $.trim($name.val()); var $email = $('input[name="guestInfo[email]"]'); var email = $.trim($email.val()); email = email != $email.attr('placeholder') ? email : null; var $phone = $('input[name="guestInfo[phone]"]'); var phone = $.trim($phone.val()); phone = phone != $phone.attr('placeholder') ? phone : null; if (!name) { hasError = true; $('.error-empty-guest').show(); $name.addClass('error-field'); } else { $('.error-empty-guest').hide(); $name.removeClass('error-field'); } var $errorEmptyGuestContact = $('.error-empty-guest-contact'); var $errorEmptyGuestPhoneEmail = $('.error-empty-guest-phone-email'); var $errorEmptyGuestPhone = $('.error-empty-guest-phone'); var $errorEmptyGuestEmail = $('.error-empty-guest-email'); $errorEmptyGuestContact.hide(); $errorEmptyGuestPhoneEmail.hide(); $errorEmptyGuestPhone.hide(); $errorEmptyGuestEmail.hide(); $email.removeClass('error-field'); $phone.removeClass('error-field'); if (requiredGuestContacts == REQUIRED_GUEST_CONTACTS && (!email && !phone)) { hasError = true; $errorEmptyGuestContact.show(); $email.addClass('error-field'); $phone.addClass('error-field'); } else if (requiredGuestContacts == REQUIRED_GUEST_PHONE_EMAIL && (!email || !phone)) { hasError = true; if (!email && !phone) { $errorEmptyGuestPhoneEmail.show(); $phone.addClass('error-field'); $email.addClass('error-field'); } else if (!email) { $errorEmptyGuestEmail.show(); $email.addClass('error-field'); } else if (!phone) { $errorEmptyGuestPhone.show(); $phone.addClass('error-field'); } } else if (requiredGuestContacts == REQUIRED_GUEST_PHONE && !phone) { hasError = true; $errorEmptyGuestPhone.show(); $phone.addClass('error-field'); } else if (requiredGuestContacts == REQUIRED_GUEST_EMAIL && !email) { hasError = true; $errorEmptyGuestEmail.show(); $email.addClass('error-field'); } if (email && !email.match(/^(([^()[\]\\.,;:\s@\"]+(\.[^()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) { hasError = true; $('.error-incorrect-guest-email').show(); $email.addClass('error-field'); } else { $('.error-incorrect-guest-email').hide(); } if (phone && !$phone.inputmask('isComplete')) { hasError = true; $('.error-incorrect-guest-phone').show(); $phone.addClass('error-field'); } else { $('.error-incorrect-guest-phone').hide(); } var $keystring = $('input[name="vinqu-keystring"]'); if ($keystring.length) { var keystring = $.trim($keystring.val()); if (keystring.length != 3) { hasError = true; $('.error-empty-captcha').show(); $('input[name="vinqu-keystring"]').addClass('error-field'); $('.captchaLabel').addClass('error-text'); } else { $('.error-empty-captcha').hide(); $('input[name="vinqu-keystring"]').removeClass('error-field'); $('.captchaLabel').removeClass('error-text'); } } } if (hasError) { $('.query-errors').show(); return false; } else { $('.query-errors').hide(); return true; } } function filledQuery() { var $partInput = $('.add-part-input'); var part = $.trim($partInput.val()); if (queryCount > 0 || part !== $partInput.attr('placeholder') && part.length > 0) { return true; } var isVin = $('input[name="selectVinOrFrame"]:checked').is('#check-vin'); var $vin = $('.vinqu-block input[name=vin]:not(:disabled)'); var vin = null; if ($vin.length) { vin = $.trim($vin.val()); if (vin == $vin.attr('placeholder')) { vin = null; } } var $frame = $('.vinqu-block input[name=frame]:not(:disabled)'); var frame = null; if ($frame.length) { frame = $.trim($frame.val()); if (frame == $frame.attr('placeholder')) { frame = null; } } if (vin && vin != '' && isVin || !isVin && frame && frame != '') { return true; } var result = false; $('.vinqu-block .params input, .vinqu-block .params textarea').each(function() { if ($(this).val().length > 0) { result = true; } }); if (result) { return true; } var client_id = $('#client_id').val(); var $guestBlocks = $('.guest-block input:visible'); if ($guestBlocks.length && !expertMode && client_id == 0 && !is4mycar) { var guestBlocksFilled = true; $guestBlocks.each(function() { var $this = $(this); var val = $.trim($this.val()); return guestBlocksFilled = !(val && val != $this.attr('placeholder')); }); if (!guestBlocksFilled) { return true; } } var $commentField = $('.comment-field'); var comment = $.trim($commentField.val()); return comment && comment != $commentField.attr('placeholder'); } function clearCarbaseBlock() { $('#choiceYears option').removeAttr('selected').first().attr('selected', 'selected'); $('#choiceManufacturers option').removeAttr('selected').first().attr('selected', 'selected'); $('#choiceManufacturers').attr('disabled', 'disabled'); $('#choiceModels option').removeAttr('selected').first().attr('selected', 'selected'); $('#choiceModels').attr('disabled', 'disabled').show(); $('#choiceModifications option').removeAttr('selected').first().attr('selected', 'selected'); $('#choiceModifications').attr('disabled', 'disabled').show(); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').attr('disabled', 'disabled').hide(); $('#newModification').attr('disabled', 'disabled').hide(); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); } function validateVin(number) { return /^[a-hj-npr-zA-HJ-NPR-Z0-9]{17,17}$/.test(number); } setInterval(function() { showApproximateQueryPrice(); if (checkQuery()) { $('.submit-query:not(.submited)').removeAttr('disabled'); } else { $('.submit-query').prop('disabled', true); } }, 2000);

Отправка запроса по vin

Контактная информация

или

Информация об автомобиле

Выбрать авто

Ваш запрос

'; var $choicedModification = $('.choicedModification'); var $unknownModification = $('.unknownModification'); if ($choicedModification.length) { $choicedModification.replaceWith($(carBlock)); } else { $(carBlock).insertAfter($unknownModification); } $unknownModification.hide(); }; var processSendAjax = function(sendAjaxData, step) { showChoicedCar(sendAjaxData); var $loader = $('.loader'); if (step !== 'yearChoice') { // по проcьбам клиента, которого смущало, что что-то моргает при загрузке $loader.show(); } sendAjaxData.showAll = 1; $.ajax({ type: 'get', url: '//admin.nodacdn.net/ajax/modules/vinqu/car.choice/run.php', data: sendAjaxData, dataType: 'jsonp', error: function() { if (fail && typeof(fail) == 'function') { fail(); } }, success: function(data) { switch(step) { case 'yearChoice': var $choiceYears = $('#choiceYears'); if (data.years) { toggleAppearance(step); $.each(data.years, function (index, value) { $choiceYears.append(''); }); } $loader.hide(); showChoicedCar(data); if (success && typeof(success) == 'function') { success(); } break; case 'manufacturerChoice': var $choiceManufacturers = $('#choiceManufacturers'); toggleAppearance(step); if (data.manufacturers) { $.each(data.manufacturers, function (index, value) { $choiceManufacturers.append(''); }); } $loader.hide(); showChoicedCar(data); if (success && typeof(success) == 'function') { success(); } if (data.manufacturers && data.manufacturers.length == 1) { $choiceManufacturers.find(':not(option:disabled)').prop('selected', true); $choiceManufacturers.trigger('change'); } break; case 'modelChoice': var $choiceModels = $('#choiceModels'); if (data.models) { toggleAppearance(step); $.each(data.models, function (index, value) { $choiceModels.append(''); }); $loader.hide(); } $('.vin-frame-label').show(); var $vinquBlock = $('.vinqu-block'); var $vinquParamsBlock = $vinquBlock.find('.params'); $vinquParamsBlock.html(''); $.ajax({ url: '//admin.nodacdn.net/ajax/modules/vinqu/get.brand.info.php?brand=' + sendAjaxData.manufacturerName, success: function(resp) { if (!resp.status) { showError(lang_serverError); } else { if (resp.brand && resp.brand.fields) { for (var k in resp.brand.fields) { var field = resp.brand.fields[k]; var item = '
'; item += '
' + field.descr + ' ?
'; var required = field.is_required ? 'required="required"' : ''; if (field.with_image == 1) { item += '
'; item += ''; item += '
'; item += ''; item += '
'; } else { if (field.length > 50) { item += ''; } else { item += ''; } } item += '
'; if ($vinquParamsBlock.html() == '') { $vinquParamsBlock.append($vinquBlock.find('.params-label').clone().show()); } $vinquParamsBlock.append(item); } } var $vinBlock = $('.vinqu-block input[name=vin]'); $vinBlock.removeAttr('disabled'); var $frameBlock = $('.vinqu-block input[name=frame]'); $frameBlock.removeAttr('disabled'); } $('.loader').hide(); $('#getChoice').removeAttr('disabled'); $('#cancelChoice').removeAttr('disabled'); }, method: 'GET', dataType: 'jsonp' }); showChoicedCar(data); if (success && typeof(success) == 'function') { success(); } break; case 'modificationChoice': $('#addNewModel').removeAttr('disabled'); $('#addNewModification').removeAttr('disabled'); var $choiceModifications = $('#choiceModifications'); if (data.modifications) { toggleAppearance(step); $.each(data.modifications, function (index, value) { var hpTranslate = 'л.с.'; $choiceModifications.append(''); var $imageUrl = $('#imageUrl' + value.id); if ($imageUrl.length) { $imageUrl.val(value.imageUrl); } else { $imageUrl = $('', { type: 'hidden', id: 'imageUrl' + value.id, value: value.imageUrl }); $imageUrl.appendTo('body'); } }); } showChoicedCar(data); $loader.hide(); if (success && typeof(success) == 'function') { success(); } $('.carbase-block-init-frame').hide(); break; case 'getChoice': if (data) { if (sendAjaxData.addingToGarage) { $.ajax({ 'url':'/vinqu/?action=ajax_get_garage_cars', success: function(resp) { $('.car-list-block').html(resp); } }); } var carBlock = '
'; if (data.modificationId) { carBlock += ''; } if (data.carId) { carBlock += ''; } carBlock += '
'; carBlock += '' + data.manufacturerName + ' ' + data.modelName + '
'; carBlock += data.modificationName; carBlock += '
'; $('.selected-car-block .selected-car').html(carBlock); $('.carChoiceBlock').slideUp(function() { $('.choicedModification').remove(); $('.unknownModification').show(); }); $('.carbase-blocks').addClass('hidden'); $('.selected-car-block').slideDown(); clearCarbaseBlock(); if (success && typeof(success) == 'function') { success(); } $loader.hide(); } } } }); }; switch(step) { case 'carChoice': if (!!sendAjaxData.year && !!sendAjaxData.modificationId) { $('#addingToGarageButton').removeAttr('disabled'); } showChoicedCar(sendAjaxData); break; case 'getChoice': if (!!sendAjaxData.isNewModel && !sendAjaxData.newModelName || !!sendAjaxData.isNewModification && !sendAjaxData.newModificationName) { break; } $('#addingToGarageButton').attr('disabled', 'disabled'); processSendAjax(sendAjaxData, step); break; case 'yearChoice': processSendAjax(sendAjaxData, step); break; case 'manufacturerChoice': if (!!sendAjaxData.year) { if (sendAjaxData === undefined) { sendAjaxData = {} } sendAjaxData.resellerId = $('input[name=resellerId]').val(); processSendAjax(sendAjaxData, step); } break; case 'modelChoice': if (!!sendAjaxData.year && !!sendAjaxData.manufacturerId) { processSendAjax(sendAjaxData, step); } break; case 'modificationChoice': if (!!sendAjaxData.year && !!sendAjaxData.manufacturerId && !!sendAjaxData.modelId) { $('#addNewModel').attr('disabled', 'disabled'); $('#addNewModification').attr('disabled', 'disabled'); processSendAjax(sendAjaxData, step); } break; } } /** * Переключаем внешний вид * @param step */ function toggleAppearance(step) { switch (step) { case 'initChoice': $('#choiceYears').html('').attr('disabled', 'disabled'); $('#choiceManufacturers').html('').attr('disabled', 'disabled').val(''); $('#choiceModels').html('').attr('disabled', 'disabled').val('').show(); $('#choiceModifications').html('').attr('disabled', 'disabled').val('').show(); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').hide().val('').attr('disabled', 'disabled'); $('#newModification').hide().val('').attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'yearChoice': $('#choiceYears').html('').removeAttr('disabled').trigger('change'); $('#choiceManufacturers').attr('disabled', 'disabled').val('').trigger('change'); $('#choiceModels').attr('disabled', 'disabled').val('').show().trigger('change'); $('#choiceModifications').attr('disabled', 'disabled').val('').show().trigger('change'); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').hide().val('').attr('disabled', 'disabled'); $('#newModification').hide().val('').attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'afterYearChoice': $('#choiceManufacturers').html('').attr('disabled', 'disabled').val(''); $('#choiceModels').html('').attr('disabled', 'disabled').val('').show(); $('#choiceModifications').html('').attr('disabled', 'disabled').val('').show(); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').hide().val('').attr('disabled', 'disabled'); $('#newModification').hide().val('').attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'afterChoiceModels': $('#choiceModifications').attr('disabled', 'disabled').val('').show(); $('#addNewModel').val($('#addNewModel').data('larr')).show(); $('#addNewModification').hide(); $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').addClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'afterManufacturerChoice': $('#choiceModels').attr('disabled', 'disabled').val('').show(); $('#choiceModifications').attr('disabled', 'disabled').val('').show(); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').hide().val('').attr('disabled', 'disabled'); $('#newModification').hide().val('').attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'manufacturerChoice': $('#choiceManufacturers').html('').removeAttr('disabled').trigger('change'); $('#choiceModels').attr('disabled', 'disabled').val('').show().trigger('change'); $('#choiceModifications').attr('disabled', 'disabled').val('').show().trigger('change'); $('#addNewModel').hide(); $('#addNewModification').hide(); $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').removeClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'modelChoice': $('#choiceModels').html('').removeAttr('disabled').show().trigger('change'); $('#choiceModifications').attr('disabled', 'disabled').val('').show().trigger('change'); $('#addNewModel').val($('#addNewModel').data('larr')).show(); $('#addNewModification').hide(); $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').addClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'modelList': $('#choiceModels').show().removeAttr('disabled'); $('#choiceModifications').show(); $('#addNewModel').val($('#addNewModel').data('larr')).show(); $('.choiceModels-container').addClass('choice-show'); if ($('#choiceModels :selected').val() != '') { $('#addNewModification').val($('#addNewModification').data('larr')).show(); $('.choiceModifications-container').addClass('choice-show'); } else { $('#addNewModification').hide(); $('.choiceModifications-container').removeClass('choice-show'); } $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); break; case 'modelAdd': $('#choiceModels').hide().val(''); $('#choiceModifications').hide().val(''); $('#choiceModels').trigger('change'); $('#addNewModel').val($('#addNewModel').data("rarr")).show(); $('#choiceModifications').trigger('change'); $('#choiceModels').hide().attr('disabled', 'disabled'); $('#choiceModifications').hide().attr('disabled', 'disabled'); $('#addNewModification').hide(); $('#newModel').show().removeAttr('disabled').focus(); $('#newModification').show().removeAttr('disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModels-container').addClass('choice-show'); $('.choiceModifications-container').removeClass('choice-show'); break; case 'modificationChoice': $('#choiceModifications').html('').removeAttr('disabled').show().trigger('change'); $('#addNewModification').val($('#addNewModification').data('larr')).show(); $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('.choiceModifications-container').addClass('choice-show'); break; case 'modificationList': $('#choiceModifications').show().removeAttr('disabled'); $('#addNewModification').val($('#addNewModification').data('larr')).show(); $('#newModel').hide().attr('disabled', 'disabled'); $('#newModification').hide().attr('disabled', 'disabled'); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModifications-container').addClass('choice-show'); break; case 'modificationAdd': $('#addNewModification').val($('#addNewModification').data('rarr')).show(); $('#choiceModifications').hide().val('').trigger('change').attr('disabled', 'disabled'); $('#newModification').show().removeAttr('disabled').focus(); $('#addingToGarageButton').attr('disabled', 'disabled'); $('.choiceModifications-container').addClass('choice-show'); break; default: break; } isReadyToGetChoice(); }