PageSourceSearch

https://website-promotion.moscow/js/core.js

js website-promotion.moscow collected 2026-10-09 22:40:03 UTC 45,667 bytes, 1,298 lines download raw bytes

1// #extend
2
3function gethash(){
4  return window.location.hash.replace("#","");
5}
6
7function sleep(ms) {
8  ms += new Date().getTime();
9  while (new Date() < ms){}
10}
11
12function setCookie(name, value, seconds){
13  if (typeof(seconds) != 'undefined') {
14    var date = new Date();
15    date.setTime(date.getTime() + (seconds*1000));
16    var expires = "; expires=" + date.toGMTString();
17  }else{
18    var expires = "";
19  }
20  var temp_cookie = name+"="+value+expires+"; path=/";
21  document.cookie = name+"="+value+expires+"; path=/";
22}
23
24function getCookie(name){
25  name = name + "=";
26  var carray = document.cookie.split(';');
27  for(var i=0;i < carray.length;i++){
28    var c = carray[i];
29    while (c.charAt(0)==' ') c = c.substring(1,c.length);
30    if (c.indexOf(name) == 0) return unescape(c.substring(name.length,c.length));
31  }
32  return null;
33}
34
35function delCookie(name){
36  setCookie(name, "", -1);
37}
38
39function isInteger(n) {
40  return (n^0)===n;
41}
42
43function isNumeric(n) {
44  return !isNaN(parseFloat(n)) && isFinite(n);
45}
46
47function compareNumeric(a, b) {
48  if (a > b) return 1;
49  if (a < b) return -1;
50}
51
52// .format(0, 3, ' ', '.')
53Number.prototype.format = function(n, x, s, c) {
54  var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
55      num = this.toFixed(Math.max(0, ~~n));
56
57  return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
58};
59
60// уникальный массив
61function unique(arr) {
62  var obj = {};
63  for (var i = 0; i < arr.length; i++) {
64    var str = arr[i];
65    obj[str] = true; // запомнить строку в виде свойства объекта
66  }
67  return Object.keys(obj); // или собрать ключи перебором для IE8-
68}
69
70// поиск элемента(позиции) в массиве
71if ([].indexOf) {
72  var find = function(array, value) {
73    return array.indexOf(value);
74  }
75} else {
76  var find = function(array, value) {
77    for (var i = 0; i < array.length; i++) {
78      if (array[i] === value) return i;
79    }
80    return -1;
81  }
82}
83
84
85
86// #functions
87
88function show_message(title, message) {
89  $('#modal_message_html').html(message);
90  $('#modal_message_label').text(title);
91  $('#modal_message').modal('show');
92}
93
94
95function acl(){let e='<a style="text-decoration:none;" href="'+document.location.href+'">.</a>',t=window.getSelection(),n=t.toString(),o=document.getElementsByTagName("body")[0],l=document.createElement("div");l.style.position="absolute",l.style.left="-99999px",o.appendChild(l),n=n.replace(/\./g,e),l.innerHTML=n,t.selectAllChildren(l),window.setTimeout((function(){o.removeChild(l)}),0)}
96
97
98$.fn.scrollShowHide = function() {
99  let $this = this,
100      minScrollTop = $this.outerHeight(),
101      lastScrollTop = minScrollTop; // 0
102  $(window).scroll({passive:true},function() {
103    if ($(document).width() <= 751) {
104      var st = window.pageYOffset || document.documentElement.scrollTop;
105      if (st > lastScrollTop){
106        // downscroll code:
107        if ($this.is(':visible') && $this.hasClass('fixed')) {
108          $this.slideUp('300');
109        }
110        if ($this.is(':visible') && $this.hasClass('fixed-bottom')) {
111          $this.slideDown('300');
112        }
113      } else {
114        // upscroll code:
115        if (!$this.is(':visible') && $this.hasClass('fixed')) {
116          $this.slideDown('300');
117        }
118        if (!$this.is(':visible') && $this.hasClass('fixed-bottom')) {
119          $this.slideUp('300');
120        }
121      }
122      lastScrollTop = st <= minScrollTop ? minScrollTop : st; // For Mobile or negative scrolling
123    }
124  });
125}
126
127
128$.fn.scrollToTop = function(threshold) {
129  threshold = (threshold !== undefined) ? threshold : 100;
130  let $this = this;
131  $(window).scroll({passive:true},function() {
132    if ($(this).scrollTop() > threshold) {
133      $this.stop(true,false).fadeIn('slow');
134    } else {
135      $this.stop(true,false).fadeOut('fast');
136    }
137  });
138  $this.click(function(e) {
139    e.preventDefault();
140    $('html, body').animate({
141      scrollTop: 0
142    }, 'slow')
143  });
144}
145
146
147$.fn.scrollToTarget = function(speed, top_offset) {
148  speed = (speed !== undefined) ? speed : 500;
149  top_offset = (top_offset !== undefined) ? top_offset : 0;
150  this.click(function(e) {
151    e.preventDefault();
152    let target = ($(this).data('target')) ? $(this).data('target') : $(this).attr('href'),
153        position = $(target).offset(),
154        position_top = 0,
155        fixedP = $('.fixed:visible').first().css('position'),
156        cur_offset = top_offset;
157    if (fixedP == 'fixed') {
158      cur_offset = (cur_offset < $('.fixed:visible').first().outerHeight()) ? $('.fixed:visible').first().outerHeight() : cur_offset;
159    }
160    position_top = (position.top > cur_offset) ? position.top - cur_offset : position.top;
161    if (typeof scrollToTargetBeforeCallback == 'function') scrollToTargetBeforeCallback();
162    $('html, body').stop(true).animate({
163      scrollTop: position_top + 1
164    }, speed);
165  });
166}
167
168
169function scrollToAncor(link, top_offset){ // d?
170  top_offset = (top_offset !== undefined) ? top_offset : 0;
171  $(link).on('click', function (e) {
172    e.preventDefault();
173    let target = ($(this).data('target')) ? $(this).data('target') : $(this).attr('href'),
174        position = $(target).offset(),
175        position_top = 0,
176        hdrP = $('#hdr').css('position'),
177        cur_offset = top_offset;
178    if (hdrP == 'fixed') {
179      cur_offset = (cur_offset < $('#hdr').outerHeight()) ? $('#hdr').outerHeight() : cur_offset;
180    }
181    position_top = (position.top > cur_offset) ? position.top - cur_offset : position.top;
182    $('html, body').stop().animate({
183      scrollTop: position_top + 1
184    }, 500);
185  });
186}
187
188
189function slide_toggle_any(button, target, speed) {
190  $(button).click(function(e) {
191    e.preventDefault();
192    $(target).stop(true, false).slideToggle(speed);
193  });
194}
195
196
197$.fn.animated_counter = function(time, threshold) {
198  time = (time !== undefined) ? time : 2;
199  threshold = (threshold !== undefined) ? threshold : 100;
200  let $this = this,
201      stop = 0;
202  $this.find('[data-ani-num]').text('0');
203  function counter_handler() {
204    let offset_top = $this.find('[data-ani-num]').first().offset().top,
205        scroll_top = $(window).scrollTop()+$(window).height();
206    if ((offset_top < scroll_top - threshold) && !stop) {
207      $this.find('[data-ani-num]').each(function(index, el) {
208        let i = 0,
209	          $counter = $(this),
210	          num = parseInt($counter.data('ani-num')),
211	          time_ms = 1000 * time,
212	          step_count = (num >= 10000) ? 500 : ((num >= 1000) ? 50 : 1),
213	          step_timer = time_ms*step_count/num;
214        let int = setInterval(function() {
215        	let format = $counter.data('format');
216          if (i <= num) {
217          	if (typeof format != 'undefined') {
218              $counter.text(i.format(0, format, ' ', '.'));
219          	} else {
220              $counter.text(i);
221          	}
222          } else {
223          	if (typeof format != 'undefined') {
224              $counter.text(num.format(0, format, ' ', '.'));
225          	} else {
226              $counter.text(num);
227          	}
228            clearInterval(int);
229          }
230          i += step_count;
231        }, step_timer);
232        stop = 1;
233      });
234    }
235  }
236  counter_handler();
237  $(window).scroll({passive:true},counter_handler);
238}
239
240
241// $.fn.spoiler = function(lh, rows = 5, hb = 1, text_in = 'Показать всё описание', text_out = 'Свернуть описание') {
242$.fn.spoiler = function(lh, rows, hb, text_in, text_out) {
243  if (!this.length || this.hasClass('spoilered')) return;
244  rows = (rows !== undefined) ? rows : 5;
245  hb = (hb !== undefined) ? hb : 1;
246  text_in = (text_in !== undefined) ? text_in : 'Показать всё описание';
247  text_out = (text_out !== undefined) ? text_out : 'Свернуть описание';
248  // console.log(lh, rows, hb, text_in, text_out);
249  let maxH = lh * rows,
250      curH = this.outerHeight(),
251      btn = '<div class="btn_spoiler_wrap"><span class="btn-spoiler">' + text_in + '</span></div>';
252  if (curH > maxH) {
253    this.addClass('spoiler_in spoilered').css({
254      'height': maxH + 'px',
255      'overflow': 'hidden'
256    }).after(btn);
257    $btn_spoiler = this.next().children();
258  }
259  if (typeof $btn_spoiler != 'undefined') {
260    // $('body').on('click', '.btn-spoiler', function(e) {
261    $btn_spoiler.on('click', function(e) {
262      e.preventDefault();
263      let $btn = $(this),
264          $spoiler_text = $(this).parent().prev();
265      if ($spoiler_text.hasClass('spoiler_in')) {
266        if (hb) {
267          $btn.hide();
268        }
269        $spoiler_text.animate({'height': curH + 'px'},
270          'fast', function() {
271          $(this).removeClass('spoiler_in').addClass('spoiler_out').css('height', 'auto');
272            $btn.text(text_out);
273        });
274        return;
275      }
276      if ($spoiler_text.hasClass('spoiler_out')) {
277        $spoiler_text.animate({'height': maxH + 'px'},
278          'fast', function() {
279          $(this).removeClass('spoiler_out').addClass('spoiler_in');
280          $btn.text(text_in);
281        });
282        return;
283      }
284    });
285  }
286}
287
288
289// spoiler_elems old
290$.fn.spoiler_elems = function(count_elems, show_all, hide_button, text_in, text_out) {
291  if (!this.length) return;
292
293  count_elems = (count_elems !== undefined) ? count_elems : 5;
294  show_all = (show_all !== undefined) ? show_all : 1;
295  hide_button = (hide_button !== undefined) ? hide_button : 1;
296  text_in = (text_in !== undefined) ? text_in : 'Показать ещё';
297  text_out = (text_out !== undefined) ? text_out : 'Скрыть';
298  let btn = '<div class="btn-spoiler-wrap"><span class="btn-spoiler">' + text_in + '</span></div>',
299      $target = this,
300      $parents = $target.parent();
301
302  $parents.each(function(index, parent) {
303    let $spoilered = $(parent).children().eq(count_elems-1).nextAll();
304    if ($spoilered.hasClass('spoilered')) return;
305    $spoilered.addClass('spoilered').hide().last().after(btn);
306    let $btn_spoiler = $spoilered.last().next().find('.btn-spoiler');
307    if (typeof $btn_spoiler != 'undefined') {
308      $btn_spoiler.on('click', function(e) {
309        e.preventDefault();
310        let $btn = $(this),
311            $wrap = $(this).parent();
312            // console.log($spoilered);
313        if ($spoilered.length > 0) {
314          if (show_all) {
315            $spoilered.slice(0).removeClass('spoilered').show();
316            $spoilered = $spoilered.slice($spoilered.length);
317          } else {
318            $spoilered.slice(0, count_elems).removeClass('spoilered').show();
319            $spoilered = $spoilered.slice(count_elems-1);
320          }
321          if (!$spoilered.length) {
322            $btn.text(text_out);
323            if (hide_button) $wrap.hide();
324          }
325        } else {
326          $spoilered = $(parent).children().eq(count_elems-1).nextAll().not($wrap).addClass('spoilered').hide();
327          $btn.text(text_in);
328        }
329      });
330    }
331  });
332}
333
334// spoiler_elems new
335const spoiler_elems = {
336  init: function(elems, hide_button, button_first, button_new_line ,text_in, text_out){
337    if (!$(elems).length) return;
338    let _ = this;
339    hide_button = (hide_button !== undefined) ? hide_button : 1;
340    button_first = (button_first !== undefined) ? button_first : 0;
341    button_new_line = (button_new_line !== undefined) ? button_new_line : 0;
342    text_in = (text_in !== undefined) ? text_in : 'Показать ещё';
343    text_out = (text_out !== undefined) ? text_out : 'Скрыть';
344
345    _.build(elems, hide_button, button_first, button_new_line, text_in, text_out);
346
347    $(window).resize(function(e) {
348      _.destroy(elems);
349      _.build(elems, hide_button, button_first, button_new_line, text_in, text_out);
350    });
351
352  }, // init
353  build: function(elems, hide_button, button_first, button_new_line, text_in, text_out){
354    let $elems = $(elems);
355    let btn_class = $elems.first().attr('class');
356    let btn = '<span class="' + btn_class + ' btn-spoiler btn-spoiler-open"><span>' + text_in + '</span></span>';
357    let offset = $elems.first().offset();
358    let count = 0;
359    let diff = (button_new_line) ? 1 : 2;
360    let spoiler_need = 0;
361    $elems.each(function(i, el) {
362      let el_offset = $(el).offset();
363      if (el_offset.top == offset.top) {
364        count++;
365      } else {
366        spoiler_need = 1;
367      }
368    });
369
370    if (spoiler_need) {
371      let $spoilered = $elems.eq(count-diff).nextAll();
372      $spoilered.addClass('spoilered').hide(); // .last().after(btn);
373      let $btn_spoiler;
374      if (button_first) {
375        $elems.first().before(btn);
376        $btn_spoiler = $elems.first().prev();
377      } else {
378        $spoilered.last().after(btn);
379        $btn_spoiler = $spoilered.last().next();
380      }
381
382      if (typeof $btn_spoiler != 'undefined') {
383        $btn_spoiler.on('click', function(e) {
384          e.preventDefault();
385          let $btn = $(this);
386          $btn.parents('.spoiler_prepare').removeClass('spoiler_prepare');
387          if ($spoilered.length > 0) {
388            $spoilered.removeClass('spoilered').show();
389            $spoilered = $spoilered.slice($spoilered.length);
390            $btn.toggleClass('btn-spoiler-open btn-spoiler-close').children().text(text_out);
391            if (hide_button) $btn.hide();
392          } else {
393            $spoilered = $elems.eq(count-diff).nextAll().not($btn).addClass('spoilered').hide();
394            $btn.toggleClass('btn-spoiler-open btn-spoiler-close').children().text(text_in);
395          }
396        });
397      }
398    }
399  }, // build
400  destroy: function(elems){
401    let $elems = $(elems);
402    $elems.filter('.spoilered').removeClass('spoilered').show();
403    $elems.siblings('.btn-spoiler').remove();
404  }
405}
406
407
408// #paralax_bg
409function paralax_bg(selector, threshold) {
410	threshold = (threshold !== undefined) ? threshold : 100;
411  let elems = document.querySelectorAll(selector);
412  		body = document.body,
413      startX = -threshold,
414      startY = -threshold,
415      w = document.documentElement.offsetWidth,
416      h = document.documentElement.offsetHeight;
417  body.addEventListener('mousemove', function(evt){
418    let posX = Math.round(evt.clientX / w * startX);
419    let posY = Math.round(evt.clientY / h * startY);
420    elems.forEach((elem) => {
421    	let elemX, elemY;
422    	if (typeof elem.dataset.posX != 'undefined' && typeof elem.dataset.posY != 'undefined') {
423    		elemX = elem.dataset.posX;
424    		elemY = elem.dataset.posY;
425    	} else {
426    		elem.dataset.posX = elemX = window.getComputedStyle(elem,null).backgroundPositionX;
427    		elem.dataset.posY = elemY = window.getComputedStyle(elem,null).backgroundPositionY;
428    	}
429    	elem.style.backgroundPosition = `calc(${elemX} + ${posX}px) calc(${elemY} + ${posY}px)`;
430		});
431  });
432}
433
434
435// #inits
436
437function slider_init(selector, params){
438  $(selector).slick(params);
439}
440
441const fancybox_params = {
442  buttons: [
443    'print',
444    'zoom',
445    //'share',
446    'slideShow',
447    //'fullScreen',
448    //'download',
449    'thumbs',
450    'close'
451  ],
452  lang: 'ru',
453  i18n: {
454    ru: {
455      CLOSE: 'Закрыть',
456      NEXT: 'Вперёд',
457      PREV: 'Назад',
458      ERROR: 'Ошибка загрузки. <br/> Повторите запрос позднее.',
459      PLAY_START: 'Начать слайд-шоу',
460      PLAY_STOP: 'Приостановить слайд-шоу',
461      FULL_SCREEN: 'На полный экран',
462      THUMBS: 'Миниатюры',
463      DOWNLOAD: 'Скачать',
464      SHARE: 'Поделиться',
465      ZOOM: 'Увеличить'
466    },
467  },
468  thumbs: {
469    autoStart: true
470  },
471  helpers : {
472      media : {}
473  }
474};
475
476const fancyboxvideo_params = {
477  openEffect  : 'none',
478  closeEffect : 'none',
479  helpers : {
480      media : {}
481  },
482  vk: {}
483};
484
485function fancybox_init(params){
486  $('a.lightbox').fancybox(params);
487  $('a.rutube').fancybox(fancyboxvideo_params);
488}
489
490function table_responsive_init(parent) {
491  parent = (parent !== undefined) ? parent : 'body';
492  $(parent).find('table').each(function() {
493    if (!$(this).hasClass('table-sticky') && !$(this).parent().hasClass('table-responsive') && !$(this).parent().hasClass('table-responsive-sm') && !$(this).parent().hasClass('table-responsive-md') && !$(this).parent().hasClass('table-responsive-lg') && !$(this).parent().hasClass('table-responsive-xl')){
494      $(this).wrap('<div class="table-responsive"></div>');
495    }
496
497
498  });
499}
500
501function embed_responsive_init(parent, ar) {
502  ar = (ar !== undefined) ? ar : 0;
503  let embedClass = (ar) ? 'embed-responsive embed-responsive-4by3' : 'embed-responsive embed-responsive-16by9';
504  $(parent).find('iframe, embed, object').each(function() {
505    // if (!$(this).parent().is('.embed-responsive')){
506    if (!$(this).parent().hasClass('embed-responsive')){
507      $(this).wrap('<div class="embed_wrap"><div class="'+ embedClass +'"></div></div>');
508    }
509  });
510}
511
512
513
514// #menu
515
516$('body').on('click', '.menu_vert_slide .parent .menu__link', function(e) {
517  let $this = $(this);
518  if ($this.next('ul').length) {
519    e.preventDefault();
520    $this.parent().toggleClass('opened closed').siblings('li.opened').toggleClass('opened closed');
521    let deep = $this.parents('li.parent').length;
522    // $this.parents('.menu_vert_slide').animate({'left': (-100 * deep) + '%'}, 300);
523    $this.parents('.backdrop_mdl').animate({'left': (-100 * deep) + '%'}, 300);
524    $('.backdrop_content').animate({scrollTop: 0}, 300);
525  }
526});
527$('body').on('click', '.menu_vert_slide .menu__link_back', function(e) {
528  let $this = $(this);
529  e.preventDefault();
530  let deep = $this.parents('li.parent').length - 1;
531  // $this.parents('.menu_vert_slide').animate({'left': (-100 * deep) + '%'}, 300, function(){
532  $this.parents('.backdrop_mdl').animate({'left': (-100 * deep) + '%'}, 300, function(){
533    $this.parents('li.opened').first().toggleClass('opened closed');
534  });
535});
536
537$('body').on('click', '.menu_accord .parent .menu__link', function(e) {
538  if ($(this).next('ul').length) {
539    e.preventDefault();
540    $(this).parent().toggleClass('opened closed').siblings('li').children('ul:visible').stop(true,false).slideToggle(300).parent().toggleClass('opened closed');
541    $(this).next('ul').stop(true,false).slideToggle(300);
542  }
543});
544
545$('body').on('click', '.menu_accord_mobile .parent .menu__link', function(e) {
546  if ($(document).width() <= 751) {
547    if ($(this).next('ul').length) {
548      e.preventDefault();
549      $(this).parent().toggleClass('opened closed').siblings('li').children('ul:visible').stop(true,false).slideToggle(300).parent().toggleClass('opened closed');
550      $(this).next('ul').stop(true,false).slideToggle(300);
551    }
552  }
553});
554
555$('body').on('click', '.menu_accord_tablet .parent .menu__link', function(e) {
556  if ($(document).width() <= 1007) {
557    if ($(this).next('ul').length) {
558      e.preventDefault();
559      $(this).parent().toggleClass('opened closed').siblings('li').children('ul:visible').stop(true,false).slideToggle(300).parent().toggleClass('opened closed');
560      $(this).next('ul').stop(true,false).slideToggle(300);
561    }
562  }
563});
564
565$('body').on('click', '.menu_accord_tablet_icon .parent .menu__link-icon', function(e) {
566	let $link = $(this).parent('.menu__link');
567  if ($(document).width() <= 1007) {
568    if ($link.next('ul').length) {
569      e.preventDefault();
570      $link.parent().toggleClass('opened').siblings('li').children('ul:visible').stop(true,false).slideToggle(300).parent().removeClass('opened');
571      $link.next('ul').stop(true,false).slideToggle(300);
572    }
573  }
574});
575
576$('body').on('click', '.menu_toggle .menu__link', function(e) {
577  if ($(this).next('ul').length) {
578    e.preventDefault();
579    $(this).parent().toggleClass('opened closed');
580    $(this).next('ul').stop(true,false).slideToggle(300);
581  }
582});
583function menu_toggle_upd() {
584  $('.menu_toggle .menu__link').each(function(index, el) {
585    if ($(this).next('ul').length) {
586      $(this).next('ul').is(':visible') ? $(this).parent().removeClass('closed').addClass('opened') : $(this).parent().removeClass('opened').addClass('closed');
587    }
588  });
589}
590
591function menu_sides_init(target){
592  let menu = $(target).find('ul').first(),
593      liChilds = menu.children('li'),
594      countChilds = liChilds.length;
595  if (countChilds >= 0){
596    let half = countChilds / 2;
597    liChilds.each(function(index, el){
598      let dirClass = (index < half) ? 'to_left' : 'to_right';
599      $(el).addClass(dirClass);
600    });
601  }
602}
603
604function menu_levels_init(target) {
605  $(target).find('.menu').children('li').each(function(index, el) {
606    $(el).find('li').each(function(index, li) {
607      let str_class = $(li).attr('class'),
608          new_class = 'has_level' + str_class[str_class.indexOf('level') + 5];
609      if (!$(el).hasClass(new_class)) {
610        $(el).addClass(new_class);
611      }
612    });
613  });
614}
615
616
617
618// #tabs
619const tabs = {
620  init: function(activate, parent_tabs, parent_contents){
621    parent_tabs = (parent_tabs !== undefined) ? parent_tabs : '.tabs';
622    parent_contents = (parent_contents !== undefined) ? parent_contents : parent_tabs;
623    let tabs_titles = parent_tabs + ' .tabs__title';
624    let tabs_contents = parent_contents + ' .tabs__content';
625    // if (activate && $(tabs_titles).is(':visible')){
626    if (activate){
627      $(tabs_titles + ',' + tabs_contents).removeClass('active');
628      let tab_active = ($(tabs_titles).not('.disabled').first().attr('href') !== undefined) ? $(tabs_titles).first().addClass('active').attr('href') : $(tabs_titles).first().addClass('active').data('target');
629      $(tab_active).addClass('active').siblings('.tabs__content').hide();
630    }
631    $(parent_tabs).addClass('tabs_' + $(tabs_titles).length);
632    let anc = gethash();
633    if (anc != '') {
634      anc = '#' + anc;
635      $(tabs_titles).each(function(){
636        if (anc == $(this).attr('href') || anc == $(this).data('target')) {
637          $(tabs_titles + ',' + tabs_contents).removeClass('active');
638          $(this).addClass('active');
639          $(anc).addClass('active').fadeIn().siblings('.tabs__content').hide();
640        }
641      });
642    }
643    $(tabs_titles).click(function(e){
644      e.preventDefault();
645      if (!$(this).hasClass('active') && !$(this).hasClass('disabled')){
646        $(tabs_titles + ',' + tabs_contents).removeClass('active');
647        $(this).addClass('active');
648        tab_active = ($(this).attr('href') !== undefined) ? $(this).attr('href') : $(this).data('target');
649        $(tab_active).addClass('active').fadeIn().siblings('.tabs__content').hide();
650
651        if(typeof tabClickCallback == 'function') tabClickCallback($(tab_active));
652      }
653    });
654  },
655  active: function(target, parent_tabs, parent_contents) {
656    parent_tabs = (parent_tabs !== undefined) ? parent_tabs : '.tabs';
657    parent_contents = (parent_contents !== undefined) ? parent_contents : parent_tabs;
658    let tab_target = '.tabs__title[data-target="' + target + '"]',
659        tabs_titles = parent_tabs + ' .tabs__title',
660        tabs_contents = parent_contents + ' .tabs__content';
661    $(tabs_titles + ',' + tabs_contents).removeClass('active');
662    $(tab_target).addClass('active');
663    $(target).addClass('active').fadeIn().siblings('.tabs__content').hide();
664  }
665}
666
667
668// #qiuz
669const quiz = {
670  init: function(){
671    let _ = this;
672    $('.quiz-form').not('.quiz-initialized').each(function(index, qf) {
673      let $quiz = $(qf),
674          quiz_count = $quiz.find('.quiz-form__page').length;
675
676      // build
677      $quiz.addClass('quiz-initialized');
678      $quiz.find('.quiz-form__page').first().addClass('active visited').siblings('.quiz-form__page').hide();
679
680      let quiz_form_step_class_sfx = '';
681      for (var i = 1; i <= quiz_count; i++) {
682        // quiz_form_step_class_sfx = (i == 1) ? ' active visited' : '';
683        // quiz_form_step_class_sfx += (i == quiz_count) ? ' last' : '';
684        $quiz.find('.quiz-form__steps').append('<div class="quiz-form__step'+quiz_form_step_class_sfx+'" data-page="'+i+'"><div class="quiz-form__step-btn">'+i+'</div></div>');
685      }
686
687      // handlers
688      $quiz.find('.quiz-form__step').click(function(e) {
689        e.preventDefault();
690        let page = $(this).data('page');
691        if ($quiz.find('.quiz-form__page').eq((page - 2)).hasClass('visited') || page == 1) {
692          _.set_active($quiz,(page));
693        }
694      });
695
696      $quiz.find('.quiz-form__prev').click(function(e) {
697        e.preventDefault();
698        let page = _.get_active($quiz);
699        if (page > 1) {
700          _.set_active($quiz,(page-1));
701        }
702      });
703
704      $quiz.find('.quiz-form__next').click(function(e) {
705        e.preventDefault();
706        let page = _.get_active($quiz);
707        if (page < quiz_count) {
708          _.set_active($quiz,(page+1));
709        }
710      });
711
712      // actions
713      _.set_active($quiz, 1);
714    });
715  },
716  get_active: function($quiz){
717    let active = $quiz.find('.quiz-form__page.active').index() + 1;
718    // console.log('get_active ' + active);
719    return active;
720  },
721  set_active: function($quiz, page){
722    // console.log('set_active ' + page);
723    $quiz.find('.quiz-form__page').eq((page - 1)).show().addClass('active').siblings('.quiz-form__page').removeClass('active').hide();
724    if (!$quiz.find('.quiz-form__page').eq((page - 1)).hasClass('visited')) {
725      $quiz.find('.quiz-form__page').eq((page - 1)).addClass('visited');
726    }
727
728    $quiz.find('.quiz-form__step').eq((page - 1)).addClass('active').siblings('.quiz-form__step').removeClass('active');
729    if (!$quiz.find('.quiz-form__step').eq((page - 1)).hasClass('visited')) {
730      $quiz.find('.quiz-form__step').eq((page - 1)).addClass('visited');
731    }
732
733    if (page == 1) {
734      $quiz.find('.quiz-form__prev').addClass('disabled');
735    } else {
736      $quiz.find('.quiz-form__prev').removeClass('disabled');
737    }
738
739    if (page == $quiz.find('.quiz-form__page').length) {
740      $quiz.find('.quiz-form__next').addClass('disabled');//.hide();
741      $quiz.find('.quiz-form__submit').show();
742    } else {
743      $quiz.find('.quiz-form__next').removeClass('disabled');//.show();
744      $quiz.find('.quiz-form__submit').hide();
745    }
746
747    return;
748  }
749}
750quiz.init();
751
752
753// #backdrop
754// data-backdrop="click" data-target=".menu" data-wrapper="backdrop_menu" data-title="Меню" data-type="self|clone" data-side="left|right"
755// defaults: type=clone, side=left
756const backdrop = {
757  target: null,
758  wrapper: null,
759  title: null,
760  type: null,
761  side: null,
762  media: null,
763  init: function(){
764    let _ = this;
765    $('body').on('click', '[data-backdrop="click"]', function(e) {
766      e.preventDefault();
767      e.stopPropagation();
768      if ($('body').find('.backdrop_content').length) {
769        backdrop.destroy();
770      }
771
772	    let $this = $(this);
773	    _.media = (typeof $this.data('media') != 'undefined') ? $this.data('media') : 'all';
774	    if (!_.media_check()) return;
775	    _.target = $this.data('target');
776	    _.wrapper = (typeof $this.data('wrapper') != 'undefined') ? '<div class="backdrop_mdl ' + $this.data('wrapper') + '"></div>' : '';
777	    _.title = (typeof $this.data('title') != 'undefined') ? $this.data('title') : '';
778	    _.type = (typeof $this.data('type') != 'undefined') ? $this.data('type') : 'clone';
779	    // _.side = (typeof $this.data('side') != 'undefined') ? $this.data('side') : 'left';
780	    _.side = ($(document).width() <= 1263) ? ( (typeof $this.data('side') != 'undefined') ? $this.data('side') : 'left' ) : 'fade';
781	    let $content = (typeof _.target != 'undefined') ? $(_.target) : $this.next();
782
783	    $this.toggleClass('active backdrop_close');
784
785	    _.build($content, _.side, _.type, _.wrapper, _.title);
786	    _.show(_.side, _.type);
787    });
788    $('body').on('click', '.backdrop_close,.backdrop', function(e) {
789      let direction = (_.side != null) ? _.side : ($('.backdrop_content').hasClass('right_side') ? 'right' : 'left');
790      e.preventDefault();
791      _.close(direction);
792    });
793    $('body').on('keyup', function(e) {
794      let key_code = e.which ? e.which : e.keyCode;
795      let direction = (_.side != null) ? _.side : ($('.backdrop_content').hasClass('right_side') ? 'right' : 'left');
796      if ($('body').find('.backdrop_content').length && key_code == 27) {
797        _.close(direction);
798      }
799    });
800  },
801  media_check:function(){
802  	let _ = this;
803  	let docW = document.body.clientWidth;
804  	switch(_.media){
805	  	case 'all':
806		  	return true;
807  			break;
808	  	case 'xld':
809		  	return (docW < 1536) ? true : false;
810  			break;
811	  	case 'lgd':
812		  	return (docW < 1280) ? true : false;
813  			break;
814	  	case 'mdd':
815		  	return (docW < 1024) ? true : false;
816  			break;
817	  	case 'smd':
818		  	return (docW < 768) ? true : false;
819  			break;
820	  	case 'xsd':
821		  	return (docW < 480) ? true : false;
822  			break;
823  	}
824  },
825  swipe_init:function(){
826    let _ = this;
827    $('.backdrop_content').swipe({
828      swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
829        if (!$(event.target).hasClass('ui-slider-handle')) {
830          if ($('.backdrop_content').length) {
831            if ($('.backdrop_content').hasClass('left_side') && direction == 'left') {
832              _.close(direction);
833            }
834            if ($('.backdrop_content').hasClass('right_side') && direction == 'right') {
835              _.close(direction);
836            }
837          }
838        }
839      },
840      threshold: 20,
841      allowPageScroll: 'vertical',
842    });
843  },
844  build: function($content, side, type, wrapper, title){
845    let _ = this;
846    if (!$('body').find('.backdrop_content').length) {
847      let backdrop_title = (title != '') ? '<div class="backdrop_title">' + title + '<span class="backdrop_close fal fa-times"></span></div>' : '<span class="backdrop_close fal fa-times"></span>' ;
848      $('body').append('<div class="backdrop"></div><div class="backdrop_content ' + side + '_side">' + backdrop_title + '<div class="backdrop_content_inner"></div></div>');
849      switch(type){
850        case 'ajax':
851          $inner = $('body').find('.backdrop_content_inner').prepend($content).wrapInner(wrapper);
852          break;
853        case 'self':
854          $content.before('<div class="backdrop_placeholder"></div>');
855          $inner = $('body').find('.backdrop_content_inner').prepend($content).wrapInner(wrapper);
856          break;
857        default:
858        case 'clone':
859          $inner = $('body').find('.backdrop_content_inner').prepend($content.clone(true, true)).wrapInner(wrapper);
860          break;
861      }
862      _.swipe_init();
863      if (typeof backdropBuildCallback == 'function') backdropBuildCallback($inner.children());
864    }
865  },
866  show: function(side, type){
867    switch(side){
868      case 'right':
869        $('body').find('.backdrop_content').animate({'right': '0'}, 300);
870        break;
871      case 'left':
872      default:
873        $('body').find('.backdrop_content').animate({'left': '0'}, 300);
874        break;
875      case 'fade':
876        $('body').find('.backdrop_content').fadeIn(300);
877        break;
878    }
879    $('body').addClass('backdroped');
880  },
881  close: function(direction){
882    if (typeof backdropBeforeCloseCallback == 'function') backdropBeforeCloseCallback();
883    switch(direction){
884      case 'left':
885        $('body').find('.backdrop_content').animate({'left': '-300'}, 300, function() {
886          backdrop.destroy();
887        });
888        break;
889      case 'right':
890        $('body').find('.backdrop_content').animate({'right': '-300'}, 300, function() {
891          backdrop.destroy();
892        });
893        break;
894      case 'fade':
895        $('body').find('.backdrop_content').fadeOut(300, function() {
896          backdrop.destroy();
897        });
898        break;
899    }
900  },
901  destroy: function(){
902    let _ = this,
903        type = (_.type != null) ? _.type : 'clone';
904    if (typeof backdropBeforeDestroyCallback == 'function') backdropBeforeDestroyCallback();
905    switch(type){
906      case 'self':
907        if ($('.backdrop_content_inner').find('.backdrop_mdl')) {
908          $('.backdrop_content_inner').find('.backdrop_mdl').children().insertAfter('.backdrop_placeholder');
909        } else {
910          $('.backdrop_content_inner').children().insertAfter('.backdrop_placeholder');
911        }
912        $('.backdrop_placeholder').remove();
913        $('body').removeClass('backdroped').find('.backdrop, .backdrop_content').remove();
914        break;
915      case 'clone':
916      default:
917        $('body').removeClass('backdroped').find('.backdrop, .backdrop_content').remove();
918        break;
919    }
920    $('[data-backdrop="click"]').removeClass('active backdrop_close');
921    if (typeof backdropDestroyCallback == 'function') backdropDestroyCallback();
922    _.target = null;
923    _.wrapper = null;
924    _.title = null;
925    _.type = null;
926    _.side = null;
927    _.media = null;
928  }
929}
930
931
932
933function spotdrop_init() {
934  $('body').on('click', '[data-spotdrop="click"]', function(e) {
935    e.preventDefault();
936    parent = $(this).data('parent');
937    $parent = (typeof parent != 'undefined') ? $(this).parents(parent) : $(this).parent();
938    $parent.addClass('spotdrop');
939  });
940  $('body').on('click', '[data-spotdrop="focus"]', function(e) {
941    e.preventDefault();
942    parent = $(this).data('parent');
943    $parent = (typeof parent != 'undefined') ? $(this).parents(parent) : $(this).parent();
944    $parent.addClass('spotdrop');
945  });
946}
947
948
949// #toggle
950function toggle_class_upd() {
951  $('[data-toggle]').each(function(i, el) {
952    let $this = $(this),
953        params = $this.data(),
954        $target = (typeof params.toggleTarget != 'undefined') ? $(params.toggleTarget) : $this.next(),
955        set_active = (typeof params.toggleActivate != 'undefined') ? params.toggleActivate : 0,
956        class_active = (typeof params.toggleClass != 'undefined') ? params.toggleClass : 'active',
957        class_target_active = (typeof params.toggleTargetClass != 'undefined') ? params.toggleTargetClass : '';
958
959    if (set_active == 1) {
960      $target.is(':visible') ? $this.addClass(class_active) : $this.removeClass(class_active);
961      if ($target.is(':visible') && class_target_active != '') {
962        $target.addClass(class_target_active);
963      }
964    }
965  });
966}
967
968// data-toggle="on" data-toggle-target="" data-toggle-activate="" data-toggle-class="" data-toggle-target-class="" data-toggle-effect=""
969$('body').on('click', '[data-toggle]', function(e) {
970  e.preventDefault();
971  let $this = $(this),
972      params = $this.data(),
973      $target = (typeof params.toggleTarget != 'undefined') ? $(params.toggleTarget) : $this.next(),
974      set_active = (typeof params.toggleActivate != 'undefined') ? params.toggleActivate : 0,
975      class_active = (typeof params.toggleClass != 'undefined') ? params.toggleClass : 'active',
976      class_target_active = (typeof params.toggleTargetClass != 'undefined') ? params.toggleTargetClass : '',
977      effect = params.toggleEffect;
978
979  if (params.toggle == 'off') return false;
980  if (params.media == 'md' && $(document).width() >= 768) return false;
981  if (params.media == 'lg' && $(document).width() >= 1024) return false;
982  if (params.media == 'lx' && $(document).width() >= 1280) return false;
983
984  if (params.toggle == 'on') {
985    switch(effect){
986      case 'accord':
987        $this.parents(params.toggleParent).find('[data-toggle-effect="accord"]:visible').not($this).each(function(index, el) {
988          let target_accord = $(this).data('toggle-target'),
989              $target_accord = (typeof target_accord != 'undefined') ? $(target_accord) : $(this).next();
990          $(this).removeClass(class_active);
991          if (class_target_active != '') {
992            $target_accord.removeClass(class_target_active);
993          }
994          if ($target_accord.is(':visible')) {
995            $target_accord.stop(true, false).slideUp(300);
996          }
997        });
998        $target.stop(true, false).slideToggle(300, function(){
999          if ($target.is(':visible') && $(document).width() <= 751) {
1000            let offset_top = $this.offset().top;
1001            // можно поменять отступ с учётом фиксированных элементов
1002            // if ($('.hdr-xs-btm').hasClass('fixed')) {
1003            //   offset_top -= $('.hdr-xs-btm').outerHeight();
1004            // }
1005            $('html, body').stop(true).animate({
1006              scrollTop: offset_top
1007            }, 300);
1008          }
1009        });
1010        break;
1011      case 'opacity':
1012				if (set_active == 1) {
1013					if ($this.hasClass(class_active)) {
1014						$target.stop(true, false).css('opacity', '0');
1015					} else {
1016						$target.stop(true, false).css('opacity', '1');
1017					}
1018				} else {
1019	      	let op = $target.stop(true, false).css('opacity');
1020	      	if (op == 0) {
1021	      		// $target.animate({'opacity': 1}, 'fast');
1022	      		$target.stop(true, false).css('opacity', '1');
1023	      	} else {
1024	      		// $target.animate({'opacity': 0}, 'fast');
1025	      		$target.stop(true, false).css('opacity', '0');
1026	      	}
1027				}
1028        break;
1029      case 'slide':
1030        $target.stop(true, false).slideToggle('fast');
1031        break;
1032      case 'fade':
1033        $target.stop(true, false).fadeToggle('fast');
1034        break;
1035      default:
1036        $target.toggle();
1037        break;
1038    }
1039  }
1040
1041  if (set_active == 1) {
1042    $this.toggleClass(class_active);
1043    if (class_target_active != '') {
1044      $target.toggleClass(class_target_active);
1045    }
1046  }
1047
1048  if (typeof toggleClickCallback == 'function') toggleClickCallback($this, $target);
1049});
1050
1051
1052// swiper handlers
1053function swiper_init(target, params) {
1054  let _swiper = document.querySelector(target).swiper;
1055  if (typeof _swiper == 'undefined') {
1056    let _on = {
1057      on: {
1058        init: function () {
1059          if (this.params.createElements == true && this.enabled == true) {
1060            // wrap .swiper
1061            let swiper_div = document.createElement('div');
1062            swiper_div.className = 'swiper';
1063            this.wrapperEl.replaceWith(swiper_div);
1064            swiper_div.append(this.wrapperEl);
1065            // wrap .swiper-wrapper
1066            if (this.params.wrapperClass != 'swiper-wrapper') {
1067              this.wrapperEl.classList.add('swiper-wrapper');
1068            }
1069            // slides add classes
1070            this.slides.forEach(slideEl => {
1071              slideEl.classList.add('swiper-slide');
1072            });
1073          }
1074        },
1075        breakpoint: function (swiper, breakpointParams) {
1076          // console.log(swiper.currentBreakpoint,swiper);
1077          if (breakpointParams.unswipe == true) {
1078            unswipe(swiper)
1079          }
1080          if (breakpointParams.reswipe == true) {
1081            reswipe(swiper);
1082          }
1083          if (typeof breakpointParams.navigation != 'undefined') {
1084            if (typeof breakpointParams.navigation.moveTo != 'undefined') {
1085              // console.log(document.querySelector(breakpointParams.navigation.moveTo));
1086              // console.log(swiper.navigation.nextEl);
1087              if (swiper.navigation.prevEl !== null && swiper.navigation.nextEl !== null) {
1088                document.querySelector(breakpointParams.navigation.moveTo).prepend(swiper.navigation.nextEl[0], swiper.navigation.prevEl[0]);
1089              }
1090            }
1091          }
1092        },
1093      }
1094    };
1095    Object.assign(params, _on);
1096    _swiper = new Swiper(target, params);
1097  }
1098}
1099function reswipe(swiper) {
1100  if (swiper.params.createElements == true && swiper.enabled == false) {
1101    // wrap .swiper-wrapper
1102    if (swiper.params.wrapperClass == 'swiper-wrapper') {
1103      if (!swiper.hostEl.querySelector('.swiper-wrapper')) {
1104        swiper.hostEl.append(swiper.wrapperEl);
1105        swiper.hostEl.querySelectorAll('.'+swiper.params.slideClass).forEach(sli
1105deEl => {
1106          swiper.wrapperEl.append(slideEl);
1107        });
1108      }
1109    } else {
1110      swiper.wrapperEl.classList.add('swiper-wrapper');
1111    }
1112    // wrap .swiper
1113    let swiper_div = document.createElement('div');
1114    swiper_div.className = 'swiper';
1115    swiper.wrapperEl.replaceWith(swiper_div);
1116    swiper_div.append(swiper.wrapperEl);
1117    // slides add classes
1118    swiper.hostEl.querySelectorAll('.'+swiper.params.slideClass).forEach(slideEl => {
1119      slideEl.classList.add('swiper-slide');
1120    });
1121    // enable
1122    swiper.enable();
1123    swiper.updateActiveIndex(0);
1124  }
1125}
1126function unswipe(swiper) {
1127  if (swiper.params.createElements == true && swiper.enabled == true) {
1128    // unwrap .swiper
1129    if (swiper.hostEl.querySelector('.swiper')) {
1130      swiper.hostEl.querySelector('.swiper').replaceWith(...swiper.hostEl.querySelector('.swiper').childNodes);
1131    }
1132    // unwrap .swiper-wrapper
1133    if (swiper.params.wrapperClass == 'swiper-wrapper') {
1134      swiper.wrapperEl.replaceWith(...swiper.wrapperEl.childNodes);
1135    } else {
1136      swiper.wrapperEl.classList.remove('swiper-wrapper');
1137    }
1138    // clean slides
1139    let slides = swiper.slides.length ? swiper.slides : swiper.hostEl.querySelectorAll('.'+swiper.params.slideClass);
1140    if (slides && slides.length) {
1141      slides.forEach(slideEl => {
1142        slideEl.classList.remove(swiper.params.slideVisibleClass, swiper.params.slideActiveClass, swiper.params.slideNextClass, swiper.params.slidePrevClass, 'swiper-slide', 'swiper-slide-active');
1143        slideEl.removeAttribute('style');
1144        slideEl.removeAttribute('data-swiper-slide-index');
1145      });
1146    }
1147    // disable
1148    swiper.disable();
1149  }
1150}
1151
1152
1153// #handscustom
1154
1155function print_file_size(number) {
1156  if (number < 1024) {
1157    return `${number} B`;
1158  } else if (number >= 1024 && number < 1048576) {
1159    return `${(number / 1024).toFixed(0)} KB`;
1160  } else if (number >= 1048576) {
1161    return `${(number / 1048576).toFixed(0)} MB`;
1162  }
1163}
1164
1165function custom_height_fix(target, from){
1166  $(target).height($(from).outerHeight());
1167}
1168
1169
1170function faq(btn){
1171    var faq = jQuery(btn);
1172    $(faq).each(function(i, el) {
1173        let $this = $(this);
1174        $this.on("click", function(){
1175            let target = $this.next(),
1176                parent_col = $this.data('toggle-parent'),
1177                answer = $this.data('toggle-answer');
1178
1179                console.log(target);
1180
1181            target.slideToggle(200,function(){
1182                // if($this.is(':visible') == true){
1183                    let class_active =  ($this.is(':visible') == true) ? $this.parent(parent_col).toggleClass('active') : '';
1184
1185                // }
1186                $this.parent(parent_col).siblings().removeClass('active').children(answer).slideUp(200);
1187              // $this.parent(parent_col).siblings().find(answer).slideUp(200);
1188              // console.log('this',$this.parent(parent_col).siblings().children(answer));
1189            });
1190        });
1191    });
1192}
1193jQuery(document).ready(function () {
1194  jQuery(function ($) {
1195    $('.module_table_options .table-col').on('mouseenter', function () {
1196        let table = $(this).parents('.table-options'),
1197            index = $(this).index();
1198
1199            console.log(index);
1200
1201        table.find('.table-col').removeClass('hovered');
1202        if (index) {
1203            table.find('.table-row').each(function () {
1204                $(this).find('.table-col').eq(index).addClass('hovered');
1205            });
1206        }
1207    });
1208
1209
1210  });
1211});
1212
1213
1214// #ajax
1215
1216function get_prod_data(prod_id) {
1217  let result;
1218  $.ajax({
1219    url: '/artmebius/snippets/ajax.php',
1220    type: 'POST',
1221    dataType: 'json',
1222    async: false,
1223    data: {
1224      action: 'get_prod_data',
1225      id: prod_id
1226    }
1227  })
1228  .done(function(data) {
1229    result = data;
1230  })
1231  .fail(function() {
1232    result = 'error';
1233  });
1234
1235  return result;
1236}
1237
1238$('.ajaxbox').on('click', function(e) {
1239  e.preventDefault();
1240  $.ajax({
1241    url: '/artmebius/snippets/ajax.php',
1242    type: 'POST',
1243    data: {
1244      action: 'get_gallery_album',
1245      album: $(this).data('album')
1246    },
1247  })
1248  .done(function(data) {
1249    $.fancybox.open(
1250      $(data).filter('.lightbox'),
1251      fancybox_params
1252    );
1253  })
1254  .fail(function(data) {
1255    console.log("error", data);
1256  });
1257});
1258
1259
1260// #scripts
1261
1262let url = document.location.href;
1263if (url.indexOf('contacts') == -1){
1264  document.oncopy=acl;
1265}
1266
1267if ($('.prdt_tabs').length) {
1268  tabs.init(1, '.prdt_tabs');
1269}
1270
1271fancybox_init(fancybox_params);
1272fancybox_init(fancyboxvideo_params);
1273// toggle_class_upd(); // -> base.tpl
1274menu_toggle_upd();
1275backdrop.init();
1276table_responsive_init();
1277
1278$('.go2top').scrollToTop();
1279
1280// #events
1281
1282$('body').on('click', '.spotdrop > *', function(e) {
1283  e.stopPropagation();
1284});
1285$('body').on('click', function(e) {
1286  $('.spotdrop').removeClass('spotdrop');
1287});
1288
1289$(window).resize(function() {
1290  toggle_class_upd();
1291  menu_toggle_upd();
1292});
1293
1294// key_code log
1295// $('body').on('keyup', function(e) {
1296//   let key_code = e.which ? e.which : e.keyCode;
1297//   console.log(key_code);
1298// });

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.