PageSourceSearch

https://osnovahram.kh.ua/js/template.js

js osnovahram.kh.ua collected 2026-10-08 07:15:27 UTC 9,831 bytes, 304 lines download raw bytes

1$(document).ready(function() {
2
3    //MOBILE MENU TOOGLE
4    var $window = $(window),
5        $html = $('html');
6
7    $window.resize(function resize() {
8        if ($window.width() < 800) {
9            return $('.main-nav, .top-nav').addClass('mobile');
10        }
11        $('.main-nav, .top-nav').removeClass('mobile');
12    }).trigger('resize');
13
14    var $menu_with_children = $('.mobile .uMenuV .uWithSubmenu > span, .mobile .uMenuV .uWithSubmenu > a, .sidebar .uMenuV .uWithSubmenu > span, .sidebar .uMenuV .uWithSubmenu > a');
15    $menu_with_children.on('click', function(e){
16        e.preventDefault();
17        var $this = $(this);
18        if (!$this.parent().find('> ul').hasClass('visible')) {
19            $this.parent().find('> ul').addClass('visible').slideDown('slow');
20        } else{
21            $this.parent().find('> ul').removeClass('visible').slideUp('slow');
22        }
23    });
24
25
26    //GREEDY NAVIGATION
27    var $nav = $('.greed-nav');
28    var $btn = $('.greed-nav .greed');
29    var $vlinks = $('.greed-nav .uMenuRoot');
30    var $hlinks = $('.greed-nav .hidden-links');
31
32    var breaks = [];
33
34    function updateNav() {
35
36        var availableSpace = $btn.hasClass('hidden') ? $nav.width() : $nav.width() - $btn.width() - 0;
37
38        if ($vlinks.width() > availableSpace) {
39
40            breaks.push($vlinks.width());
41
42            $vlinks.children().last().prependTo($hlinks);
43
44            if ($btn.hasClass('hidden')) {
45                $btn.removeClass('hidden');
46            }
47
48        } else {
49
50            if (availableSpace > breaks[breaks.length - 1]) {
51
52                $hlinks.children().first().appendTo($vlinks);
53                breaks.pop();
54            }
55
56            if (breaks.length < 1) {
57                $btn.addClass('hidden');
58                $hlinks.addClass('hidden');
59            }
60        }
61
62        $btn.attr("count", breaks.length);
63
64        if ($vlinks.width() > availableSpace) {
65            updateNav();
66        }
67
68    }
69
70    $(window).resize(function() {
71        updateNav();
72    });
73
74    $btn.on('click', function() {
75        $hlinks.toggleClass('hidden');
76    });
77
78    updateNav();
79
80
81    //TOOGLE MENU
82    $("ul.goods-menu li").click(function() {
83        $("ul.goods-menu li").removeClass("active");
84        $(this).addClass("active");
85    });
86
87
88
89    //SELSTYLE
90    $(".shop-options-s").each(function() {
91        $(this).after("<ul class=\"select-options\"></ul>");
92        $(this).hide();
93    });
94    $(".shop-options-s option").each(function() {
95        if ($(this).text() != "Выбрать") {
96            $(this).parent().next().append("<li id=\"" + $(this).parent().attr("id") + "-" + $(this).attr("value") + "\" class=\"option-link\">" + $(this).text() + "</li> ");
97        }
98    });
99    $(".option-link").click(function() {
100        linkIdArray = $(this).attr("id").split('-');
101        selectId = linkIdArray[0] + '-' + linkIdArray[1] + '-' + linkIdArray[2] + '-' + linkIdArray[3];
102        optionValue = linkIdArray[4];
103        $(".val .active").each(function() {
104            if (this.id.indexOf(selectId) != -1) {
105                $(this).attr("class", "option-link");
106            }
107        });
108        if (this.className.indexOf('active') == -1) {
109            this.className = 'option-link active';
110            $("#" + selectId + " option").each(function() {
111                if ($(this).attr("value") == optionValue) {
112                    $(this).attr("selected", "selected");
113                }
114            });
115            $("#" + selectId).change();
116        } else {
117            this.className = 'option-link';
118            $("#" + selectId + " option[value='0']").attr("selected", "selected");
119            $("#" + selectId + " option[value='0']").attr("class", "option-link active");
120            $("#" + selectId).change();
121        }
122        return false;
123    });
124
125//ROCKET TO TOP
126    jQuery(window).scroll(function() {
127        if (jQuery(window).scrollTop() < 50) {
128            jQuery('#rocketmeluncur').slideUp(500);
129        } else {
130            jQuery('#rocketmeluncur').slideDown(500);
131        }
132        var ftrocketmeluncur = jQuery("#ft")[0] ? jQuery("#ft")[0] : jQuery(document.body)[0];
133        var scrolltoprocketmeluncur = $('rocketmeluncur');
134        var viewPortHeightrocketmeluncur = parseInt(document.documentElement.clientHeight);
135        var scrollHeightrocketmeluncur = parseInt(document.body.getBoundingClientRect().top);
136        var basewrocketmeluncur = parseInt(ftrocketmeluncur.clientWidth);
137        var swrocketmeluncur = scrolltoprocketmeluncur.clientWidth;
138        if (basewrocketmeluncur < 1000) {
139            var leftrocketmeluncur = parseInt(fetchOffset(ftrocketmeluncur)['left']);
140            leftrocketmeluncur = leftrocketmeluncur < swrocketmeluncur ? leftrocketmeluncur * 2 - swrocketmeluncur : leftrocketmeluncur;
141            scrolltoprocketmeluncur.style.left = (basewrocketmeluncur + leftrocketmeluncur) + ('px');
142        } else {
143            scrolltoprocketmeluncur.css('left', 'auto');
144            scrolltoprocketmeluncur.css('right', '10px');
145        }
146    });
147
148    jQuery('#rocketmeluncur').click(function() {
149        jQuery("html, body").animate({
150            scrollTop: '0px',
151            display: 'none'
152        }, {
153            duration: 600,
154            easing: 'linear'
155        });
156
157        var self = this;
158        this.className += ' ' + "launchrocket";
159        setTimeout(function() {
160            self.className = 'showrocket';
161        }, 800);
162    });
163
164
165
166    //FULLPAGESEARCH
167    document.getElementById("fws").onclick = function() {
168        document.getElementById("full-search").classList.add("active");
169        document.querySelector("input").focus();
170        var goods = [];
171		$.get('/export.xml', function(data) {
172			$(data).find('item').each(function(elem) {
173				goods[elem] = [$('title', this).next().next().text(), $('title', this).text(), $('link', this).text(), $('link', this).prev().text(), $('link', this).next().text(), $('link',this).next().next().next().next().text()];
174			}); 
175		});
176		
177		$("input[name='query']").keyup(function(){
178		
179			var query = $(this).val(); 
180			var result = 0;
181			var limit = 6;
182			$("#search-results").remove();
183			if (query !== 0) {
184				$(goods).each(function(){
185					if (result<limit) {
186						if(this[1].toLowerCase().indexOf(query.toLowerCase())!=-1){
187							if (result === 0) {
188								$("form[action='/shop/search']").append("<ul class=\"clr\" id=\"search-results\"></ul>");
189							}
190							$("#search-results").append("<li><a href=\""+this[2]+"\"><img src=\""+this[3]+"\" /><span>"+this[1]+"</span></a></li>");
191							result++;
192							if (result == 6 && query.length !=1) {
193								$("#search-results").append("<li><button class=\"all-results\" type=\"submit\"><i class=\"flaticon-right204\"></i>Все результаты</button></li>");
194								$("#search-results").addClass("all-res");
195							}
196						}
197					} else {
198						return false;
199					}
200				});
201			}
202			
203		});
204
205    };
206
207    document.getElementById("fws-close").onclick = function() {
208        document.getElementById("full-search").classList.remove("active");
209    };
210
211
212    //PLACEHOLDER
213    $('[placeholder]').focus(function() {
214        var input = $(this);
215        if (input.val() == input.attr('placeholder')) {
216            input.val('');
217            input.removeClass('placeholder');
218        }
219    }).blur(function() {
220        var input = $(this);
221        if (input.val() === '' || input.val() == input.attr('placeholder')) {
222            input.addClass('placeholder');
223            input.val(input.attr('placeholder'));
224        }
225    }).blur().parents('form').submit(function() {
226        $(this).find('[placeholder]').each(function() {
227            var input = $(this);
228            if (input.val() == input.attr('placeholder')) {
229                input.val('');
230            }
231        });
232    });
233
234
235    //DATE VIEW
236    $('.ndate').each(function() {
237        date = String($(this).attr('title')).split('.');
238        temp_date = new Date();
239        day = temp_date.getDate();
240        month = temp_date.getMonth() + 1;
241        if (month < 10) {
242            month = '0' + month;
243        }
244        if (date[0] == 'Вчера') {
245            date[0] = day - 1;
246            if (date[0] === 0) {
247                if (month < 10) {
248                    temp_date = new Date();
249                    day = temp_date.getDate() - 1;
250                    month = temp_date.getMonth();
251                    date[0] = day;
252                    date[1] = '0' + month;
253                }
254            } else {
255                date[1] = month;
256            }
257        }
258        if (date[0] == 'Сегодня') {
259            date[1] = month;
260            date[0] = day;
261        }
262        mes = '';
263        switch (date[1]) {
264            case '01':
265                mes = 'января';
266                break;
267            case '02':
268                mes = 'февраля';
269                break;
270            case '03':
271                mes = 'марта';
272                break;
273            case '04':
274                mes = 'апреля';
275                break;
276            case '05':
277                mes = 'мая';
278                break;
279            case '06':
280                mes = 'июня';
281                break;
282            case '07':
283                mes = 'июля';
284                break;
285            case '08':
286                mes = 'августа';
287                break;
288            case '09':
289                mes = 'сентября';
290                break;
291            case '10':
292                mes = 'октября';
293                break;
294            case '11':
295                mes = 'ноября';
296                break;
297            case '12':
298                mes = 'декабря';
299                break;
300        }
301        $(this).html('<span class="cou">' + date[0] + '</span> <span class="des">' + mes + '</span>');
302    });
303
304});

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.