PageSourceSearch

https://babochkispb.ru/js/scripts.js

js babochkispb.ru collected 2026-10-04 19:35:29 UTC 22,094 bytes, 727 lines download raw bytes

1var isMobile  = false,
2    isApple   = false,
3    animateIt = true,
4    blogCols  = 3,      // 1, 2 or 3
5    gViewMode = 'grid', // 'grid' or 'list'
6    gNewDays  = 7;
7
8var words = {
9    plusIcon:   'Увеличить',
10    minusIcon:  'Уменьшить',
11    allPhotos:  'Все',
12    upButton:   'Вверх ↑',
13    removeGood: 'Удалить',
14    showMore:   'Показать еще'
15};  
16
17if (navigator.userAgent.match(/Android/i) ||
18    navigator.userAgent.match(/webOS/i) ||
19    navigator.userAgent.match(/iPhone/i) ||
20    navigator.userAgent.match(/iPad/i)||
21    navigator.userAgent.match(/iPod/i) ||
22    navigator.userAgent.match(/IEMobile/i) ||
23    navigator.userAgent.match(/BlackBerry/i)) {
24    isMobile = true;
25};
26
27if (navigator.userAgent.match(/iPhone/i) ||
28    navigator.userAgent.match(/iPad/i)||
29    navigator.userAgent.match(/iPod/i)) {
30    isApple = true;
31};
32
33
34window.onload = function () {
35
36    // preloader
37    $('#loader').fadeOut(500);
38    
39};
40
41
42
43// css3 animation
44
45if (isMobile == true) {
46    $('.animated').removeClass('animated');
47};
48if (isMobile == false && animateIt == true) {
49    $('*[data-animated]').addClass('animated');
50};
51function animated_contents() {
52    $(".animated:appeared").each(function (i) {
53        var $this    = $(this),
54            animated = $(this).data('animated');
55        setTimeout(function () {
56            $this.addClass(animated);
57        }, 100 * i);
58    });
59};
60if (isMobile == false && animateIt == true) {
61    animated_contents();
62    $(window).scroll(function () {
63        animated_contents();
64    });
65};
66
67
68// scroll to
69$("body").on('click', '[href*="#"]:not(.ulightbox)', function(e){
70     var fixed_offset = 40;
71     $('html,body').stop().animate({ scrollTop: $(this.hash).offset().top - fixed_offset }, 1000);
72     e.preventDefault();
73});
74
75
76// search form
77$(function() {
78    $('.search-select').change(function() {
79    if ($('.search-select :selected').val() == 1) {
80        $('.search-all').hide();
81        $('.search-shop').show();
82    } else {
83        $('.search-shop').hide();
84        $('.search-all').show();
85    }
86    });
87});
88
89
90// categories
91$(function() {
92    $('.shc-button').click(function(){
93        $('.shc-block').slideToggle(300);
94    });
95});
96
97
98// cart
99$(function() {
100    $('#shop-basket').on({
101        click: function() {
102            $("#nav").addClass('nav-basket-opened');
103        },
104        mouseleave: function() {
105            $("#nav").removeClass('nav-basket-opened');
106        }
107    });    
108});
109
110
111$(function() {
112    $('.user-links').on({
113        click: function() {
114            $(this).addClass('opened');
115        },
116        mouseleave: function() {
117            $(this).removeClass('opened');
118        }
119    });
120});
121
122
123// header
124/*
125$(window).scroll(function() {
126    if ($(window).width() > 1647) {
127        if ($(window).scrollTop() > 150) {
128            $('#nav').addClass('fixed');
129            $('.nav-bottom').show();
130            $('.shc-block').hide();
131        } else {
132            $('#nav').removeClass('fixed');
133            $('.nav-bottom').hide();
134        }
135    } else {
136        if ($(window).width() > 970) {
137            if ($(window).scrollTop() > 215) {
138                $('#nav').addClass('fixed');
139                $('.nav-bottom').show();
140                $('.shc-block').hide();
141            } else {
142                $('#nav').removeClass('fixed');
143                $('.nav-bottom').hide();
144            }
145        }
146    }
147});
148*/
149
150
151// search
152$(function() {
153    $('.search-form-body').on({
154        click: function() {
155            $(this).addClass('opened');
156        },
157        mouseleave: function() {
158            $(this).removeClass('opened');
159        }
160    });
161});
162
163
164// up! button
165$(function() {
166    $('<span id="go-top" class="fas fa-angle-up" title="'+words['upButton']+'"></span>').appendTo('body');
167    $('#go-top').css({
168                'opacity'    : '0',
169                'visibility' : 'hidden'
170            });
171    $(window).scroll(function() {
172        if ($(this).scrollTop() > 500) {
173            $('#go-top').css({
174                'opacity'    : '1',
175                'visibility' : 'visible'
176            });
177        } else {
178            $('#go-top').css({
179                'opacity'    : '0',
180                'visibility' : 'hidden'
181            });
182        }
183    });
184    $('#go-top').click(function() {
185        $('body,html').animate({
186            scrollTop: 0
187        }, 800);
188        return false
189    });    
190});
191
192
193$(function() {
194    $('.top-open').click(function() {
195        $('.top-line').toggle(0);
196        $(this).find('span').toggleClass('fa-angle-down fa-angle-up');
197    });
198});
199
200
201// phone mask
202$(function() {
203    $('input[type="tel"]').mask("+7 (999) 999-99-99");
204});
205
206
207
208// shop categories
209$(function() {
210    $('.shc-block > .cat-tree > li').slice(8).hide();
211    $('.shc-more').click(function() {
212        $('.shc-block > .cat-tree > li').slice(8).slideToggle();
213        $(this).find('i').toggleClass('fa-plus fa-minus');
214    });
215});
216
217
218
219// slider
220$(function() {
221    $("#slider").aSlider({
222        prevBtn: '.slide-arrow.fa-angle-left',
223        nextBtn: '.slide-arrow.fa-angle-right',
224        fadeSpeed: 500,
225        autoPlay: true,
226        autoPlayDelay: 6000
227    });
228});
229
230
231// carousel
232$(function() {
233    $(".goods-carousel-section .gcarousel .goods-list").each(function() {
234        var carousel = $(this),
235            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
236            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
237        $(this).owlCarousel({
238            items: 6,
239            itemsDesktop: [1647, 4],
240            itemsDesktopSmall: [1268, 4],
241            itemsTablet: [991, 3],
242            itemsTabletSmall: [780, 2],
243            itemsMobile: [567, 1]
244        });
245        prev.click(function() {
246            carousel.trigger('owl.prev');
247        });
248        next.click(function() {
249            carousel.trigger('owl.next');
250        });
251    });
252    $(".new-goods-carousel .gcarousel .goods-list").each(function() {
253        var carousel = $(this),
254            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
255            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
256        $(this).owlCarousel({
257            items: 4,
258            itemsDesktop: [1647, 3],
259            itemsDesktopSmall: [1268, 3],
260            itemsTablet: [991, 3],
261            itemsTabletSmall: [780, 2],
262            itemsMobile: [567, 1]
263        });
264        prev.click(function() {
265            carousel.trigger('owl.prev');
266        });
267        next.click(function() {
268            carousel.trigger('owl.next');
269        });
270    });
271    $(".reviews-carousel .gcarousel .r-list").each(function() {
272        var carousel = $(this),
273            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
274            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
275        $(this).owlCarousel({
276            items: 1,
277            itemsDesktop: [1199, 1],
278            itemsDesktopSmall: [1268, 1],
279            itemsTablet: [991, 1],
280            itemsTabletSmall: [780, 1],
281            itemsMobile: [567, 1]
282        });
283        prev.click(function() {
284            carousel.trigger('owl.prev');
285        });
286        next.click(function() {
287            carousel.trigger('owl.next');
288        });
289    });
290    $(".gcarousel .logo-list").each(function() {
291        var carousel = $(this),
292            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
293            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
294        $(this).owlCarousel({
295            items: 6,
296            itemsDesktop: [1647, 5],
297            itemsDesktopSmall: [1268, 4],
298            itemsTablet: [991, 3],
299            itemsTabletSmall: [780, 2],
300            itemsMobile: [567, 1]
301        });
302        prev.click(function() {
303            carousel.trigger('owl.prev');
304        });
305        next.click(function() {
306            carousel.trigger('owl.next');
307        });
308    });
309    $(".gcarousel .blog-list").each(function() {
310        var carousel = $(this),
311            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
312            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
313        $(this).owlCarousel({
314            items: 4,
315            itemsDesktop: [1647, 3],
316            itemsDesktopSmall: [1268, 3],
317            itemsTablet: [991, 2],
318            itemsTabletSmall: [780, 1],
319            itemsMobile: [567, 1]
320        });
321        prev.click(function() {
322            carousel.trigger('owl.prev');
323        });
324        next.click(function() {
325            carousel.trigger('owl.next');
326        });
327    });
328    $(".gp-more-goods .gcarousel .goods-list").each(function() {
329        var carousel = $(this),
330            prev = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-left'),
331            next = $(this).parent().parent().parent().find('.gcarouselarrow.fa-angle-right');
332        $(this).owlCarousel({
333            items: 5,
334            itemsDesktop: [1647, 4],
335            itemsDesktopSmall: [1268, 4],
336            itemsTablet: [991, 3],
337            itemsTabletSmall: [780, 2],
338            itemsMobile: [567, 1]
339        });
340        prev.click(function() {
341            carousel.trigger('owl.prev');
342        });
343        next.click(function() {
344            carousel.trigger('owl.next');
345        });
346    });
347});
348
349
350// menu
351$(function() {
352    $('#menu .uMenuRoot > li.uWithSubmenu > a').append('<i class="fas fa-angle-down"></i>');
353    $('#menu .uMenuRoot ul li.uWithSubmenu > a').append('<i class="fas fa-angle-right"></i>');
354
355    // mobile
356    $('.menu-icon').click(function() {
357        $('body').addClass('noscroll');
358        $('#menu .uMenuRoot').clone().appendTo('.mobile-menu-container');
359        $('.mobile-menu-container').fadeIn(300);
360        $('.mobile-menu-container .uMenuRoot li.uWithSubmenu > a').after('<i class="fas fa-angle-down"></i>');
361        $('.mobile-menu-container .uMenuRoot li i').click(function() {
362            $(this).toggleClass('fa-angle-down').toggleClass('fa-angle-up');
363            $(this).parent().toggleClass('uWithSubmenuActive').find('ul:first').slideToggle(300);
364        });
365    });
366    
367    $('.mobile-menu-container-close').click(function() {
368        $('.mobile-menu-container').fadeOut(300);
369        $('.mobile-menu-container .uMenuRoot').remove();
370        $('body').removeClass('noscroll');
371    });
372
373});
374
375
376// counts
377$(function() {
378    $(document.body).on('appear', '.count-val', function(e, $affected) {
379        var c = $(this).data('count');
380        if ( $(this).is(':appeared') && !$(this).hasClass('starting') ) {
381            $(this).addClass('starting');
382            $(this).countTo({
383                from: 0,
384                to: c
385            });
386        }
387    });
388    $('.count-val').appear({force_process: true});
389});
390
391
392// skills
393$(function() {
394    $(document.body).on('appear', '.skill-line-wrap > span', function(e, $affected) {
395        var percent = $(this).data('percent');
396        if ( $(this).is(':appeared') && !$(this).hasClass('skill-starting') ) {
397            $(this).children('b').append(percent+'%');
398            $(this).addClass('skill-starting');         
399            $(this).width($(this).parent().width()*percent/100);
400        }
401    });
402    $('.skill-line-wrap > span').appear({force_process: true});
403});
404
405
406
407// timer
408$(function() {
409    var dateArr = [2016, 3, 23],  // задаем дату в формате [год, месяц, число], до которой будет вестись отсчет
410        endDate = new Date(dateArr[0], dateArr[1] - 1, dateArr[2]);
411    $('.uc-timer').countdown({until: endDate, format: 'DHMS'});
412});
413
414
415
416
417// tabs
418$(function() {
419    $('.tabs').aTabs();
420    $('.gp-tabs').aTabs();
421});
422
423
424
425// categories
426$(function() {
427    $(".block .catsTd .catNumData").each(function(){
428        var cat_num_data = $(this).text().replace(/[^0-9]/g, "");
429        $(this).text(cat_num_data);
430    });
431});
432
433
434
435// quote
436$(function() {
437    $('.bbQuoteName, .quoteMessage').removeAttr('style');
438});
439
440
441
442
443// new goods
444$(function(){
445    if (typeof _ucoz_date != 'undefined') { c_date = new Date(_ucoz_date.replace(/(\d+).(\d+).(\d+)/, '$3/$2/$1')); }
446    $('.g-new').each(function() {
447        g_date = new Date($(this).data('date').replace(/(\d+).(\d+).(\d+)/, '$3/$2/$1'));
448        n_date = Math.floor((c_date - g_date) / (1000 * 60 * 60 * 24));
449        if (n_date <= gNewDays) {
450            $(this).css('display', 'block');
451        };
452    });
453});
454
455
456
457// plus mimus catalog
458$(function(){
459    $('.g-to-basket-2 input[type="text"]').before('<button class="gp-minus" title="'+words['minu
459sIcon']+'">-</button>');
460    $('.g-to-basket-2 input[type="text"]').after('<button class="gp-plus" title="'+words['plusIcon']+'">+</button>');
461    $('.g-to-basket-2 .gp-plus').click(function() {
462        var inputVal = +$(this).parent().find('input[type="text"]').val();
463        $(this).parent().find('input[type="text"]').val(inputVal+1)
464    });
465    $('.g-to-basket-2 .gp-minus').click(function() {
466        var inputVal = +$(this).parent().find('input[type="text"]').val();
467        if ( inputVal > 1 ) {
468            $(this).parent().find('input[type="text"]').val(inputVal-1);
469        }
470    });
471
472    $('.g-to-basket-2 input[type="button"]').val('');
473});
474
475
476// plus minus
477$(function(){
478    $('.gp-buttons input[type="text"]').before('<button class="gp-minus" title="'+words['minusIcon']+'">-</button>');
479    $('.gp-buttons input[type="text"]').after('<button class="gp-plus" title="'+words['plusIcon']+'">+</button>');
480    $('.gp-buttons .gp-plus').click(function() {
481        var inputVal = +$('.gp-buttons input[type="text"]').val();
482        $('.gp-buttons input[type="text"]').val(inputVal+1)
483    });
484    $('.gp-buttons .gp-minus').click(function() {
485        var inputVal = +$('.gp-buttons input[type="text"]').val();
486        if ( inputVal > 1 ) {
487            $('.gp-buttons input[type="text"]').val(inputVal-1)
488        }
489    });    
490});
491
492
493// plus-minus order page
494$(function(){
495    $('.order-item-cnt input[type="text"]').before('<span class="o-minus" title="'+words['minusIcon']+'">-</span>');
496    $('.order-item-cnt input[type="text"]').after('<span class="o-plus" title="'+words['plusIcon']+'">+</span>');
497    $('.order-item-cnt .o-plus').click(function() {
498        var field = $(this).parent().find('input[type="text"]');
499        var inputVal = +field.val();
500        field.val(inputVal+1);
501    });
502    $('.order-item-cnt .o-minus').click(function() {
503        var field = $(this).parent().find('input[type="text"]');
504        var inputVal = +field.val();
505        if ( inputVal > 1 ) {
506            field.val(inputVal-1)
507        }
508    });
509});
510
511// order page, remove
512$(function() {
513    if (_ucoz_pageId !== 'order') {
514    	$('.order-item-del').append('<i class="far fa-trash-alt" title="'+words['removeGood']+'"></i>');
515    	$('.order-item-del .far').click(function(){ 
516    	    $(this).parent().find('input[type="checkbox"]').prop('checked', true);
517    	    if(_shopLockButtons()) return false;
518    	    _shopFadeControl('order-table');
519    	    _uPostForm('order-form');
520    	});
521    }
522});
523
524
525// order-page, other
526$(function() {
527    if (_ucoz_pageId !== 'order') {
528	   $('#order-table').after('<div id="order-total-line">'+$('#order-table tbody tr:last-child').html()+'</div>');
529	   $('#order-table tbody tr:last-child').html('');
530    } else {
531	   $('#print-button').css('margin', '30px 0');
532    }
533
534    $('.payment-item').each(function() {
535        if ($(this).prop("checked") == true) {
536            $(this).parent().parent().find('.pl-text').fadeIn(300);
537        }
538    });
539    $('.payment-item').click(function() {
540        $('.pl-text').fadeOut(0);
541        $(this).parent().parent().find('.pl-text').fadeIn(300);
542    });
543
544    $('.delivery-item').each(function() {
545        if ($(this).prop("checked") == true) {
546            $(this).parent().parent().find('div[id^=delivery-descr]').fadeIn(300);
547        }
548    });
549    $('.delivery-item').click(function() {
550        $('div[id^=delivery-descr]').fadeOut(0);
551        $(this).parent().parent().find('div[id^=delivery-descr]').fadeIn(300);
552    });
553});
554
555
556// blog posts
557$(function() {
558    $('#allEntries .post').parent().addClass('post-wrap').parent().addClass('oh');
559    if (blogCols == 1) {
560        $('.post-wrap').css('margin-bottom', '30px');
561    };
562    if (blogCols == 2) {
563        $('.post-wrap').addClass('col2');
564    };
565    if (blogCols == 3) {
566        $('.post-wrap').addClass('col3');
567    };
568    if (_ucoz_moduleId == 'blog' && _ucoz_pageId == 'entry') {
569        $('.post-page-tags noindex').html($('.post-page-tags noindex').html().replace(/\,/g, ''));
570    };
571});
572
573
574
575// photos
576$(function() {
577    $('.photo').parent().removeAttr('id').removeAttr('class').removeAttr('style').parent().removeAttr('id').removeAttr('class').removeAttr('style').addClass('photo-wrap col3').parent().removeAttr('id').removeAttr('class').removeAttr('style').addClass('photo-list');
578});
579
580
581// FAQ
582$(function() {
583    $('.faq:first').addClass('opened').find('.faq-message').slideToggle(0);
584    $('.faq-title').click(function() {
585        if (!$(this).parent().hasClass('opened')) {
586            $('.faq.opened').removeClass('opened').find('.faq-message').slideToggle(300);
587            $(this).parent().toggleClass('opened').find('.faq-message').slideToggle(300);
588        } else {
589            $(this).parent().toggleClass('opened').find('.faq-message').slideToggle(300);
590        }
591    });
592});
593
594
595
596// other 
597$(function() {
598    $('.sh-pages-left button').html(words['showMore']+'<i class="fas fa-angle-down"></i>');
599    $('.block-body ul.cat-tree li').has('ul').addClass('cat-tree-with-ul');
600
601    if ($(window).width() < 1279 ) {
602        $('#sidebar .filters-block').remove().prependTo('#content').css({
603            'float': 'none',
604            'width': '100%'
605        });
606    };
607});
608
609$(window).resize(function() {
610    if ($(this).width() < 1279 ) {
611        $('#sidebar .filters-block').remove().prependTo('#content').css({
612            'float': 'none',
613            'width': '100%'
614        });
615    }
616    if ($(this).width() > 1278 ) {
617        $('#content .filters-block').remove().prependTo('#sidebar');
618    }
619});
620
621$(function() {
622    $('.shop_spec_grp td').wrapInner('<div class="shop_spec_grp_td_content"></div>');
623    $('.gp-rev-form').hide();
624    $('.gp-show-rev-form').click(function() {
625        $('.gp-rev-form').slideToggle();
626    });
627});
628
629$(function() {
630    if(typeof shopFilterMinPrice !== 'undefined') {$('#price_min').val(shopFilterMinPrice);}
631    if(typeof shopFilterMaxPrice !== 'undefined') {$('#price_max').val(shopFilterMaxPrice);}
632});
633
634
635
636// goods view mode
637$(function(){
638    switch (getCookie('itemViewMode')) {
639        case 'grid':
640            $('.goods-view-mode-grid').addClass('goods-view-mode-active');
641            $('#content #goods-cont').removeClass('list-item-view-mode-list');
642        break
643        case 'list':
644            $('.goods-view-mode-list').addClass('goods-view-mode-active');
645            $('#content #goods-cont').addClass('list-item-view-mode-list');
646            $('.list-item').each(function() {
647                $(this).css({
648                    'min-height': $(this).find('.g-image').height()
649                });
650            });
651        break
652        case undefined:
653            setCookie('itemViewMode', gViewMode);
654            switch (getCookie('itemViewMode')) {
655                case 'grid':
656                    $('.goods-view-mode-grid').addClass('goods-view-mode-active');
657                    $('#content #goods-cont').removeClass('list-item-view-mode-list');
658                break
659                case 'list':
660                    $('.goods-view-mode-list').addClass('goods-view-mode-active');
661                    $('#content #goods-cont').addClass('list-item-view-mode-list');
662                break
663                default:
664                alert('ERROR!\ninvalid gViewMode: "'+gViewMode+'"');
665            };
666        break
667        default:
668            alert('ERROR!\ninvalid gViewMode: "'+gViewMode+'"');
669    };
670
671    $('.goods-view-mode > span').click(function() {
672        if ( $(this).hasClass('goods-view-mode-active') ) {
673            return false;
674        }   else {
675            $('.goods-view-mode > span').removeClass('goods-view-mode-active');
676            $(this).addClass('goods-view-mode-active');
677            if ( $(this).hasClass('goods-view-mode-grid') ) {
678                setCookie('itemViewMode', 'grid');
679                $('#content #goods-cont').removeClass('list-item-view-mode-list');
680            } else if ( $(this).hasClass('goods-view-mode-list') ) {
681                setCookie('itemViewMode', 'list');
682                $('#content #goods-cont').addClass('list-item-view-mode-list');
683                $('.list-item').each(function() {
684                    $(this).css({
685                        'min-height': $(this).find('.g-image').height()
686                    });
687                });
688            }
689        }
690    });
691});
692
693
694// cookies
695function setCookie(name, value, options) {
696    options = options || {};
697    var expires = options.expires;
698    if (typeof expires == "number" && expires) {
699        var d = new Date();
700        d.setTime(d.getTime() + expires * 1000);
701        expires = options.expires = d;
702    }
703    if (expires && expires.toUTCString) {
704        options.expires = expires.toUTCString();
705    }
706    value = encodeURIComponent(value);
707    var updatedCookie = name + "=" + value;
708    for (var propName in options) {
709        updatedCookie += "; " + propName;
710        var propValue = options[propName];
711        if (propValue !== true) {
712            updatedCookie += "=" + propValue;
713        }
714    }
715    document.cookie = updatedCookie;
716};
717function getCookie(name) {
718    var matches = document.cookie.match(new RegExp(
719        "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
720    ));
721    return matches ? decodeURIComponent(matches[1]) : undefined;
722};
723function deleteCookie(name) {
724    setCookie(name, "", {
725        expires: -1
726    });
727};

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.