PageSourceSearch

https://airis.spb.ru/local/templates/design_18/js/main.js

js airis.spb.ru collected 2026-10-09 18:20:09 UTC 15,425 bytes, 487 lines download raw bytes

1var wait = '<i class="fas fa-spinner fa-pulse waiter"></i>';
2
3function spoilerInit() {
4
5    //спойлер
6    $(".open_spoiler").off("click").on("click", function() {
7        var spoiler = $(this).next(".spoiler");
8        if (spoiler.is(':visible')) {
9            spoiler.hide();
10        } else {
11            spoiler.show();
12        }
13        return false;
14    });
15}
16
17function highslideInit() {
18
19	//увеличение картинок
20	$('a.highslide').click(function(e) {
21		return hs.expand(this);
22	});
23}
24
25function modalInit() {
26
27	/* Открытие мoдaльнoгo oкнa входа на сайт */
28    $('a[data-modal]').click( function(event){
29        var modal_class = $(this).attr('data-modal');
30        if (modal_class) {
31            event.preventDefault();
32            $('#overlay').fadeIn(400, function () {
33                $('.modal_form.' + modal_class)
34                    .css('display', 'block')
35                    .animate({opacity: 1, top: '50%'}, 200);
36            });
37        }
38    });
39    /* Зaкрытие мoдaльнoгo oкнa */
40    $('.modal_close, #overlay').click( function(){
41        $('.modal_form')
42            .animate({opacity: 0, top: '45%'}, 200,
43            function(){ // пoсле aнимaции
44                $(this).css('display', 'none');
45                $('#overlay').fadeOut(400);
46            }
47        );
48    });
49}
50
51function setCookie (name, value, sec, path, domain, secure) {
52
53    var date = new Date( new Date().getTime() + sec * 1000 );
54    var expires = date.toUTCString();
55    document.cookie = name + "=" + escape(value) +
56    ((expires) ? "; expires=" + expires : "") +
57    ((path) ? "; path=" + path : "") +
58    ((domain) ? "; domain=" + domain : "") +
59    ((secure) ? "; secure" : "");
60}
61
62function getCookie(name) {
63    var cookie = " " + document.cookie;
64    var search = " " + name + "=";
65    var setStr = null;
66    var offset = 0;
67    var end = 0;
68    if (cookie.length > 0) {
69        offset = cookie.indexOf(search);
70        if (offset != -1) {
71            offset += search.length;
72            end = cookie.indexOf(";", offset)
73            if (end == -1) {
74                end = cookie.length;
75            }
76            setStr = unescape(cookie.substring(offset, end));
77        }
78    }
79    return(setStr);
80}
81
82function airis_number_format(n) {
83	n = parseFloat(n);
84    n = n.toFixed(2);
85    n = n.toString();
86    while (true) {
87        var n2 = n.replace(/(\d)(\d{3})($|,|\.)/g, '$1,$2$3');
88        if (n == n2) break;
89        n = n2
90    }
91    return n
92}
93
94function padezh(number, titles) {
95    cases = [2, 0, 1, 1, 1, 2];
96    return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
97}
98function productAnalit (name, id, brand, category, position, list){
99	console.log(id);
100    roistat.event.send('add_to_cart')
101	dataLayer.push({
102		'event': 'addToCart',
103		'ecommerce': {
104			'currencyCode': 'RUB',
105			'add': {
106				'actionField': {'list': list},			// 'add' actionFieldObject measures.
107				'products': [{                        //  adding a product to a shopping cart.
108					'name': name,
109					'id': id,
110					'brand': brand,
111					'category': category,
112					'quantity': 1,
113					'position': position
114				}]
115			}
116		}
117	});
118
119	if ('ym' in window)
120	{
121		ym(22580131, 'reachGoal', 'add_to_cart');
122	}
123}
124//настройки highslide
125hs.graphicsDir = '/js/highslide/graphics/';
126hs.wrapperClassName = 'wide-border';
127hs.showCredits = false;
128hs.expandCursor = null;
129hs.restoreCursor = null;
130
131
132//скрипт для уведомления куки
133const cookieNotify = () => {
134    
135
136    // Проверяем, есть ли кука о согласии
137    function checkCookie() {
138        return document.cookie.split(';').some((item) => item.trim().startsWith('cookieConsent='));
139    }
140
141    if (checkCookie()) return
142
143    // Если куки нет - показываем уведомление
144
145    const cookieNoti = document.createElement('div');
146    cookieNoti.className = 'cookie-noti'
147    cookieNoti.innerHTML = `
148        <div>
149            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
150            <path d="M11.9998 13.3998L7.0998 18.2998C6.91647 18.4831 6.68314 18.5748 6.3998 18.5748C6.11647 18.5748 5.88314 18.4831 5.6998 18.2998C5.51647 18.1165 5.4248 17.8831 5.4248 17.5998C5.4248 17.3165 5.51647 17.0831 5.6998 16.8998L10.5998 11.9998L5.6998 7.0998C5.51647 6.91647 5.4248 6.68314 5.4248 6.3998C5.4248 6.11647 5.51647 5.88314 5.6998 5.6998C5.88314 5.51647 6.11647 5.4248 6.3998 5.4248C6.68314 5.4248 6.91647 5.51647 7.0998 5.6998L11.9998 10.5998L16.8998 5.6998C17.0831 5.51647 17.3165 5.4248 17.5998 5.4248C17.8831 5.4248 18.1165 5.51647 18.2998 5.6998C18.4831 5.88314 18.5748 6.11647 18.5748 6.3998C18.5748 6.68314 18.4831 6.91647 18.2998 7.0998L13.3998 11.9998L18.2998 16.8998C18.4831 17.0831 18.5748 17.3165 18.5748 17.5998C18.5748 17.8831 18.4831 18.1165 18.2998 18.2998C18.1165 18.4831 17.8831 18.5748 17.5998 18.5748C17.3165 18.5748 17.0831 18.4831 16.8998 18.2998L11.9998 13.3998Z" fill="black" />
151            </svg>
152        </div>
153        Мы используем файлы cookie. Продолжая пользоваться сайтом, вы даёте согласие на использование файлов cookies. Вы можете запретить сохранение cookie в настройках вашего браузера.
154        <button>Понятно</button>
155    `
156    
157    const closeBtn = cookieNoti.querySelector('div');
158    const agreeBtn = cookieNoti.querySelector('button');
159
160    document.body.appendChild(cookieNoti)
161    cookieNoti.classList.add('active');
162
163
164    // Установка куки на 1 год
165    function setCookie() {
166        const date = new Date();
167        date.setFullYear(date.getFullYear() + 1);
168        document.cookie = `cookieConsent=true; expires=${date.toUTCString()}; path=/`;
169        cookieNoti.classList.remove('active');
170
171    }
172
173    // Обработчики событий
174    closeBtn.addEventListener('click', function () {
175        cookieNoti.classList.remove('active');
176
177    });
178
179    agreeBtn.addEventListener('click', function () {
180        setCookie();
181    });
182}
183
184
185$(document).ready(function(){
186    cookieNotify()
187
188    $('.popup_link').fancybox();
189    $("img.lazyload").lazyload();
190
191    // выбор города
192    $(".top-header__city").click(function(){
193        $(this).find(".city-dropdown").slideToggle("toggle");
194    });
195
196	// адаптивное меню
197	$(".mobile-burger").click(function () {
198	   $(".navigation").slideToggle("toggle");
199	});
200	$(".catalog-menu__mobile").click(function () {
201	   $(".catalog-menu__items").slideToggle("toggle");
202	});
203
204    //ленивые картинки
205    $("img.lazy").lazyload();
206
207	//табы
208	$('.tabs__menu a').click(function(e) {
209		e.preventDefault();
210		$('.tabs__menu .tabs__active').removeClass('tabs__active');
211		$(this).addClass('tabs__active');
212		var tab = $(this).attr('href');
213		$('.tabs__tab').not(tab).css({'display':'none'});
214		$(tab).fadeIn(400);
215	});
216
217	//режим правки битрикса
218	var center = $('.center-col');
219	$('#bx_incl_area_13_2').addClass('left-col col-12 col-md-12 col-lg-3');
220	if ($('#bx_incl_area_14').length > 0) {
221		$('#bx_incl_area_14').prepend(center.html()).addClass('center-col col-12 col-md-12 col-lg-9');
222		center.remove();
223	}
224
225	//плавный скролл к якорю
226	$('a.scroll[href^="#"]').on('click', function(event) {
227        event.preventDefault();
228
229        var sc = $(this).attr("href"),
230            dn = $(sc).offset().top;
231
232        $('html, body').animate({scrollTop: dn}, 1000);
233    });
234
235
236
237
238        $(window).scroll(function(){
239            if ($(this).scrollTop() > 100) {
240                $('.scrollup').fadeIn();
241            } else {
242                $('.scrollup').fadeOut();
243            }
244        });
245
246        $('.scrollup').click(function(){
247            $("html, body").animate({ scrollTop: 0 }, 600);
248            return false;
249        });
250
251
252
253
254    spoilerInit();
255	highslideInit();
256	modalInit();
257
258  refresh_basket()
259});
260
261function getEmail(){
262	roistat.event.send('email');
263	ym(22580131, 'reachGoal', 'email');
264	ga('send', {hitType: 'event', eventCategory: 'email',  eventAction: 'click'});
265
266}
267
268
269var basketProducts = {};
270function digiAddToCart(productId, quantity)
271{
272    $.ajax({
273        url: '/js/ajax/add2basket.php',
274        data: {
275            id: productId,
276            col: quantity
277        },
278        type: 'POST',
279        cache: false,
280        dataType: 'json',
281        success: function (data){
282            basketProducts[productId] = quantity;
283            refresh_basket();
284        }
285    });
286
287}
288
289$.ajax({
290    url: '/local/ajax/add2basket.php',
291    data: {
292
293        action: 'check_product',
294    },
295    type: 'POST',
296    cache: false,
297    dataType: 'json',
298    success: function (data){
299        basketProducts = data.result;
300        window.basketProducts = basketProducts;
301    }
302});
303
304
305
306function digiCheckCart(productId)
307{
308    productId = "" + productId;
309    return basketProducts[productId];
310}
311
312
313function subscriptionProduct(productId)
314{
315
316    $.ajax({
317        url: '/local/ajax/subscriptionProduct.php',
318        data: {
319            id: productId,
320        },
321        type: 'POST',
322        cache: false,
323        dataType: 'json',
324        success: function (data){
325            console.log(data);
326            if(data.succes){
327                $('#overlay').fadeIn(400, function () {
328                    let page = $('.page-wrapper');
329                    let modal = $('.modal_subs');
330                    if (modal.length == 0){
331                        page.append(modal_outer());
332                        modal = $('.modal_subs', page);
333                        let sub = '';
334                        sub += '<div class="modal_form__field subscribe_form row">';
335                        sub += '<p class="col-12">Введите нужное вам количество</p>';
336                        sub += '<div class="qty col-12">';
337                        sub += '<input type="number" name="qty" value="" maxlength="5">';
338                        sub += '<span class="formula"> x <span class="fsv">' + data.packaging + '</span> ' + data.measure + ' = <span class="rslt">0</span> ' + data.measure + '</span>';
339                        sub += '<input type="hidden" name="product_id" value="' + data.id + '">';
340                        sub += '</div>';
341                        sub += '<div class="col-12"><button class="button button-normal subscribe">Подписаться</button></div>';
342                        sub += '</div>';
343                        modal.append(sub);
344                    }
345                    initModalEvent();
346                    $('#overlay').fadeIn(400, function () {
347                        modal.css('display', 'block').animate({opacity: 1, top: '50%'}, 200);
348                    });
349
350                });
351
352            }else{
353                $('#overlay').fadeIn(400, function () {
354                    let page = $('.page-wrapper');
355                    let modal = $('.modal_subs');
356                    if (modal.length == 0){
357                        page.append(modal_outer());
358                        modal = $('.modal_subs', page);
359                        let unsub = '';
360                        unsub += '<div class="modal_form__field unsubscribe_form row">';
361                        unsub += '<p class="col-12">Вы подписаны на поступление товара</p>';
362                        unsub += '<input type="hidden" name="product_id" value="' + data.productId + '">';
363                        unsub += '<input type="hidden" name="id" value="' + data.id + '">';
364                        unsub += '<div class="col-12"><button class="button button-normal unsubscribe">Отписаться</button></div>';
365                        unsub += '</div>';
366                        modal.append(unsub);
367                    }
368                    initModalEvent();
369                    $('#overlay').fadeIn(400, function () {
370                        modal.css('display', 'block').animate({opacity: 1, top: '50%'}, 200);
371                    });
372
373                });
374
375            }
376
377        }
378    });
379}
380
381function jsCitrusCustomFormInit()
382{
383	jQuery(function ($) {
384		$('.js-citrus-custom-form').find('[name="GIFT"]').remove();
385	});
386}
387
388function modalOuterSub()
389{
390    let modal = "";
391
392    modal += '<div class="modal_form modal_subs">';
393    modal += '<span class="modal_close"></span>';
394    modal += '<span class="modal_form__title">
394Уведомить о поступлении</span>';
395    modal += '</div>';
396
397    return modal;
398}
399
400function initModalEvent()
401{
402    $('.modal_subs input[name=qty]').off('keyup').on('keyup', function () {
403        if($(this).val() > 0){
404            var modal = $(this).parents('.modal_subs'),
405            fsv = $('.fsv', modal).text();
406            proverka(this);
407
408            $('.rslt', modal).text(fsv * $(this).val());
409            return true;
410        }
411        $(this).val('');
412        return false;
413
414    });
415
416    $('.modal_subs .modal_close, #overlay').off('click').on('click', function () {
417        $('.modal_subs')
418            .animate({opacity: 0, top: '45%'}, 200,
419            function () { // пoсле aнимaции
420                $(this).css('display', 'none');
421                $(this).remove();
422                $('#overlay').fadeOut(400);
423            }
424        );
425    });
426
427    $('.modal_subs button.subscribe').off('click').on('click', function (e) {
428
429        let modalSub = $(this).parents('.modal_subs'),
430            product_id = modalSub.find('input[name=product_id]').val(),
431            qty = modalSub.find('.rslt').text(),
432            params = {
433                "subscribe": "Y",
434                "product_id": product_id,
435                "qty": qty
436            },
437            message = '';
438
439        $.post(
440            "/local/components/airis/catalog.product.subscribe/ajax.php",
441            params,
442            function (data) {
443                if (data.error) {
444                    message += '<p class="col-12 error">' + data.message + '</p>';
445                }
446
447                $('.modal_form__field', modalSub).remove();
448                modalSub.append(data.message);
449            }, "json");
450
451        return false;
452    });
453
454    $('.modal_subs button.unsubscribe').off('click').on('click', function () {
455
456        let modal = $(this).parents('.modal_subs'),
457            product_id = modal.find('input[name=product_id]').val(),
458            id = modal.find('input[name=product_id]').val(),
459            params = {
460                "unsubscribe": "Y",
461                "id": id,
462                "product_id": product_id
463            },
464            message = '';
465
466        $.post(
467            "/local/components/airis/catalog.product.subscribe/ajax.php",
468            params,
469            function (data) {
470                if (data.error) {
471                    message += '<p class="col-12 error">' + data.message + '</p>';
472                } else {
473                    message += '<p class="col-12">' + data.message + '</p>';
474                    var btn = $('span[data-item=' + product_id + ']');
475                    btn.removeAttr('data-id');
476                    $('span[data-modal]', btn).text('Уведомить');
477                }
478
479                $('.modal_form__field', modal).remove();
480                modal.append(message);
481            }, "json");
482
483        return false;
484    });
485}
486
487jsCitrusCustomFormInit();

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.