PageSourceSearch

http://vdohnovenie.su/t/v568/images/js/title.js

js vdohnovenie.su collected 2026-10-07 17:55:42 UTC 70,770 bytes, 2,342 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$(function () {
152	$(document).click(function (event) {
153		$('.contacts-block').each(function() {
154			if ($(event.target).closest($(this)).length) {
155				return;
156			} else {
157				$(this).find('.tgl-but').prop("checked", false);
158				$(this).find('.icon').removeClass('active');
159			}
160		});
161	});
162
163	function setMargin($block) {
164		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
165			$block.find(".block-body-drop").css({
166				"margin-left": "0px"
167			});
168		} else {
169			var left = $block.offset().left * -1;
170			$block.find(".block-body-drop").css({
171				"margin-left": left + "px"
172			});
173		}
174	}
175
176	$('.contacts-block').each(function() {
177		var $block = $(this),
178			allClasses = $block.attr("class").split(" "),
179			mainClass = allClasses[0],
180			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
181			styles = document.styleSheets;
182
183		for(var i = 0; i < styles.length; i++) {
184			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
185				for(var j = 0; j < styles[i].cssRules.length; j++) {
186					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
187						$block.data("fullwidth", 1);
188						setMargin($block);
189						break;
190					}
191				}
192				break;
193			}
194		}
195	});
196
197	$(window).resize(function() {
198		$('.contacts-block').each(function() {
199			var $block = $(this);
200			if ($block.data("fullwidth") == 1) {
201				setMargin($block);
202			}
203		});
204	});
205
206	$('.contacts-block').each(function() {
207		var $block = $(this);
208		$block.find('.icon').click(function() {
209			if ($block.data("fullwidth") == 1) {
210				setMargin($block);
211			}
212			if ($block.find('.tgl-but').prop("checked")) {
213				$(this).removeClass('active');
214			} else {
215				$(this).addClass('active');
216			}
217		});
218	});
219});
220$(function() {
221
222	var debounce = (function () {
223		return function (fn, time) {
224			var timer, func;
225			func = function() {
226				var args = [].slice.call(arguments, 0);
227				window.clearTimeout(timer);
228				timer = window.setTimeout(function () {
229					window.requestAnimationFrame && window.requestAnimationFrame(function() {
230						fn.apply(null, args);
231					}) || fn.apply(null, args);
232				}, time)
233			};
234			return func;
235		}
236	}());
237
238	$('.slider').each(function() {
239		var $this = $(this),
240			options = {},
241			bxslider,
242			$slider_item = $this.find('.slider-item');
243		options.mode = $this.attr('data-setting-mode');
244		options.pagerCustom = $this.attr('data-setting-pager_selector');
245		options.prevSelector = $this.attr('data-setting-prev_selector');
246		options.nextSelector = $this.attr('data-setting-next_selector');
247		options.prevText = $this.attr('data-setting-prev_text') || '';
248		options.nextText = $this.attr('data-setting-next_text') || '';
249		options.auto = !!parseInt($this.attr('data-setting-auto'));
250		options.controls = !!parseInt($this.attr('data-setting-controls'));
251		options.pager = !!parseInt($this.attr('data-setting-pager'));
252		options.pause = parseInt($this.attr('data-setting-pause'), 10) || 4000;
253		options.autoControlsSelector = $this.attr('data-setting-auto_controls_selector');
254		options.autoControls =  !!parseInt($this.attr('data-setting-auto_controls').split(',')[0]);
255		options.autoControlsCombine =  !!parseInt($this.attr('data-setting-autoControlsCombine'));
256		options.useCSS = false;
257		options.responsive = false;
258		options.autoHover = true;
259
260		var itemLength = $slider_item.length;
261		var $pager_wrap = $this.find('.slider-pager-wrap');
262		var $pager = '<a href="" data-slide-index=""><span></span></a>';
263		var $dotsType = $this.attr('data-type-pager');
264		var textPosition = $this.attr('data-text_position');
265		var $pager_wrap_inner = $('<div class="slider-pager"></div>');
266		var force = true;
267
268		var $new_pagers_html = ''+
269			'<div class="bx-auto_controls">'+
270			'<div class="auto_controls">'+
271			'<div class="bx-controls-auto">'+
272			'<div class="bx-controls-auto-item"><a class="bx-start"></a></div>'+
273			'<div class="bx-controls-auto-item"><a class="bx-stop"></a></div>'+
274			'</div>'+
275			'</div>'+
276			'</div>';
277
278		if (!options.autoControls && options.auto) {
279			options.onSlideAfter = function () {
280				bxslider.startAuto();
281			}
282		}
283
284		function init() {
285
286			if (bxslider) {
287				bxslider.destroySlider();
288			}
289			if (!$this.is(':visible')) {
290				return;
291			}
292
293			$this.find('.slider-item[data-src]').each(function () {
294				$(this).css('background-image', 'url("' + $(this).data('src') + '")');
295			});
296
297			if ($this.find('.slider-item .overfill').length == 0) {
298				$this.find('.slider-item').prepend('<div class="overfill"></div>');
299			}
300
301			var bg_attc = $this.css('background-attachment');
302			var bg_cl = $this.css('background-clip');
303			var bg_colr = $this.css('background-color');
304			var bg_image = $this.css('background-image');
305			var bg_org = $this.css('background-origin');
306			var bg_rep = $this.css('background-repeat');
307			var bg_size = $this.css('background-size');
308
309
310			$this.find('.overfill').css({
311				'background-attachment': bg_attc,
312				'background-clip': bg_cl,
313				'background-color': bg_colr,
314				'background-image': bg_image,
315				'background-origin': bg_org,
316				'background-repeat': bg_rep,
317				'background-size': bg_size
318			});
319
320			$this.find('>.overfill').remove();
321
322			if(textPosition=='out' && force){
323				var $textWrap = $this.find('.text_wrapper');
324				var text_options = {};
325				var $textInner = $textWrap.find('.text_inner');
326				var clone_text = $textInner.find('.text_slider').clone();
327				text_options.mode = $this.attr('data-setting-mode');
328				text_options.auto = false;
329				text_options.controls = false;
330				text_options.pager = false;
331				text_options.autoControlsSelector = false;
332				text_options.autoControls =  false;
333				text_options.autoControlsCombine =  false;
334
335
336				if($this.find('>.wrap_text_dm').length > 0){
337					for (var i = 1; i < itemLength; i++) {
338						$textInner.append(clone_text.clone());
339					}
340					$this.find('>.wrap_text_dm').remove();
341				}
342
343				if(text_options.mode=="fade"){
344					var itemHeight = Math.max.apply(Math, $textInner.find('.text_slider').map(function() {
345						return $(this).height()
346					}).get());
347					$textInner.css('min-height', itemHeight);
348				}
349
350				var textSlider = $textInner.bxSlider(text_options);
351				$textInner.data('bxslider', textSlider);
352
353				options.onSlideNext = function(){
354					textSlider.goToNextSlide();
355				};
356
357				options.onSlidePrev = function(){
358					textSlider.goToPrevSlide();
359				};
360
361				options.onSlideBefore = function($slideElement, oldIndex, newIndex){
362					if(newIndex == 0 && oldIndex == textSlider.getSlideCount() - 1 || newIndex-oldIndex == 1) {
363						textSlider.goToNextSlide();
364					} else if(oldIndex == 0 && newIndex == textSlider.getSlideCount() - 1 || oldIndex-newIndex == 1){
365						textSlider.goToPrevSlide();
366					} else {
367						textSlider.goToSlide(newIndex);
368					}
369				};
370				force = false;
371
372			} else if(textPosition=='in' && $this.find('>.wrap_text_dm').length > 0){
373				var clone_text = $this.find('.text-slider').clone();
374				$this.find('.slider-item .overfill').after(clone_text);
375				$this.find('>.wrap_text_dm').remove();
376			}
377
378
379			if(itemLength>1){
380				if (bxslider) {
381					if (options.pager && $pager_wrap.find('.slider-pager').length==0) {
382						if($pager_wrap.find('.bx-auto_controls').length==0){
383							$pager_wrap.append($new_pagers_html);
384						}
385						$pager_wrap.find('.bx-auto_controls').append($pager_wrap_inner);
386
387						for (var i = 0; i < itemLength; i++) {
388							$pager_wrap_inner.append($pager);
389						}
390
391						$pager = $pager_wrap_inner.find('a');
392						$pager.each(function () {
393							var $this = $(this);
394							var index = $this.index();
395							$this.attr('data-slide-index', index);
396							if ($dotsType == 'figures') {
397								$this.find('span').html(index + 1);
398							}
399						});
400					}
401
402					bxslider.reloadSlider(options);
403
404				} else {
405					$this.find('.slider-inner').data('bxslider', (bxslider = $this.find('.slider-inner').bxSlider(options)));
406				}
407			}
408			else{
409				$this.find('.slider-controls').addClass('hidden');
410				$this.find('.slider-pager-wrap').addClass('hidden');
411			}
412		}
413
414		$(window).on('resize', debounce(init, 300));
415
416		init();
417	});
418});
419/*
420 *  wmS3Menu v1.0.0
421 *  K.I. 433
422 */
423;(function ($, window, document, undefined ) {
424	var pluginName = 'wmS3Menu',
425		defaults = {
426			screenButton: false,
427			responsiveTl: false,
428			responsiveTp: false,
429			responsiveMl: false,
430			moreText: '...',
431			childIcons: false,
432			childIconsClass: 'has-child-icon'
433		};
434	// Проверка на касание
435	var isTouchable = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
436	var $win = $(window);
437	var winWidth = $win.width();
438	var $doc = $(document);
439
440	var pluginObj = {
441		_events: {
442			hover: function(menuWrap, item, settings){
443				var link = item.find('> a');
444				var linkIcon = link.find('.' + settings.childIconsClass);
445				var iconLen = linkIcon.length;
446				var subMenu = item.find('> ul');
447				var showTimeout;
448				// Отображение
449				function menuShow() {
450					clearTimeout(showTimeout);
451					item.siblings().find('> ul').css('display', '');
452					// Определение положения выпадашки чтобы не выводилось за пределы окна
453					pluginObj._menuPosition(subMenu);
454
455					link.addClass('hover');
456					if (iconLen) {
457						linkIcon.addClass('hover');
458					}
459				}
460				// Скрытие
461				function menuHide() {
462					showTimeout = setTimeout(function(){
463						link.removeClass('hover');
464						subMenu.css('display', '');
465						if (iconLen) {
466							linkIcon.removeClass('hover');
467						}
468					}, 500);
469				}
470				// Отключение и подключение событий
471				item.off({
472					'mouseenter.wmS3Menu': menuShow,
473					'mouseleave.wmS3Menu': menuHide
474				});
475				item.on({
476					'mouseenter.wmS3Menu': menuShow,
477					'mouseleave.wmS3Menu': menuHide
478				});
479			},
480			click: function(menuWrap, item, settings){
481				var link = item.find('> a');
482				var linkIcon = link.find('.' + settings.childIconsClass);
483				var iconLen = linkIcon.length;
484				var subMenu = item.find('> ul');
485				// Переключение отображения
486				function menuToggle() {
487					if (subMenu.is(':visible')) {
488						if (isTouchable) {
489							document.location = link.attr('href');
490						}
491						link.removeClass('hover');
492						subMenu.css('display', '');
493						item.removeClass('submenu-opened');
494						if (iconLen) {
495							linkIcon.removeClass('hover');
496						}
497					} else {
498						item.siblings().find('> ul').css('display', '');
499						item.siblings().find('> a').removeClass('hover');
500						item.siblings().find('> a .' + settings.childIconsClass).removeClass('hover');
501						// Определение положения выпадашки чтобы не выводилось за пределы окна
502						pluginObj._menuPosition(subMenu);
503
504						link.addClass('hover');
505						item.addClass('submenu-opened');
506						if (iconLen) {
507							linkIcon.addClass('hover');
508						}
509					}
510					return false;
511				}
512				// Отключение и подключение событий
513				link.off('click.wmS3Menu');
514				link.on('click.wmS3Menu', menuToggle);
515			},
516			click_tree: function(menuWrap, item, settings){
517				var link = item.find('> a');
518				var linkIcon = link.find('.' + settings.childIconsClass);
519				var subMenu = item.find('> ul');
520				// Переключение отображения
521				function menuToggle(event) {
522					var targ = $(event.target);
523
524					if (targ.closest(linkIcon).length) {
525						if (subMenu.is(':visible')) {
526							link.removeClass('hover');
527							subMenu.css('display', '');
528							item.removeClass('submenu-opened');
529							linkIcon.removeClass('hover');
530						} else {
531							// Определение положения выпадашки чтобы не выводилось за пределы окна
532							pluginObj._menuPosition(subMenu);
533
534							link.addClass('hover');
535							item.addClass('submenu-opened');
536							linkIcon.addClass('hover');
537						}
538						return false;
539					}
540				}
541				// Отключение и подключение событий
542				link.off('click.wmS3Menu');
543				link.on('click.wmS3Menu', menuToggle);
544			}
545		},
546		_menuPosition: function(subMenu) {
547			// Определение положения выпадашки чтобы не выводилось за пределы окна
548			winWidth = $win.width();
549
550			subMenu.css('display', 'block');
551
552			if (subMenu.parent().hasClass('first-level') === false) {
553				subMenu.css({
554					'visibility': 'hidden',
555					'opacity': 0
556				});
557
558				var menuRect = subMenu[0].getBoundingClientRect();
559				var marginR = parseInt(subMenu.css('margin-right'));
560				var parentWidth = subMenu.parent().width();
561
562				if (marginR > parentWidth) {
563					subMenu.css('margin-right', parentWidth);
564				}
565
566				if (menuRect.right >= winWidth) {
567					subMenu.css({
568						'left': '-100%',
569						'margin-left': 0
570					});
571				}
572				subMenu.css({
573					'visibility': '',
574					'opacity': ''
575				});
576			}
577		}
578	};
579	function Plugin(element, options) {
580		this.element = element;
581
582		this.options = $.extend({}, defaults, options, $(this.element).data()) ;
583
584		this._defaults = defaults;
585		this._name = pluginName;
586
587		this.init();
588	}
589	Plugin.prototype = {
590		init: function () {
591			var settings = this.options;
592			// Определение ширины медиа
593			var moreButFlag = false;
594			if (window.matchMedia('all and (max-width: 480px)').matches) {
595				moreButFlag = settings.responsiveMl;
596			} else if (window.matchMedia('all and (max-width: 640px)').matches) {
597				//moreButFlag = settings.responsiveTp;
598			} else if (window.matchMedia('all and (max-width: 768px)').matches) {
599				moreButFlag = settings.responsiveTl;
600			} else {
601				moreButFlag = settings.screenButton;
602			}
603			// Обертка меню
604			var menuWrap = $(this.element);
605			var menuClass = menuWrap.attr('class');
606			var menuMainUl = $(this.element.querySelector('ul'));
607			var widgetClass = menuClass.match(/widget-\d+/)[0];
608			// Проверка на наличие меню в Side panel
609			if (window.side_panel_controller && side_panel_controller.inPanel(widgetClass)) {
610				moreButFlag = false;
611			}
612
613			menuMainUl.children().addClass('first-level');
614			// Настройки для горизонтального меню
615			if (!!menuClass.match(/horizontal/i)) {
616				var menuWidth = menuMainUl.width();
617				var itemsWidth = 0, hideArr = [], hideLength;
618				// Кнопка More
619				var moreBut = menuMainUl.find('.more-button');
620				if (!moreBut.length) {
621					moreBut = $('<li class="more-button"><a href="#"><span>' + settings.moreText + '</span></a></li>');// data-trigger="click"
622					menuMainUl.append(moreBut);
623				}
624				// Меню More
625				var moreMenu = moreBut.find('> ul');
626				if (!moreMenu.length) {
627					moreMenu = $('<ul></ul>');
628					moreBut.append(moreMenu);
629				}
630
631				moreBut.removeClass('removed').attr('data-trigger', 'hover');
632				menuMainUl.children().css('display', '');
633
634				var firstLevelItems = menuMainUl.children(':visible').not('.more-button');
635				moreMenu.html('');
636
637				if (moreButFlag === 'more' || moreButFlag === 'button') {
638					moreBut.removeClass('disabled');
639
640					menuWidth -= moreBut.outerWidth();
641
642					firstLevelItems.each(function(){
643						var thisItem = $(this);
644						itemsWidth += thisItem.outerWidth(true);
645						if (itemsWidth >= menuWidth) {
646							hideArr.push(thisItem.clone());
647							thisItem.hide();
648						}
649					});
650
651					hideLength = hideArr.length;
652					if (hideLength) {
653						for (var ind = 0; ind < hideLength; ind++) {
654							moreMenu.append(hideArr[ind]);
655						}
656						moreBut.removeClass('disabled');
657					} else {
658						moreBut.addClass('disabled');
659					}
660				} else {
661					moreBut.addClass('disabled');
662				}
663			}
664			// Вложенные подуровни меню
665			var menuInner = menuMainUl.find('ul');
666			var menuItems = menuInner.parent();
667			var menuLinks = menuItems.find('> a');
668			// Стрелочки для подуровней
669			var menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
670			var childIconLen = menuLinksIcons.length;
671			// Тип отображения меню
672			var mShow = 'popup';
673			if (!!menuClass.match(/dropdown/i)) {
674				mShow = 'dropdown';
675			} else if (!!menuClass.match(/treemenu/i)) {
676				mShow = 'treemenu';
677			}
678			if (mShow === 'popup') {
679				menuInner.hide();
680			}
681			if (childIconLen) {
682				menuLinksIcons.remove();
683			}
684			if (!!settings.childIcons) {
685				// Добавление стрелочек для подуровней
686				var childIconHTML = '<em class="' + settings.childIconsClass + '"></em>';
687
688				if (mShow === 'treemenu') {
689					childIconHTML = '<em class="' + settings.childIconsClass + '"><b style="position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;"></b></em>';
690				}
691
692				var childIconTag = $(childIconHTML);
693				menuLinks.append(childIconTag.clone());
694
695				menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
696				childIconLen = menuLinksIcons.length;
697			}
698			// Удаление всех событий на ссылках
699			menuLinks.removeClass('hover').off('click.wmS3Menu');
700			menuInner.css('display', '');
701			if (childIconLen) {
702				menuLinksIcons.removeClass('hover');
703			}
704
705			menuItems.each(function() {
706				var thisItem = $(this);
707				var trigger = thisItem.data('trigger') || 'hover';
708
709				if (mShow === 'dropdown' || isTouchable) {
710					trigger = 'click';
711				} else if (mShow === 'treemenu') {
712					trigger = 'click_tree';
713				}
714				pluginObj._events[trigger](menuWrap, thisItem, settings);
715			});
716			// Клик по документу
717			if (isTouchable) {
718				function docClick(e) {
719					var target = $(e.target);
720					if (target.closest(menuWrap).length === 0) {
721						menuLinks.removeClass('hover');
722						menuInner.css('display', '');
723						menuItems.removeClass('submenu-opened');
724
725						if (childIconLen) {
726							menuLinksIcons.removeClass('hover');
727						}
728					}
729				}
730				$doc.off('touchstart.wmS3Menu', docClick);
731				$doc.on('touchstart.wmS3Menu', docClick);
732			}
733		},
734		update: function () {
735			this.init();
736		}
737	};
738	if (!$.fn[pluginName]) {
739		$.fn[pluginName] = function (options) {
740			var args = arguments;
741			if (options === undefined || typeof options === 'object') {
742				return this.each(function () {
743					if (!$.data(this, 'plugin_' + pluginName)) {
744						$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
745					}
746				});
747			} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
748				var returns;
749				this.each(function () {
750					var instance = $.data(this, 'plugin_' + pluginName);
751					if (instance instanceof Plugin && typeof instance[options] === 'function') {
752						returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
753					}
754					if (options === 'destroy') {
755						$.data(this, 'plugin_' + pluginName, null);
756					}
757				});
758				return returns !== undefined ? returns : this;
759			}
760		};
761	}
762	$(function () {
763		var wmMenuWrap = $('.wm-widget-menu.horizontal');
764		wmMenuWrap[pluginName]();
765
766		$win.on('resize.wmS3Menu', function(){
767			wmMenuWrap[pluginName]('update');
768		});
769	});
770
771	setTimeout(function(){
772		$win.trigger('resize');
773	}, 500);
774}(jQuery, window, document));
775$(function() {
776
777	var debounce = (function () {
778		return function (fn, time) {
779			var timer, func;
780			func = function() {
781				var args = [].slice.call(arguments, 0);
782				window.clearTimeout(timer);
783				timer = window.setTimeout(function () {
784					window.requestAnimationFrame && window.requestAnimationFrame(function() {
785						fn.apply(null, args);
786					}) || fn.apply(null, args);
787				}, time)
788			};
789			return func;
790		}
791	}());
792
793	var throttle = (function() {
794		return function (fn, threshhold, scope) {
795			threshhold || (threshhold = 250);
796			var last,
797				deferTimer,
798				func;
799			func = function () {
800				var context = scope || this;
801				var now = +new Date,
802					args = arguments;
803				if (last && now < last + threshhold) {
804					// hold on to it
805					clearTimeout(deferTimer);
806					deferTimer = setTimeout(function () {
807						last = now;
808						fn.apply(context, args);
809					}, threshhold);
810				} else {
811					last = now;
812					fn.apply(context, args);
813				}
814			};
815			return func;
816		}
817	}());
818
819	$('.horizontal_blocklist').each(function() {
820		var $blocklist = $(this),
821			$items = $blocklist.find('.item-outer'),
822			$list = $blocklist.find('.list'),
823			$body = $blocklist.find('.body'),
824			$controls = $blocklist.find('.controls'),
825			$pagers = $blocklist.find('.bx-pager-wrap'),
826			options = {},
827			count,
828			col_arr, pager_arr, controls_arr,
829			bxslider,
830			auto_controls_arr,
831			containerWidth,
832			isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
833			media_type,
834			slider_arr = $blocklist.attr('data-slider').split(","),
835			swipe_arr = $blocklist.attr('data-swipe').split(",");
836
837		if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) {
838
839			options.pagerSelector= $blocklist.attr('data-setting-pager_selector');
840			options.prevSelector = $blocklist.attr('data-setting-prev_selector');
841			options.nextSelector = $blocklist.attr('data-setting-next_selector');
842			options.prevText = $blocklist.attr('data-setting-prev_text') || '';
843			options.nextText = $blocklist.attr('data-setting-next_text') || '';
844			options.auto = !!parseInt($blocklist.attr('data-setting-auto'));
845			options.controls = !!parseInt($blocklist.attr('data-setting-controls'));
846			options.pager = !!parseInt($blocklist.attr('data-setting-pager').split(',')[0]);
847			options.pause = parseInt($blocklist.attr('data-setting-pause'), 10) || 4000;
848			options.useCSS = isMobile;
849			options.infiniteLoop = true;
850			options.adaptiveHeight = false;
851			options.mode = $blocklist.attr('data-setting-mode') || 'horizontal';
852			options.touchEnabled = options.mode === 'horizontal';
853			options.slideMargin = 0;
854			options.maxSlides = parseInt($blocklist.attr('data-setting-count'), 10) || 1;
855			options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides;
856			options.moveSlides = $blocklist.attr('data-setting-move') || 0;
857			options.autoControlsSelector = $blocklist.attr('data-setting-auto_controls_selector');
858			options.autoControls =  !!parseInt($blocklist.attr('data-setting-auto_controls').split(',')[0]);;
859			options.autoControlsCombine =  !!parseInt($blocklist.attr('data-setting-autoControlsCombine'));
860
861			col_arr = $blocklist.attr('data-setting-columns').split(",");
862			pager_arr = $blocklist.attr('data-setting-pager').split(",");
863			controls_arr = $blocklist.attr('data-setting-controls').split(",");
864			auto_controls_arr = $blocklist.attr('data-setting-auto_controls').split(",");
865
866			if (!options.autoControls && options.auto) {
867				options.onSlideAfter = function() {
868					bxslider.startAuto();
869				}
870			}
871
872			$items.removeClass('hidden');
873			if ($list.parent().hasClass('bx-viewport')) {
874				$list.unwrap();
875				$list.unwrap();
876			}
877
878			function init(force) {
879				var media_type,
880					body_width = $('body').width();
881
882				var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"];
883				var media_ind, setting_columns,
884					isJustify, space_between;
885				var slider_arr = $blocklist.attr('data-slider').split(",");
886
887				var newContainerWidth = $blocklist.width(), itemHeight, viewportHeight;
888				if (!$blocklist.is(':visible')) {
889					if (bxslider) {
890						bxslider.destroySlider();
891					}
892					return;
893				}
894				if (force!='force' && containerWidth && containerWidth === newContainerWidth) {
895					return;
896				}
897				containerWidth = newContainerWidth;
898
899				if (bxslider) {
900					bxslider.destroySlider();
901				}
902
903				if (body_width >= 961) {
904					media_type = "screen";
905				} else if (body_width <= 960 && body_width >= 769) {
906					media_type = "tablet_landscape";
907				} else if (body_width <= 768 && body_width >= 641) {
908					media_type = "tablet_portrait";
909				} else if (body_width <= 640 && body_width >= 481) {
910					media_type = "mobile_landscape";
911				} else if (body_width <= 480) {
912					media_type = "mobile_portrait";
913				}
914				media_ind = mediaList.indexOf(media_type);
915				count = parseInt($blocklist.attr('data-setting-count'), 10);
916
917				isJustify = $body.css('justify-content') == "space-between" ? true : false;
918
919				$controls.css("pointer-events","none");
920				$controls.find('.prev').css("pointer-events","auto");
921				$controls.find('.next').css("pointer-events","auto");
922
923				$list.width('auto');
924				$items
925					.attr('style', '')
926					.slice(1).addClass('hidden').end()
927					.width(options.slideWidth = $items.width())
928					.removeClass('hidden');
929
930				if (pager_arr.length > 1) {
931					options.pager = !!parseInt(pager_arr[media_ind]);
932				}
933				if (controls_arr.length > 1) {
934					options.controls = !!parseInt(controls_arr[media_ind]);
935				}
936				if (auto_controls_arr.length > 1) {
937					options.autoControls = !!parseInt(auto_controls_arr[media_ind]);
938				}
939
940				$(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"});
941				$blocklist.find(".controls").css({"display": options.controls == true ? "flex" : "none"});
942
943				if (options.mode === 'vertical') {
944					itemHeight = Math.max.apply(Math, $items.map(function() {
945						return $(this).height()
946					}).get());
947					$items.css('min-height', itemHeight);
948					viewportHeight = itemHeight * count;
949				} else {
950					setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]);
951					if (setting_columns) {
952						count = setting_columns;
953					}
954					options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width()));
955				}
956
957				if (isJustify) {
958					if (options.maxSlides > 1) {
959						space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1));
960						space_between = space_between < 0 ? 0 : space_between;
961					} else {
962						space_between = 0;
963					}
964					options.slideMargin = space_between;
965				}
966
967				if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) {
968					$list.css({'justify-content': 'flex-start'});
969					if (bxslider) {
970						bxslider.reloadSlider(options);
971					} else {
972						$list.data('bxslider', (bxslider = $list.bxSlider(options)));
973					}
974					if(options.pager){
975						$pagers.css('display', 'flex');
976					}
977				} else {
978					if(swipe_arr[media_ind]!=1){
979						$list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'});
980						$items.css('width', $items.width()-1);
981					} else {
982						$list.css({'flex-wrap': 'nowrap'});
983					}
984					$pagers.hide();
985					$controls.hide();
986				}
987
988				if (viewportHeight && slider_arr[media_ind] == 1) {
989					$list.parent().css('min-height', viewportHeight);
990				}
991				if (options.mode === 'horizontal') {
992					var align = {};
993					switch ($body.css('justify-content')) {
994						case 'flex-end':
995							align['margin-left'] = 'auto';
996							align['margin-right'] = '0px';
997							break;
998						case 'center':
999							align['margin-left'] = 'auto';
1000							align['margin-right'] = 'auto';
1001							break;
1002						default:
1003							align['margin-left'] = '0px';
1004							align['margin-right'] = 'auto';
1005					}
1006					$blocklist.find('.bx-wrapper').css(align);
1007				}
1008			}
1009
1010			$(window).on('resize', debounce(init, 300));
1011			$(window).on('load', function(){
1012				init('force');
1013			});
1014
1015			init();
1016		} else {
1017			$pagers.hide();
1018			$controls.hide();
1019		}
1020
1021		$(window).on('resize', debounce(swipeScrollInit, 300));
1022		swipeScrollInit();
1023
1024		function swipeScrollInit() {
1025			var $shadowLeft = $blocklist.find(".swipe-shadow-left");
1026			var $shadowRight = $blocklist.find(".swipe-shadow-right");
1027			if ($list.css("overflow-x") == "auto") {
1028				var scroll_width = $list.get(0).scrollWidth;
1029				var view_width = $list.width();
1030				$shadowLeft.css("pointer-events","none");
1031				$shadowRight.css("pointer-events","none");
1032
1033				$list.off('scroll');
1034				$list.on('scroll', throttle(swipeScrollCheack, 200));
1035
1036				swipeScrollCheack();
1037
1038				function swipeScrollCheack() {
1039					var scroll_left = $list.scrollLeft();
1040
1041					if (scroll_left > 0) {
1042						$shadowLeft.show();
1043					} else {
1044						$shadowLeft.hide();
1045					}
1046
1047					if (scroll_left + view_width >= scroll_width - 1) {
1048						$shadowRight.hide();
1049					} else {
1050						$shadowRight.show();
1051					}
1052				}
1053			} else {
1054				$shadowLeft.hide();
1055				$shadowRight.hide();
1056			}
1057		}
1058
1059	});
1060});
1061/*
1062 *  wmS3Menu v1.0.0
1063 *  K.I. 433
1064 */
1065;(function ($, window, document, undefined ) {
1066	var pluginName = 'wmS3Menu',
1067		defaults = {
1068			screenButton: false,
1069			responsiveTl: false,
1070			responsiveTp: false,
1071			responsiveMl: false,
1072			moreText: '...',
1073			childIcons: false,
1074			childIconsClass: 'has-child-icon'
1075		};
1076	// Проверка на касание
1077	var isTouchable = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
1078	var $win = $(window);
1079	var winWidth = $win.width();
1080	var $doc = $(document);
1081
1082	var pluginObj = {
1083		_events: {
1084			hover: function(menuWrap, item, settings){
1085				var link = item.find('> a');
1086				var linkIcon = link.find('.' + settings.childIconsClass);
1087				var iconLen = linkIcon.length;
1088				var subMenu = item.find('> ul');
1089				var showTimeout;
1090				// Отображение
1091				function menuShow() {
1092					clearTimeout(showTimeout);
1093					item.siblings().find('> ul').css('display', '');
1094					// Определение положения выпадашки чтобы не выводилось за пределы окна
1095					pluginObj._menuPosition(subMenu);
1096
1097					link.addClass('hover');
1098					if (iconLen) {
1099						linkIcon.addClass('hover');
1100					}
1101				}
1102				// Скрытие
1103				function menuHide() {
1104					showTimeout = setTimeout(function(){
1105						link.removeClass('hover');
1106						subMenu.css('display', '');
1107						if (iconLen) {
1108							linkIcon.removeClass('hover');
1109						}
1110					}, 500);
1111				}
1112				// Отключение и подключение событий
1113				item.off({
1114					'mouseenter.wmS3Menu': menuShow,
1115					'mouseleave.wmS3Menu': menuHide
1116				});
1117				item.on({
1118					'mouseenter.wmS3Menu': menuShow,
1119					'mouseleave.wmS3Menu': menuHide
1120				});
1121			},
1122			click: function(menuWrap, item, settings){
1123				var link = item.find('> a');
1124				var linkIcon = link.find('.' + settings.childIconsClass);
1125				var iconLen = linkIcon.length;
1126				var subMenu = item.find('> ul');
1127				// Переключение отображения
1128				function menuToggle() {
1129					if (subMenu.is(':visible')) {
1130						if (isTouchable) {
1131							document.location = link.attr('href');
1132						}
1133						link.removeClass('hover');
1134						subMenu.css('display', '');
1135						item.removeClass('submenu-opened');
1136						if (iconLen) {
1137							linkIcon.removeClass('hover');
1138						}
1139					} else {
1140						item.siblings().find('> ul').css('display', '');
1141						item.siblings().find('> a').removeClass('hover');
1142						item.siblings().find('> a .' + settings.childIconsClass).removeClass('hover');
1143						// Определение положения выпадашки чтобы не выводилось за пределы окна
1144						pluginObj._menuPosition(subMenu);
1145
1146						link.addClass('hover');
1147						item.addClass('submenu-opened');
1148						if (iconLen) {
1149							linkIcon.addClass('hover');
1150						}
1151					}
1152					return false;
1153				}
1154				// Отключение и подключение событий
1155				link.off('click.wmS3Menu');
1156				link.on('click.wmS3Menu', menuToggle);
1157			},
1158			click_tree: function(menuWrap, item, settings){
1159				var link = item.find('> a');
1160				var linkIcon = link.find('.' + settings.childIconsClass);
1161				var subMenu = item.find('> ul');
1162				// Переключение отображения
1163				function menuToggle(event) {
1164					var targ = $(event.target);
1165
1166					if (targ.closest(linkIcon).length) {
1167						if (subMenu.is(':visible')) {
1168							link.removeClass('hover');
1169							subMenu.css('display', '');
1170							item.removeClass('submenu-opened');
1171							linkIcon.removeClass('hover');
1172						} else {
1173							// Определение положения выпадашки чтобы не выводилось за пределы окна
1174							pluginObj._menuPosition(subMenu);
1175
1176							link.addClass('hover');
1177							item.addClass('submenu-opened');
1178							linkIcon.addClass('hover');
1179						}
1180						return false;
1181					}
1182				}
1183				// Отключение и подключение событий
1184				link.off('click.wmS3Menu');
1185				link.on('click.wmS3Menu', menuToggle);
1186			}
1187		},
1188		_menuPosition: function(subMenu) {
1189			// Определение положения выпадашки чтобы не выводилось за пределы окна
1190			winWidth = $win.width();
1191
1192			subMenu.css('display', 'block');
1193
1194			if (subMenu.parent().hasClass('first-level') === false) {
1195				subMenu.css({
1196					'visibility': 'hidden',
1197					'opacity': 0
1198				});
1199
1200				var menuRect = subMenu[0].getBoundingClientRect();
1201				var marginR = parseInt(subMenu.css('margin-right'));
1202				var parentWidth = subMenu.parent().width();
1203
1204				if (marginR > parentWidth) {
1205					subMenu.css('margin-right', parentWidth);
1206				}
1207
1208				if (menuRect.right >= winWidth) {
1209					subMenu.css({
1210						'left': '-100%',
1211						'margin-left': 0
1212					});
1213				}
1214				subMenu.css({
1215					'visibility': '',
1216					'opacity': ''
1217				});
1218			}
1219		}
1220	};
1221	function Plugin(element, options) {
1222		this.element = element;
1223
1224		this.options = $.extend({}, defaults, options, $(this.element).data()) ;
1225
1226		this._defaults = defaults;
1227		this._name = pluginName;
1228
1229		this.init();
1230	}
1231	Plugin.prototype = {
1232		init: function () {
1233			var settings = this.options;
1234			// Определение ширины медиа
1235			var moreButFlag = false;
1236			if (window.matchMedia('all and (max-width: 480px)').matches) {
1237				moreButFlag = settings.responsiveMl;
1238			} else if (window.matchMedia('all and (max-width: 640px)').matches) {
1239				//moreButFlag = settings.responsiveTp;
1240			} else if (window.matchMedia('all and (max-width: 768px)').matches) {
1241				moreButFlag = settings.responsiveTl;
1242			} else {
1243				moreButFlag = settings.screenButton;
1244			}
1245			// Обертка меню
1246			var menuWrap = $(this.element);
1247			var menuClass = menuWrap.attr('class');
1248			var menuMainUl = $(this.element.querySelector('ul'));
1249			var widgetClass = menuClass.match(/widget-\d+/)[0];
1250			// Проверка на наличие меню в Side panel
1251			if (window.side_panel_controller && side_panel_controller.inPanel(widgetClass)) {
1252				moreButFlag = false;
1253			}
1254
1255			menuMainUl.children().addClass('first-level');
1256			// Настройки для горизонтального меню
1257			if (!!menuClass.match(/horizontal/i)) {
1258				var menuWidth = menuMainUl.width();
1259				var itemsWidth = 0, hideArr = [], hideLength;
1260				// Кнопка More
1261				var moreBut = menuMainUl.find('.more-button');
1262				if (!moreBut.length) {
1263					moreBut = $('<li class="more-button"><a href="#"><span>' + settings.moreText + '</span></a></li>');// data-trigger="click"
1264					menuMainUl.append(moreBut);
1265				}
1266				// Меню More
1267				var moreMenu = moreBut.find('> ul');
1268				if (!moreMenu.length) {
1269					moreMenu = $('<ul></ul>');
1270					moreBut.append(moreMenu);
1271				}
1272
1273				moreBut.removeClass('removed').attr('data-trigger', 'hover');
1274				menuMainUl.children().css('display', '');
1275
1276				var firstLevelItems = menuMainUl.children(':visible').not('.more-button');
1277				moreMenu.html('');
1278
1279				if (moreButFlag === 'more' || moreButFlag === 'button') {
1280					moreBut.removeClass('disabled');
1281
1282					menuWidth -= moreBut.outerWidth();
1283
1284					firstLevelItems.each(function(){
1285						var thisItem = $(this);
1286						itemsWidth += thisItem.outerWidth(true);
1287						if (itemsWidth >= menuWidth) {
1288							hideArr.push(thisItem.clone());
1289							thisItem.hide();
1290						}
1291					});
1292
1293					hideLength = hideArr.length;
1294					if (hideLength) {
1295						for (var ind = 0; ind < hideLength; ind++) {
1296							moreMenu.append(hideArr[ind]);
1297						}
1298						moreBut.removeClass('disabled');
1299					} else {
1300						moreBut.addClass('disabled');
1301					}
1302				} else {
1303					moreBut.addClass('disabled');
1304				}
1305			}
1306			// Вложенные подуровни меню
1307			var menuInner = menuMainUl.find('ul');
1308			var menuItems = menuInner.parent();
1309			var menuLinks = menuItems.find('> a');
1310			// Стрелочки для подуровней
1311			var menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
1312			var childIconLen = menuLinksIcons.length;
1313			// Тип отображения меню
1314			var mShow = 'popup';
1315			if (!!menuClass.match(/dropdown/i)) {
1316				mShow = 'dropdown';
1317			} else if (!!menuClass.match(/treemenu/i)) {
1318				mShow = 'treemenu';
1319			}
1320			if (mShow === 'popup') {
1321				menuInner.hide();
1322			}
1323			if (childIconLen) {
1324				menuLinksIcons.remove();
1325			}
1326			if (!!settings.childIcons) {
1327				// Добавление стрелочек для подуровней
1328				var childIconHTML = '<em class="' + settings.childIconsClass + '"></em>';
1329
1330				if (mShow === 'treemenu') {
1331					childIconHTML = '<em class="' + settings.childIconsClass + '"><b style="position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;"></b></em>';
1332				}
1333
1334				var childIconTag = $(childIconHTML);
1335				menuLinks.append(childIconTag.clone());
1336
1337				menuLinksIcons = menuLinks.find('.' + settings.childIconsClass);
1338				childIconLen = menuLinksIcons.length;
1339			}
1340			// Удаление всех событий на ссылках
1341			menuLinks.removeClass('hover').off('click.wmS3Menu');
1342			menuInner.css('display', '');
1343			if (childIconLen) {
1344				menuLinksIcons.removeClass('hover');
1345			}
1346
1347			menuItems.each(function() {
1348				var thisItem = $(this);
1349				var trigger = thisItem.data('trigger') || 'hover';
1350
1351				if (mShow === 'dropdown' || isTouchable) {
1352					trigger = 'click';
1353				} else if (mShow === 'treemenu') {
1354					trigger = 'click_tree';
1355				}
1356				pluginObj._events[trigger](menuWrap, thisItem, settings);
1357			});
1358			// Клик по документу
1359			if (isTouchable) {
1360				function docClick(e) {
1361					var target = $(e.target);
1362					if (target.closest(menuWrap).length === 0) {
1363						menuLinks.removeClass('hover');
1364						menuInner.css('display', '');
1365						menuItems.removeClass('submenu-opened');
1366
1367						if (childIconLen) {
1368							menuLinksIcons.removeClass('hover');
1369						}
1370					}
1371				}
1372				$doc.off('touchstart.wmS3Menu', docClick);
1373				$doc.on('touchstart.wmS3Menu', docClick);
1374			}
1375		},
1376		update: function () {
1377			this.init();
1378		}
1379	};
1380	if (!$.fn[pluginName]) {
1381		$.fn[pluginName] = function (options) {
1382			var args = arguments;
1383			if (options === undefined || typeof options === 'object') {
1384				return this.each(function () {
1385					if (!$.data(this, 'plugin_' + pluginName)) {
1386						$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
1387					}
1388				});
1389			} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
1390				var returns;
1391				this.each(function () {
1392					var instance = $.data(this, 'plugin_' + pluginName);
1393					if (instance instanceof Plugin && typeof instance[options] === 'function') {
1394						returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
1395					}
1396					if (options === 'destroy') {
1397						$.data(this, 'plugin_' + pluginName, null);
1398					}
1399				});
1400				return returns !== undefined ? returns : this;
1401			}
1402		};
1403	}
1404	$(function () {
1405		var wmMenuWrap = $('.wm-widget-menu.vertical');
1406		wmMenuWrap[pluginName]();
1407
1408		$win.on('resize.wmS3Menu', function(){
1409			wmMenuWrap[pluginName]('update');
1410		});
1411	});
1412
1413	setTimeout(function(){
1414		$win.trigger('resize');
1415	}, 500);
1416}(jQuery, window, document));
1417$(function() {
1418
1419	var debounce = (function () {
1420		return function (fn, time) {
1421			var timer, func;
1422			func = function() {
1423				var args = [].slice.call(arguments, 0);
1424				window.clearTimeout(timer);
1425				timer = window.setTimeout(function () {
1426					window.requestAnimationFrame && window.requestAnimationFrame(function() {
1427						fn.apply(null, args);
1428					}) || fn.apply(null, args);
1429				}, time)
1430			};
1431			return func;
1432		}
1433	}());
1434
1435	var throttle = (function() {
1436		return function (fn, threshhold, scope) {
1437			threshhold || (threshhold = 250);
1438			var last,
1439				deferTimer,
1440				func;
1441			func = function () {
1442				var context = scope || this;
1443				var now = +new Date,
1444					args = arguments;
1445				if (last && now < last + threshhold) {
1446					// hold on to it
1447					clearTimeout(deferTimer);
1448					deferTimer = setTimeout(function () {
1449						last = now;
1450						fn.apply(context, args);
1451					}, threshhold);
1452				} else {
1453					last = now;
1454					fn.apply(context, args);
1455				}
1456			};
1457			return func;
1458		}
1459	}());
1460
1461	$('.news-block').each(function() {
1462		var $newsblock = $(this),
1463			$items = $newsblock.find('.item-outer'),
1464			$list = $newsblock.find('.news__list'),
1465			$body = $newsblock.find('.body'),
1466			$controls = $newsblock.find('.controls'),
1467			$pagers = $newsblock.find('.bx-pager-wrap'),
1468			options = {},
1469			count,
1470			auto_controls_arr,
1471			col_arr, pager_arr, controls_arr,
1472			bxslider,
1473			containerWidth,
1474			isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
1475			slider_arr = $newsblock.attr('data-slider').split(","),
1476			swipe_arr = $newsblock.attr('data-swipe').split(",");
1477
1478		if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) {
1479
1480			options.pagerSelector= $newsblock.attr('data-setting-pager_selector');
1481			options.prevSelector = $newsblock.attr('data-setting-prev_selector');
1482			options.nextSelector = $newsblock.attr('data-setting-next_selector');
1483			options.prevText = $newsblock.attr('data-setting-prev_text') || '';
1484			options.nextText = $newsblock.attr('data-setting-next_text') || '';
1485			options.auto = !!parseInt($newsblock.attr('data-setting-auto'));
1486			options.controls = !!parseInt($newsblock.attr('data-setting-controls'));
1487			options.pager = !!parseInt($newsblock.attr('data-setting-pager').split(',')[0]);
1488			options.pause = parseInt($newsblock.attr('data-setting-pause'), 10) || 4000;
1489			options.useCSS = isMobile;
1490			options.infiniteLoop = true;
1491			options.adaptiveHeight = false;
1492			options.mode = $newsblock.attr('data-setting-mode') || 'horizontal';
1493			options.touchEnabled = options.mode === 'horizontal';
1494			options.slideMargin = 0;
1495			options.maxSlides = parseInt($newsblock.attr('data-setting-count'), 10) || 1;
1496			options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides;
1497			options.moveSlides = $newsblock.attr('data-setting-move') || 0;
1498			options.autoControlsSelector = $newsblock.attr('data-setting-auto_controls_selector');
1499			options.autoControls =  !!parseInt($newsblock.attr('data-setting-auto_controls').split(',')[0]);
1500			options.autoControlsCombine =  !!parseInt($newsblock.attr('data-setting-autoControlsCombine'));
1501			options.autoHover = true;
1502
1503			col_arr = $newsblock.attr('data-setting-columns').split(",");
1504			pager_arr = $newsblock.attr('data-setting-pager').split(",");
1505			controls_arr = $newsblock.attr('data-setting-controls').split(",");
1506			auto_controls_arr = $newsblock.attr('data-setting-auto_controls').split(",");
1507
1508			if (!options.autoControls && options.auto) {
1509				options.onSlideAfter = function() {
1510					bxslider.startAuto();
1511				}
1512			}
1513
1514			$items.removeClass('hidden');
1515			if ($list.parent().hasClass('bx-viewport')) {
1516				$list.unwrap();
1517				$list.unwrap();
1518			}
1519
1520			function init(force) {
1521				var media_type,
1522					body_width = $('body').width();
1523
1524				var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"];
1525				var media_ind, setting_columns,
1526					isJustify, space_between;
1527				var slider_arr = $newsblock.attr('data-slider').split(",");
1528
1529				var newContainerWidth = $newsblock.width(), itemHeight, viewportHeight;
1530				if (!$newsblock.is(':visible')) {
1531					if (bxslider) {
1532						bxslider.destroySlider();
1533					}
1534					return;
1535				}
1536				if (force!='force' && containerWidth && containerWidth === newContainerWidth) {
1537					return;
1538				}
1539				containerWidth = newContainerWidth;
1540
1541				if (bxslider) {
1542					bxslider.destroySlider();
1543				}
1544
1545				if (body_width >= 961) {
1546					media_type = "screen";
1547				} else if (body_width <= 960 && body_width >= 769) {
1548					media_type = "tablet_landscape";
1549				} else if (body_width <= 768 && body_width >= 641) {
1550					media_type = "tablet_portrait";
1551				} else if (body_width <= 640 && body_width >= 481) {
1552					media_type = "mobile_landscape";
1553				} else if (body_width <= 480) {
1554					media_type = "mobile_portrait";
1555				}
1556				media_ind = mediaList.indexOf(media_type);
1557				count = parseInt($newsblock.attr('data-setting-count'), 10);
1558
1559				isJustify = $body.css('justify-content') == "space-between" ? true : false;
1560
1561				$controls.css("pointer-events","none");
1562				$controls.find('.prev').css("pointer-events","auto");
1563				$controls.find('.next').css("pointer-events","auto");
1564
1565				$list.width('auto');
1566				$items
1567					.attr('style', '')
1568					.slice(1).addClass('hidden').end()
1569					.width(options.slideWidth = $items.width())
1570					.removeClass('hidden');
1571
1572				if (pager_arr.length > 1) {
1573					options.pager = !!parseInt(pager_arr[media_ind]);
1574				}
1575				if (controls_arr.length > 1) {
1576					options.controls = !!parseInt(controls_arr[media_ind]);
1577				}
1578				if (auto_controls_arr.length > 1) {
1579					options.autoControls = !!parseInt(auto_controls_arr[media_ind]);
1580				}
1581
1582				$(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"});
1583				$newsblock.find(".controls").css({"display": options.controls == true ? "flex" : "none"});
1584
1585				if (options.mode === 'vertical') {
1586					itemHeight = Math.max.apply(Math, $items.map(function() {
1587						return $(this).height()
1588					}).get());
1589					$items.css('min-height', itemHeight);
1590					viewportHeight = itemHeight * count;
1591				} else {
1592					setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]);
1593					if (setting_columns) {
1594						count = setting_columns;
1595					}
1596					options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width()));
1597				}
1598
1599				if (isJustify) {
1600					if (options.maxSlides > 1) {
1601						space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1));
1602						space_between = space_between < 0 ? 0 : space_between;
1603					} else {
1604						space_between = 0;
1605					}
1606					options.slideMargin = space_between;
1607				}
1608
1609				if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) {
1610					$list.css({'justify-content': 'flex-start'});
1611					if (bxslider) {
1612						bxslider.reloadSlider(options);
1613					} else {
1614						$list.data('bxslider', (bxslider = $list.bxSlider(options)));
1615					}
1616					if(options.pager){
1617						$pagers.css('display', 'flex');
1618					}
1619				} else {
1620					if(swipe_arr[media_ind]!=1){
1621						$list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'});
1622						$items.css('width', $items.width()-1);
1623					} else {
1624						$list.css({'flex-wrap': 'nowrap'});
1625					}
1626					$pagers.hide();
1627					$controls.hide();
1628				}
1629
1630				if (viewportHeight && slider_arr[media_ind] == 1) {
1631					$list.parent().css('min-height', viewportHeight);
1632				}
1633				if (options.mode === 'horizontal') {
1634					var align = {};
1635					switch ($body.css('justify-content')) {
1636						case 'flex-end':
1637							align['margin-left'] = 'auto';
1638							align['margin-right'] = '0px';
1639							break;
1640						case 'center':
1641							align['margin-left'] = 'auto';
1642							align['margin-right'] = 'auto';
1643							break;
1644						default:
1645							align['margin-left'] = '0px';
1646							align['margin-right'] = 'auto';
1647					}
1648					$newsblock.find('.bx-wrapper').css(align);
1649				}
1650			}
1651
1652			$(window).on('resize', debounce(init, 300));
1653			$(window).on('load', function(){
1654				init('force');
1655			});
1656
1657			init();
1658		} else {
1659			$pagers.hide();
1660			$controls.hide();
1661		}
1662
1663		$(window).on('resize', debounce(swipeScrollInit, 300));
1664		swipeScrollInit();
1665
1666		function swipeScrollInit() {
1667			var $shadowLeft = $newsblock.find(".swipe-shadow-left");
1668			var $shadowRight = $newsblock.find(".swipe-shadow-right");
1669			if ($list.css("overflow-x") == "auto") {
1670				var scroll_width = $list.get(0).scrollWidth;
1671				var view_width = $list.width();
1672				$shadowLeft.css("pointer-events","none");
1673				$shadowRight.css("pointer-events","none");
1674
1675				$list.off('scroll');
1676				$list.on('scroll', throttle(swipeScrollCheack, 200));
1677
1678				swipeScrollCheack();
1679
1680				function swipeScrollCheack() {
1681					var scroll_left = $list.scrollLeft();
1682
1683					if (scroll_left > 0) {
1684						$shadowLeft.show();
1685					} else {
1686						$shadowLeft.hide();
1687					}
1688
1689					if (scroll_left + view_width >= scroll_width - 1) {
1690						$shadowRight.hide();
1691					} else {
1692						$shadowRight.show();
1693					}
1694				}
1695			} else {
1696				$shadowLeft.hide();
1697				$shadowRight.hide();
1698			}
1699		}
1700
1701	});
1702});
1703$(function() {
1704	$('.up_button').click(function () {
1705		var up_speed = $(this).data('speed')
1706		$('body, html').animate({
1707			scrollTop: 0
1708		}, up_speed);
1709	});
1710});
1711document.addEventListener('DOMContentLoaded', function() {
1712	var bodyScrollBarWidth = (function () {
1713		var widthHidden, widthScroll, currentValue, currentPriority;
1714		currentValue = document.body.style.getPropertyValue('overflow');
1715		currentPriority = document.body.style.getPropertyPriority('overflow');
1716		document.body.style.setProperty('overflow', 'hidden', 'important');
1717		widthHidden = document.body.clientWidth;
1718		document.body.style.setProperty('overflow', 'scroll', 'important');
1719		widthScroll = document.body.clientWidth;
1720		document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority);
1721		return widthHidden - widthScroll;
1722	}());
1723	var media = {
1724		'tablet-landscape': 960,
1725		'tablet-portrait': 768,
1726		'mobile-landscape': 640,
1727		'mobile-portrait': 480
1728	};
1729	var side_panel = document.querySelector('.side-panel');
1730	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;
1731	var layers, content_width, flip, full_width, elements = {}, comments = {};
1732
1733	if (!side_panel || side_panel.classList.contains('removed')) {
1734		return;
1735	}
1736
1737	flip = side_panel.getAttribute('data-position') === 'right';
1738
1739	try {
1740		layers =  JSON.parse(side_panel.getAttribute('data-layers').replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"'));
1741	} catch(e) {
1742		console.error(e);
1743	}
1744
1745	if (typeof layers !== 'object' || Object.keys(layers).length === 0) {
1746		return;
1747	}
1748
1749	Object.keys(layers).forEach(function(clss) {
1750		elements[clss] = document.querySelector('.' + clss);
1751		comments[clss] = document.createComment(clss);
1752		if (elements[clss]) {
1753			elements[clss].parentNode.insertBefore(comments[clss], elements[clss]);
1754		} else {
1755			delete layers[clss];
1756		}
1757	});
1758
1759	side_panel_button = side_panel.querySelector('.side-panel-button');
1760	side_panel_close = side_panel.querySelector('.side-panel-close');
1761	side_panel_content = side_panel.querySelector('.side-panel-content');
1762	side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content;
1763	side_panel_mask = side_panel.querySelector('.side-panel-mask');
1764	side_panel_top = side_panel.querySelector('.side-panel-top-inner');
1765
1766	side_panel.classList.remove('hidden');
1767	side_panel_button.classList.remove('hidden');
1768	side_panel_button.style.display = 'none';
1769	side_panel_content.classList.remove('hidden');
1770	side_panel_content.style.display = 'none';
1771	side_panel_mask.classList.remove('hidden');
1772	side_panel_mask.style.display = 'none';
1773
1774	content_width = getComputedStyle(side_panel_content, null).width;
1775
1776	leftEdge = 0;
1777	rightEdge = parseInt(content_width) + 50;
1778
1779	if (content_width === 'auto') {
1780		rightEdge = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1781		full_width = true;
1782	}
1783
1784	isPhantom = !!parseInt($(side_panel).attr("data-phantom"));
1785
1786	if (isPhantom) {
1787		$(side_panel).css({"pointer-events": "none"});
1788	} else {
1789		$(side_panel).css({"pointer-events": "auto"});
1790	}
1791
1792	if (flip) {
1793		side_panel_content.style.left = 'auto';
1794		side_panel_content.style.right = '0';
1795	}
1796
1797	window.side_panel_controller = side_panel_controller = new DrawerController({
1798		target: side_panel,
1799		full_width: full_width,
1800		left: leftEdge,
1801		right: rightEdge,
1802		position: 0,
1803		flip: flip,
1804		curve: 'ease-in-out',
1805		willOpen: function() {
1806			side_panel_mask.style.display = 'block';
1807			side_panel_content.style.display = 'block';
1808			document.body.classList.add('noscroll');
1809			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
1810				document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent'
1811			}
1812		},
1813		didClose: function() {
1814			side_panel_mask.style.display = 'none';
1815			side_panel_content.style.display = 'none';
1816			document.body.classList.remove('noscroll');
1817			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
1818				document.body.style.borderRight = ''
1819			}
1820		},
1821		onAnimate: function(position) {
1822			side_panel_mask.style.opacity = position / rightEdge;
1823			side_panel_content.style.transform = 'translate3d(' + (flip ? rightEdge - position : position - rightEdge) + 'px,0,0)';
1824		}
1825	});
1826
1827	side_panel_controller.inPanel = function(clss) {
1828		var viewportWidth;
1829		var current_media;
1830
1831		if (typeof clss !== 'string') {
1832			return false;
1833		}
1834
1835		if (clss.charAt(0) === '.') {
1836			clss = clss.slice(1);
1837		}
1838
1839		viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1840
1841		Object.keys(media).forEach(function(key) {
1842			if (viewportWidth <= media[key]) {
1843				current_media = key;
1844			}
1845		});
1846
1847		if (typeof current_media === 'undefined') {
1848			current_media = 'screen';
1849		}
1850
1851		return layers[clss] && layers[clss][current_media];
1852	};
1853
1854	side_panel_button.addEventListener('click', function(e) {
1855		e.preventDefault();
1856		side_panel_controller.toggle();
1857		return false;
1858	});
1859
1860	if (side_panel_close) {
1861		side_panel_close.addEventListener('click', function(e) {
1862			e.preventDefault();
1863			side_panel_controller.close();
1864			return false;
1865		});
1866	}
1867
1868	side_panel_mask.addEventListener('click', function() {
1869		side_panel_controller.close();
1870		return false;
1871	});
1872
1873
1874	var debounce = (function () {
1875		return function (fn, time) {
1876			var timer, func;
1877			if (window.requestAnimationFrame) {
1878				func = function() {
1879					timer && cancelAnimationFrame(timer);
1880					timer = requestAnimationFrame(fn);
1881				}
1882			} else {
1883				func = function() {
1884					window.clearTimeout(timer);
1885					timer = window.setTimeout(function () {
1886						fn();
1887					}, time)
1888				};
1889			}
1890			return func;
1891		}
1892	}());
1893
1894	function checkSidePanel() {
1895		var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1896		var current_media;
1897		var emptySide = true;
1898		var emptyTop = true;
1899
1900		if (checkSidePanel.viewportWidth === viewportWidth) {
1901			return;
1902		}
1903
1904		checkSidePanel.viewportWidth = viewportWidth;
1905
1906		Object.keys(media).forEach(function(key) {
1907			if (viewportWidth <= media[key]) {
1908				current_media = key;
1909			}
1910		});
1911
1912		if (typeof current_media === 'undefined') {
1913			current_media = 'screen';
1914		}
1915
1916		Object.keys(layers).forEach(function(clss){
1917			var element, comment;
1918
1919			element = elements[clss];
1920			comment = comments[clss];
1921
1922			if (current_media in layers[clss]) {
1923				if (layers[clss][current_media] == 'onTop') {
1924					side_panel_top.appendChild(element);
1925					emptyTop = false;
1926				} else {
1927					side_panel_content_inner.appendChild(element);
1928					emptySide = false;
1929				}
1930			} else {
1931				if (comment) {
1932					comment.parentNode.insertBefore(element, comment);
1933				}
1934			}
1935		});
1936
1937		if (emptySide) {
1938			side_panel_button.style.display = 'none';
1939		} else {
1940			side_panel_button.style.display = 'block';
1941		}
1942
1943		if (!emptyTop || !emptySide) {
1944			side_panel.style.display = 'block';
1945		} else {
1946			side_panel.style.display = 'none';
1947			side_panel_controller.close();
1948		}
1949	}
1950
1951	checkSidePanel = debounce(checkSidePanel, 40);
1952
1953	checkSidePanel();
1954	window.addEventListener('resize', checkSidePanel);
1955});
1956/*
1957 * @license
1958 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1959 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1960 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1961 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1962 * Code distributed by Google as part of the polymer project is also
1963 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1964 */
1965
1966"use strict";
1967
1968(function (exports) {
1969
1970	function sign(number) {
1971		if (number < 0)
1972			return -1;
1973		if (number > 0)
1974			return 1;
1975		return 0;
1976	}
1977
1978	function Animator(delegate) {
1979		this.delegate = delegate;
1980		this.startTimeStamp = 0;
1981		this.request_ = null;
1982	};
1983
1984	Animator.prototype.scheduleAnimation = function () {
1985		if (this.request_)
1986			return;
1987		this.request_ = requestAnimationFrame(this.onAnimation_.bind(this));
1988	};
1989
1990	Animator.prototype.startAnimation = function () {
1991		this.startTimeStamp = 0;
1992		this.scheduleAnimation();
1993	};
1994
1995	Animator.prototype.stopAnimation = function () {
1996		cancelAnimationFrame(this.request_);
1997		this.startTimeStamp = 0;
1998		this.request_ = null;
1999	};
2000
2001	Animator.prototype.onAnimation_ = function (timeStamp) {
2002		this.request_ = null;
2003		if (!this.startTimeStamp)
2004			this.startTimeStamp = timeStamp;
2005		if (this.delegate.onAnimation(timeStamp))
2006			this.scheduleAnimation();
2007	};
2008
2009	function VelocityTracker() {
2010		this.recentTouchMoves_ = [];
2011		this.velocityX = 0;
2012		this.velocityY = 0;
2013	}
2014
2015	VelocityTracker.kTimeWindow = 50;
2016
2017	VelocityTracker.prototype.pruneHistory_ = function (timeStamp) {
2018		for (var i = 0; i < this.recentTouchMoves_.length; ++i) {
2019			if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) {
2020				this.recentTouchMoves_ = this.recentTouchMoves_.slice(i);
2021				return;
2022			}
2023		}
2024		// All touchmoves are old.
2025		this.recentTouchMoves_ = [];
2026	};
2027
2028	VelocityTracker.prototype.update_ = function (e) {
2029		this.pruneHistory_(e.timeStamp);
2030		this.recentTouchMoves_.push(e);
2031
2032		var oldestTouchMove = this.recentTouchMoves_[0];
2033
2034		var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX;
2035		var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY;
2036		var deltaT = e.timeStamp - oldestTouchMove.timeStamp;
2037
2038		if (deltaT > 0) {
2039			this.velocityX = deltaX / deltaT;
2040			this.velocityY = deltaY / deltaT;
2041		} else {
2042			this.velocityX = 0;
2043			this.velocityY = 0;
2044		}
2045	};
2046
2047	VelocityTracker.prototype.onTouchStart = function (e) {
2048		this.recentTouchMoves_.push(e);
2049		this.velocityX = 0;
2050		this.velocityY = 0;
2051	};
2052
2053	VelocityTracker.prototype.onTouchMove = function (e) {
2054		this.update_(e);
2055	};
2056
2057	VelocityTracker.prototype.onTouchEnd = function (e) {
2058		this.update_(e);
2059		this.recentTouchMoves_ = [];
2060	};
2061
2062	function LinearTimingFunction() {
2063	};
2064
2065	LinearTimingFunction.prototype.scaleTime = function (fraction) {
2066		return fraction;
2067	};
2068
2069	function CubicBezierTimingFunction(spec) {
2070		this.map = [];
2071		for (var ii = 0; ii <= 100; ii += 1) {
2072			var i = ii / 100;
2073			this.map.push([
2074				3 * i * (1 - i) * (1 - i) * spec[0] +
2075				3 * i * i * (1 - i) * spec[2] + i * i * i,
2076				3 * i * (1 - i) * (1 - i) * spec[1] +
2077				3 * i * i * (1 - i) * spec[3] + i * i * i
2078			]);
2079		}
2080	};
2081
2082	CubicBezierTimingFunction.prototype.scaleTime = function (fraction) {
2083		var fst = 0;
2084		while (fst !== 100 && fraction > this.map[fst][0]) {
2085			fst += 1;
2086		}
2087		if (fraction === this.map[fst][0] || fst === 0) {
2088			return this.map[fst][1];
2089		}
2090		var yDiff = this.map[fst][1] - this.map[fst - 1][1];
2091		var xDiff = this.map[fst][0] - this.map[fst - 1][0];
2092		var p = (fraction - this.map[fst - 1][0]) / xDiff;
2093		return this.map[fst - 1][1] + p * yDiff;
2094	};
2095
2096	var presetTimingFunctions = {
2097		'linear': new LinearTimingFunction(),
2098		'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]),
2099		'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]),
2100		'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]),
2101		'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]),
2102	};
2103
2104	function DrawerController(options) {
2105		this.velocityTracker = new VelocityTracker();
2106		this.animator = new Animator(this);
2107
2108		this.target = options.target;
2109		this.left = options.left;
2110		this.right = options.right;
2111		this.position = options.position;
2112		this.flip = options.flip;
2113		this.full_width = options.full_width;
2114
2115		this.width = this.right - this.left;
2116		this.curve = presetTimingFunctions[options.curve || 'linear'];
2117
2118		this.willOpenCallback = options.willOpen;
2119		this.didCloseCallback = options.didClose;
2120		this.animateCallback = options.onAnimate;
2121
2122		this.state = DrawerController.kClosed;
2123
2124		this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS;
2125
2126		this.onTouchMove = this.onTouchMove.bind(this);
2127		this.onTouchEnd = this.onTouchEnd.bind(this);
2128
2129		if (!this.full_width) {
2130			this.target.addEventListener('touchstart', this.onTouchStart.bind(this));
2131		}
2132	}
2133
2134	DrawerController.kOpened = 'opened';
2135	DrawerController.kClosed = 'closed';
2136	DrawerController.kOpening = 'opening';
2137	DrawerController.kClosing = 'closing';
2138	DrawerController.kDragging = 'dragging';
2139	DrawerController.kFlinging = 'flinging';
2140
2141	DrawerController.kBaseSettleDurationMS = 246;
2142	DrawerController.kMaxSettleDurationMS = 600;
2143
2144	DrawerController.kMinFlingVelocity = 0.4;  // Matches Android framework.
2145	DrawerController.kTouchSlop = 5;  // Matches Android framework.
2146	DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop;
2147
2148	DrawerController.prototype.restrictToCurrent = function (offset) {
2149		return Math.max(this.left, Math.min(this.position, offset));
2150	};
2151
2152	DrawerController.prototype.restrictToBounds = function (offset) {
2153		return Math.max(this.left, Math.min(this.right, offset));
2154	};
2155
2156	DrawerController.prototype.onTouchStart = function (e) {
2157		this.velocityTracker.onTouchStart(e);
2158
2159		var touchX;
2160		if (this.flip) {
2161			touchX = document.documentElement.clientWidth - e.changedTouches[0].clientX;
2162		} else {
2163			touchX = e.changedTouches[0].clientX;
2164		}
2165		var touchY = e.changedTouches[0].clientY;
2166
2167		if (this.state != DrawerController.kOpened) {
2168			if (touchX != this.restrictToCurrent(touchX))
2169				return;
2170			this.state = DrawerController.kDragging;
2171		}
2172
2173		this.animator.stopAnimation();
2174		this.target.addEventListener('touchmove', this.onTouchMove);
2175		this.target.addEventListener('touchend', this.onTouchEnd);
2176		// TODO(abarth): Handle touchcancel.
2177
2178		this.startX = touchX;
2179		this.startY = touchY;
2180		this.startPosition = this.position;
2181		this.touchBaseX = Math.min(touchX, this.startPosition);
2182	};
2183
2184	DrawerController.prototype.onTouchMove = function (e) {
2185		this.velocityTracker.onTouchMove(e);
2186
2187		if (this.state == DrawerController.kOpened) {
2188			var deltaX;
2189			if (this.flip) {
2190				deltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.startX;
2191			} else {
2192				deltaX = e.changedTouches[0].clientX - this.startX;
2193			}
2194			var deltaY = e.changedTouches[0].clientY - this.startY;
2195
2196			if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) {
2197				e.preventDefault();
2198				return;
2199			}
2200
2201			if (Math.abs(deltaY) > Math.abs(deltaX)) {
2202				this.target.removeEventListener('touchmove', this.onTouchMove);
2203				this.target.removeEventListener('touchend', this.onTouchEnd);
2204				return;
2205			}
2206
2207			this.state = DrawerController.kDragging;
2208		}
2209
2210		e.preventDefault();
2211		var touchDeltaX;
2212		if (this.flip) {
2213			touchDeltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.touchBaseX;
2214		} else {
2215			touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX;
2216		}
2217		this.position = this.restrictToBounds(this.startPosition + touchDeltaX);
2218		this.animator.scheduleAnimation();
2219	};
2220
2221	DrawerController.prototype.onTouchEnd = function (e) {
2222		this.velocityTracker.onTouchEnd(e);
2223		this.target.removeEventListener('touchmove', this.onTouchMove);
2224		this.target.removeEventListener('touchend', this.onTouchEnd);
2225
2226		var velocityX = this.velocityTracker.velocityX;
2227
2228		if (this.flip) {
2229			velocityX *= -1;
2230		}
2231
2232		if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) {
2233			this.fling(velocityX);
2234		} else if (this.isOpen()) {
2235			this.open();
2236		} else {
2237			this.close();
2238		}
2239	};
2240
2241	DrawerController.prototype.openFraction = function () {
2242		var width = this.right - this.left;
2243		var offset = this.position - this.left;
2244		return offset / width;
2245	};
2246
2247	DrawerController.prototype.isOpen = function () {
2248		return this.openFraction() >= 0.5;
2249	};
2250
2251	DrawerController.prototype.isOpening = function () {
2252		return this.state == DrawerController.kOpening ||
2253			(this.state == DrawerController.kFlinging && this.animationVelocityX > 0);
2254	}
2255
2256	DrawerController.prototype.isClosing = function () {
2257		return this.state == DrawerController.kClosing ||
2258			(this.state == DrawerController.kFlinging && this.animationVelocityX < 0);
2259	}
2260
2261	DrawerController.prototype.toggle = function () {
2262		if (this.isOpen())
2263			this.close();
2264		else
2265			this.open();
2266	};
2267
2268	DrawerController.prototype.open = function () {
2269		if (this.full_width) {
2270			this.willOpenCallback.call(this.target);
2271			return;
2272		}
2273		if (!this.position)
2274			this.willOpenCallback.call(this.target);
2275
2276		this.animator.stopAnimation();
2277		this.animationDuration = 400;
2278		this.state = DrawerController.kOpening;
2279		this.animate();
2280	};
2281
2282	DrawerController.prototype.close = function () {
2283		if (this.full_width) {
2284			this.didCloseCallback.call(this.target);
2285			return;
2286		}
2287		this.animator.stopAnimation();
2288		this.animationDuration = 400;
2289		this.state = DrawerController.kClosing;
2290		this.animate();
2291	};
2292
2293	DrawerController.prototype.fling = function (velocityX) {
2294		this.animator.stopAnimation();
2295		this.animationVelocityX = velocityX;
2296		this.state = DrawerController.kFlinging;
2297		this.animate();
2298	};
2299
2300	DrawerController.prototype.animate = function () {
2301		this.positionAnimationBase = this.position;
2302		this.animator.startAnimation();
2303	};
2304
2305	DrawerController.prototype.targetPosition = function (deltaT) {
2306		if (this.state == DrawerController.kFlinging)
2307			return this.positionAnimationBase + this.animationVelocityX * deltaT;
2308		var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration);
2309		var animationWidth = this.state == DrawerController.kOpening ?
2310		this.width - this.positionAnimationBase : -this.positionAnimationBase;
2311		return this.positionAnimationBase + targetFraction * animationWidth;
2312	};
2313
2314	DrawerController.prototype.onAnimation = function (timeStamp) {
2315		if (this.state == DrawerController.kDragging) {
2316			this.animateCallback.call(this.target, this.position);
2317			return false;
2318		}
2319
2320		var deltaT = timeStamp - this.animator.startTimeStamp;
2321		var targetPosition = this.targetPosition(deltaT);
2322		this.position = this.restrictToBounds(targetPosition);
2323
2324		this.animateCallback.call(this.target, this.position);
2325
2326		if (targetPosition <= this.left && this.isClosing()) {
2327			this.state = DrawerController.kClosed;
2328			this.didCloseCallback.call(this.target);
2329			return false;
2330		}
2331		if (targetPosition >= this.right && this.isOpening()) {
2332			this.state = DrawerController.kOpened;
2333			return false;
2334		}
2335
2336		return true;
2337	};
2338
2339
2340	exports.DrawerController = DrawerController;
2341
2342})(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.