PageSourceSearch

https://www.kinder-mir.com/templates/kinder-mir/resource/js/theme.js?v=25

js kinder-mir.com collected 2026-09-30 09:55:15 UTC 7,390 bytes, 199 lines download raw bytes

1/**
2* Скрипт инициализирует стандартные функции для работы темы
3*/
4
5$.detectMedia = function( checkMedia ) {
6    var init = function() {
7        var detectMedia = function() {
8            var
9                currentMedia = $('body').data('currentMedia'),
10                newMedia = '';
11
12            if ($(document).width() < 760) {
13                newMedia = 'mobile';
14            }
15            if ($(document).width() >= 760 && $(document).width() <= 980) {
16                newMedia = 'portrait';
17            }
18
19            if (currentMedia != newMedia) {
20                $('body').data('currentMedia', newMedia);
21            }
22        }
23        $(window).on('resize.detectMedia', detectMedia);
24        detectMedia();
25    }
26
27    var check = function(media) {
28        return $('body').data('currentMedia') == media;
29    }
30
31    if (checkMedia) {
32        return check(checkMedia);
33    } else {
34        init();
35    }
36};
37
38//Инициализируем работу data-href у ссылок
39$.initDataHref = function() {
40    $('a[data-href]:not(.addToCart):not(.applyCoupon):not(.ajaxPaginator)').on('click', function() {
41        if ($.detectMedia('mobile') || !$(this).hasClass('inDialog')) {
42            location.href = $(this).data('href');
43        }
44    });
45};
46
47//Инициализируем работу блока, скрывающего длинный текст
48$.initCut = function() {
49    $('.rs-cut').each(function(){
50        $(this).css('max-height', ($(this).data('cut-height')) ? $(this).data('cut-height') : '200px');
51        $(this).append('<div class="cut-switcher"></div>');
52        $(this).children().last().click(function(){
53            if ($(this).parent().hasClass('open')) {
54                $(this).parent().css('max-height', ($(this).parent().data('cut-height')) ? $(this).parent().data('cut-height') : '200px');
55            } else {
56                $(this).parent().css('max-height', '10000px');
57            }
58            $(this).parent().toggleClass('open');
59        });
60    });
61};
62
63$(function() {
64
65    //Решение для корректного отображения масштаба в Iphone, Ipad
66    if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
67        var viewportmeta = document.querySelector('meta[name="viewport"]');
68        if (viewportmeta) {
69            viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
70            document.body.addEventListener('gesturestart', function () {
71                viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
72            }, false);
73        }
74    }//----
75
76    $.cart(); //Инициализируем корзину
77    $('.inDialog').openInDialog();
78    $('.activeTabs').activeTabs();
79    $('input[type="checkbox"]:not(.noStyle)').each(function() {
80        if (!$(this).parents('.admin-style').length) $(this).styler();
81    });
82    $.detectMedia();
83    $.initDataHref();
84    $.initCut();
85
86    //Инициализируем быстрый поиск по товарам
87    $(window).resize(function() {
88        $( ".searchLine .query.autocomplete" ).autocomplete( "close" );
89    });
90
91    //Инициализируем открытие картинок во всплывающем окне
92    $('a[rel="lightbox"], .lightimage').colorbox({
93       rel:'lightbox',
94       className: 'titleMargin',
95       opacity:0.2
96    });
97
98    $('[data-toggle="popover"]').popover({placement : 'auto', trigger: 'click'});
99    $(document).on('click', function (e) {
100        $('[data-toggle="popover"],[data-original-title]').each(function () {
101            if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
102                (($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false  // fix for BS 3.3.6
103            }
104
105        });
106    });
107
108    /**
109    * Автозаполнение в строке поиска
110    */
111    $( ".searchLine .query.autocomplete" ).each(function() {
112        $(this).autocomplete({
113            source: $(this).data('sourceUrl'),
114            appendTo: '#queryBox',
115            minLength: 3,
116            select: function( event, ui ) {
117                location.href=ui.item.url;
118                return false;
119            },
120            messages: {
121                noResults: '',
122                results: function() {}
123            }
124        }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
125            ul.addClass('searchItems');
126            var li = $( "<li />" );
127            var link_class = "";
128            if (item.image){
129                var img = $('<img />').attr('src', item.image).css('visibility', 'hidden').load(function() {
130                    $(this).css('visibility', 'visible');
131                });
132                li.append($('<div class="image" />').append(img));
133            }else{
134                link_class = "class='noimage'";
135            }
136
137            if (item.type == 'search'){
138                li.addClass('allSearchResults');
139            }
140
141
142            var item_html = '<a '+link_class+'><span class="label">' + item.label + '</span>';
143            if (item.barcode){ //Если артикул есть
144                item_html += '<span class="barcode">' + item.barcode + '</span>';
145            }else if (item.type == 'brand'){
146                item_html += '<span class="barcode">' + lang.t('Проиводитель') + '</span>';
147            }else if (item.type == 'category'){
148                item_html += '<span class="barcode">' + lang.t('Категория') + '</span>';
149            }
150            if (item.price){ //Если цена есть
151                item_html += '<span class="price">' + item.price + '</span>';
152            }
153            if (item.preview){ //Если цена превью (для статей)
154                item_html += '<span class="preview">' + item.preview + '</span>';
155            }
156            item_html += '</a>';
157
158            return li
159                .append( item_html )
160                .appendTo( ul );
161        };
162    });
163});
164
165//Инициализируем обновляемые зоны
166$(window).bind('new-content', function(e) {
167    $('.activeTabs', e.target).activeTabs({
168        onTabChange: function() {
169            if ($(this).closest('#colorbox')) $.colorbox.resize();
170        }
171    });
172
173    $('input[type="checkbox"]', e.target).each(function() {
174        if (!$(this).parents('.admin-style').length) $(this).styler();
175    });
176    $('.inDialog', e.target).openInDialog();
177    $('.rs-parent-switcher', e.target).switcher({parentSelector: '*:first'});
178    $.initDataHref();
179    $.initCut();
180});
181
182$(document).ready(function(){
183  $('.open-spoiler').click(function(){
184    $('.spoiler').show('slow');
185  });
186  $('.close-spoiler').click(function(){
187    $('.spoiler').hide('slow');
188  });
189
190  if($('.fcost .myCost').text() == 0) {$('.fcost .myCost').text('Цена: по запросу');$('.myCurrency').css('display','none');}
191  $(document).change(function() {
192    if($('.fcost .myCost').text() == 0) {$('.fcost .myCost').text('Цена: по запросу');$('.myCurrency').css('display','none');}
193  })
194});
195
196$(document).ready(function(){
197    $('.levelType-list .levelRow:first-child label').click();
198    $('.showOfferSelect .info.extra').matchHeight();
199})

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.