PageSourceSearch

https://biokot.com/wp-content/themes/beru/js/common.js

js biokot.com collected 2026-10-04 13:25:21 UTC 12,928 bytes, 428 lines download raw bytes

1jQuery(document).ready(function() {
2	
3	var width_main = jQuery('.articleMain').width();
4	jQuery('.content img.fullwidth').each(function() {
5	    jQuery(this).css({
6	        'max-width': width_main,
7	        'height': 'auto'
8		});
9	});
10	
11	jQuery('.content img.signature').each(function() {
12	    var title = jQuery(this).attr('title');
13	    jQuery(this).removeAttr('title');
14	    jQuery(this).wrap('<div class="signature_block"></div>').parent().append('<span class="signature_text">' . concat(title) . concat('</span>'));
15	})
16	
17})
18
19jQuery(document).ready(function($){
20
21	// Прокрутка на все якоря (#) и на a[name]. v1.1
22	$('.article-review a[href*="#"], #kcmenu a[href*="#"], .rating__table td a[href*="#"]').on('click.smoothscroll', function( e ){
23		var hash    = this.hash,
24			_hash   = hash.replace(/#/,''),
25			theHref = $(this).attr('href').replace(/#.*/, '');
26
27		if( theHref && location.href.replace(/#.*/,'') != theHref ) return; // не текущая страница
28
29		var $target = _hash === '' ? $('body') : $( hash + ', a[name="'+ _hash +'"]').first();
30
31		if( ! $target.length ) return;
32
33		e.preventDefault();
34
35		$('html, body').stop().animate({ scrollTop: $target.offset().top - 100 }, 400, 'swing', function(){
36			window.location.hash = hash;
37		});
38	});
39
40});
41
42$(document).ready(function () {
43    
44    $('.commentItem__like').click(function(){
45        var data_id = $(this).attr("data-id");
46        if ($.cookie('comment_box_rat_new_plus_minus' + data_id) == null) {
47		var btn = $(this);
48		var data = {
49			'action': 'rating_comments_plus',
50			'comment_id' : $(this).attr("data-id")
51		};
52		$.ajax({
53			url: $(this).attr("data-ajaxurl"), // обработчик
54			data:data, // данные
55			type:'POST', // тип запроса
56			success:function(data){	
57				if( data ) {
58					if( data == 'err') {
59						alert('Ошибка голосования!');
60					} else { 
61					    $('#div-comment-'.concat(data_id)).find('.commentItem__like span').text(data);
62					}
63				}
64			}
65		});
66		$.cookie('comment_box_rat_new_plus_minus' + data_id, 'true', { expires: 365 });
67        } else {
68            alert('Вы уже голосовали!')
69        }
70	});
71	
72	$('.commentItem__dislike').click(function(){
73	    var data_id = $(this).attr("data-id");
74	    if ($.cookie('comment_box_rat_new_plus_minus' + data_id) == null) {
75		var btn = $(this);
76		var data = {
77			'action': 'rating_comments_minus',
78			'comment_id' : $(this).attr("data-id")
79		};
80		$.ajax({
81			url: $(this).attr("data-ajaxurl"), // обработчик
82			data:data, // данные
83			type:'POST', // тип запроса
84			success:function(data){		
85				if( data ) {
86					if( data == 'err') {
87						alert('Ошибка голосования!');
88					} else { 
89					    $('#div-comment-'.concat(data_id)).find('.commentItem__dislike span').text(data);
90					}
91				}
92			}
93		});
94		$.cookie('comment_box_rat_new_plus_minus' + data_id, 'true', { expires: 365 });
95        } else {
96            alert('Вы уже голосовали!')
97        }
98	});
99    
100    $('.author-box__plus').click(function(){
101        var data_id = $(this).attr("data-id");
102        if ($.cookie('author_box_rat_new_plus_minus' + data_id) == null) {
103		var btn = $(this);
104		var data = {
105			'action': 'rating_plus',
106			'post_id' : $(this).attr("data-id")
107		};
108		$.ajax({
109			url: $(this).attr("data-ajaxurl"), // обработчик
110			data:data, // данные
111			type:'POST', // тип запроса
112			success:function(data){		
113				if( data ) {
114					if( data == 'err') {
115						alert('Ошибка голосования!');
116					} else { 
117					    $(".author-box__plus span").text(data); 
118					}
119				}
120			}
121		});
122		$.cookie('author_box_rat_new_plus_minus' + data_id, 'true', { expires: 365 });
123        } else {
124            alert('Вы уже голосовали!')
125        }
126	});
127	
128	$('.author-box__minus').click(function(){
129	    var data_id = $(this).attr("data-id");
130	    if ($.cookie('author_box_rat_new_plus_minus' + data_id) == null) {
131		var btn = $(this);
132		var data = {
133			'action': 'rating_minus',
134			'post_id' : $(this).attr("data-id")
135		};
136		$.ajax({
137			url: $(this).attr("data-ajaxurl"), // обработчик
138			data:data, // данные
139			type:'POST', // тип запроса
140			success:function(data){		
141				if( data ) {
142					if( data == 'err') {
143						alert('Ошибка голосования!');
144					} else { 
145					    $(".author-box__minus span").text(data); 
146					}
147				}
148			}
149		});
150		$.cookie('author_box_rat_new_plus_minus' + data_id, 'true', { expires: 365 });
151        } else {
152            alert('Вы уже голосовали!')
153        }
154	});
155
156 $('.slider').slick({
157    slidesToShow: 5,
158    arrows: false,
159    slidesToScroll: 1,
160    responsive: [
161    {
162      breakpoint: 1500,
163      settings: {
164        slidesToShow: 4,
165        slidesToScroll: 1,
166      }
167    },
168    {
169      breakpoint: 1024,
170      settings: {
171        slidesToShow: 2,
172        slidesToScroll: 1
173      }
174    },
175
176    {
177      breakpoint: 768,
178      settings: {
179        slidesToShow: 1,
180        slidesToScroll: 1
181      }
182    }
183  ]
184 });
185
186 $('.prev-slide').on('click', function() {
187  $('.slider').slick('slickPrev');
188	 //Загружаем изображения если есть
189	 var myLazyLoad = new LazyLoad({elements_selector: "[data-src],[data-bg]",load_delay: 0});
190	 myLazyLoad.update();
191 });
192
193 $('.next-slide').on('click', function() {
194  $('.slider').slick('slickNext');
195	 //Загружаем изображения если есть
196	 var myLazyLoad = new LazyLoad({elements_selector: "[data-src],[data-bg]",load_delay: 0});
197	 myLazyLoad.update();
198 });
199
200 $('.articleList').slick({
201    dots: false,
202    slidesToShow: 4,
203    slidesToScroll: 1,
204    prevArrow: '<div class="prev"></div>',
205    nextArrow: '<div class="next"></div>',
206    responsive: [
207    {
208      breakpoint: 1500,
209      settings: {
210        slidesToShow: 3,
211        slidesToScroll: 1,
212      }
213    },
214    {
215      breakpoint: 1024,
216      settings: {
217        slidesToShow: 2,
218        slidesToScroll: 1
219      }
220    },
221    {
222      breakpoint: 768,
223      settings: {
224        variableWidth: true,
225        arrows: false,
226        slidesToShow: 1, 
227        slidesToScroll: 1
228      }
229    }
230  ]
231 });
232
233$(window).on("scroll", function () {
234    var scrolled = $(this).scrollTop();
235    if( scrolled > 140 ) {
236        $('.header').addClass('scrolled');
237        //$('.logo__img img').attr('src', 'img/icons/small-logo.svg');
238    }   
239    if( scrolled <= 100 ) {     
240        $('.header').removeClass('scrolled');
241       // $('.logo__img img').attr('src', 'img/icons/logo.svg');
242    }
243
244    if (scrolled > 50) {
245       //$('.scroll-top').fadeIn();
246	   $('.scroll-top').show();
247    } else {
248		$('.scroll-top').hide();
249      //$('.scroll-top').fadeOut();
250    }
251
252    var scrollTop = $(window).scrollTop(); 
253    var docHeight = $(document).height(); 
254    var winHeight = $(window).height(); 
255    var scrollPercent = (scrollTop) / (docHeight); 
256    var scrollPercentRounded = Math.round(scrollPercent*100); 
257    //alert(winHeight);
258
259    $('.scroll-top .txt').html(scrollPercentRounded + '%'); 
260      
261    if(scrollPercentRounded > 98) {
262      $('.scroll-top .txt').addClass('txt-white');
263    } else {
264      $('.scroll-top .txt').removeClass('txt-white');
265    }
266});
267
268    $('.scroll-top').click(function () {
269        $('body,html').animate({
270            scrollTop: 0
271        }, 500);
272        return false;
273    });
274
275  
276
277  $('.slider__link').mouseover(function(){
278    $('.slider__link').removeClass('slider__link-active');
279    $(this).addClass('slider__link-active');
280    let img = $(this).data('image');
281
282    if( $('.jddQqE image').attr("xlink:href") == img ) {
283      return false
284    } else {
285      $('.jddQqE image').attr({'xlink:href': img});
286
287      $('.svg1').css( "display", "none" ).css( "top", "-100%" ).css( "display", "block" ).animate({top: "0px"}, 250);
288
289      $('.svg2').css( "display", "none" ).css( "bottom", "-100%" ).css( "display", "block" ).animate({bottom: "0px"}, 250);
290    }
291  });
292
293  if($(window).width() < 720) {
294    $('.slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
295      $('.slider__link').removeClass('slider__link-active');
296
297      $('.slick-active .slider__link').addClass('slider__link-active');
298
299      let img = $('.slick-active .slider__link').data('image');
300
301      if( $('.jddQqE image').attr("xlink:href") == img ) {
302      return false
303    } else {
304      $('.jddQqE image').attr({'xlink:href': img});
305
306      $('.svg1').css( "display", "none" ).css( "top", "-100%" ).css( "display", "block" ).animate({top: "0px"}, 250);
307
308      $('.svg2').css( "display", "none" ).css( "bottom", "-100%" ).css( "display", "block" ).animate({bottom: "0px"}, 250);
309    }
310    });
311
312    
313  }
314  $('.characteristicsItem__title').click(function(){
315    $(this).toggleClass('characteristicsItem__title-active');
316    $(this).parent().find('.characteristicsItem__list').slideToggle('slow');
317  });
318  
319  //
320  // $('button.mobile-header__btn').click(function(){
321  //   $('.mobile-search').slideToggle(200);
322  // });
323
324
325  // $( 'body' ).wrapInner( '<div class="page-wrapper"></div>' );
326  // $('body').append('<nav id="mob-menu"><ul></ul></nav>');
327  // $('.main-menu > li').clone().appendTo("#mob-menu > ul").removeAttr('class');
328  // $('.top-menu > li').clone().appendTo("#mob-menu > ul").removeAttr('class');
329  
330  $(window).on("load scroll", function () {
331    scroll = $(this).scrollTop();
332});
333
334  // t = $("html");
335  //   var c = $("#mob-menu").mmenu({
336  //   offCanvas: {
337  //     position  : 'right'
338  //   },
339  //   navbar: {
340  //     title: "Меню"
341  //   },
342  //   pageScroll : {
343  //     scroll : true,
344  //     update : true,
345  //     scrollOffset : 300
346  //   }
347  //   }).data("mmenu"),
348  //     d = $(".mobile-header__link").on("click", function(e) {
349  //       e.preventDefault(), t.hasClass("mm-opened") ? c.close() : c.open()
350  //     });
351  //           c.bind("close:finish", function() {
352  //             $('.mobile-header').css('top', 0);
353  //             setTimeout(function() {
354  //               d.removeClass("active")
355  //             }, 10)
356  //           }), c.bind("open:finish", function() {
357  //             $('.mobile-header').css('top', scroll);
358  //             setTimeout(function() {
359  //               d.addClass("active")
360  //             }, 10)
361  //           });
362  //
363  // $('.main-menu > li.menu-item-has-children > a').click(function(e) {
364  //   e.preventDefault();
365  //   $(this).toggleClass('link-active');
366  //   $(this).parent().find('> .sub-menu').slideToggle(200);
367  // });
368  //
369  // $('.mm-listview').removeClass('dropdown-menu').removeClass('sub-menu');
370  // $('.mm-listview > li').removeAttr('class');
371
372});
373
374
375	$('.rating_block .item.list').click(function() {
376		var id = $(this).data('tovar'); 
377		if ($.cookie('post_' + $(this).data('id')) == null) {		
378			$.cookie('post_' + $(this).data('id') + '_tovar_'+ $(this).data('tovar'), 'true', { expires: 365 });
379			$.cookie('post_' + $(this).data('id'), 'true', { expires: 365 });
380			$(this).addClass('active');
381			$.ajax({
382				url: '/wp-admin/admin-ajax.php', // обработчик
383				data: 'action=poll&post_id=' + $(this).data('id') + '&tovar=' + $(this).data('tovar'), // данные
384				type:'POST', // тип запроса
385				success:function(data){
386					if( data ) { 
387						$('#pull').hide();
388						$('#result').show('slow');
389						$('#result').removeClass('hidest');
390						$("#result .item[data-tovar=" + id + "]").addClass("active");
391						$("#result .item[data-tovar=" + id + "]").find('.count').text(parseInt($("#result .item[data-tovar=" + id + "]").find('.count').text()) + 1);
392					}
393				}
394			});
395		} else {
396			alert("Вы уже голосовали!");
397			$('#pull').hide();
398			$('#result').removeClass('hidest', 500);
399		}
400	});
401
402$('.rating_block .item:not(.list)').each(function() {
403	if ( $.cookie('post_' + $(this).data('id') + '_tovar_'+ $(this).data('tovar')) != null ) {
404			$(this).addClass('active');
405	}
406});
407
408
409if ( location.hash == '#result' ) {
410	$('#pull').hide();
411			$('#result').removeClass('hidest', 500);
412}
413$('span.show-result').click(function() {
414	$('#pull').hide();
415			$('#result').removeClass('hidest', 500);
416});
417
418$('span.show-pull').click(function() {
419	$('#pull').show();
420			$('#result').addClass('hidest', 500);
421});
422
423$(".opros_link").on("click","a", function (event) {
424        event.preventDefault();
425        var id  = $(this).attr('href'),
426            top = $(id).offset().top;
427        $('body,html').animate({scrollTop: top}, 1500);
428    });

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.