PageSourceSearch

https://somz59.ru/t/v44/images/js/main.js

js somz59.ru collected 2026-10-09 22:40:00 UTC 40,675 bytes, 1,418 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() {
508	var $search = $('.wm-search');
509
510	var debounce = (function () {
511		return function (fn, time) {
512			var timer, func;
513			func = function() {
514				var args = [].slice.call(arguments, 0);
515				window.clearTimeout(timer);
516				timer = window.setTimeout(function () {
517					window.requestAnimationFrame && window.requestAnimationFrame(function() {
518						fn.apply(null, args);
519					}) || fn.apply(null, args);
520				}, time)
521			};
522			return func;
523		}
524	}());
525
526	function init() {
527		$search.each(function() {
528			var $this = $(this),
529				options = {};
530			var curMedia = $this.attr('data-setting-media');
531			if ($this.attr('data-setting-animate_list')) {
532				var media_type,
533					body_width = $('body').width();
534				var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"];
535				var media_ind, animate_list_arr;
536
537
538				if (body_width >= 961) {
539					media_type = "screen";
540				} else if (body_width <= 960 && body_width >= 769) {
541					media_type = "tablet_landscape";
542				} else if (body_width <= 768 && body_width >= 641) {
543					media_type = "tablet_portrait";
544				} else if (body_width <= 640 && body_width >= 481) {
545					media_type = "mobile_landscape";
546				} else if (body_width <= 480) {
547					media_type = "mobile_portrait";
548				}
549
550				media_ind = mediaList.indexOf(media_type);
551				animate_list_arr = $this.attr('data-setting-animate_list').split(",");
552
553				options.animation = $this.attr('data-setting-type');
554				if(curMedia != media_type) {
555					if (animate_list_arr[media_ind] == 1) {
556						$this.attr('data-setting-media', media_type);
557						$this.find('.wm-search-inner').wmSearch(options);
558					} else {
559						$this.find('.wm-search-inner').wmSearch('destroy');
560					}
561				}
562			}
563		});
564	}
565
566	$(window).on('resize', debounce(init, 300));
567
568	init();
569
570});
571(function($) {
572	function getInternetExplorerVersion(){
573		var rv = -1;
574		if (navigator.appName == 'Microsoft Internet Explorer')	{
575			var ua = navigator.userAgent;
576			var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
577			if (re.exec(ua) != null)
578				rv = parseFloat( RegExp.$1 );
579		} else if (navigator.appName == 'Netscape')	{
580			var ua = navigator.userAgent;
581			var re  = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
582			if (re.exec(ua) != null)
583				rv = parseFloat( RegExp.$1 );
584		}
585		return rv;
586	}
587
588	$.fn.wmSearch = function(options){
589		if (options === 'destroy') {
590			return this.each(function () {
591				var $this = $(this);
592				var inp = $this.find('input[name=search]');
593				var search_but = $this.find('button');
594				var $wrap = $this.parent('div');
595
596				$this.css('justify-content','flex-start');
597				$wrap.css('visibility','visible');
598				search_but.css('visibility','visible');
599				inp.stop(true).show().css({
600					'opacity': '',
601					'max-width':''
602				});
603
604				if ($this.data('wm_search')) {
605					search_but.off('.' + $this.data('wm_search'));
606					$(document).off('.' + $this.data('wm_search'));
607					$this.removeData('wm_search');
608				}
609			});
610		} else {
611			var defaults = $.extend({
612				animation : 'fade'
613			}, options);
614
615			return this.each(function () {
616				var clss = 'wm_search_' + Date.now();
617				var $this = $(this);
618				var inp = $this.find('input[name=search]');
619				var search_but = $this.find('button');
620				var $wrap = $this.parent('div');
621
622				$this.css('justify-content','flex-end');
623				$wrap.css('visibility','hidden');
624				search_but.css('visibility','visible');
625
626				if ($this.data('wm_search')) {
627					return;
628				}
629
630
631				if (defaults.animation == 'slide') {
632					var iebrw = getInternetExplorerVersion();
633					if (iebrw == 9 || iebrw == 10 || iebrw == 11) {
634						inp.hide();
635						search_but.on('click.' + clss, function () {
636							var wrapVis = $wrap.css('visibility');
637							if(wrapVis=="hidden"){
638								$wrap.css('visibility','visible');
639								inp.fadeIn().focus();
640								return false;
641							}
642						});
643
644						$(document).on('click.' + clss, function(event){
645							if( $(event.target).closest('.wm-search-inner').length )
646								return;
647							inp.fadeOut();
648							$wrap.css('visibility','hidden');
649							event.stopPropagation();
650						});
651					} else {
652						inp.css({
653							'max-width':'0px',
654							'opacity':'0'
655						});
656						search_but.on('click.' + clss, function () {
657							var wrapVis = $wrap.css('visibility');
658							if(wrapVis=="hidden"){
659								$wrap.css('visibility','visible');
660								inp.addClass('slide_search').css({
661									'opacity': '1',
662									'max-width':'100%'
663								}).focus();
664								return false;
665							}
666
667						});
668						$(document).on('click.' + clss, function(event){
669							if( $(event.target).closest('.wm-search-inner').length )
670								return;
671							inp.css({
672								'opacity': '0',
673								'max-width':'0'
674							});
675							$wrap.css('visibility','hidden');
676							event.stopPropagation();
677						});
678					}
679				} else {
680					search_but.on('click.' + clss, function () {
681						var wrapVis = $wrap.css('visibility');
682						if(wrapVis=="hidden"){
683							$wrap.css('visibility','visible');
684							inp.fadeIn().focus();
685							return false;
686						}
687					});
688					inp.hide();
689					$(document).on('click.' + clss, function(event){
690						if( $(event.target).closest('.wm-search-inner').length )
691							return;
692						inp.fadeOut();
693						$wrap.css('visibility','hidden');
694						event.stopPropagation();
695					});
696				}
697
698				$this.data('wm_search', clss);
699
700			});
701		}
702	}
703})(jQuery);
704$(function () {
705	$(document).click(function (event) {
706		$('.contacts-block').each(function() {
707			if ($(event.target).closest($(this)).length) {
708				return;
709			} else {
710				$(this).find('.tgl-but').prop("checked", false);
711				$(this).find('.icon').removeClass('active');
712			}
713		});
714	});
715
716	function setMargin($block) {
717		if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) {
718			$block.find(".block-body-drop").css({
719				"margin-left": "0px"
720			});
721		} else {
722			var left = $block.offset().left * -1;
723			$block.find(".block-body-drop").css({
724				"margin-left": left + "px"
725			});
726		}
727	}
728
729	$('.contacts-block').each(function() {
730		var $block = $(this),
731			allClasses = $block.attr("class").split(" "),
732			mainClass = allClasses[0],
733			mainSelector = ".side-panel ."+mainClass+" .block-body-drop",
734			styles = document.styleSheets;
735
736		for(var i = 0; i < styles.length; i++) {
737			if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) {
738				for(var j = 0; j < styles[i].cssRules.length; j++) {
739					if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") {
740						$block.data("fullwidth", 1);
741						setMargin($block);
742						break;
743					}
744				}
745				break;
746			}
747		}
748	});
749
750	$(window).resize(function() {
751		$('.contacts-block').each(function() {
752			var $block = $(this);
753			if ($block.data("fullwidth") == 1) {
754				setMargin($block);
755			}
756		});
757	});
758
759	$('.contacts-block').each(function() {
760		var $block = $(this);
761		$block.find('.icon').click(function() {
762			if ($block.data("fullwidth") == 1) {
763				setMargin($block);
764			}
765			if ($block.find('.tgl-but').prop("checked")) {
766				$(this).removeClass('active');
767			} else {
768				$(this).addClass('active');
769			}
770		});
771	});
772});
773document.addEventListener('DOMContentLoaded', function() {
774	var bodyScrollBarWidth = (function () {
775		var widthHidden, widthScroll, currentValue, currentPriority;
776		currentValue = document.body.style.getPropertyValue('overflow');
777		currentPriority = document.body.style.getPropertyPriority('overflow');
778		document.body.style.setProperty('overflow', 'hidden', 'important');
779		widthHidden = document.body.clientWidth;
780		document.body.style.setProperty('overflow', 'scroll', 'important');
781		widthScroll = document.body.clientWidth;
782		document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority);
783		return widthHidden - widthScroll;
784	}());
785	var media = {
786		'tablet-landscape': 960,
787		'tablet-portrait': 768,
788		'mobile-landscape': 640,
789		'mobile-portrait': 480
790	};
791	var side_panel = document.querySelector('.side-panel');
792	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;
793	var layers, content_width, flip, full_width, elements = {}, comments = {};
794
795	if (!side_panel || side_panel.classList.contains('removed')) {
796		return;
797	}
798
799	flip = side_panel.getAttribute('data-position') === 'right';
800
801	try {
802		layers = side_panel.getAttribute('data-layers');
803		if (layers !== "") {
804			layers = JSON.parse(layers.replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"'));
805		}
806	} catch(e) {
807		console.error(e);
808	}
809
810	if (typeof layers !== 'object' || Object.keys(layers).length === 0) {
811		return;
812	}
813
814	Object.keys(layers).forEach(function(clss) {
815		elements[clss] = document.querySelector('.' + clss);
816		comments[clss] = document.createComment(clss);
817		if (elements[clss]) {
818			elements[clss].parentNode.insertBefore(comments[clss], elements[clss]);
819		} else {
820			delete layers[clss];
821		}
822	});
823
824	side_panel_button = side_panel.querySelector('.side-panel-button');
825	side_panel_close = side_panel.querySelector('.side-panel-close');
826	side_panel_content = side_panel.querySelector('.side-panel-content');
827	side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content;
828	side_panel_mask = side_panel.querySelector('.side-panel-mask');
829	side_panel_top = side_panel.querySelector('.side-panel-top-inner');
830
831	side_panel.classList.remove('hidden');
832	side_panel_button.classList.remove('hidden');
833	side_panel_button.style.display = 'none';
834	side_panel_content.classList.remove('hidden');
835	side_panel_content.style.display = 'none';
836	side_panel_mask.classList.remove('hidden');
837	side_panel_mask.style.display = 'none';
838
839	content_width = getComputedStyle(side_panel_content, null).width;
840
841	leftEdge = 0;
842	rightEdge = parseInt(content_width) + 50;
843
844	if (content_width === 'auto') {
845		rightEdge = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
846		full_width = true;
847	}
848
849	isPhantom = !!parseInt($(side_panel).attr("data-phantom"));
850
851	if (isPhantom) {
852		$(side_panel).css({"pointer-events": "none"});
853	} else {
854		$(side_panel).css({"pointer-events": "auto"});
855	}
856
857	if (flip) {
858		side_panel_content.style.left = 'auto';
859		side_panel_content.style.right = '0';
860	}
861
862	if (full_width) {
863		side_panel_content.style.left = '0';
864		side_panel_content.style.right = '0';
865	}
866
867	window.side_panel_controller = side_panel_controller = new DrawerController({
868		target: side_panel,
869		full_width: full_width,
870		left: leftEdge,
871		right: rightEdge,
872		position: 0,
873		flip: flip,
874		curve: 'ease-in-out',
875		willOpen: function() {
876			side_panel_mask.style.display = 'block';
877			side_panel_content.style.display = 'block';
878			document.body.classList.add('noscroll');
879			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
880				document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent'
881			}
882		},
883		didClose: function() {
884			side_panel_mask.style.display = 'none';
885			side_panel_content.style.display = 'none';
886			document.body.classList.remove('noscroll');
887			if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) {
888				document.body.style.borderRight = ''
889			}
890		},
891		onAnimate: function(position) {
892			side_panel_mask.style.opacity = position / rightEdge;
893			side_panel_content.style.transform = 'translate3d(' + (flip ? rightEdge - position : position - rightEdge) + 'px,0,0)';
894		}
895	});
896
897	side_panel_controller.inPanel = function(clss) {
898		var viewportWidth;
899		var current_media;
900
901		if (typeof clss !== 'string') {
902			return false;
903		}
904
905		if (clss.charAt(0) === '.') {
906			clss = clss.slice(1);
907		}
908
909		viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
910
911		Object.keys(media).forEach(function(key) {
912			if (viewportWidth <= media[key]) {
913				current_media = key;
914			}
915		});
916
917		if (typeof current_media === 'undefined') {
918			current_media = 'screen';
919		}
920
921		return layers[clss] && layers[clss][current_media];
922	};
923
924	side_panel_button.addEventListener('click', function(e) {
925		e.preventDefault();
926		side_panel_controller.toggle();
927		return false;
928	});
929
930	if (side_panel_close) {
931		side_panel_close.addEventListener('click', function(e) {
932			e.preventDefault();
933			side_panel_controller.close();
934			return false;
935		});
936	}
937
938	side_panel_mask.addEventListener('click', function() {
939		side_panel_controller.close();
940		return false;
941	});
942
943	document.addEventListener('keyup', function(e) {
944		if (e.keyCode === 27) {
945			side_panel_controller.close();
946			return false;
947		}
948	});
949
950	var debounce = (function () {
951		return function (fn, time) {
952			var timer, func;
953			if (window.requestAnimationFrame) {
954				func = function() {
955					timer && cancelAnimationFrame(timer);
956					timer = requestAnimationFrame(fn);
957				}
958			} else {
959				func = function() {
960					window.clearTimeout(timer);
961					timer = window.setTimeout(function () {
962						fn();
963					}, time)
964				};
965			}
966			return func;
967		}
968	}());
969
970	function checkSidePanel() {
971		var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
972		var current_media;
973		var emptySide = true;
974		var emptyTop = true;
975
976		if (checkSidePanel.viewportWidth === viewportWidth) {
977			return;
978		}
979
980		checkSidePanel.viewportWidth = viewportWidth;
981
982		Object.keys(media).forEach(function(key) {
983			if (viewportWidth <= media[key]) {
984				current_media = key;
985			}
986		});
987
988		if (typeof current_media === 'undefined') {
989			current_media = 'screen';
990		}
991
992		Object.keys(layers).forEach(function(clss){
993			var element, comment;
994
995			element = elements[clss];
996			comment = comments[clss];
997
998			if (current_media in layers[clss]) {
999				if (layers[clss][current_media] === 'onTop') {
1000					side_panel_top.appendChild(element);
1001					emptyTop = false;
1002				} else {
1003					side_panel_content_inner.appendChild(element);
1004					emptySide = false;
1005				}
1006			} else {
1007				if (comment) {
1008					comment.parentNode.insertBefore(element, comment);
1009				}
1010			}
1011		});
1012
1013		if (emptySide) {
1014			side_panel_button.style.display = 'none';
1015		} else {
1016			side_panel_button.style.display = 'block';
1017		}
1018
1019		if (!emptyTop || !emptySide) {
1020			side_panel.style.display = 'block';
1021		} else {
1022			side_panel.style.display = 'none';
1023			side_panel_controller.close();
1024		}
1025	}
1026
1027	checkSidePanel = debounce(checkSidePanel, 40);
1028
1029	checkSidePanel();
1030	window.addEventListener('resize', checkSidePanel);
1031});
1032/*
1033 * @license
1034 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1035 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1036 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1037 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1038 * Code distributed by Google as part of the polymer project is also
1039 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1040 */
1041
1042"use strict";
1043
1044(function (exports) {
1045
1046	function sign(number) {
1047		if (number < 0)
1048			return -1;
1049		if (number > 0)
1050			return 1;
1051		return 0;
1052	}
1053
1054	function Animator(delegate) {
1055		this.delegate = delegate;
1056		this.startTimeStamp = 0;
1057		this.request_ = null;
1058	};
1059
1060	Animator.prototype.scheduleAnimation = function () {
1061		if (this.request_)
1062			return;
1063		this.request_ = requestAnimationFrame(this.onAnimation_.bind(this));
1064	};
1065
1066	Animator.prototype.startAnimation = function () {
1067		this.startTimeStamp = 0;
1068		this.scheduleAnimation();
1069	};
1070
1071	Animator.prototype.stopAnimation = function () {
1072		cancelAnimationFrame(this.request_);
1073		this.startTimeStamp = 0;
1074		this.request_ = null;
1075	};
1076
1077	Animator.prototype.onAnimation_ = function (timeStamp) {
1078		this.request_ = null;
1079		if (!this.startTimeStamp)
1080			this.startTimeStamp = timeStamp;
1081		if (this.delegate.onAnimation(timeStamp))
1082			this.scheduleAnimation();
1083	};
1084
1085	function VelocityTracker() {
1086		this.recentTouchMoves_ = [];
1087		this.velocityX = 0;
1088		this.velocityY = 0;
1089	}
1090
1091	VelocityTracker.kTimeWindow = 50;
1092
1093	VelocityTracker.prototype.pruneHistory_ = function (timeStamp) {
1094		for (var i = 0; i < this.recentTouchMoves_.length; ++i) {
1095			if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) {
1096				this.recentTouchMoves_ = this.recentTouchMoves_.slice(i);
1097				return;
1098			}
1099		}
1100		// All touchmoves are old.
1101		this.recentTouchMoves_ = [];
1102	};
1103
1104	VelocityTracker.prototype.update_ = function (e) {
1105		this.pruneHistory_(e.timeStamp);
1106		this.recentTouchMoves_.push(e);
1107
1108		var oldestTouchMove = this.recentTouchMoves_[0];
1109
1110		var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX;
1111		var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY;
1112		var deltaT = e.timeStamp - oldestTouchMove.timeStamp;
1113
1114		if (deltaT > 0) {
1115			this.velocityX = deltaX / deltaT;
1116			this.velocityY = deltaY / deltaT;
1117		} else {
1118			this.velocityX = 0;
1119			this.velocityY = 0;
1120		}
1121	};
1122
1123	VelocityTracker.prototype.onTouchStart = function (e) {
1124		this.recentTouchMoves_.push(e);
1125		this.velocityX = 0;
1126		this.velocityY = 0;
1127	};
1128
1129	VelocityTracker.prototype.onTouchMove = function (e) {
1130		this.update_(e);
1131	};
1132
1133	VelocityTracker.prototype.onTouchEnd = function (e) {
1134		this.update_(e);
1135		this.recentTouchMoves_ = [];
1136	};
1137
1138	function LinearTimingFunction() {
1139	};
1140
1141	LinearTimingFunction.prototype.scaleTime = function (fraction) {
1142		return fraction;
1143	};
1144
1145	function CubicBezierTimingFunction(spec) {
1146		this.map = [];
1147		for (var ii = 0; ii <= 100; ii += 1) {
1148			var i = ii / 100;
1149			this.map.push([
1150				3 * i * (1 - i) * (1 - i) * spec[0] +
1151				3 * i * i * (1 - i) * spec[2] + i * i * i,
1152				3 * i * (1 - i) * (1 - i) * spec[1] +
1153				3 * i * i * (1 - i) * spec[3] + i * i * i
1154			]);
1155		}
1156	};
1157
1158	CubicBezierTimingFunction.prototype.scaleTime = function (fraction) {
1159		var fst = 0;
1160		while (fst !== 100 && fraction > this.map[fst][0]) {
1161			fst += 1;
1162		}
1163		if (fraction === this.map[fst][0] || fst === 0) {
1164			return this.map[fst][1];
1165		}
1166		var yDiff = this.map[fst][1] - this.map[fst - 1][1];
1167		var xDiff = this.map[fst][0] - this.map[fst - 1][0];
1168		var p = (fraction - this.map[fst - 1][0]) / xDiff;
1169		return this.map[fst - 1][1] + p * yDiff;
1170	};
1171
1172	var presetTimingFunctions = {
1173		'linear': new LinearTimingFunction(),
1174		'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]),
1175		'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]),
1176		'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]),
1177		'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]),
1178	};
1179
1180	function DrawerController(options) {
1181		this.velocityTracker = new VelocityTracker();
1182		this.animator = new Animator(this);
1183
1184		this.target = options.target;
1185		this.left = options.left;
1186		this.right = options.right;
1187		this.position = options.position;
1188		this.flip = options.flip;
1189		this.full_width = options.full_width;
1190
1191		this.width = this.right - this.left;
1192		this.curve = presetTimingFunctions[options.curve || 'linear'];
1193
1194		this.willOpenCallback = options.willOpen;
1195		this.didCloseCallback = options.didClose;
1196		this.animateCallback = options.onAnimate;
1197
1198		this.state = DrawerController.kClosed;
1199
1200		this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS;
1201
1202		this.onTouchMove = this.onTouchMove.bind(this);
1203		this.onTouchEnd = this.onTouchEnd.bind(this);
1204
1205		if (!this.full_width) {
1206			this.target.addEventListener('touchstart', this.onTouchStart.bind(this));
1207		}
1208	}
1209
1210	DrawerController.kOpened = 'opened';
1211	DrawerController.kClosed = 'closed';
1212	DrawerController.kOpening = 'opening';
1213	DrawerController.kClosing = 'closing';
1214	DrawerController.kDragging = 'dragging';
1215	DrawerController.kFlinging = 'flinging';
1216
1217	DrawerController.kBaseSettleDurationMS = 246;
1218	DrawerController.kMaxSettleDurationMS = 600;
1219
1220	DrawerController.kMinFlingVelocity = 0.4;  // Matches Android framework.
1221	DrawerController.kTouchSlop = 5;  // Matches Android framework.
1222	DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop;
1223
1224	DrawerController.prototype.restrictToCurrent = function (offset) {
1225		return Math.max(this.left, Math.min(this.position, offset));
1226	};
1227
1228	DrawerController.prototype.restrictToBounds = function (offset) {
1229		return Math.max(this.left, Math.min(this.right, offset));
1230	};
1231
1232	DrawerController.prototype.onTouchStart = function (e) {
1233		this.velocityTracker.onTouchStart(e);
1234
1235		var touchX;
1236		if (this.flip) {
1237			touchX = document.documentElement.clientWidth - e.changedTouches[0].clientX;
1238		} else {
1239			touchX = e.changedTouches[0].clientX;
1240		}
1241		var touchY = e.changedTouches[0].clientY;
1242
1243		if (this.state != DrawerController.kOpened) {
1244			if (touchX != this.restrictToCurrent(touchX))
1245				return;
1246			this.state = DrawerController.kDragging;
1247		}
1248
1249		this.animator.stopAnimation();
1250		this.target.addEventListener('touchmove', this.onTouchMove);
1251		this.target.addEventListener('touchend', this.onTouchEnd);
1252		// TODO(abarth): Handle touchcancel.
1253
1254		this.startX = touchX;
1255		this.startY = touchY;
1256		this.startPosition = this.position;
1257		this.touchBaseX = Math.min(touchX, this.startPosition);
1258	};
1259
1260	DrawerController.prototype.onTouchMove = function (e) {
1261		this.velocityTracker.onTouchMove(e);
1262
1263		if (this.state == DrawerController.kOpened) {
1264			var deltaX;
1265			if (this.flip) {
1266				deltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.startX;
1267			} else {
1268				deltaX = e.changedTouches[0].clientX - this.startX;
1269			}
1270			var deltaY = e.changedTouches[0].clientY - this.startY;
1271
1272			if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) {
1273				e.preventDefault();
1274				return;
1275			}
1276
1277			if (Math.abs(deltaY) > Math.abs(deltaX)) {
1278				this.target.removeEventListener('touchmove', this.onTouchMove);
1279				this.target.removeEventListener('touchend', this.onTouchEnd);
1280				return;
1281			}
1282
1283			this.state = DrawerController.kDragging;
1284		}
1285
1286		e.preventDefault();
1287		var touchDeltaX;
1288		if (this.flip) {
1289			touchDeltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.touchBaseX;
1290		} else {
1291			touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX;
1292		}
1293		this.position = this.restrictToBounds(this.startPosition + touchDeltaX);
1294		this.animator.scheduleAnimation();
1295	};
1296
1297	DrawerController.prototype.onTouchEnd = function (e) {
1298		this.velocityTracker.onTouchEnd(e);
1299		this.target.removeEventListener('touchmove', this.onTouchMove);
1300		this.target.removeEventListener('touchend', this.onTouchEnd);
1301
1302		var velocityX = this.velocityTracker.velocityX;
1303
1304		if (this.flip) {
1305			velocityX *= -1;
1306		}
1307
1308		if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) {
1309			this.fling(velocityX);
1310		} else if (this.isOpen()) {
1311			this.open();
1312		} else {
1313			this.close();
1314		}
1315	};
1316
1317	DrawerController.prototype.openFraction = function () {
1318		var width = this.right - this.left;
1319		var offset = this.position - this.left;
1320		return offset / width;
1321	};
1322
1323	DrawerController.prototype.isOpen = function () {
1324		return this.openFraction() >= 0.5;
1325	};
1326
1327	DrawerController.prototype.isOpening = function () {
1328		return this.state == DrawerController.kOpening ||
1329			(this.state == DrawerController.kFlinging && this.animationVelocityX > 0);
1330	}
1331
1332	DrawerController.prototype.isClosing = function () {
1333		return this.state == DrawerController.kClosing ||
1334			(this.state == DrawerController.kFlinging && this.animationVelocityX < 0);
1335	}
1336
1337	DrawerController.prototype.toggle = function () {
1338		if (this.isOpen())
1339			this.close();
1340		else
1341			this.open();
1342	};
1343
1344	DrawerController.prototype.open = function () {
1345		if (this.full_width) {
1346			this.willOpenCallback.call(this.target);
1347			return;
1348		}
1349		if (!this.position)
1350			this.willOpenCallback.call(this.target);
1351
1352		this.animator.stopAnimation();
1353		this.animationDuration = 400;
1354		this.state = DrawerController.kOpening;
1355		this.animate();
1356	};
1357
1358	DrawerController.prototype.close = function () {
1359		if (this.full_width) {
1360			this.didCloseCallback.call(this.target);
1361			return;
1362		}
1363		this.animator.stopAnimation();
1364		this.animationDuration = 400;
1365		this.state = DrawerController.kClosing;
1366		this.animate();
1367	};
1368
1369	DrawerController.prototype.fling = function (velocityX) {
1370		this.animator.stopAnimation();
1371		this.animationVelocityX = velocityX;
1372		this.state = DrawerController.kFlinging;
1373		this.animate();
1374	};
1375
1376	DrawerController.prototype.animate = function () {
1377		this.positionAnimationBase = this.position;
1378		this.animator.startAnimation();
1379	};
1380
1381	DrawerController.prototype.targetPosition = function (deltaT) {
1382		if (this.state == DrawerController.kFlinging)
1383			return this.positionAnimationBase + this.animationVelocityX * deltaT;
1384		var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration);
1385		var animationWidth = this.state == DrawerController.kOpening ?
1386		this.width - this.positionAnimationBase : -this.positionAnimationBase;
1387		return this.positionAnimationBase + targetFraction * animationWidth;
1388	};
1389
1390	DrawerController.prototype.onAnimation = function (timeStamp) {
1391		if (this.state == DrawerController.kDragging) {
1392			this.animateCallback.call(this.target, this.position);
1393			return false;
1394		}
1395
1396		var deltaT = timeStamp - this.animator.startTimeStamp;
1397		var targetPosition = this.targetPosition(deltaT);
1398		this.position = this.restrictToBounds(targetPosition);
1399
1400		this.animateCallback.call(this.target, this.position);
1401
1402		if (targetPosition <= this.left && this.isClosing()) {
1403			this.state = DrawerController.kClosed;
1404			this.didCloseCallback.call(this.target);
1405			return false;
1406		}
1407		if (targetPosition >= this.right && this.isOpening()) {
1408			this.state = DrawerController.kOpened;
1409			return false;
1410		}
1411
1412		return true;
1413	};
1414
1415
1416	exports.DrawerController = DrawerController;
1417
1418})(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.