PageSourceSearch

https://rusmedhom.ru/t/v679/images/js/title.js

js rusmedhom.ru collected 2026-10-02 07:19:19 UTC 100,726 bytes, 3,173 lines download raw bytes

1;(function($) {
2	// wrap tables in content for swipe on mobile devices
3	$(function() {
4		var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(navigator.userAgent);
5
6		$('article.content').find('table').wrap('<div class="for-mobile-view"></div>');
7
8		if(isMobile){
9			$('html').addClass('mobile');
10		}
11
12	});
13}(jQuery));$(function () {
14	$(document).click(function (event) {
15		$('.contacts-block').each(function() {
16			if ($(event.target).closest($(this)).length) {
17				return;
18			} else {
19				$(this).find('.tgl-but').prop("checked", false);
20				$(this).find('.icon').removeClass('active');
21			}
22		});
23	});
24
25	function setMargin($block) {
26		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
27			$block.find(".block-body-drop").css({
28				"margin-left": "0px"
29			});
30		} else {
31			var left = $block.offset().left * -1;
32			$block.find(".block-body-drop").css({
33				"margin-left": left + "px"
34			});
35		}
36	}
37
38	$('.contacts-block').each(function() {
39		var $block = $(this),
40			allClasses = $block.attr("class").split(" "),
41			mainClass = allClasses[0],
42			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
43			styles = document.styleSheets;
44
45		for(var i = 0; i < styles.length; i++) {
46			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
47				for(var j = 0; j < styles[i].cssRules.length; j++) {
48					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
49						$block.data("fullwidth", 1);
50						setMargin($block);
51						break;
52					}
53				}
54				break;
55			}
56		}
57	});
58
59	$(window).resize(function() {
60		$('.contacts-block').each(function() {
61			var $block = $(this);
62			if ($block.data("fullwidth") == 1) {
63				setMargin($block);
64			}
65		});
66	});
67
68	$('.contacts-block').each(function() {
69		var $block = $(this);
70		$block.find('.icon').click(function() {
71			if ($block.data("fullwidth") == 1) {
72				setMargin($block);
73			}
74			if ($block.find('.tgl-but').prop("checked")) {
75				$(this).removeClass('active');
76			} else {
77				$(this).addClass('active');
78			}
79		});
80	});
81});
82$(function () {
83	$(document).click(function (event) {
84		$('.contacts-block').each(function() {
85			if ($(event.target).closest($(this)).length) {
86				return;
87			} else {
88				$(this).find('.tgl-but').prop("checked", false);
89				$(this).find('.icon').removeClass('active');
90			}
91		});
92	});
93
94	function setMargin($block) {
95		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
96			$block.find(".block-body-drop").css({
97				"margin-left": "0px"
98			});
99		} else {
100			var left = $block.offset().left * -1;
101			$block.find(".block-body-drop").css({
102				"margin-left": left + "px"
103			});
104		}
105	}
106
107	$('.contacts-block').each(function() {
108		var $block = $(this),
109			allClasses = $block.attr("class").split(" "),
110			mainClass = allClasses[0],
111			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
112			styles = document.styleSheets;
113
114		for(var i = 0; i < styles.length; i++) {
115			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
116				for(var j = 0; j < styles[i].cssRules.length; j++) {
117					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
118						$block.data("fullwidth", 1);
119						setMargin($block);
120						break;
121					}
122				}
123				break;
124			}
125		}
126	});
127
128	$(window).resize(function() {
129		$('.contacts-block').each(function() {
130			var $block = $(this);
131			if ($block.data("fullwidth") == 1) {
132				setMargin($block);
133			}
134		});
135	});
136
137	$('.contacts-block').each(function() {
138		var $block = $(this);
139		$block.find('.icon').click(function() {
140			if ($block.data("fullwidth") == 1) {
141				setMargin($block);
142			}
143			if ($block.find('.tgl-but').prop("checked")) {
144				$(this).removeClass('active');
145			} else {
146				$(this).addClass('active');
147			}
148		});
149	});
150});
151/*
152 *  wmS3Menu v1.0.0
153 *  K.I. 433
154 */
155;(function ($, window, document, undefined ) {
156	var pluginName = 'wmS3Menu',
157		defaults = {
158			screenButton: false,
159			responsiveTl: false,
160			responsiveTp: false,
161			responsiveMl: false,
162			moreText: '...',
163			childIcons: false,
164			childIconsClass: 'has-child-icon'
165		};
166	// Проверка на касание
167	var isTouchable = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
168	var $win = $(window);
169	var winWidth = $win.width();
170	var $doc = $(document);
171
172	var pluginObj = {
173		_events: {
174			hover: function(menuWrap, item, settings){
175				var link = item.find('> a');
176				var linkIcon = link.find('.' + settings.childIconsClass);
177				var iconLen = linkIcon.length;
178				var subMenu = item.find('> ul');
179				var showTimeout;
180				// Отображение
181				function menuShow() {
182					clearTimeout(showTimeout);
183					item.siblings().find('> ul').css('display', '');
184					// Определение положения выпадашки чтобы не выводилось за пределы окна
185					pluginObj._menuPosition(subMenu);
186
187					link.addClass('hover');
188					if (iconLen) {
189						linkIcon.addClass('hover');
190					}
191				}
192				// Скрытие
193				function menuHide() {
194					showTimeout = setTimeout(function(){
195						link.removeClass('hover');
196						subMenu.css('display', '');
197						if (iconLen) {
198							linkIcon.removeClass('hover');
199						}
200					}, 500);
201				}
202				// Отключение и подключение событий
203				item.off({
204					'mouseenter.wmS3Menu': menuShow,
205					'mouseleave.wmS3Menu': menuHide
206				});
207				item.on({
208					'mouseenter.wmS3Menu': menuShow,
209					'mouseleave.wmS3Menu': menuHide
210				});
211			},
212			click: function(menuWrap, item, settings){
213				var link = item.find('> a');
214				var linkIcon = link.find('.' + settings.childIconsClass);
215				var iconLen = linkIcon.length;
216				var subMenu = item.find('> ul');
217				// Переключение отображения
218				function menuToggle() {
219					if (subMenu.is(':visible')) {
220						if (isTouchable) {
221							document.location = link.attr('href');
222						}
223						link.removeClass('hover');
224						subMenu.css('display', '');
225						item.removeClass('submenu-opened');
226						if (iconLen) {
227							linkIcon.removeClass('hover');
228						}
229					} else {
230						item.siblings().find('> ul').css('display', '');
231						item.siblings().find('> a').removeClass('hover');
232						item.siblings().find('> a .' + settings.childIconsClass).removeClass('hover');
233						// Определение положения выпадашки чтобы не выводилось за пределы окна
234						pluginObj._menuPosition(subMenu);
235
236						link.addClass('hover');
237						item.addClass('submenu-opened');
238						if (iconLen) {
239							linkIcon.addClass('hover');
240						}
241					}
242					return false;
243				}
244				// Отключение и подключение событий
245				link.off('click.wmS3Menu');
246				link.on('click.wmS3Menu', menuToggle);
247			},
248			click_tree: function(menuWrap, item, settings){
249				var link = item.find('> a');
250				var linkIcon = link.find('.' + settings.childIconsClass);
251				var subMenu = item.find('> ul');
252				// Переключение отображения
253				function menuToggle(event) {
254					var targ = $(event.target);
255
256					if (targ.closest(linkIcon).length) {
257						if (subMenu.is(':visible')) {
258							link.removeClass('hover');
259							subMenu.css('display', '');
260							item.removeClass('submenu-opened');
261							linkIcon.removeClass('hover');
262						} else {
263							// Определение положения выпадашки чтобы не выводилось за пределы окна
264							pluginObj._menuPosition(subMenu);
265
266							link.addClass('hover');
267							item.addClass('submenu-opened');
268							linkIcon.addClass('hover');
269						}
270						return false;
271					}
272				}
273				// Отключение и подключение событий
274				link.off('click.wmS3Menu');
275				link.on('click.wmS3Menu', menuToggle);
276			}
277		},
278		_menuPosition: function(subMenu) {
279			// Определение положения выпадашки чтобы не выводилось за пределы окна
280			winWidth = $win.width();
281
282			subMenu.css('display', 'block');
283
284			if (subMenu.parent().hasClass('first-level') === false) {
285				subMenu.css({
286					'visibility': 'hidden',
287					'opacity': 0
288				});
289
290				var menuRect = subMenu[0].getBoundingClientRect();
291				var marginR = parseInt(subMenu.css('margin-right'));
292				var parentWidth = subMenu.parent().width();
293
294				if (marginR > parentWidth) {
295					subMenu.css('margin-right', parentWidth);
296				}
297
298				if (menuRect.right >= winWidth) {
299					subMenu.css({
300						'left': '-100%',
301						'margin-left': 0
302					});
303				}
304				subMenu.css({
305					'visibility': '',
306					'opacity': ''
307				});
308			}
309		}
310	};
311	function Plugin(element, options) {
312		this.element = element;
313
314		this.options = $.extend({}, defaults, options, $(this.element).data()) ;
315
316		this._defaults = defaults;
317		this._name = pluginName;
318
319		this.init();
320	}
321	Plugin.prototype = {
322		init: function () {
323			var settings = this.options;
324			// Определение ширины медиа
325			var moreButFlag = false;
326			if (window.matchMedia('all and (max-width: 480px)').matches) {
327				moreButFlag = settings.responsiveMl;
328			} else if (window.matchMedia('all and (max-width: 640px)').matches) {
329				//moreButFlag = settings.responsiveTp;
330			} else if (window.matchMedia('all and (max-width: 768px)').matches) {
331				moreButFlag = settings.responsiveTl;
332			} else {
333				moreButFlag = settings.screenButton;
334			}
335			// Обертка меню
336			var menuWrap = $(this.element);
337			var menuClass = menuWrap.attr('class');
338			var menuMainUl = $(this.element.querySelector('ul'));
339			var widgetClass = menuClass.match(/widget-\d+/)[0];
340			// Проверка на наличие меню в Side panel
341			if (window.side_panel_controller && side_panel_controller.inPanel(widgetClass)) {
342				moreButFlag = false;
343			}
344
345			menuMainUl.children().addClass('first-level');
346			// Настройки для горизонтального меню
347			if (!!menuClass.match(/horizontal/i)) {
348				var menuWidth = menuMainUl.width();
349				var itemsWidth = 0, hideArr = [], hideLength;
350				// Кнопка More
351				var moreBut = menuMainUl.find('.more-button');
352				if (!moreBut.length) {
353					moreBut = $('<li class="more-button"><a href="#"><span>' + settings.moreText + '</span></a></li>');// data-trigger="click"
354					menuMainUl.append(moreBut);
355				}
356				// Меню More
357				var moreMenu = moreBut.find('> ul');
358				if (!moreMenu.length) {
359					moreMenu = $('<ul></ul>');
360					moreBut.append(moreMenu);
361				}
362
363				moreBut.removeClass('removed').attr('data-trigger', 'hover');
364				menuMainUl.children().css('display', '');
365
366				var firstLevelItems = menuMainUl.children(':visible').not('.more-button');
367				moreMenu.html('');
368
369				if (moreButFlag === 'more' || moreButFlag === 'button') {
370					moreBut.removeClass('disabled');
371
372					menuWidth -= moreBut.outerWidth();
373
374					firstLevelItems.each(function(){
375						var thisItem = $(this);
376						itemsWidth += thisItem.outerWidth(true);
377						if (itemsWidth >= menuWidth) {
378							hideArr.push(thisItem.clone());
379							thisItem.hide();
380						}
381					});
382
383					hideLength = hideArr.length;
384					if (hideLength) {
385						for (var ind = 0; ind < hideLength; ind++) {
386							moreMenu.append(hideArr[ind]);
387						}
388						moreBut.removeClass('disabled');
389					} else {
390						moreBut.addClass('disabled');
391					}
392				} else {
393					moreBut.addClass('disabled');
394				}
395			}
396			// Вложенные подуровни меню
397			var menuInner = menuMainUl.find('ul');
398			var menuItems = menuInner.parent();
399			var menuLinks = menuItems.find('> a');
400			// Стрелочки для подуровней
401			var menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
402			var childIconLen = menuLinksIcons.length;
403			// Тип отображения меню
404			var mShow = 'popup';
405			if (!!menuClass.match(/dropdown/i)) {
406				mShow = 'dropdown';
407			} else if (!!menuClass.match(/treemenu/i)) {
408				mShow = 'treemenu';
409			}
410			if (mShow === 'popup') {
411				menuInner.hide();
412			}
413			if (childIconLen) {
414				menuLinksIcons.remove();
415			}
416			if (!!settings.childIcons) {
417				// Добавление стрелочек для подуровней
418				var childIconHTML = '<em class="' + settings.childIconsClass + '"></em>';
419
420				if (mShow === 'treemenu') {
421					childIconHTML = '<em class="' + settings.childIconsClass + '"><b style="position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;"></b></em>';
422				}
423
424				var childIconTag = $(childIconHTML);
425				menuLinks.append(childIconTag.clone());
426
427				menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
428				childIconLen = menuLinksIcons.length;
429			}
430			// Удаление всех событий на ссылках
431			menuLinks.removeClass('hover').off('click.wmS3Menu');
432			menuInner.css('display', '');
433			if (childIconLen) {
434				menuLinksIcons.removeClass('hover');
435			}
436
437			menuItems.each(function() {
438				var thisItem = $(this);
439				var trigger = thisItem.data('trigger') || 'hover';
440
441				if (mShow === 'dropdown' || isTouchable) {
442					trigger = 'click';
443				} else if (mShow === 'treemenu') {
444					trigger = 'click_tree';
445				}
446				pluginObj._events[trigger](menuWrap, thisItem, settings);
447			});
448			// Клик по документу
449			if (isTouchable) {
450				function docClick(e) {
451					var target = $(e.target);
452					if (target.closest(menuWrap).length === 0) {
453						menuLinks.removeClass('hover');
454						menuInner.css('display', '');
455						menuItems.removeClass('submenu-opened');
456
457						if (childIconLen) {
458							menuLinksIcons.removeClass('hover');
459						}
460					}
461				}
462				$doc.off('touchstart.wmS3Menu', docClick);
463				$doc.on('touchstart.wmS3Menu', docClick);
464			}
465		},
466		update: function () {
467			this.init();
468		}
469	};
470	if (!$.fn[pluginName]) {
471		$.fn[pluginName] = function (options) {
472			var args = arguments;
473			if (options === undefined || typeof options === 'object') {
474				return this.each(function () {
475					if (!$.data(this, 'plugin_' + pluginName)) {
476						$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
477					}
478				});
479			} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
480				var returns;
481				this.each(function () {
482					var instance = $.data(this, 'plugin_' + pluginName);
483					if (instance instanceof Plugin && typeof instance[options] === 'function') {
484						returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
485					}
486					if (options === 'destroy') {
487						$.data(this, 'plugin_' + pluginName, null);
488					}
489				});
490				return returns !== undefined ? returns : this;
491			}
492		};
493	}
494	$(function () {
495		var wmMenuWrap = $('.wm-widget-menu.horizontal');
496		wmMenuWrap[pluginName]();
497
498		$win.on('resize.wmS3Menu', function(){
499			wmMenuWrap[pluginName]('update');
500		});
501	});
502
503	setTimeout(function(){
504		$win.trigger('resize');
505	}, 500);
506}(jQuery, window, document));
507;(function(window, document) {
508    if (!window.photoSwipeSettings) {
509        window.photoSwipeSettings = {};
510    }
511
512    var psSettings = window.photoSwipeSettings;
513
514    function initPhotoSwipeFunc(settings) {
515        if (!settings.preloadImages) {
516            settings.preloadImages = false;
517        }
518
519        var settingsKeys = Object.keys(psSettings);
520
521        if (settingsKeys.length) {
522            settingsKeys.forEach(function(key) {
523                if (key !== 'hashData') {
524                    psSettings[key].push(settings[key]);
525                }
526            });
527        } else {
528            Object.keys(settings).forEach(function(key) {
529                psSettings[key] = [];
530
531                psSettings[key].push(settings[key]);
532            });
533        }
534
535        var galleryIteration = 0;
536
537        psSettings.gallery.forEach(function(str){
538            if (str === settings.gallery) {
539                galleryIteration++;
540            }
541            var index = psSettings.gallery.indexOf(settings.gallery);
542
543            if (galleryIteration > 1) {
544                settingsKeys.forEach(function(key) {
545                    if (key !== 'hashData') {
546                        psSettings[key].splice(index, 1);
547                    }
548                });
549                galleryIteration = 0;
550            }
551        });
552
553        if (!psSettings.hashData) {
554            psSettings.hashData = photoswipeParseHash();
555        }
556
557        var hashData = psSettings.hashData;
558        var hashDataKeys = Object.keys(hashData);
559
560        if (hashDataKeys.length) {
561            settings.preloadImages = true;
562        }
563
564        var galleryElements = document.querySelectorAll(psSettings.gallery.join(','));
565        var galleryLength = galleryElements.length;
566
567        var pswpHTML = '<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button>';
568        var pswpHTMLEnd = '<div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div></div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>';
569        var pswpShare = '', pswpFullscreen = '', pswpZoom = '', curGallery;
570
571        for(var i = 0; i < galleryLength; i++) {
572            curGallery = galleryElements[i];
573
574            if (curGallery.getAttribute('data-popup-share') === '1') {
575                pswpShare = '<button class="pswp__button pswp__button--share" title="Share"></button>'
576            }
577            if (curGallery.getAttribute('data-popup-fullscreen') === '1') {
578                pswpFullscreen = '<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>';
579            }
580            if (curGallery.getAttribute('data-popup-zoom') === '1') {
581                pswpZoom = '<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>';
582            }
583
584            curGallery.setAttribute('data-pswp-uid', i+1);
585            curGallery.dataGID = i+1;
586
587            if (settings.preloadImages) {
588                parseGalleryImages(curGallery);
589            } else {
590                parseGalleryThumbs(curGallery);
591
592                if (hashData.pid && hashData.gid && hashData.gid === curGallery.dataGID) {
593                    openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
594                }
595            }
596        }
597
598        var pswpOverlay = document.querySelectorAll('.pswp');
599
600        if (pswpOverlay.length === 0) {
601            pswpHTML = pswpHTML + pswpShare + pswpFullscreen + psw
601pZoom + pswpHTMLEnd;
602
603            var pswpContainer = document.createElement('div');
604            pswpContainer.innerHTML = pswpHTML;
605
606            document.body.appendChild(pswpContainer);
607        }
608
609        function parseGalleryImages(gallery){
610            var images = gallery.querySelectorAll(settings.item + ' img');
611            var imagesLen = images.length;
612            var loadedArr = [];
613
614            for (var ind = 0; ind < imagesLen; ind++) {
615                setDataSize(images[ind]);
616            }
617            function setDataSize(img) {
618                var tempImg = new Image();
619
620                var link = closest(img, function(el) {
621                    return (el.tagName && el.tagName === 'A');
622                });
623
624				if(link){
625                    tempImg.src = link.getAttribute('href');
626				}
627
628
629                tempImg.addEventListener('load', function() {
630                    link.setAttribute('data-size', tempImg.naturalWidth + 'x' + tempImg.naturalHeight);
631                    tempImg = null;
632
633                    loadedArr.push('loaded');
634
635                    if (loadedArr.length === imagesLen) {
636                        parseGalleryThumbs(gallery);
637
638                        if (hashData.pid && hashData.gid && hashData.gid === gallery.dataGID) {
639                            openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
640                        }
641                    }
642                });
643            }
644        }
645        function parseGalleryThumbs(gallery) {
646            var thumbs = gallery.querySelectorAll(settings.item);
647            var thumbsLen = thumbs.length;
648            var items = [];
649            var item, link, image, title, desc, size, obj;
650
651            for (var i = 0; i < thumbsLen; i++) {
652                item = thumbs[i];
653
654                item.dataPSIndex = i;
655                item.addEventListener('click', onThumbsClick);
656
657                image = item.querySelector('img');
658                link = item.querySelector('a[data-size]');
659
660                title = link.getAttribute('data-title');
661                desc = item.querySelector(settings.itemDesc);
662
663                size = link.getAttribute('data-size').split('x');
664
665                obj = {
666                    src: link.getAttribute('href'),
667                    w: parseInt(size[0], 10),
668                    h: parseInt(size[1], 10)
669                };
670
671                if (title) {
672                    obj.title = title;
673                }
674
675                if (desc && desc.innerHTML) {
676                    obj.title += '<br /><small>' + desc.innerHTML + '</small>';
677                }
678
679                if (link.children.length > 0) {
680                    obj.msrc = image.getAttribute('src');
681                }
682
683                obj.el = item;
684
685                items.push(obj);
686            }
687
688            return items;
689        }
690        function onThumbsClick(e) {
691            e = e || window.event;
692
693            e.preventDefault ? e.preventDefault() : e.returnValue = false;
694
695            var eTarget = e.target || e.srcElement;
696
697            var clickedItem = closest(eTarget, function(el) {
698                return ('dataPSIndex' in el);
699            });
700
701            var clickedGallery = closest(clickedItem, function(el) {
702                return el.getAttribute('data-pswp-uid');
703            });
704
705            var index = clickedItem.dataPSIndex;
706
707            openPhotoSwipe(index, clickedGallery);
708
709            return false;
710        }
711        function closest(el, fn) {
712            return el && (fn(el) ? el : closest(el.parentNode, fn));
713        }
714        function openPhotoSwipe(index, gallery, disableAnimation, fromURL) {
715            var pswpElement = document.querySelectorAll('.pswp')[0];
716            if (!gallery) {
717                return false;
718            }
719            var items = parseGalleryThumbs(gallery);
720            var options = {
721                galleryUID: gallery.getAttribute('data-pswp-uid'),
722                getThumbBoundsFn: function(index) {
723                    var thumbnail = items[index].el.getElementsByTagName('img')[0];
724                    var pageYScroll = window.pageYOffset || document.documentElement.scrollTop;
725                    var rect = thumbnail.getBoundingClientRect();
726
727                    return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
728                }
729            };
730            if (fromURL) {
731                if(options['galleryPIDs']) {
732                    for (var j = 0; j < items.length; j++) {
733                        if (items[j].pid === index) {
734                            options.index = j;
735                            break;
736                        }
737                    }
738                } else {
739                    options.index = parseInt(index, 10) - 1;
740                }
741            } else {
742                options.index = parseInt(index, 10);
743            }
744            if (isNaN(options.index) ) {
745                return;
746            }
747            if (disableAnimation) {
748                options.showAnimationDuration = 0;
749                options.hideAnimationDuration = 0;
750            }
751            var pswpGallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
752            pswpGallery.init();
753            pswpGallery.listen('close', function() {
754                setTimeout(function(){
755                    pswpElement.classList.remove('pswp--open');
756                }, 500);
757            });
758        }
759        function photoswipeParseHash() {
760            var hash = location.hash.substring(1), params = {};
761
762            if (hash.length < 5) {
763                return params;
764            }
765
766            var vars = hash.split('&'), varsL = vars.length, pair;
767
768            for (var i = 0; i < varsL; i++) {
769                if (!vars[i]) {continue;}
770
771                pair = vars[i].split('=');
772
773                if (pair.length < 2) {continue;}
774
775                params[pair[0]] = pair[1];
776            }
777
778            if (params.gid) {
779                params.gid = parseInt(params.gid, 10);
780            }
781
782            return params;
783        }
784    }
785
786    if (!window.initPhotoSwipeFunc) {
787        window.initPhotoSwipeFunc = initPhotoSwipeFunc;
788    }
789}(window, document));
790
791$(function() {
792
793	var $win = $(window);
794
795	var debounce = (function () {
796		return function (fn, time) {
797			var timer, func;
798			func = function() {
799				var args = [].slice.call(arguments, 0);
800				window.clearTimeout(timer);
801				timer = window.setTimeout(function () {
802					window.requestAnimationFrame && window.requestAnimationFrame(function() {
803						fn.apply(null, args);
804					}) || fn.apply(null, args);
805				}, time)
806			};
807			return func;
808		}
809	}());
810
811	var throttle = (function() {
812		return function (fn, threshhold, scope) {
813			threshhold || (threshhold = 250);
814			var last,
815				deferTimer,
816				func;
817			func = function () {
818				var context = scope || this;
819				var now = +new Date,
820					args = arguments;
821				if (last && now < last + threshhold) {
822					// hold on to it
823					clearTimeout(deferTimer);
824					deferTimer = setTimeout(function () {
825						last = now;
826						fn.apply(context, args);
827					}, threshhold);
828				} else {
829					last = now;
830					fn.apply(context, args);
831				}
832			};
833			return func;
834		}
835	}());
836
837	var psSettings = {
838		gallery: '.blocklist .body',
839		item: '.image',
840		itemDesc: '.text',
841		preloadImages: true
842	};
843
844	$('.blocklist').each(function() {
845		var $blocklist = $(this),
846			$items = $blocklist.find('.item-outer'),
847			$list = $blocklist.find('.list'),
848			$body = $blocklist.find('.body'),
849			$controls = $blocklist.find('.controls'),
850			$pagers = $blocklist.find('.bx-pager-wrap'),
851			//$auto_controls = $blocklist.find('.auto_controls'),
852			options = {},
853			count,
854			col_arr, pager_arr, controls_arr,
855			bxslider,
856			auto_controls_arr,
857			containerWidth,
858			isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
859			media_type,
860			//id = $blocklist.attr('data-layer_id') ? $blocklist.attr('data-layer_id') : $blocklist.attr('item_id'),
861			slider_arr = $blocklist.attr('data-slider').split(","),
862			swipe_arr = $blocklist.attr('data-swipe').split(",");
863
864		if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) {
865
866			options.pagerSelector= $blocklist.attr('data-setting-pager_selector');
867			options.prevSelector = $blocklist.attr('data-setting-prev_selector');
868			options.nextSelector = $blocklist.attr('data-setting-next_selector');
869			options.prevText = $blocklist.attr('data-setting-prev_text') || '';
870			options.nextText = $blocklist.attr('data-setting-next_text') || '';
871			options.auto = !!parseInt($blocklist.attr('data-setting-auto'));
872			options.controls = !!parseInt($blocklist.attr('data-setting-controls'));
873			options.pager = !!parseInt($blocklist.attr('data-setting-pager').split(',')[0]);
874			options.pause = parseInt($blocklist.attr('data-setting-pause'), 10) || 4000;
875			options.useCSS = isMobile;
876			options.infiniteLoop = true;
877			options.adaptiveHeight = true;
878			options.mode = $blocklist.attr('data-setting-mode') || 'horizontal';
879			options.touchEnabled = options.mode === 'horizontal';
880			options.slideMargin = 0;
881			options.maxSlides = parseInt($blocklist.attr('data-setting-count').split(',')[0], 10) || 1;
882			options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides;
883			options.moveSlides = $blocklist.attr('data-setting-move') || 0;
884			options.autoControlsSelector = $blocklist.attr('data-setting-auto_controls_selector');
885			options.autoControls =  !!parseInt($blocklist.attr('data-setting-auto_controls').split(',')[0]);
886			options.autoControlsCombine =  !!parseInt($blocklist.attr('data-setting-autoControlsCombine'));
887			options.autoHover = true;
888
889			col_arr = $blocklist.attr('data-setting-columns').split(",");
890			pager_arr = $blocklist.attr('data-setting-pager').split(",");
891			controls_arr = $blocklist.attr('data-setting-controls').split(",");
892			auto_controls_arr = $blocklist.attr('data-setting-auto_controls').split(",");
893
894			if (!options.autoControls && options.auto) {
895				options.onSlideAfter = function() {
896					bxslider.startAuto();
897				}
898			}
899
900			$items.removeClass('hidden');
901			if ($list.parent().hasClass('bx-viewport')) {
902				$list.unwrap();
903				$list.unwrap();
904			}
905
906			function init(force) {
907				var setting_columns,
908					isJustify, space_between,
909					body_width = $('body').width(),
910					mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"],
911					slider_arr = $blocklist.attr('data-slider').split(",");
912
913
914				if (body_width >= 961) {
915					media_type = "screen";
916				} else if (body_width <= 960 && body_width >= 769) {
917					media_type = "tablet_landscape";
918				} else if (body_width <= 768 && body_width >= 641) {
919					media_type = "tablet_portrait";
920				} else if (body_width <= 640 && body_width >= 481) {
921					media_type = "mobile_landscape";
922				} else if (body_width <= 480) {
923					media_type = "mobile_portrait";
924				}
925				var media_ind = mediaList.indexOf(media_type);
926				var newContainerWidth = $blocklist.width(), itemHeight, viewportHeight;
927
928				if (!$blocklist.is(':visible')) {
929					if (bxslider) {
930						bxslider.destroySlider();
931					}
932					return;
933				}
934				if (force!='force' && containerWidth && containerWidth === newContainerWidth) {
935					return;
936				}
937				containerWidth = newContainerWidth;
938
939				if (bxslider) {
940					bxslider.destroySlider();
941				}
942
943				count = parseInt($blocklist.attr('data-setting-count').split(',')[media_ind], 10);
944				isJustify = $body.css('justify-content') == "space-between" ? true : false;
945
946				$controls.css("pointer-events","none");
947				$controls.find('.prev').css("pointer-events","auto");
948				$controls.find('.next').css("pointer-events","auto");
949
950				$list.width('auto');
951
952				$items
953					.attr('style', '')
954					.slice(1).addClass('hidden').end()
955					.width(options.slideWidth = $items.width())
956					.removeClass('hidden');
957
958				if (pager_arr.length > 1) {
959					options.pager = !!parseInt(pager_arr[media_ind]);
960				}
961				if (controls_arr.length > 1) {
962					options.controls = !!parseInt(controls_arr[media_ind]);
963				}
964				if (auto_controls_arr.length > 1) {
965					options.autoControls = !!parseInt(auto_controls_arr[media_ind]);
966				}
967
968				$(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"});
969				$blocklist.find(".controls").css({"display": options.controls == true ? "flex" : "none"});
970
971				if (options.mode === 'vertical') {
972					itemHeight = Math.max.apply(Math, $items.map(function() {
973						return $(this).height()
974					}).get());
975					$items.css('min-height', itemHeight);
976					viewportHeight = itemHeight * count;
977					options.maxSlides = options.minSlides = count;
978				} else {
979					setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]);
980					if (setting_columns) {
981						count = setting_columns;
982					}
983					options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width()));
984				}
985
986				if (isJustify) {
987					if (options.maxSlides > 1) {
988						space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1));
989						space_between = space_between < 0 ? 0 : space_between;
990					} else {
991						space_between = 0;
992					}
993					options.slideMargin = space_between;
994				}
995				if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) {
996					$list.css({'justify-content': 'flex-start'});
997					if (bxslider) {
998						bxslider.reloadSlider(options);
999					} else {
1000						$list.data('bxslider', (bxslider = $list.bxSlider(options)));
1001					}
1002					if(options.pager){
1003						$pagers.css('display', 'flex');
1004					}
1005				} else {
1006					if(swipe_arr[media_ind]!=1){
1007                        $list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'});
1008                        if($list.width()/count < $items.width()) {
1009                            $items.css('width', $items.width()-1);
1010                        } else {
1011                            $items.css('width', $items.width());
1012                        }
1013					} else {
1014						$list.css({'flex-wrap': 'nowrap'});
1015					}
1016					$pagers.hide();
1017					$controls.hide();
1018				}
1019
1020				if (viewportHeight && slider_arr[media_ind] == 1) {
1021					$list.parent().css('min-height', viewportHeight);
1022				}
1023				if (options.mode === 'horizontal') {
1024					var align = {};
1025					switch ($body.css('justify-content')) {
1026						case 'flex-end':
1027							align['margin-left'] = 'auto';
1028							align['margin-right'] = '0px';
1029							break;
1030						case 'center':
1031							align['margin-left'] = 'auto';
1032							align['margin-right'] = 'auto';
1033							break;
1034						default:
1035							align['margin-left'] = '0px';
1036							align['margin-right'] = 'auto';
1037					}
1038					$blocklist.find('.bx-wrapper').css(align);
1039				}
1040
1041				$blocklist.wm_img_convert();
1042			}
1043
1044			$win.on('resize', debounce(init, 300));
1045			$win.on('load', function(){
1046				init('force');
1047				$win.trigger('resize');
1048			});
1049
1050			init();
1051		} else {
1052			$pagers.hide();
1053			$controls.hide();
1054		}
1055
1056		$win.on('resize', debounce(swipeScrollInit, 300));
1057		swipeScrollInit();
1058
1059		function swipeScrollInit() {
1060			var $shadowLeft = $blocklist.find(".swipe-shadow-left");
1061			var $shadowRight = $blocklist.find(".swipe-shadow-right");
1062			if ($list.css("overflow-x") == "auto") {
1063				var scroll_width = $list.get(0).scrollWidth;
1064				var view_width = $list.width();
1065				$shadowLeft.css("pointer-events","none");
1066				$shadowRight.css("pointer-events","none");
1067
1068				$list.off('scroll');
1069				$list.on('scroll', throttle(swipeScrollCheack, 200));
1070
1071				swipeScrollCheack();
1072
1073				function swipeScrollCheack() {
1074					var scroll_left = $list.scrollLeft();
1075
1076					if (scroll_left > 0) {
1077						$shadowLeft.show();
1078					} else {
1079						$shadowLeft.hide();
1080					}
1081
1082					if (scroll_left + view_width >= scroll_width - 1) {
1083						$shadowRight.hide();
1084					} else {
1085						$shadowRight.show();
1086					}
1087				}
1088			} else {
1089				$shadowLeft.hide();
1090				$shadowRight.hide();
1091			}
1092		}
1093		if($blocklist.attr('data_photo_swipe') == 1){
1094            //$('.pswp').appendTo('body');
1095            initPhotoSwipeFunc(psSettings);
1096			$win.on('resize', function() {
1097                initPhotoSwipeFunc(psSettings);
1098            });
1099		}
1100
1101        $(document).on('click', '.shop2-product-btn2', function(e) {
1102
1103            var $this = $(this),
1104                $form = $this.closest('form'),
1105                form = $form.get(0),
1106                adds = $form.find('.additional-cart-params'),
1107                len = adds.length,
1108                i, el,
1109                a4 = form.amount.value,
1110                kind_id = form.kind_id.value;
1111
1112            e.preventDefault();
1113
1114            if (len) {
1115                a4 = {
1116                    amount: a4
1117                };
1118
1119                for (i = 0; i < len; i += 1) {
1120                    el = adds[i];
1121                    if (el.value) {
1122                        a4[el.name] = el.value;
1123                    }
1124                }
1125            }
1126
1127            shop2.cart.add(kind_id, a4, function(d) {
1128
1129                $('#shop2-cart-preview').replaceWith(d.data);
1130
1131                if (d.errstr) {
1132                    shop2.msg(d.errstr, $this);
1133                } else {
1134                    shop2.msg(window._s3Lang.JS_ADDED, $this);
1135                }
1136
1137                if (d.panel) {
1138                    $('#shop2-panel').replaceWith(d.panel);
1139                }
1140            });
1141
1142        });
1143
1144	});
1145
1146	var blockListBody = document.querySelectorAll('.blocklist .body-outer');
1147
1148	s3ContentColumns(blockListBody, {
1149		body: '.list',
1150		items: '.item-outer'
1151	});
1152});
1153// s3ContentColumns v1.0.0
1154(function(window, document, undefined) {
1155	var vendors = ['ms', 'moz', 'webkit', 'o'], vendorsLength = 4;
1156	var docElem = document.documentElement;
1157	var winWidth = window.innerWidth || docElem.clientWidth || document.body.clientWidth;
1158	var classListFlag = ('classList' in docElem);
1159	var defaults = {
1160		body: false,
1161		items: 'random',
1162		columns: '0,0,0,0,0',
1163		onBeforeInit: function() {},
1164		onAfterInit: function() {}
1165	};
1166	var elementMethods = {
1167		sHasClass: function(classN) {
1168			var elem = this;
1169			if (classListFlag) {
1170				return elem.classList.contains(classN);
1171			} else {
1172				return elem.className && new RegExp('\\b' + classN + '\\b').test(elem.className);
1173			}
1174		},
1175		sAddClass: function(classes) {
1176			var elem = this, classArr = classes.split(/\s/g), classLength = classArr.length, clInd;
1177			if (classListFlag) {
1178				for (clInd = 0; clInd < classLength; clInd++) {elem.classList.add(classArr[clInd]);}
1179			} else {
1180				for (clInd = 0; clInd < classLength; clInd++) {
1181					if (!elem.sHasClass(classArr[clInd])) {elem.className += ' ' + classArr[clInd];}
1182				}
1183			}
1184			return elem;
1185		},
1186		sRemoveClass: function(classes) {
1187			var elem = this, classArr = classes.split(/\s/g), classLength = classArr.length, clInd;
1188			if (classListFlag) {
1189				for (clInd = 0; clInd < classLength; clInd++) {elem.classList.remove(classArr[clInd]);}
1190			} else {
1191				var reg;
1192				for (clInd = 0; clInd < classLength; clInd++) {
1193					reg = new RegExp('\\b' + classArr[clInd] + '\\b', 'g');
1194					elem.className = elem.className.replace(reg, ' ').replace(/^\s\s*|\s\s*$/, '');
1195				}
1196			}
1197			return elem;
1198		},
1199		sCSS: function(property, value) {
1200			var elem = this, css3Reg = new RegExp('perspective|transform|box-sizing|user-select', 'g');
1201			function cssPrefix(prop) {
1202				if (prop.match(css3Reg) && !(prop in elem.style)) {
1203					for (var v = 0; v < vendorsLength; v++) {
1204						if ('-'+vendors[v]+'-'+prop in elem.style) {
1205							prop = '-'+vendors[v]+'-'+prop;
1206							break;
1207						}
1208					}
1209				}
1210				return prop;
1211			}
1212			if (typeof property === 'string' && value !== undefined) {
1213				elem.style[cssPrefix(property)] = value;
1214			} else if (typeof property === 'string' && value === undefined) {
1215				return getComputedStyle(elem)[property];
1216			} else if (typeof property === 'object') {
1217				for (var cssProp in property) {
1218					if (property.hasOwnProperty(cssProp)) {
1219						elem.style[cssPrefix(cssProp)] = property[cssProp];
1220					}
1221				}
1222			}
1223			return elem;
1224		},
1225		sDataset: function(){
1226			var elem = this, tempData = {};
1227			function setValue(val) {
1228				var num = parseInt(val), nanVal = NaN;
1229				if (val === 'false') {
1230					return false;
1231				} else if (val === 'true') {
1232					return true;
1233				} else if (!(/\D/.test(val)) && typeof num === 'number' && num !== nanVal) {
1234					return num;
1235				} else {
1236					return val;
1237				}
1238			}
1239			if (elem.dataset) {
1240				for (var propName in elem.dataset) {
1241					if (!elem.dataset.hasOwnProperty(propName)) {continue;}
1242					tempData[propName] = setValue(elem.dataset[propName]);
1243				}
1244			} else {
1245				var elAttr = elem.attributes, attrLen = elAttr.length;
1246				for (var ati = 0; ati < attrLen; ati++) {
1247					if (/data-/.test(elAttr[ati].name) === false) {continue;}
1248					var dOpt = elAttr[ati].name.replace(/data-|-\w/gi, function(str) {
1249						if (str === 'data-') {return '';}
1250						return str.replace('-', '').toUpperCase();
1251					});
1252					tempData[dOpt] = setValue(elAttr[ati].value);
1253				}
1254			}
1255			return tempData;
1256		},
1257		sClosest: function(fn) {
1258			var elem = this, prnt = elem.parentNode;
1259			return elem && (fn(elem) ? elem : ('sClosest' in prnt ? prnt.sClosest(fn) : prnt));
1260		}
1261	};
1262	for (var method in elementMethods) {
1263		if (elementMethods.hasOwnProperty(method) && !Element.prototype[method]) {
1264			Object.defineProperty(Element.prototype, method, {
1265				enumerable: false,
1266				value: elementMethods[method]
1267			});
1268		}
1269	}
1270	var pluginObj = {
1271		getDOMEl: function(selector) {
1272			if (selector && typeof(selector) === 'string' && /[.\-]\b/g.test(selector)) {
1273				return document.querySelector(selector);
1274			} else if (selector && typeof(selector) === 'object' && selector.tagName) {
1275				return selector;
1276			} else {
1277				return false;
1278			}
1279		},
1280		extend: function(out) {
1281			out = out || {};
1282			var i = 1, argLen = arguments.length;
1283			for (; i < argLen; i++) {
1284				if (!arguments[i]) {continue;}
1285				for (var key in arguments[i]) {
1286					if (arguments[i].hasOwnProperty(key)) {out[key] = arguments[i][key];}
1287				}
1288			}
1289			return out;
1290		},
1291		getMedia: function() {
1292			var mediaType = 'screen', mediaIndex = 0;
1293			if (window.matchMedia('all and (max-width: 480px)').matches) {
1294				mediaType = 'mobile_portrait';
1295				mediaIndex = 4;
1296			} else if (window.matchMedia('all and (max-width: 640px)').matches) {
1297				mediaType = 'mobile_landscape';
1298				mediaIndex = 3;
1299			} else if (window.matchMedia('all and (max-width: 768px)').matches) {
1300				mediaType = 'tablet_portrait';
1301				mediaIndex = 2;
1302			} else if (window.matchMedia('all and (max-width: 960px)').matches) {
1303				mediaType = 'tablet_landscape';
1304				mediaIndex = 1;
1305			}
1306			return [mediaIndex, mediaType];
1307		},
1308		getArray: function(arg) {
1309			var arr = [], len, ind, tempArr = [];
1310			function setValue(val) {
1311				var num = parseInt(val), nanVal = NaN;
1312				if (val === 'false') {
1313					return false;
1314				} else if (val === 'true') {
1315					return true;
1316				} else if (!(/\D/.test(val)) && typeof num === 'number' && num !== nanVal) {
1317					return num;
1318				} else {
1319					return val;
1320				}
1321			}
1322			if (typeof arg === 'string') {
1323				arr = arg.split(',');
1324			}
1325			len = arr.length;
1326			for (ind = 0; ind < len; ind++) {
1327				tempArr.push(setValue(arr[ind]));
1328			}
1329			return tempArr;
1330		},
1331		createColumnsTable: function(wrap) {
1332			var data = wrap.dataColumns, index;
1333
1334			data.options.onBeforeInit(wrap, data);
1335
1336			var columnsAmount = data.columnsArr[data.media[0]];
1337			var columnsTable = wrap.querySelector('.columns-table');
1338
1339			if (columnsTable) {
1340				var itemsTable = data.items[0].sClosest(function(elem){return elem.sHasClass('columns-table');});
1341
1342				if (itemsTable && itemsTable.sHasClass('columns-table')) {
1343					for (index = 0; index < data.itemsAmount; index++) {
1344						data.body.appendChild(data.items[index]);
1345					}
1346				}
1347				if (columnsAmount) {
1348					columnsTable.innerHTML = '';
1349				} else {
1350					data.body.removeChild(columnsTable);
1351				}
1352			} else {
1353				if (columnsAmount) {
1354					columnsTable = document.createElement('div').sAddClass('columns-table');
1355					data.body.appendChild(columnsTable);
1356				}
1357			}
1358
1359			if (columnsAmount) {
1360				var cellStr = '';
1361				if (data.itemsAmount < columnsAmount) {
1362					columnsAmount = data.itemsAmount;
1363				}
1364
1365				for (index = 0; index < columnsAmount; index++) {
1366					cellStr += '<div class="columns-cell"></div>';
1367				}
1368
1369				columnsTable.innerHTML = cellStr;
1370
1371				var columnsCells = wrap.querySelectorAll('.columns-cell');
1372
1373				if (columnsAmount === 1) {
1374					for (index = 0; index < data.itemsAmount; index++) {
1375						columnsCells[0].appendChild(data.items[index]);
1376					}
1377				} else {
1378					var cellWidth = columnsCells[0].clientWidth || parseFloat(columnsCells[0].sCSS('width'));
1379
1380					data.body.sCSS('width', cellWidth + 'px');
1381
1382					var totalHeight = data.body.offsetHeight;
1383					var avgColumn = Math.ceil(totalHeight / columnsAmount);
1384					var heightCounter = 0;
1385					var columnArrInd = 0;
1386					var remColumn, remItems, newAvgColumn;
1387					var currItem, currHeight, nextItem, nextHeight;
1388
1389					for (var itemInd = 0; itemInd < data.itemsAmount; itemInd++) {
1390						currItem = data.items[itemInd];
1391
1392						if (currItem === undefined || currItem.sHasClass('columns-table')) {continue;}
1393
1394						currHeight = currItem.offsetHeight;
1395
1396						nextItem = data.items[itemInd + 1];
1397						nextHeight = 0;
1398						if (nextItem) {
1399							nextHeight = nextItem.offsetHeight;
1400						}
1401						if (columnArrInd >= columnsAmount) {
1402							columnArrInd = columnsAmount - 1;
1403						}
1404						columnsCells[columnArrInd].appendChild(currItem);
1405
1406						totalHeight -= currHeight;
1407						heightCounter += currHeight;
1408
1409						if (totalHeight) {
1410							remColumn = columnsAmount - (columnArrInd + 1);
1411							remItems = data.itemsAmount - (itemInd + 1);
1412							newAvgColumn = totalHeight / remColumn;
1413
1414							var surplus = newAvgColumn - heightCounter;
1415
1416							var testA = remItems <= remColumn;
1417							var testB = nextHeight >= newAvgColumn;
1418							var testC = surplus <= nextHeight/2;
1419							var testD = avgColumn >= newAvgColumn && heightCounter >= newAvgColumn;
1420
1421							if (testA || testB || testC || testD) {
1422								heightCounter = 0;
1423								columnArrInd++;
1424							}
1425						}
1426					}
1427
1428					data.body.sCSS('width', '');
1429				}
1430			}
1431
1432			data.options.onAfterInit(wrap, data);
1433		}
1434	};
1435	var pluginMethods = {
1436		init: function(element, params) {
1437			var wrap = pluginObj.getDOMEl(element);
1438
1439			if (!wrap) {return false;}
1440
1441			var data = wrap.dataColumns, body, items, itemsAmount;
1442
1443			if (wrap && typeof(params) === 'string') {
1444				if (data && data.status === 'inited') {
1445					return false;
1446				} else if (data && data.options) {
1447					params = pluginObj.extend({}, data.options);
1448				}
1449			}
1450			if (wrap && typeof(params) !== 'string') {
1451				var options = pluginObj.extend({}, defaults, params, wrap.sDataset());
1452
1453				body = wrap.querySelector(options.body) || wrap;
1454
1455				items = wrap.querySelectorAll(options.items);
1456				if (items && !items.length) {
1457					items = [];
1458					var contentNodes = body.childNodes;
1459					var nodesLength = contentNodes.length;
1460					var tempTag, key, tempArr = [];
1461					for (key = 0; key < nodesLength; key++) {
1462						if (!contentNodes[key].tagName && contentNodes[key].nodeValue && /[\wа-яё]+/gi.test(contentNodes[key].nodeValue)) {
1463							tempTag = document.createElement('span');
1464							tempTag.innerHTML = contentNodes[key].nodeValue.replace(/^\s+|\s+$/g, '');
1465							tempArr.push([contentNodes[key], tempTag]);
1466						}
1467					}
1468					nodesLength = tempArr.length;
1469					for (key = 0; key < nodesLength; key++) {
1470						body.insertBefore(tempArr[key][1], tempArr[key][0].nextSibling);
1471						tempArr[key][0].nodeValue = '';
1472					}
1473					nodesLength = body.children.length;
1474					for (key = 0; key < nodesLength; key++) {
1475						items.push(body.children[key]);
1476					}
1477				}
1478				itemsAmount = items.length;
1479
1480				data = wrap.dataColumns = {
1481					options: options,
1482					status: 'inited',
1483					media: pluginObj.getMedia(),
1484					body: body,
1485					items: items,
1486					itemsAmount: itemsAmount,
1487					columnsArr: pluginObj.getArray(options.columns),
1488					handlers: {
1489						resizeWindow: function() {
1490							var newWinWidth = window.innerWidth || docElem.clientWidth || document.body.clientWidth;
1491							if (newWinWidth !== winWidth) {
1492								var newMedia = pluginObj.getMedia();
1493								if (newMedia[1] !== data.media[1]) {
1494									data.media = newMedia;
1495									pluginObj.createColumnsTable(wrap);
1496								}
1497							}
1498						}
1499					}
1500				};
1501
1502				var contentImages = wrap.querySelectorAll('img');
1503				var imagesLength = contentImages.length, hasSVG = false;
1504
1505				if (imagesLength) {
1506					var imagesLoadCounter = 0, currentImg, curSrc;
1507
1508					for (var imgInd = 0; imgInd < imagesLength; imgInd++) {
1509						currentImg = contentImages[imgInd];
1510						if (/image\/svg\+xml|\.svg$/g.test(currentImg.getAttribute('src'))) {
1511							hasSVG = true;
1512							break;
1513						}
1514						if (currentImg.complete || currentImg.complete === undefined){
1515							curSrc = currentImg.src + '?imgsrc=' + (new Date()).getTime();
1516							currentImg.src = curSrc;
1517						}
1518						currentImg.addEventListener('load', function() {
1519							imagesLoadCounter++;
1520							if (imagesLoadCounter === imagesLength) {
1521								initPlugin();
1522							}
1523						});
1524					}
1525					if (hasSVG) {
1526						initPlugin();
1527					}
1528				} else {
1529					initPlugin();
1530				}
1531			}
1532
1533			function initPlugin() {
1534				if (items && itemsAmount) {
1535					pluginObj.createColumnsTable(wrap);
1536
1537					window.addEventListener('resize', data.handlers.resizeWindow);
1538				}
1539			}
1540
1541			return wrap;
1542		}
1543	};
1544	function s3ContentColumnsPlugin(element, method) {
1545		if (!element) {return false;}
1546		if (pluginMethods[method]) {
1547			return pluginMethods[method].apply(this, arguments);
1548		} else if (typeof method === 'object' || !method) {
1549			if (pluginObj.getDOMEl(element)) {
1550				return pluginMethods.init.apply(this, arguments);
1551			} else if (element.length) {
1552				var elementsLen = element.length;
1553				for (var argInd = 0; argInd < elementsLen; argInd++) {
1554					pluginMethods.init(element[argInd], method);
1555				}
1556			}
1557		} else {
1558			return console.error('Метод ' +  method + ' не найден в плагине s3ContentColumns');
1559		}
1560	}
1561	if (!window.s3ContentColumns) {
1562		window.s3ContentColumns = s3ContentColumnsPlugin;
1563	}
1564}(window, document));
1565$(function() {
1566
1567	var debounce = (function () {
1568		return function (fn, time) {
1569			var timer, func;
1570			func = function() {
1571				var args = [].slice.call(arguments, 0);
1572				window.clearTimeout(timer);
1573				timer = window.setTimeout(function () {
1574					window.requestAnimationFrame && window.requestAnimationFrame(function() {
1575						fn.apply(null, args);
1576					}) || fn.apply(null, args);
1577				}, time)
1578			};
1579			return func;
1580		}
1581	}());
1582
1583	$('.slider').each(function() {
1584		var $this = $(this),
1585			options = {},
1586			bxslider,
1587			$slider_item = $this.find('.slider-item');
1588		options.mode = $this.attr('data-setting-mode');
1589		options.pagerCustom = $this.attr('data-setting-pager_selector');
1590		options.prevSelector = $this.attr('data-setting-prev_selector');
1591		options.nextSelector = $this.attr('data-setting-next_selector');
1592		options.prevText = $this.attr('data-setting-prev_text') || '';
1593		options.nextText = $this.attr('data-setting-next_text') || '';
1594		options.auto = !!parseInt($this.attr('data-setting-auto'));
1595		options.controls = !!parseInt($this.attr('data-setting-controls'));
1596		options.pager = !!parseInt($this.attr('data-setting-pager'));
1597		options.pause = parseInt($this.attr('data-setting-pause'), 10) || 4000;
1598		options.autoControlsSelector = $this.attr('data-setting-auto_controls_selector');
1599		options.autoControls =  !!parseInt($this.attr('data-setting-auto_controls').split(',')[0]);
1600		options.autoControlsCombine =  !!parseInt($this.attr('data-setting-autoControlsCombine'));
1601		options.useCSS = false;
1602		options.responsive = false;
1603		options.autoHover = true;
1604
1605		var itemLength = $slider_item.length;
1606		var $pager_wrap = $this.find('.slider-pager-wrap');
1607		var $pager = '<a href="" data-slide-index=""><span></span></a>';
1608		var $dotsType = $this.attr('data-type-pager');
1609		var textPosition = $this.attr('data-text_position');
1610        var dataTextBlock = $this.attr('data-text-block');
1611		var $pager_wrap_inner = $('<div class="slider-pager"></div>');
1612		var force = true;
1613
1614		var $new_pagers_html = ''+
1615			'<div class="bx-auto_controls">'+
1616			'<div class="auto_controls">'+
1617			'<div class="bx-controls-auto">'+
1618			'<div class="bx-controls-auto-item"><a class="bx-start"></a></div>'+
1619			'<div class="bx-controls-auto-item"><a class="bx-stop"></a></div>'+
1620			'</div>'+
1621			'</div>'+
1622			'</div>';
1623
1624		if (!options.autoControls && options.auto) {
1625			options.onSlideAfter = function () {
1626				bxslider.startAuto();
1627			}
1628		}
1629
1630		function init() {
1631
1632			if (bxslider) {
1633				bxslider.destroySlider();
1634			}
1635			if (!$this.is(':visible')) {
1636				return;
1637			}
1638
1639			$this.find('.slider-item[data-src]').each(function () {
1640				$(this).css('background-image', 'url("' + $(this).data('src') + '")');
1641			});
1642
1643			if ($this.find('.slider-item .overfill').length == 0) {
1644				$this.find('.slider-item').prepend('<div class="overfill"></div>');
1645			}
1646
1647			var bg_attc = $this.css('background-attachment');
1648			var bg_cl = $this.css('background-clip');
1649			var bg_colr = $this.css('background-color');
1650			var bg_image = $this.css('background-image');
1651			var bg_org = $this.css('background-origin');
1652			var bg_rep = $this.css('background-repeat');
1653			var bg_size = $this.css('background-size');
1654
1655
1656			$this.find('.overfill').css({
1657				'background-attachment': bg_attc,
1658				'background-clip': bg_cl,
1659				'background-color': bg_colr,
1660				'background-image': bg_image,
1661				'background-origin': bg_org,
1662				'background-repeat': bg_rep,
1663				'background-size': bg_size
1664			});
1665
1666			$this.find('>.overfill').remove();
1667
1668			if(textPosition=='out' && force){
1669				var $textWrap = $this.find('.text_wrapper');
1670				var text_options = {};
1671				var $textInner = $textWrap.find('.text_inner');
1672				var clone_text = $textInner.find('.text_slider').clone();
1673				text_options.mode = $this.attr('data-setting-mode');
1674				text_options.auto = false;
1675				text_options.controls = false;
1676				text_options.pager = false;
1677				text_options.autoControlsSelector = false;
1678				text_options.autoControls =  false;
1679				text_options.autoControlsCombine =  false;
1680
1681
1682				if($this.find('>.wrap_text_dm').length > 0){
1683					for (var i = 1; i < itemLength; i++) {
1684						$textInner.append(clone_text.clone());
1685					}
1686					$this.find('>.wrap_text_dm').remove();
1687				}
1688
1689				if(text_options.mode=="fade"){
1690					var itemHeight = Math.max.apply(Math, $textInner.find('.text_slider').map(function() {
1691						return $(this).height()
1692					}).get());
1693					$textInner.css('min-height', itemHeight);
1694				}
1695
1696				var textSlider = $textInner.bxSlider(text_options);
1697				$textInner.data('bxslider', textSlider);
1698
1699				options.onSlideNext = function(){
1700					textSlider.goToNextSlide();
1701				};
1702
1703				options.onSlidePrev = function(){
1704					textSlider.goToPrevSlide();
1705				};
1706
1707				options.onSlideBefore = function($slideElement, oldIndex, newIndex){
1708					if(newIndex == 0 && oldIndex == textSlider.getSlideCount() - 1 || newIndex-oldIndex == 1) {
1709						textSlider.goToNextSlide();
1710					} else if(oldIndex == 0 && newIndex == textSlider.getSlideCount() - 1 || oldIndex-newIndex == 1){
1711						textSlider.goToPrevSlide();
1712					} else {
1713						textSlider.goToSlide(newIndex);
1714					}
1715				};
1716				force = false;
1717
1718			} else if(textPosition=='in' && $this.find('>.wrap_text_dm').length > 0){
1719				var clone_text = $this.find('.text-slider').clone();
1720				$this.find('.slider-item .overfill').after(clone_text);
1721				$this.find('>.wrap_text_dm').remove();
1722			}
1723
1724
1725			if(itemLength>1){
1726				if (bxslider) {
1727					if (options.pager && $pager_wrap.find('.slider-pager').length==0) {
1728						if($pager_wrap.find('.bx-auto_controls').length==0){
1729							$pager_wrap.append($new_pagers_html);
1730						}
1731						$pager_wrap.find('.bx-auto_controls').append($pager_wrap_inner);
1732
1733						for (var i = 0; i < itemLength; i++) {
1734							$pager_wrap_inner.append($pager);
1735						}
1736
1737						$pager = $pager_wrap_inner.find('a');
1738						$pager.each(function () {
1739							var $this = $(this);
1740							var index = $this.index();
1741							$this.attr('data-slide-index', index);
1742							if ($dotsType == 'figures') {
1743								$this.find('span').html(index + 1);
1744							}
1745						});
1746					}
1747
1748					bxslider.reloadSlider(options);
1749
1750				} else {
1751					$this.find('.slider-inner').data('bxslider', (bxslider = $this.find('.slider-inner').bxSlider(options)));
1752				}
1753			}
1754			else{
1755				$this.find('.slider-controls').addClass('hidden');
1756				$this.find('.slider-pager-wrap').addClass('hidden');
1757			}
1758		}
1759
1760		$(window).on('resize', debounce(init, 300));
1761
1762		init();
1763	});
1764});
1765$(function() {
1766
1767	var debounce = (function () {
1768		return function (fn, time) {
1769			var timer, func;
1770			func = function() {
1771				var args = [].slice.call(arguments, 0);
1772				window.clearTimeout(timer);
1773				timer = window.setTimeout(function () {
1774					window.requestAnimationFrame && window.requestAnimationFrame(function() {
1775						fn.apply(null, args);
1776					}) || fn.apply(null, args);
1777				}, time)
1778			};
1779			return func;
1780		}
1781	}());
1782
1783	var throttle = (function() {
1784		return function (fn, threshhold, scope) {
1785			threshhold || (threshhold = 250);
1786			var last,
1787				deferTimer,
1788				func;
1789			func = function () {
1790				var context = scope || this;
1791				var now = +new Date,
1792					args = arguments;
1793				if (last && now < last + threshhold) {
1794					// hold on to it
1795					clearTimeout(deferTimer);
1796					deferTimer = setTimeout(function () {
1797						last = now;
1798						fn.apply(context, args);
1799					}, threshhold);
1800				} else {
1801					last = now;
1802					fn.apply(context, args);
1803				}
1804			};
1805			return func;
1806		}
1807	}());
1808
1809	$('.news-block').each(function() {
1810		var $newsblock = $(this),
1811			$items = $newsblock.find('.item-outer'),
1812			$list = $newsblock.find('.news__list'),
1813			$body = $newsblock.find('.body'),
1814			$controls = $newsblock.find('.controls'),
1815			$pagers = $newsblock.find('.bx-pager-wrap'),
1816			options = {},
1817			count,
1818			auto_controls_arr,
1819			col_arr, pager_arr, controls_arr,
1820			bxslider,
1821			containerWidth,
1822			isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
1823			slider_arr = $newsblock.attr('data-slider').split(","),
1824			swipe_arr = $newsblock.attr('data-swipe').split(",");
1825
1826		if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) {
1827
1828			options.pagerSelector= $newsblock.attr('data-setting-pager_selector');
1829			options.prevSelector = $newsblock.attr('data-setting-prev_selector');
1830			options.nextSelector = $newsblock.attr('data-setting-next_selector');
1831			options.prevText = $newsblock.attr('data-setting-prev_text') || '';
1832			options.nextText = $newsblock.attr('data-setting-next_text') || '';
1833			options.auto = !!parseInt($newsblock.attr('data-setting-auto'));
1834			options.controls = !!parseInt($newsblock.attr('data-setting-control
1834s'));
1835			options.pager = !!parseInt($newsblock.attr('data-setting-pager').split(',')[0]);
1836			options.pause = parseInt($newsblock.attr('data-setting-pause'), 10) || 4000;
1837			options.useCSS = isMobile;
1838			options.infiniteLoop = true;
1839			options.adaptiveHeight = false;
1840			options.mode = $newsblock.attr('data-setting-mode') || 'horizontal';
1841			options.touchEnabled = options.mode === 'horizontal';
1842			options.slideMargin = 0;
1843			options.maxSlides = parseInt($newsblock.attr('data-setting-count').split(',')[0], 10) || 1;
1844			options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides;
1845			options.moveSlides = $newsblock.attr('data-setting-move') || 0;
1846			options.autoControlsSelector = $newsblock.attr('data-setting-auto_controls_selector');
1847			options.autoControls =  !!parseInt($newsblock.attr('data-setting-auto_controls').split(',')[0]);
1848			options.autoControlsCombine =  !!parseInt($newsblock.attr('data-setting-autoControlsCombine'));
1849			options.autoHover = true;
1850
1851			col_arr = $newsblock.attr('data-setting-columns').split(",");
1852			pager_arr = $newsblock.attr('data-setting-pager').split(",");
1853			controls_arr = $newsblock.attr('data-setting-controls').split(",");
1854			auto_controls_arr = $newsblock.attr('data-setting-auto_controls').split(",");
1855
1856			if (!options.autoControls && options.auto) {
1857				options.onSlideAfter = function() {
1858					bxslider.startAuto();
1859				}
1860			}
1861
1862			$items.removeClass('hidden');
1863			if ($list.parent().hasClass('bx-viewport')) {
1864				$list.unwrap();
1865				$list.unwrap();
1866			}
1867
1868			function init(force) {
1869				var media_type,
1870					body_width = $('body').width();
1871
1872				var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"];
1873				var media_ind, setting_columns,
1874					isJustify, space_between;
1875				var slider_arr = $newsblock.attr('data-slider').split(",");
1876
1877				var newContainerWidth = $newsblock.width(), itemHeight, viewportHeight;
1878				if (!$newsblock.is(':visible')) {
1879					if (bxslider) {
1880						bxslider.destroySlider();
1881					}
1882					return;
1883				}
1884				if (force!='force' && containerWidth && containerWidth === newContainerWidth) {
1885					return;
1886				}
1887				containerWidth = newContainerWidth;
1888
1889				if (bxslider) {
1890					bxslider.destroySlider();
1891				}
1892
1893				if (body_width >= 961) {
1894					media_type = "screen";
1895				} else if (body_width <= 960 && body_width >= 769) {
1896					media_type = "tablet_landscape";
1897				} else if (body_width <= 768 && body_width >= 641) {
1898					media_type = "tablet_portrait";
1899				} else if (body_width <= 640 && body_width >= 481) {
1900					media_type = "mobile_landscape";
1901				} else if (body_width <= 480) {
1902					media_type = "mobile_portrait";
1903				}
1904				media_ind = mediaList.indexOf(media_type);
1905
1906                count = parseInt($newsblock.attr('data-setting-count').split(',')[media_ind], 10);
1907				isJustify = $body.css('justify-content') == "space-between" ? true : false;
1908
1909				$controls.css("pointer-events","none");
1910				$controls.find('.prev').css("pointer-events","auto");
1911				$controls.find('.next').css("pointer-events","auto");
1912
1913				$list.width('auto');
1914				$items
1915					.attr('style', '')
1916					.slice(1).addClass('hidden').end()
1917					.width(options.slideWidth = $items.width())
1918					.removeClass('hidden');
1919
1920				if (pager_arr.length > 1) {
1921					options.pager = !!parseInt(pager_arr[media_ind]);
1922				}
1923				if (controls_arr.length > 1) {
1924					options.controls = !!parseInt(controls_arr[media_ind]);
1925				}
1926				if (auto_controls_arr.length > 1) {
1927					options.autoControls = !!parseInt(auto_controls_arr[media_ind]);
1928				}
1929
1930				$(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"});
1931				$newsblock.find(".controls").css({"display": options.controls == true ? "flex" : "none"});
1932
1933				if (options.mode === 'vertical') {
1934					itemHeight = Math.max.apply(Math, $items.map(function() {
1935						return $(this).height()
1936					}).get());
1937					$items.css('min-height', itemHeight);
1938					viewportHeight = itemHeight * count;
1939                    options.maxSlides = options.minSlides = count;
1940				} else {
1941					setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]);
1942					if (setting_columns) {
1943						count = setting_columns;
1944					}
1945					options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width()));
1946				}
1947
1948				if (isJustify) {
1949					if (options.maxSlides > 1) {
1950						space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1));
1951						space_between = space_between < 0 ? 0 : space_between;
1952					} else {
1953						space_between = 0;
1954					}
1955					options.slideMargin = space_between;
1956				}
1957
1958				if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) {
1959					$list.css({'justify-content': 'flex-start'});
1960					if (bxslider) {
1961						bxslider.reloadSlider(options);
1962					} else {
1963						$list.data('bxslider', (bxslider = $list.bxSlider(options)));
1964					}
1965					if(options.pager){
1966						$pagers.css('display', 'flex');
1967					}
1968				} else {
1969					if(swipe_arr[media_ind]!=1){
1970						$list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'});
1971						$items.css('width', $items.width()-1);
1972					} else {
1973						$list.css({'flex-wrap': 'nowrap'});
1974					}
1975					$pagers.hide();
1976					$controls.hide();
1977				}
1978
1979				if (viewportHeight && slider_arr[media_ind] == 1) {
1980					$list.parent().css('min-height', viewportHeight);
1981				}
1982				if (options.mode === 'horizontal') {
1983					var align = {};
1984					switch ($body.css('justify-content')) {
1985						case 'flex-end':
1986							align['margin-left'] = 'auto';
1987							align['margin-right'] = '0px';
1988							break;
1989						case 'center':
1990							align['margin-left'] = 'auto';
1991							align['margin-right'] = 'auto';
1992							break;
1993						default:
1994							align['margin-left'] = '0px';
1995							align['margin-right'] = 'auto';
1996					}
1997					$newsblock.find('.bx-wrapper').css(align);
1998				}
1999
2000				$newsblock.wm_img_convert();
2001			}
2002
2003			$(window).on('resize', debounce(init, 300));
2004			$(window).on('load', function(){
2005				init('force');
2006			});
2007
2008			init();
2009		} else {
2010			$pagers.hide();
2011			$controls.hide();
2012		}
2013
2014		$(window).on('resize', debounce(swipeScrollInit, 300));
2015		swipeScrollInit();
2016
2017		function swipeScrollInit() {
2018			var $shadowLeft = $newsblock.find(".swipe-shadow-left");
2019			var $shadowRight = $newsblock.find(".swipe-shadow-right");
2020			if ($list.css("overflow-x") == "auto") {
2021				var scroll_width = $list.get(0).scrollWidth;
2022				var view_width = $list.width();
2023				$shadowLeft.css("pointer-events","none");
2024				$shadowRight.css("pointer-events","none");
2025
2026				$list.off('scroll');
2027				$list.on('scroll', throttle(swipeScrollCheack, 200));
2028
2029				swipeScrollCheack();
2030
2031				function swipeScrollCheack() {
2032					var scroll_left = $list.scrollLeft();
2033
2034					if (scroll_left > 0) {
2035						$shadowLeft.show();
2036					} else {
2037						$shadowLeft.hide();
2038					}
2039
2040					if (scroll_left + view_width >= scroll_width - 1) {
2041						$shadowRight.hide();
2042					} else {
2043						$shadowRight.show();
2044					}
2045				}
2046			} else {
2047				$shadowLeft.hide();
2048				$shadowRight.hide();
2049			}
2050		}
2051
2052	});
2053});
2054$(function() {
2055
2056	var debounce = (function () {
2057		return function (fn, time) {
2058			var timer, func;
2059			func = function() {
2060				var args = [].slice.call(arguments, 0);
2061				window.clearTimeout(timer);
2062				timer = window.setTimeout(function () {
2063					window.requestAnimationFrame && window.requestAnimationFrame(function() {
2064						fn.apply(null, args);
2065					}) || fn.apply(null, args);
2066				}, time)
2067			};
2068			return func;
2069		}
2070	}());
2071
2072	var throttle = (function() {
2073		return function (fn, threshhold, scope) {
2074			threshhold || (threshhold = 250);
2075			var last,
2076				deferTimer,
2077				func;
2078			func = function () {
2079				var context = scope || this;
2080				var now = +new Date,
2081					args = arguments;
2082				if (last && now < last + threshhold) {
2083					// hold on to it
2084					clearTimeout(deferTimer);
2085					deferTimer = setTimeout(function () {
2086						last = now;
2087						fn.apply(context, args);
2088					}, threshhold);
2089				} else {
2090					last = now;
2091					fn.apply(context, args);
2092				}
2093			};
2094			return func;
2095		}
2096	}());
2097
2098	$('.bx-reviews').each(function() {
2099		var $reviews = $(this),
2100			$items = $reviews.find('.item-outer'),
2101			$list = $reviews.find('.list'),
2102			$body = $reviews.find('.body'),
2103			$controls = $reviews.find('.controls'),
2104			$pagers = $reviews.find('.bx-pager-wrap'),
2105			options = {},
2106			auto_controls_arr,
2107			count,
2108			col_arr, pager_arr, controls_arr,
2109			bxslider,
2110			containerWidth,
2111			isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
2112			slider_arr = $reviews.attr('data-slider').split(","),
2113			swipe_arr = $reviews.attr('data-swipe').split(",");
2114
2115		if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) {
2116
2117			options.pagerSelector= $reviews.attr('data-setting-pager_selector');
2118			options.prevSelector = $reviews.attr('data-setting-prev_selector');
2119			options.nextSelector = $reviews.attr('data-setting-next_selector');
2120			options.prevText = $reviews.attr('data-setting-prev_text') || '';
2121			options.nextText = $reviews.attr('data-setting-next_text') || '';
2122			options.auto = !!parseInt($reviews.attr('data-setting-auto'));
2123			options.controls = !!parseInt($reviews.attr('data-setting-controls'));
2124			options.pager = !!parseInt($reviews.attr('data-setting-pager').split(',')[0]);
2125			options.pause = parseInt($reviews.attr('data-setting-pause'), 10) || 4000;
2126			options.useCSS = isMobile;
2127			options.infiniteLoop = true;
2128			options.adaptiveHeight = false;
2129			options.mode = $reviews.attr('data-setting-mode') || 'horizontal';
2130			options.touchEnabled = options.mode === 'horizontal';
2131			options.slideMargin = 0;
2132            options.maxSlides = parseInt($reviews.attr('data-setting-count').split(',')[0], 10) || 1;
2133			options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides;
2134			options.moveSlides = $reviews.attr('data-setting-move') || 0;
2135			options.autoControlsSelector = $reviews.attr('data-setting-auto_controls_selector');
2136			options.autoControls =  !!parseInt($reviews.attr('data-setting-auto_controls').split(',')[0]);
2137			options.autoControlsCombine =  !!parseInt($reviews.attr('data-setting-autoControlsCombine'));
2138			options.autoHover = true;
2139
2140			col_arr = $reviews.attr('data-setting-columns').split(",");
2141			pager_arr = $reviews.attr('data-setting-pager').split(",");
2142			controls_arr = $reviews.attr('data-setting-controls').split(",");
2143			auto_controls_arr = $reviews.attr('data-setting-auto_controls').split(",");
2144
2145			if (!options.autoControls && options.auto) {
2146				options.onSlideAfter = function() {
2147					bxslider.startAuto();
2148				}
2149			}
2150
2151			$items.removeClass('hidden');
2152			if ($list.parent().hasClass('bx-viewport')) {
2153				$list.unwrap();
2154				$list.unwrap();
2155			}
2156
2157			function init(force) {
2158				var media_type,
2159					body_width = $('body').width();
2160
2161				var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"];
2162				var media_ind, setting_columns,
2163					isJustify, space_between;
2164				var slider_arr = $reviews.attr('data-slider').split(",");
2165
2166				var newContainerWidth = $reviews.width(), itemHeight, viewportHeight;
2167				if (!$reviews.is(':visible')) {
2168					if (bxslider) {
2169						bxslider.destroySlider();
2170					}
2171					return;
2172				}
2173				if (force!='force' && containerWidth && containerWidth === newContainerWidth) {
2174					return;
2175				}
2176				containerWidth = newContainerWidth;
2177
2178				if (bxslider) {
2179					bxslider.destroySlider();
2180				}
2181
2182				if (body_width >= 961) {
2183					media_type = "screen";
2184				} else if (body_width <= 960 && body_width >= 769) {
2185					media_type = "tablet_landscape";
2186				} else if (body_width <= 768 && body_width >= 641) {
2187					media_type = "tablet_portrait";
2188				} else if (body_width <= 640 && body_width >= 481) {
2189					media_type = "mobile_landscape";
2190				} else if (body_width <= 480) {
2191					media_type = "mobile_portrait";
2192				}
2193				media_ind = mediaList.indexOf(media_type);
2194				count = parseInt($reviews.attr('data-setting-count').split(',')[media_ind], 10);
2195
2196				isJustify = $body.css('justify-content') == "space-between" ? true : false;
2197
2198				$controls.css("pointer-events","none");
2199				$controls.find('.prev').css("pointer-events","auto");
2200				$controls.find('.next').css("pointer-events","auto");
2201
2202				$list.width('auto');
2203				$items
2204					.attr('style', '')
2205					.slice(1).addClass('hidden').end()
2206					.width(options.slideWidth = $items.width())
2207					.removeClass('hidden');
2208
2209				if (pager_arr.length > 1) {
2210					options.pager = !!parseInt(pager_arr[media_ind]);
2211				}
2212				if (controls_arr.length > 1) {
2213					options.controls = !!parseInt(controls_arr[media_ind]);
2214				}
2215				if (auto_controls_arr.length > 1) {
2216					options.autoControls = !!parseInt(auto_controls_arr[media_ind]);
2217				}
2218
2219				$(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"});
2220				$reviews.find(".controls").css({"display": options.controls == true ? "flex" : "none"});
2221
2222				if (options.mode === 'vertical') {
2223					itemHeight = Math.max.apply(Math, $items.map(function() {
2224						return $(this).height()
2225					}).get());
2226					$items.css('min-height', itemHeight);
2227					viewportHeight = itemHeight * count;
2228                    options.maxSlides = options.minSlides = count;
2229				} else {
2230					setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]);
2231					if (setting_columns) {
2232						count = setting_columns;
2233					}
2234					options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width()));
2235				}
2236
2237				if (isJustify) {
2238					if (options.maxSlides > 1) {
2239						space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1));
2240						space_between = space_between < 0 ? 0 : space_between;
2241					} else {
2242						space_between = 0;
2243					}
2244					options.slideMargin = space_between;
2245				}
2246
2247				if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) {
2248					$list.css({'justify-content': 'flex-start'});
2249					if (bxslider) {
2250						bxslider.reloadSlider(options);
2251					} else {
2252						$list.data('bxslider', (bxslider = $list.bxSlider(options)));
2253					}
2254					if(options.pager){
2255						$pagers.css('display', 'flex');
2256					}
2257				} else {
2258					if(swipe_arr[media_ind]!=1){
2259						$list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'});
2260						$items.css('width', $items.width()-1);
2261					} else {
2262						$list.css({'flex-wrap': 'nowrap'});
2263					}
2264					$pagers.hide();
2265					$controls.hide();
2266				}
2267
2268				if (viewportHeight && slider_arr[media_ind] == 1) {
2269					$list.parent().css('min-height', viewportHeight);
2270				}
2271				if (options.mode === 'horizontal') {
2272					var align = {};
2273					switch ($body.css('justify-content')) {
2274						case 'flex-end':
2275							align['margin-left'] = 'auto';
2276							align['margin-right'] = '0px';
2277							break;
2278						case 'center':
2279							align['margin-left'] = 'auto';
2280							align['margin-right'] = 'auto';
2281							break;
2282						default:
2283							align['margin-left'] = '0px';
2284							align['margin-right'] = 'auto';
2285					}
2286					$reviews.find('.bx-wrapper').css(align);
2287				}
2288
2289				$reviews.wm_img_convert();
2290			}
2291
2292			$(window).on('resize', debounce(init, 300));
2293			$(window).on('load', function(){
2294				init('force');
2295			});
2296
2297			init();
2298		} else {
2299			$pagers.hide();
2300			$controls.hide();
2301		}
2302
2303		$(window).on('resize', debounce(swipeScrollInit, 300));
2304		swipeScrollInit();
2305
2306		function swipeScrollInit() {
2307			var $shadowLeft = $reviews.find(".swipe-shadow-left");
2308			var $shadowRight = $reviews.find(".swipe-shadow-right");
2309			if ($list.css("overflow-x") == "auto") {
2310				var scroll_width = $list.get(0).scrollWidth;
2311				var view_width = $list.width();
2312				$shadowLeft.css("pointer-events","none");
2313				$shadowRight.css("pointer-events","none");
2314
2315				$list.off('scroll');
2316				$list.on('scroll', throttle(swipeScrollCheack, 200));
2317
2318				swipeScrollCheack();
2319
2320				function swipeScrollCheack() {
2321					var scroll_left = $list.scrollLeft();
2322
2323					if (scroll_left > 0) {
2324						$shadowLeft.show();
2325					} else {
2326						$shadowLeft.hide();
2327					}
2328
2329					if (scroll_left + view_width >= scroll_width - 1) {
2330						$shadowRight.hide();
2331					} else {
2332						$shadowRight.show();
2333					}
2334				}
2335			} else {
2336				$shadowLeft.hide();
2337				$shadowRight.hide();
2338			}
2339		}
2340
2341	});
2342});
2343$(function() {
2344	$('.up_button').click(function () {
2345		var up_speed = $(this).data('speed')
2346		$('body, html').animate({
2347			scrollTop: 0
2348		}, up_speed);
2349	});
2350});
2351$(function () {
2352	$(document).click(function (event) {
2353		$('.contacts-block').each(function() {
2354			if ($(event.target).closest($(this)).length) {
2355				return;
2356			} else {
2357				$(this).find('.tgl-but').prop("checked", false);
2358				$(this).find('.icon').removeClass('active');
2359			}
2360		});
2361	});
2362
2363	function setMargin($block) {
2364		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
2365			$block.find(".block-body-drop").css({
2366				"margin-left": "0px"
2367			});
2368		} else {
2369			var left = $block.offset().left * -1;
2370			$block.find(".block-body-drop").css({
2371				"margin-left": left + "px"
2372			});
2373		}
2374	}
2375
2376	$('.contacts-block').each(function() {
2377		var $block = $(this),
2378			allClasses = $block.attr("class").split(" "),
2379			mainClass = allClasses[0],
2380			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
2381			styles = document.styleSheets;
2382
2383		for(var i = 0; i < styles.length; i++) {
2384			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
2385				for(var j = 0; j < styles[i].cssRules.length; j++) {
2386					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
2387						$block.data("fullwidth", 1);
2388						setMargin($block);
2389						break;
2390					}
2391				}
2392				break;
2393			}
2394		}
2395	});
2396
2397	$(window).resize(function() {
2398		$('.contacts-block').each(function() {
2399			var $block = $(this);
2400			if ($block.data("fullwidth") == 1) {
2401				setMargin($block);
2402			}
2403		});
2404	});
2405
2406	$('.contacts-block').each(function() {
2407		var $block = $(this);
2408		$block.find('.icon').click(function() {
2409			if ($block.data("fullwidth") == 1) {
2410				setMargin($block);
2411			}
2412			if ($block.find('.tgl-but').prop("checked")) {
2413				$(this).removeClass('active');
2414			} else {
2415				$(this).addClass('active');
2416			}
2417		});
2418	});
2419});
2420$(function() {
2421	if (window.ymaps) {
2422		ymaps.ready(function () {
2423			$('.widget-type-map[data-center]').each(function () {
2424				var self = $(this);
2425				var id = self.attr('id');
2426				var data = false;
2427				if (self.find('[type=hidden]').val()) {
2428					data = typeof JSON.parse == 'function' ? JSON.parse(self.find('[type=hidden]').val()) : eval(self.find('[type=hidden]').val());
2429				}
2430				var params = {
2431					type: self.data('type') || 'yandex#map',
2432					center: self.data('center').split(',').map(function (e) {
2433						return $.trim(e)
2434					}),
2435					zoom: self.data('zoom') || 9,
2436					controls: self.data('controls') ? self.data('controls').split(',').map(function (e) {
2437						return $.trim(e)
2438					}) : []
2439				};
2440				var myMap = new ymaps.Map(id, params);
2441				myMap.behaviors.disable('scrollZoom');
2442				if (data) {
2443					for (var i in data) {
2444						var myPlacemark = new ymaps.Placemark(data[i].point.split(',').map(function (e) {
2445							return $.trim(e);
2446						}), {
2447							iconContent: $('<div>').html(data[i].iconContent).text(),
2448							balloonContent: $('<div>').html(data[i].balloonContent).html()
2449						}, {
2450							preset: data[i].preset
2451						});
2452						myMap.geoObjects.add(myPlacemark);
2453					}
2454				}
2455			});
2456		});
2457	}
2458});
2459$(function () {
2460	$(document).click(function (event) {
2461		$('.contacts-block').each(function() {
2462			if ($(event.target).closest($(this)).length) {
2463				return;
2464			} else {
2465				$(this).find('.tgl-but').prop("checked", false);
2466				$(this).find('.icon').removeClass('active');
2467			}
2468		});
2469	});
2470
2471	function setMargin($block) {
2472		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
2473			$block.find(".block-body-drop").css({
2474				"margin-left": "0px"
2475			});
2476		} else {
2477			var left = $block.offset().left * -1;
2478			$block.find(".block-body-drop").css({
2479				"margin-left": left + "px"
2480			});
2481		}
2482	}
2483
2484	$('.contacts-block').each(function() {
2485		var $block = $(this),
2486			allClasses = $block.attr("class").split(" "),
2487			mainClass = allClasses[0],
2488			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
2489			styles = document.styleSheets;
2490
2491		for(var i = 0; i < styles.length; i++) {
2492			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
2493				for(var j = 0; j < styles[i].cssRules.length; j++) {
2494					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
2495						$block.data("fullwidth", 1);
2496						setMargin($block);
2497						break;
2498					}
2499				}
2500				break;
2501			}
2502		}
2503	});
2504
2505	$(window).resize(function() {
2506		$('.contacts-block').each(function() {
2507			var $block = $(this);
2508			if ($block.data("fullwidth") == 1) {
2509				setMargin($block);
2510			}
2511		});
2512	});
2513
2514	$('.contacts-block').each(function() {
2515		var $block = $(this);
2516		$block.find('.icon').click(function() {
2517			if ($block.data("fullwidth") == 1) {
2518				setMargin($block);
2519			}
2520			if ($block.find('.tgl-but').prop("checked")) {
2521				$(this).removeClass('active');
2522			} else {
2523				$(this).addClass('active');
2524			}
2525		});
2526	});
2527});
2528document.addEventListener('DOMContentLoaded', function() {
2529	var bodyScrollBarWidth = (function () {
2530		var widthHidden, widthScroll, currentValue, currentPriority;
2531		currentValue = document.body.style.getPropertyValue('overflow');
2532		currentPriority = document.body.style.getPropertyPriority('overflow');
2533		document.body.style.setProperty('overflow', 'hidden', 'important');
2534		widthHidden = document.body.clientWidth;
2535		document.body.style.setProperty('overflow', 'scroll', 'important');
2536		widthScroll = document.body.clientWidth;
2537		document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority);
2538		return widthHidden - widthScroll;
2539	}());
2540	var media = {
2541		'tablet-landscape': 960,
2542		'tablet-portrait': 768,
2543		'mobile-landscape': 640,
2544		'mobile-portrait': 480
2545	};
2546	var side_panel = document.querySelector('.side-panel');
2547	var side_panel_content, side_panel_content_inner, side_panel_top, side_panel_mask, side_panel_button, side_panel_close, side_panel_controller, leftEdge, rightEdge, isPhantom;
2548	var layers, content_width, flip, full_width, elements = {}, comments = {};
2549
2550	if (!side_panel || side_panel.classList.contains('removed')) {
2551		return;
2552	}
2553
2554	flip = side_panel.getAttribute('data-position') === 'right';
2555
2556	try {
2557		layers = side_panel.getAttribute('data-layers');
2558		if (layers !== "") {
2559			layers = JSON.parse(layers.replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"'));
2560		}
2561	} catch(e) {
2562		console.error(e);
2563	}
2564
2565	if (typeof layers !== 'object' || Object.keys(layers).length === 0) {
2566		return;
2567	}
2568
2569	Object.keys(layers).forEach(function(clss) {
2570		elements[clss] = document.querySelector('.' + clss);
2571		comments[clss] = document.createComment(clss);
2572		if (elements[clss]) {
2573			elements[clss].parentNode.insertBefore(comments[clss], elements[clss]);
2574		} else {
2575			delete layers[clss];
2576		}
2577	});
2578
2579	side_panel_button = side_panel.querySelector('.side-panel-button');
2580	side_panel_close = side_panel.querySelector('.side-panel-close');
2581	side_panel_content = side_panel.querySelector('.side-panel-content');
2582	side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content;
2583	side_panel_mask = side_panel.querySelector('.side-panel-mask');
2584	side_panel_top = side_panel.querySelector('.side-panel-top-inner');
2585
2586	side_panel.classList.remove('hidden');
2587	side_panel_button.classList.remove('hidden');
2588	side_panel_button.style.display = 'none';
2589	side_panel_content.classList.remove('hidden');
2590	side_panel_content.style.display = 'none';
2591	side_panel_mask.classList.remove('hidden');
2592	side_panel_mask.style.display = 'none';
2593
2594	content_width = getComputedStyle(side_panel_content, null).width;
2595
2596	leftEdge = 0;
2597	rightEdge = parseInt(content_width) + 50;
2598
2599	if (content_width === 'auto') {
2600		rightEdge = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
2601		full_width = true;
2602	}
2603
2604	isPhantom = !!parseInt($(side_panel).attr("data-phantom"));
2605
2606	if (isPhantom) {
2607		$(side_panel).css({"pointer-events": "none"});
2608	} else {
2609		$(side_panel).css({"pointer-events": "auto"});
2610	}
2611
2612	if (flip) {
2613		side_panel_content.style.left = 'auto';
2614		side_panel_content.style.right = '0';
2615	}
2616
2617	if (full_width) {
2618		side_panel_content.style.left = '0';
2619		side_panel_content.style.right = '0';
2620	}
2621
2622	window.side_panel_controller = side_panel_controller = new DrawerController({
2623		target: side_panel,
2624		full_width: full_width,
2625		left: leftEdge,
2626		right: rightEdge,
2627		position: 0,
2628		flip: flip,
2629		curve: 'ease-in-out',
2630		willOpen: function() {
2631			side_panel_mask.style.display = 'block';
2632			side_panel_content.style.display = 'block';
2633			document.body.classList.add('noscroll');
2634			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
2635				document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent'
2636			}
2637		},
2638		didClose: function() {
2639			side_panel_mask.style.display = 'none';
2640			side_panel_content.style.display = 'none';
2641			document.body.classList.remove('noscroll');
2642			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
2643				document.body.style.borderRight = ''
2644			}
2645		},
2646		onAnimate: function(position) {
2647			side_panel_mask.style.opacity = position / rightEdge;
2648			side_panel_content.style.transform = 'translate3d(' + (flip ? rightEdge - position : position - rightEdge) + 'px,0,0)';
2649		}
2650	});
2651
2652	side_panel_controller.inPanel = function(clss) {
2653		var viewportWidth;
2654		var current_media;
2655
2656		if (typeof clss !== 'string') {
2657			return false;
2658		}
2659
2660		if (clss.charAt(0) === '.') {
2661			clss = clss.slice(1);
2662		}
2663
2664		viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
2665
2666		Object.keys(media).forEach(function(key) {
2667			if (viewportWidth <= media[key]) {
2668				current_media = key;
2669			}
2670		});
2671
2672		if (typeof current_media === 'undefined') {
2673			current_media = 'screen';
2674		}
2675
2676		return layers[clss] && layers[clss][current_media];
2677	};
2678
2679	side_panel_button.addEventListener('click', function(e) {
2680		e.preventDefault();
2681		side_panel_controller.toggle();
2682		return false;
2683	});
2684
2685	if (side_panel_close) {
2686		side_panel_close.addEventListener('click', function(e) {
2687			e.preventDefault();
2688			side_panel_controller.close();
2689			return false;
2690		});
2691	}
2692
2693	side_panel_mask.addEventListener('click', function() {
2694		side_panel_controller.close();
2695		return false;
2696	});
2697
2698	document.addEventListener('keyup', function(e) {
2699		if (e.keyCode === 27) {
2700			side_panel_controller.close();
2701			return false;
2702		}
2703	});
2704
2705	var debounce = (function () {
2706		return function (fn, time) {
2707			var timer, func;
2708			if (window.requestAnimationFrame) {
2709				func = function() {
2710					timer && cancelAnimationFrame(timer);
2711					timer = requestAnimationFrame(fn);
2712				}
2713			} else {
2714				func = function() {
2715					window.clearTimeout(timer);
2716					timer = window.setTimeout(function () {
2717						fn();
2718					}, time)
2719				};
2720			}
2721			return func;
2722		}
2723	}());
2724
2725	function checkSidePanel() {
2726		var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
2727		var current_media;
2728		var emptySide = true;
2729		var emptyTop = true;
2730
2731		if (checkSidePanel.viewportWidth === viewportWidth) {
2732			return;
2733		}
2734
2735		checkSidePanel.viewportWidth = viewportWidth;
2736
2737		Object.keys(media).forEach(function(key) {
2738			if (viewportWidth <= media[key]) {
2739				current_media = key;
2740			}
2741		});
2742
2743		if (typeof current_media === 'undefined') {
2744			current_media = 'screen';
2745		}
2746
2747		Object.keys(layers).forEach(function(clss){
2748			var element, comment;
2749
2750			element = elements[clss];
2751			comment = comments[clss];
2752
2753			if (current_media in layers[clss]) {
2754				if (layers[clss][current_media] === 'onTop') {
2755					side_panel_top.appendChild(element);
2756					emptyTop = false;
2757				} else {
2758					side_panel_content_inner.appendChild(element);
2759					emptySide = false;
2760				}
2761			} else {
2762				if (comment) {
2763					comment.parentNode.insertBefore(element, comment);
2764				}
2765			}
2766		});
2767
2768		if (emptySide) {
2769			side_panel_button.style.display = 'none';
2770		} else {
2771			side_panel_button.style.display = 'block';
2772		}
2773
2774		if (!emptyTop || !emptySide) {
2775			side_panel.style.display = 'block';
2776		} else {
2777			side_panel.style.display = 'none';
2778			side_panel_controller.close();
2779		}
2780	}
2781
2782	checkSidePanel = debounce(checkSidePanel, 40);
2783
2784	checkSidePanel();
2785	window.addEventListener('resize', checkSidePanel);
2786});
2787/*
2788  @license
2789  Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
2790  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
2791  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
2792  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
2793  Code distributed by Google as part of the polymer project is also
2794  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
2795*/
2796
2797"use strict";
2798
2799(function (exports) {
2800
2801	function sign(number) {
2802		if (number < 0)
2803			return -1;
2804		if (number > 0)
2805			return 1;
2806		return 0;
2807	}
2808
2809	function Animator(delegate) {
2810		this.delegate = delegate;
2811		this.startTimeStamp = 0;
2812		this.request_ = null;
2813	};
2814
2815	Animator.prototype.scheduleAnimation = function () {
2816		if (this.request_)
2817			return;
2818		this.request_ = requestAnimationFrame(this.onAnimation_.bind(this));
2819	};
2820
2821	Animator.prototype.startAnimation = function () {
2822		this.startTimeStamp = 0;
2823		this.scheduleAnimation();
2824	};
2825
2826	Animator.prototype.stopAnimation = function () {
2827		cancelAnimationFrame(this.request_);
2828		this.startTimeStamp = 0;
2829		this.request_ = null;
2830	};
2831
2832	Animator.prototype.onAnimation_ = function (timeStamp) {
2833		this.request_ = null;
2834		if (!this.startTimeStamp)
2835			this.startTimeStamp = timeStamp;
2836		if (this.delegate.onAnimation(timeStamp))
2837			this.scheduleAnimation();
2838	};
2839
2840	function VelocityTracker() {
2841		this.recentTouchMoves_ = [];
2842		this.velocityX = 0;
2843		this.velocityY = 0;
2844	}
2845
2846	VelocityTracker.kTimeWindow = 50;
2847
2848	VelocityTracker.prototype.pruneHistory_ = function (timeStamp) {
2849		for (var i = 0; i < this.recentTouchMoves_.length; ++i) {
2850			if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) {
2851				this.recentTouchMoves_ = this.recentTouchMoves_.slice(i);
2852				return;
2853			}
2854		}
2855		// All touchmoves are old.
2856		this.recentTouchMoves_ = [];
2857	};
2858
2859	VelocityTracker.prototype.update_ = function (e) {
2860		this.pruneHistory_(e.timeStamp);
2861		this.recentTouchMoves_.push(e);
2862
2863		var oldestTouchMove = this.recentTouchMoves_[0];
2864
2865		var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX;
2866		var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY;
2867		var deltaT = e.timeStamp - oldestTouchMove.timeStamp;
2868
2869		if (deltaT > 0) {
2870			this.velocityX = deltaX / deltaT;
2871			this.velocityY = deltaY / deltaT;
2872		} else {
2873			this.velocityX = 0;
2874			this.velocityY = 0;
2875		}
2876	};
2877
2878	VelocityTracker.prototype.onTouchStart = function (e) {
2879		this.recentTouchMoves_.push(e);
2880		this.velocityX = 0;
2881		this.velocityY = 0;
2882	};
2883
2884	VelocityTracker.prototype.onTouchMove = function (e) {
2885		this.update_(e);
2886	};
2887
2888	VelocityTracker.prototype.onTouchEnd = function (e) {
2889		this.update_(e);
2890		this.recentTouchMoves_ = [];
2891	};
2892
2893	function LinearTimingFunction() {
2894	};
2895
2896	LinearTimingFunction.prototype.scaleTime = function (fraction) {
2897		return fraction;
2898	};
2899
2900	function CubicBezierTimingFunction(spec) {
2901		this.map = [];
2902		for (var ii = 0; ii <= 100; ii += 1) {
2903			var i = ii / 100;
2904			this.map.push([
2905				3 * i * (1 - i) * (1 - i) * spec[0] +
2906				3 * i * i * (1 - i) * spec[2] + i * i * i,
2907				3 * i * (1 - i) * (1 - i) * spec[1] +
2908				3 * i * i * (1 - i) * spec[3] + i * i * i
2909			]);
2910		}
2911	};
2912
2913	CubicBezierTimingFunction.prototype.scaleTime = function (fraction) {
2914		var fst = 0;
2915		while (fst !== 100 && fraction > this.map[fst][0]) {
2916			fst += 1;
2917		}
2918		if (fraction === this.map[fst][0] || fst === 0) {
2919			return this.map[fst][1];
2920		}
2921		var yDiff = this.map[fst][1] - this.map[fst - 1][1];
2922		var xDiff = this.map[fst][0] - this.map[fst - 1][0];
2923		var p = (fraction - this.map[fst - 1][0]) / xDiff;
2924		return this.map[fst - 1][1] + p * yDiff;
2925	};
2926
2927	var presetTimingFunctions = {
2928		'linear': new LinearTimingFunction(),
2929		'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]),
2930		'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]),
2931		'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]),
2932		'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]),
2933	};
2934
2935	function DrawerController(options) {
2936		this.velocityTracker = new VelocityTracker();
2937		this.animator = new Animator(this);
2938
2939		this.target = options.target;
2940		this.left = options.left;
2941		this.right = options.right;
2942		this.position = options.position;
2943		this.flip = options.flip;
2944		this.full_width = options.full_width;
2945
2946		this.width = this.right - this.left;
2947		this.curve = presetTimingFunctions[options.curve || 'linear'];
2948
2949		this.willOpenCallback = options.willOpen;
2950		this.didCloseCallback = options.didClose;
2951		this.animateCallback = options.onAnimate;
2952
2953		this.state = DrawerController.kClosed;
2954
2955		this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS;
2956
2957		this.onTouchMove = this.onTouchMove.bind(this);
2958		this.onTouchEnd = this.onTouchEnd.bind(this);
2959
2960		if (!this.full_width) {
2961			this.target.addEventListener('touchstart', this.onTouchStart.bind(this));
2962		}
2963	}
2964
2965	DrawerController.kOpened = 'opened';
2966	DrawerController.kClosed = 'closed';
2967	DrawerController.kOpening = 'opening';
2968	DrawerController.kClosing = 'closing';
2969	DrawerController.kDragging = 'dragging';
2970	DrawerController.kFlinging = 'flinging';
2971
2972	DrawerController.kBaseSettleDurationMS = 246;
2973	DrawerController.kMaxSettleDurationMS = 600;
2974
2975	DrawerController.kMinFlingVelocity = 0.4;  // Matches Android framework.
2976	DrawerController.kTouchSlop = 5;  // Matches Android framework.
2977	DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop;
2978
2979	DrawerController.prototype.restrictToCurrent = function (offset) {
2980		return Math.max(this.left, Math.min(this.position, offset));
2981	};
2982
2983	DrawerController.prototype.restrictToBounds = function (offset) {
2984		return Math.max(this.left, Math.min(this.right, offset));
2985	};
2986
2987	DrawerController.prototype.onTouchStart = function (e) {
2988		this.velocityTracker.onTouchStart(e);
2989
2990		var touchX;
2991		if (this.flip) {
2992			touchX = document.documentElement.clientWidth - e.changedTouches[0].clientX;
2993		} else {
2994			touchX = e.changedTouches[0].clientX;
2995		}
2996		var touchY = e.changedTouches[0].clientY;
2997
2998		if (this.state != DrawerController.kOpened) {
2999			if (touchX != this.restrictToCurrent(touchX))
3000				return;
3001			this.state = DrawerController.kDragging;
3002		}
3003
3004		this.animator.stopAnimation();
3005		this.target.addEventListener('touchmove', this.onTouchMove);
3006		this.target.addEventListener('touchend', this.onTouchEnd);
3007		// TODO(abarth): Handle touchcancel.
3008
3009		this.startX = touchX;
3010		this.startY = touchY;
3011		this.startPosition = this.position;
3012		this.touchBaseX = Math.min(touchX, this.startPosition);
3013	};
3014
3015	DrawerController.prototype.onTouchMove = function (e) {
3016		this.velocityTracker.onTouchMove(e);
3017
3018		if (this.state == DrawerController.kOpened) {
3019			var deltaX;
3020			if (this.flip) {
3021				deltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.startX;
3022			} else {
3023				deltaX = e.changedTouches[0].clientX - this.startX;
3024			}
3025			var deltaY = e.changedTouches[0].clientY - this.startY;
3026
3027			if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) {
3028				e.preventDefault();
3029				return;
3030			}
3031
3032			if (Math.abs(deltaY) > Math.abs(deltaX)) {
3033				this.target.removeEventListener('touchmove', this.onTouchMove);
3034				this.target.removeEventListener('touchend', this.onTouchEnd);
3035				return;
3036			}
3037
3038			this.state = DrawerController.kDragging;
3039		}
3040
3041		e.preventDefault();
3042		var touchDeltaX;
3043		if (this.flip) {
3044			touchDeltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.touchBaseX;
3045		} else {
3046			touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX;
3047		}
3048		this.position = this.restrictToBounds(this.startPosition + touchDeltaX);
3049		this.animator.scheduleAnimation();
3050	};
3051
3052	DrawerController.prototype.onTouchEnd = function (e) {
3053		this.velocityTracker.onTouchEnd(e);
3054		this.target.removeEventListener('touchmove', this.onTouchMove);
3055		this.target.removeEventListener('touchend', this.onTouchEnd);
3056
3057		var velocityX = this.velocityTracker.velocityX;
3058
3059		if (this.flip) {
3060			velocityX *= -1;
3061		}
3062
3063		if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) {
3064			this.fling(velocityX);
3065		} else if (this.isOpen()) {
3066			this.open();
3067		} else {
3068			this.close();
3069		}
3070	};
3071
3072	DrawerController.prototype.openFraction = function () {
3073		var width = this.right - this.left;
3074		var offset = this.position - this.left;
3075		return offset / width;
3076	};
3077
3078	DrawerController.prototype.isOpen = function () {
3079		return this.openFraction() >= 0.5;
3080	};
3081
3082	DrawerController.prototype.isOpening = function () {
3083		return this.state == DrawerController.kOpening ||
3084			(this.state == DrawerController.kFlinging && this.animationVelocityX > 0);
3085	}
3086
3087	DrawerController.prototype.isClosing = function () {
3088		return this.state == DrawerController.kClosing ||
3089			(this.state == DrawerController.kFlinging && this.animationVelocityX < 0);
3090	}
3091
3092	DrawerController.prototype.toggle = function () {
3093		if (this.isOpen())
3094			this.close();
3095		else
3096			this.open();
3097	};
3098
3099	DrawerController.prototype.open = function () {
3100		if (this.full_width) {
3101			this.willOpenCallback.call(this.target);
3102			return;
3103		}
3104		if (!this.position)
3105			this.willOpenCallback.call(this.target);
3106
3107		this.animator.stopAnimation();
3108		this.animationDuration = 400;
3109		this.state = DrawerController.kOpening;
3110		this.animate();
3111	};
3112
3113	DrawerController.prototype.close = function () {
3114		if (this.full_width) {
3115			this.didCloseCallback.call(this.target);
3116			return;
3117		}
3118		this.animator.stopAnimation();
3119		this.animationDuration = 400;
3120		this.state = DrawerController.kClosing;
3121		this.animate();
3122	};
3123
3124	DrawerController.prototype.fling = function (velocityX) {
3125		this.animator.stopAnimation();
3126		this.animationVelocityX = velocityX;
3127		this.state = DrawerController.kFlinging;
3128		this.animate();
3129	};
3130
3131	DrawerController.prototype.animate = function () {
3132		this.positionAnimationBase = this.position;
3133		this.animator.startAnimation();
3134	};
3135
3136	DrawerController.prototype.targetPosition = function (deltaT) {
3137		if (this.state == DrawerController.kFlinging)
3138			return this.positionAnimationBase + this.animationVelocityX * deltaT;
3139		var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration);
3140		var animationWidth = this.state == DrawerController.kOpening ?
3141		this.width - this.positionAnimationBase : -this.positionAnimationBase;
3142		return this.positionAnimationBase + targetFraction * animationWidth;
3143	};
3144
3145	DrawerController.prototype.onAnimation = function (timeStamp) {
3146		if (this.state == DrawerController.kDragging) {
3147			this.animateCallback.call(this.target, this.position);
3148			return false;
3149		}
3150
3151		var deltaT = timeStamp - this.animator.startTimeStamp;
3152		var targetPosition = this.targetPosition(deltaT);
3153		this.position = this.restrictToBounds(targetPosition);
3154
3155		this.animateCallback.call(this.target, this.position);
3156
3157		if (targetPosition <= this.left && this.isClosing()) {
3158			this.state = DrawerController.kClosed;
3159			this.didCloseCallback.call(this.target);
3160			return false;
3161		}
3162		if (targetPosition >= this.right && this.isOpening()) {
3163			this.state = DrawerController.kOpened;
3164			return false;
3165		}
3166
3167		return true;
3168	};
3169
3170
3171	exports.DrawerController = DrawerController;
3172
3173})(window);

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.