PageSourceSearch

https://indrik.ru/wp-content/themes/marketindrik/assets/js/main_scripts.js?ver=4803311

js indrik.ru collected 2026-09-24 22:58:01 UTC 19,178 bytes, 598 lines download raw bytes

1
2/*
3$(".account_goods__list_item").not('#order_buy_button_1').click(function() {	
4	$desc=$(this).find('.account_goods__list_description');
5	$btn=$(this).find('.account_goods__list_item__next');
6	if ($desc.css("display")=="none"){$desc.slideDown(300);$btn.addClass("active_row");}
7	else{$desc.slideUp(300);$btn.removeClass("active_row");}
8});
9*/
10
11var selectClass = ".account_goods__list_item__number, .account_goods__list_item__date, .account_goods__list_item__status, .account_goods__list_item__price,.account_goods__list_item__next ";
12$(selectClass).click(function() {	
13	$desc=$(this).parent().parent().find('.account_goods__list_description');
14	$btn=$(this).parent().find('.account_goods__list_item__next');
15	if ($desc.css("display")=="none"){$desc.slideDown(300);$btn.addClass("active_row");}
16	else{$desc.slideUp(300);$btn.removeClass("active_row");}
17});
18
19
20
21
22$(".password-visible").click(function() {
23	var type=$(this).data('type');	
24	var id=$(this).data('id');
25	if( $('#login_form_password_'+id).val().length !== 0 && type!=="enable") 
26	{
27		$('#login_form_password_'+id).attr('type', 'text');
28		$(this).attr("data-type", "enable").data('type', "enable");		
29	}
30	else
31	{
32		$('#login_form_password_'+id).attr('type', 'password');		
33		$(this).attr("data-type", "disabled").data('type', "disabled");
34	}	
35});
36
37function validateEmail($email) {
38  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
39  return emailReg.test( $email );
40}
41
42$( document ).ready(function() {	
43	
44	$("#login_form_name_email").change(function() {
45		if ($(this).val().length !== 0 && !validateEmail($(this).val())) 
46		{
47			$("#login_form_name__error").text("Некорректный адрес электронной почты ___@___.__...");
48			$("#login_form_name_email").addClass("input_error");
49		}
50		else {
51			$("#login_form_name__error").text("");
52			$("#login_form_name_email").removeClass("input_error");
53			}
54	});
55	
56	$("#login_form_password_2").change(function() {		
57		var pass1=$(this).val();
58		var pass2=$("#login_form_password_1").val();
59		if (pass1!==pass2)
60		{			
61			$("#login_form_password__error_2").text("Введенные пароли не совпадают");
62			$("#login_form_password_1").addClass("input_error");
63			$("#login_form_password_2").addClass("input_error");			
64		}
65		else {			
66			$("#login_form_password__error_2").text("");
67			$("#login_form_password_1").removeClass("input_error");
68			$("#login_form_password_2").removeClass("input_error");
69			}
70	});
71	
72	$("#login_form_password_1").change(function() {		
73		var pass1=$(this).val();
74		var pass2=$("#login_form_password_2").val();
75		if (pass2.length !== 0 && (pass1!==pass2))
76		{			
77			$("#login_form_password__error_2").text("Введенные пароли не совпадают");
78			$("#login_form_password_1").addClass("input_error");
79			$("#login_form_password_2").addClass("input_error");			
80		}
81		else {			
82			$("#login_form_password__error_2").text("");
83			$("#login_form_password_1").removeClass("input_error");
84			$("#login_form_password_2").removeClass("input_error");
85			}
86	});
87	
88	
89});
90
91
92
93$( document ).ready(function() {
94/*
95const selectSingle = document.querySelector('.__select');
96const selectSingle_title = selectSingle.querySelector('.__select__title');
97const selectSingle_labels = selectSingle.querySelectorAll('.__select__label');
98
99selectSingle_title.addEventListener('click', () => {
100  if ('active' === selectSingle.getAttribute('data-state')) {
101    selectSingle.setAttribute('data-state', '');
102  } else {
103    selectSingle.setAttribute('data-state', 'active');
104  }
105  
106});
107
108for (let i = 0; i < selectSingle_labels.length; i++) {
109  selectSingle_labels[i].addEventListener('click', (evt) => {
110    selectSingle_title.textContent = evt.target.textContent;
111    selectSingle.setAttribute('data-state', '');
112    
113    var type = evt.target.parentNode.getAttribute('data-type');
114    document.cookie='per_page_'+type+'='+evt.target.textContent+';max-age=4629743;path=/';
115    location.reload();
116    
117  });
118}
119
120*/
121});
122if($('.shop_main__basket').length){
123    if($('.shop_main__basket_list__item').length == 0){
124        clearbasket();
125    }
126}
127
128
129$(".mobile_menu__burger" ).click(function() {
130	$(".header__nav ").fadeIn(100);
131});
132
133$(".mobile_menu_close__button").click(function() {
134	$(".header__nav ").fadeOut(100);
135});
136
137$(".header__nav__list_item").click(function() {
138	if ($(window).width() < 768)
139	{
140		$(".header__nav__list_item_submenu").hide();
141		var type_menu=$(this).data('type');
142		var id=$(this).data('id');
143		if (type_menu=='submenu')
144		{
145			$(".header__nav__list_item_a").hide();
146			$(".mobile__go_back").attr("data-id", id);
147			
148			$(".mobile__go_back").show();
149			$("#header__nav__list_item_submenu_"+id).fadeIn(100);
150		}
151	}
152});
153
154$(".mobile__go_back").click(function() {	
155	if ($(window).width() < 768)
156	{
157		$(".header__nav__list_item_a").show();
158		$(".header__nav__list_item_submenu").hide();
159		$(".mobile__go_back").hide();
160	}
161});
162
163
164/* Кнопка Удалить все товары */
165$("#basket_clear__button").click(function() {
166	if (confirm("Очистить корзину?") == true) {		
167	$.ajax({
168        type: 'POST',
169        url: '/wp-admin/admin-ajax.php',
170        data: { action:'clear_cart' },
171        success: function(){
172            clearbasket();
173            $('.header__basket_number').html('0 ₽');
174        }
175    });
176        
177	}
178});
179
180
181function clearbasket()
182{
183	$(".basket_clear__menu").remove();
184	$(".shop_main__basket_list__item").remove();
185	$(".basket__bottom_menu").remove();
186	$(".basket__empty_message").show();
187	$(".shop_main__basket").addClass("empty_page");
188}
189
190/* Строка поиска в header */
191$('#header_search_input').keyup(function(){
192	
193    if ($(this).val().length > 3) {
194        $("#show_result_div").fadeIn(300);
195        
196        $.ajax({
197            type: 'POST',
198            url: '/wp-admin/admin-ajax.php',
199            data: {action: 'search', word: $(this).val()},
200            success: function(data){
201                $("#show_result_div").html(data).fadeIn(300);
202            }
203        });
204    } else {
205       $("#show_result_div").fadeOut(100).html('');
206    }
207});
208
209$(document).on('click', '.basket_list__item_count_del', function () {
210	var id = $(this).data('id');
211	minustv(id);
212    change_cart_qty(this);
213});
214
215$(document).on('click', '.basket_list__item_count_add', function () {
216	var id = $(this).data('id');
217	console.log()
218	plustv(id);
219    change_cart_qty(this);
220});
221
222function minustv(id)
223{
224	var sum=$("#basket_list__item_count_number_"+id).val();
225	var num=Number(sum);
226	if (num>1) {num--;}
227	$("#basket_list__item_count_number_"+id).val(num);
228}
229
230function plustv(id)
231{
232	var sum=$("#basket_list__item_count_number_"+id).val();
233	var num=Number(sum);	
234	if (num!==0)  {num++;}
235	$("#basket_list__item_count_number_"+id).val(num);
236}
237function change_cart_qty(e){
238    var id = $(e).parent().find('.qty').attr('id');
239    var price = $(e).parent().find('.qty').data('price');
240    var key = $(e).parents('.shop_main__basket_list__item').data('key');
241    var qty = $(e).parent().find('.qty').val();
242	var max_quantity = $(e).parent().find('.qty').data('max-quantity');
243	
244	if( qty > max_quantity) {
245		qty =  max_quantity;
246		$('#'+id).val(qty);
247	}
248	
249    $.ajax({
250        type: 'POST',
251        url: '/wp-admin/admin-ajax.php',
252        data: { action:'change_cart_qty', key:key, qty:qty },
253        success: function(data){
254            $('.'+id+' .item_price_one').html('<span class="price__number">'+(qty*price)+'</span><span class="price__simbol">₽</span>');
255            $('.'+id+' .item_price_two .price__count').html(qty);
256            $('.basket__bottom_menu').html(data);
257        }
258    });
259}
260
261$(document).on('click', '.product__buy_button', function (e) {		
262		e.preventDefault();
263		var typebook = $(this).data('type');
264		var idbook = $(this).data('id');
265		alert("Товар №: "+idbook+" с типом: "+typebook+" полетел в корзину!");		
266});
267
268
269$(document).on('click', '.new_products__list_Item_button', function () {
270	$(this).find('.product__btn-text').text('В корзине');
271
272    $(document).on('added_to_cart', function(){
273        $.ajax({
274            type: 'POST',
275            url: '/wp-admin/admin-ajax.php',
276            data: { action: 'total_cart'},
277            success: function(data) {
278                $('.header__basket_number').html(data);
279            }
280        });
281    });
282});
283
284/*
285$(document).on('click', '.delivery__pay_button', function (e) {		
286		
287        e.preventDefault();
288		var buyer_subscription = 0;
289		var buyer_consent = 0;
290		if ($('#buyer_subscription').is(':checked')){ buyer_subscription = 1; } else { buyer_subscription = 0;}
291		if ($('#buyer_consent').is(':checked')){buyer_consent=1;}else{buyer_consent=0;}		
292		
293		var delivery = $(this).attr('data-delivery'); 
294		var city = $(this).attr('data-city');
295		var pay = $(this).attr('data-pay');
296  
297        	
298		var buyer_fio=$('#billing_first_name').val();
299		var buyer_phone=$('#billing_phone').val();
300		var buyer_email=$('#billing_email').val();		
301		
302        
303		
304        if (!delivery || !city || !pay || buyer_fio == '' || buyer_phone == '' || buyer_email == '')
305		{
306		  alert("Выберите необходимые параметры!");
307          return false;
308		}
309        if(buyer_consent == 0) {
310           alert("Согласитесь с условиями пользовательского соглашения!");
311           return false;
312        }
313        $('form.checkout').trigger('submit');
314
315			//$('#body_order').html("Доставка: "+delivery+"<br/> Город:"+city +"<br/> Оплата:"+pay+"<br/> ФИО:" +buyer_fio+ "<br/> Телефон:"+buyer_phone+"<br/> Email:"+buyer_email+"<br/> Подписка:"+buyer_subscription+"<br/> Согласие ПДн:"+buyer_consent);
316			//$('#OrderFromMe').modal('show');     
317});
318*/
319
320$(document).on('click','.woocommerce-error', function(){
321    $(this).remove();
322});
323$('.delivery__city_select').on('change', function (e) {
324    var optionSelected = $("option:selected", this);
325    var valueSelected = $("option:selected", this).data('post');
326	$('.delivery__pay_button').attr('data-city', valueSelected);
327    
328    $.ajax({
329        type: 'POST',
330        url: '/wp-admin/admin-ajax.php',
331        data: {action: 'postprice', to:valueSelected},
332        success: function(data){
333            $('.postrusia input').val(data);
334            $('.postrusia .delivery__company__price, .postrussia .value_postprice').html('от '+data+' ₽');
335        }
336    });
337
338});
339$('body').on('click','.city-dropdown p', function(){
340    var postcode = $(this).data('postcode');
341    
342    // Скрываем курьерскую доставку, если не Москва
343    if(postcode != '101000') {
344        $('label[data-method="curier"]').parent().hide();
345    } else {
346        $('label[data-method="curier"]').parent().show();
347    }
348    if(!postcode) {
349        var postcode = '101000';
350    }
351    
352    var city = $(this).data('city');
353    $('.js-city-input').val(city);
354    $('.city-dropdown').html('').hide();
355    $.ajax({
356        type: 'POST',
357        url: '/wp-admin/admin-ajax.php',
358        data: {action: 'postprice', to:postcode},
359        success: function(data){
360            $('.postrusia input').val(data);
361            $('.postrusia .delivery__company__price, .postrussia .value_postprice').html('от '+data+' ₽');
362        }
363    });
364});
365$('.js-city-input').on('keyup', function(){
366    var val = $(this).val();
367    $('.js-city-clear').show();
368    
369    if($(this).val().length >= 2) {
370        $.ajax({
371            type:'POST',
372            url: 'https://api.cdek.ru/city/getListByTerm/jsonp.php?country_codes=RU&callback=?',
373            dataType: "jsonp",
374            data: {q: $(this).val()},
375            success: function(data) {
376                $('.city-dropdown').html('').show();
377                if(data.geonames){
378                data.geonames.forEach(function(item, i) {
379                    if(item.cityName == item.regionName) {
380                        text = item.cityName;
381                    } else {
382                        text = item.cityName+', '+item.regionName;
383                    }
384                    
385                    //var str = new RegExp(val, 'gi');
386                    //var nt = text.replace(str,'<strong>'+str+'</strong>');
387                    $('.city-dropdown').append('<p data-postcode="'+item.postCodeArray[0]+'" data-city="'+item.cityName+'">'+text+'</p>');
388                    
389                });
390                } else {
391                   $('.city-dropdown').append('<p>Город не найден</p>'); 
392                }
393            }
394        });
395    }
396});
397$('.js-city-clear').on('click', function(){
398    $('.js-city-input').val('');
399    $('.city-dropdown').html('').hide();
400    $('input[name="shipping_method"]:checked').prop('checked',false);
401    $('.delivery__company__btn.active').removeClass('active');
402    $(this).hide();
403});
404$('.delivery__company').on('change', function(){
405    var dataId = $(this).parent().data('id');
406    $('.delivery__pay_button').attr('data-delivery', dataId);
407    var price = $(this).val();
408    
409    var method = $(this).parent().data('method');
410    if(method == 'post'){
411        $('.delivery__company_list__item[data-pay=cod]').hide();
412        $('.js-order_comments').val('Доставка Почтой России');
413    } else {
414       $('.delivery__company_list__item[data-pay=cod]').show();
415       $('.js-order_comments').val('Доставка курьером');
416    }
417    
418    $.ajax({
419        type: 'POST',
420        url: '/wp-admin/admin-ajax.php',
421        data: {action: 'calculate_shipping', price: price},
422        success: function(data){
423            $('#delivery_total').html(price+' ₽');
424            $('#checkout_subtotal').html(data);
425        }
426    });
427});
428
429$('.delivery__company_pay').on('change', function(){
430    var dataId = $(this).parent().data('id');
431    $('.delivery__pay_button').attr('data-pay', dataId);
432});
433
434$(".remove_basket" ).click(function() {   
435    if (confirm("Удалить товар?") == true) {
436        var key = $(this).parents('.shop_main__basket_list__item').data('key');
437        var id = $(this).data('id');
438        var item = $('#shop_main__basket_list__item_'+id);
439        $.ajax({
440            type: 'POST',
441            url: '/wp-admin/admin-ajax.php',
442            data: { action:'cart_remove_item', key:key},
443            success: function(data){
444                $(item).remove();
445                var num = $('.shop_main__basket_list__item').length;
446                if(num > 0) {
447                    $('.basket__bottom_menu').html(data);
448                } else {
449                    clearbasket();
450                }
451                $.ajax({
452                    type: 'POST',
453                    url: '/wp-admin/admin-ajax.php',
454                    data: { action: 'total_cart'},
455                    success: function(data){
456                        $('.header__basket_number').html(data);
457                    }
458                });
459                
460            }
461    })
462    }
463});
464
465$(".delivery__company__btn" ).click(function() {
466    if($('.js-city-input').val() == '') {
467        alert('Выберите город');
468        return false;
469    }
470		var id = $(this).data('id');
471		$(".delivery__company__btn").removeClass('active');
472		$(this).addClass("active");
473		$(".delivery__company_selected").removeClass("show").addClass("fade");
474		$("#delivery__company_description_wrapp_"+id).removeClass("fade").addClass("show");			
475		$('.product_purchase_options_button').attr('data-delivery', id);
476});
477
478$(".delivery__company__pay_btn" ).click(function() {		
479		var id = $(this).data('id');
480		$(".delivery__company__pay_btn").removeClass('active');
481		$(this).addClass("active");
482		$(".delivery__company_pay_wrapp").removeClass("show").addClass("fade");
483		$("#delivery__company_pay_wrapp_"+id).removeClass("fade").addClass("show");
484		$('.product_purchase_options_button').attr('data-pay', id);
485});
486
487
488$(".header__nav__mobile_menu" ).click(function() {
489		$("body").removeClass("scrolnice").addClass("scrolnone");
490		$("#body__mobile_menu").fadeIn();				
491});
492
493$(".body__mobile_menu_close" ).click(function() {
494		$("#body__mobile_menu").fadeOut();
495		$("body").removeClass("scrolnone").addClass("scrolnice");			
496});
497
498
499/*выделяем пункты верхнего меню*/
500$(document).ready(function(){
501	var path=location.pathname.split("/")[1];	
502	if (path!=''){
503		$('.navbar-nav__list > li a[href^="/' + path + '"]').addClass('navbar-nav__list_li_a_active');		
504	}	
505});
506
507/*авторизация*/
508$('.js-signin').on('submit', function(e){
509    e.preventDefault();
510    var form = $(this).serializeArray();
511    $.ajax({
512        beforeSend: function(){$('.login_form__error').text('');},
513        type:'POST',
514        url: '/wp-admin/admin-ajax.php',
515        data: form,
516        success: function(data){
517            console.log(data);
518            if(data['status'] == 'error') {
519                $('#'+data['type']).text(data['text']);
520                return false;
521            } else {
522                location.reload();
523            }
524        }
525    });
526});
527/*регистрация*/
528$('.js-signup').on('submit', function(e){
529    e.preventDefault();
530	
531	//chech ajax recapture
532	var recaptchaResponse = document.getElementById('recaptchaResponse').value;
533    $.ajax({
534        type:'POST',
535        url: '/ajax-recaptcha.php',
536        data: {recaptchaResponse:recaptchaResponse},
537        success: function(data){
538            if(data == 'false')
539				return false;
540        }
541    });	
542	
543    $('.login_form__error').text('');
544    
545    if($('#login_form_password_1').val() != $('#login_form_password_2').val()) {
546        return false;
547    }
548    var form = $(this).serializeArray();
549    $.ajax({
550        beforeSend: function(){$('.login_form__error').text('');},
551        type:'POST',
552        url: '/wp-admin/admin-ajax.php',
553        data: form,
554        success: function(data){
555            if(data['status'] == 'error') {
556                $('#login_form_name__error').text(data['text']);
557                return false;
558            } else {
559                location.href = "/account";
560            }
561        }
562    });
563});
564/*восстановление пароля*/
565$('.js-recovery').on('submit', function(e){
566    e.preventDefault();
567    var form = $(this).serializeArray();
568    $.ajax({
569        beforeSend: function(){$('.login_form__error').text('');},
570        type:'POST',
571        url: '/wp-admin/admin-ajax.php',
572        data: form,
573        success: function(data){
574            if(data['status'] == 'error') {
575                $('#login_form_name__error').text(data['text']);
576                return false;
577            } else {
578                $('#login_form_name__error').html(data['text']);
579            }
580        }
581    });
582});
583/*действия  заказом в кабинете*/
584$('.js-order-status').on('click', function(e){
585    e.preventDefault();
586    var order_id = $(this).parents('.account_goods__list_item').data('id');
587    var status = $(this).data('status');
588    $.ajax({
589        type: 'POST',
590        url: '/wp-admin/admin-ajax.php',
591        data: {id: order_id, action: 'change_status', status: status },
592        success: function(){
593            location.reload();
594        }
595    });
596    
597});
598/*------------------*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.