1;(function($) { 2 // wrap tables in content for swipe on mobile devices 3 $(function() { 4 $('article.content').find('table').wrap('<div class="for-mobile-view"></div>'); 5 }); 6}(jQuery));/** 7 * BxSlider v4.1.2 - Fully loaded, responsive content slider 8 * http://bxslider.com 9 * 10 * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com 11 * Written while drinking Belgian ales and listening to jazz 12 * 13 * Released under the MIT license - http://opensource.org/licenses/MIT 14 */ 15!function(t){var e={},s={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,wrapperClass:"bx-wrapper",touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,autoSlideForOnePage:!1,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){},onSlideBefore:function(){},onSlideAfter:function(){},onSlideNext:function(){},onSlidePrev:function(){},onSliderResize:function(){}};t.fn.bxSlider=function(n){if(0==this.length)return this;if(this.length>1)return this.each(function(){t(this).bxSlider(n)}),this;var o={},r=this;e.el=this;var a=t(window).width(),l=t(window).height(),d=function(){o.settings=t.extend({},s,n),o.settings.slideWidth=parseInt(o.settings.slideWidth),o.children=r.children(o.settings.slideSelector),o.children.length<o.settings.minSlides&&(o.settings.minSlides=o.children.length),o.children.length<o.settings.maxSlides&&(o.settings.maxSlides=o.children.length),o.settings.randomStart&&(o.settings.startSlide=Math.floor(Math.random()*o.children.length)),o.active={index:o.settings.startSlide},o.carousel=o.settings.minSlides>1||o.settings.maxSlides>1,o.carousel&&(o.settings.preloadImages="all"),o.minThreshold=o.settings.minSlides*o.settings.slideWidth+(o.settings.minSlides-1)*o.settings.slideMargin,o.maxThreshold=o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin,o.working=!1,o.controls={},o.interval=null,o.animProp="vertical"==o.settings.mode?"top":"left",o.usingCSS=o.settings.useCSS&&"fade"!=o.settings.mode&&function(){var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return o.cssPrefix=e[i].replace("Perspective","").toLowerCase(),o.animProp="-"+o.cssPrefix+"-transform",!0;return!1}(),"vertical"==o.settings.mode&&(o.settings.maxSlides=o.settings.minSlides),r.data("origStyle",r.attr("style")),r.children(o.settings.slideSelector).each(function(){t(this).data("origStyle",t(this).attr("style"))}),c()},c=function(){r.wrap('<div class="'+o.settings.wrapperClass+'"><div class="bx-viewport"></div></div>'),o.viewport=r.parent(),o.loader=t('<div class="bx-loading" />'),o.viewport.prepend(o.loader),r.css({width:"horizontal"==o.settings.mode?100*o.children.length+215+"%":"auto",position:"relative"}),o.usingCSS&&o.settings.easing?r.css("-"+o.cssPrefix+"-transition-timing-function",o.settings.easing):o.settings.easing||(o.settings.easing="swing");f();o.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),o.viewport.parent().css({maxWidth:v()}),o.settings.pager||o.viewport.parent().css({margin:"0 auto 0px"}),o.children.css({"float":"horizontal"==o.settings.mode?"left":"none",listStyle:"none",position:"relative"}),o.children.css("width",u()),"horizontal"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginRight",o.settings.slideMargin),"vertical"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginBottom",o.settings.slideMargin),"fade"==o.settings.mode&&(o.children.css({position:"absolute",zIndex:0,display:"none"}),o.children.eq(o.settings.startSlide).css({zIndex:o.settings.slideZIndex,display:"block"})),o.controls.el=t('<div class="bx-controls" />'),o.settings.captions&&P(),o.active.last=o.settings.startSlide==x()-1,o.settings.video&&r.fitVids();var e=o.children.eq(o.settings.startSlide);"all"==o.settings.preloadImages&&(e=o.children),o.settings.ticker?o.settings.pager=!1:(o.settings.pager&&T(),o.settings.controls&&C(),o.settings.auto&&o.settings.autoControls&&E(),(o.settings.controls||o.settings.autoControls||o.settings.pager)&&o.viewport.after(o.controls.el)),g(e,h)},g=function(e,i){var s=e.find("img, iframe").length;if(0==s)return void i();var n=0;e.find("img, iframe").each(function(){t(this).one("load",function(){++n==s&&i()}).each(function(){this.complete&&t(this).load()})})},h=function(){if(o.settings.infiniteLoop&&"fade"!=o.settings.mode&&!o.settings.ticker){var e="vertical"==o.settings.mode?o.settings.minSlides:o.settings.maxSlides,i=o.children.slice(0,e).clone().addClass("bx-clone"),s=o.children.slice(-e).clone().addClass("bx-clone");r.append(i).prepend(s)}o.loader.remove(),S(),"vertical"==o.settings.mode&&(o.settings.adaptiveHeight=!0),o.viewport.height(p()),r.redrawSlider(),o.settings.onSliderLoad(o.active.index),o.initialized=!0,o.settings.responsive&&t(window).bind("resize",V),o.settings.auto&&o.settings.autoStart&&(x()>1||o.settings.autoSlideForOnePage)&&H(),o.settings.ticker&&L(),o.settings.pager&&q(o.settings.startSlide),o.settings.controls&&W(),o.settings.touchEnabled&&!o.settings.ticker&&N()},p=function(){var e=0,s=t();if("vertical"==o.settings.mode||o.settings.adaptiveHeight)if(o.carousel){var n=1==o.settings.moveSlides?o.active.index:o.active.index*m();for(s=o.children.eq(n),i=1;i<=o.settings.maxSlides-1;i++)s=n+i>=o.children.length?s.add(o.children.eq(i-1)):s.add(o.children.eq(n+i))}else s=o.children.eq(o.active.index);else s=o.children;return"vertical"==o.settings.mode?(s.each(function(i){e+=t(this).outerHeight()}),o.settings.slideMargin>0&&(e+=o.settings.slideMargin*(o.settings.minSlides-1))):e=Math.max.apply(Math,s.map(function(){return t(this).outerHeight(!1)}).get()),"border-box"==o.viewport.css("box-sizing")?e+=parseFloat(o.viewport.css("padding-top"))+parseFloat(o.viewport.css("padding-bottom"))+parseFloat(o.viewport.css("border-top-width"))+parseFloat(o.viewport.css("border-bottom-width")):"padding-box"==o.viewport.css("box-sizing")&&(e+=parseFloat(o.viewport.css("padding-top"))+parseFloat(o.viewport.css("padding-bottom"))),e},v=function(){var t="100%";return o.settings.slideWidth>0&&(t="horizontal"==o.settings.mode?o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin:o.settings.slideWidth),t},u=function(){var t=o.settings.slideWidth,e=o.viewport.width();return 0==o.settings.slideWidth||o.settings.slideWidth>e&&!o.carousel||"vertical"==o.settings.mode?t=e:o.settings.maxSlides>1&&"horizontal"==o.settings.mode&&(e>o.maxThreshold||e<o.minThreshold&&(t=(e-o.settings.slideMargin*(o.settings.minSlides-1))/o.settings.minSlides)),t},f=function(){var t=1;if("horizontal"==o.settings.mode&&o.settings.slideWidth>0)if(o.viewport.width()<o.minThreshold)t=o.settings.minSlides;else if(o.viewport.width()>o.maxThreshold)t=o.settings.maxSlides;else{var e=o.children.first().width()+o.settings.slideMargin;t=Math.floor((o.viewport.width()+o.settings.slideMargin)/e)}else"vertical"==o.settings.mode&&(t=o.settings.minSlides);return t},x=function(){var t=0;if(o.settings.moveSlides>0)if(o.settings.infiniteLoop)t=Math.ceil(o.children.length/m());else for(var e=0,i=0;e<o.children.length;)++t,e=i+f(),i+=o.settings.moveSlides<=f()?o.settings.moveSlides:f();else t=Math.ceil(o.children.length/f());return t},m=function(){return o.settings.moveSlides>0&&o.settings.moveSlides<=f()?o.settings.moveSlides:f()},S=function(){if(o.children.length>o.settings.maxSlides&&o.active.last&&!o.settings.infiniteLoop){if("horizontal"==o.settings.mode){var t=o.children.last(
15),e=t.position();b(-(e.left-(o.viewport.width()-t.outerWidth())),"reset",0)}else if("vertical"==o.settings.mode){var i=o.children.length-o.settings.minSlides,e=o.children.eq(i).position();b(-e.top,"reset",0)}}else{var e=o.children.eq(o.active.index*m()).position();o.active.index==x()-1&&(o.active.last=!0),void 0!=e&&("horizontal"==o.settings.mode?b(-e.left,"reset",0):"vertical"==o.settings.mode&&b(-e.top,"reset",0))}},b=function(t,e,i,s){if(o.usingCSS){var n="vertical"==o.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)";r.css("-"+o.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"==e?(r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),D()})):"reset"==e?r.css(o.animProp,n):"ticker"==e&&(r.css("-"+o.cssPrefix+"-transition-timing-function","linear"),r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),b(s.resetValue,"reset",0),F()}))}else{var a={};a[o.animProp]=t,"slide"==e?r.animate(a,i,o.settings.easing,function(){D()}):"reset"==e?r.css(o.animProp,t):"ticker"==e&&r.animate(a,speed,"linear",function(){b(s.resetValue,"reset",0),F()})}},w=function(){for(var e="",i=x(),s=0;i>s;s++){var n="";o.settings.buildPager&&t.isFunction(o.settings.buildPager)?(n=o.settings.buildPager(s),o.pagerEl.addClass("bx-custom-pager")):(n=s+1,o.pagerEl.addClass("bx-default-pager")),e+='<div class="bx-pager-item"><a href="" data-slide-index="'+s+'" class="bx-pager-link">'+n+"</a></div>"}o.pagerEl.html(e)},T=function(){o.settings.pagerCustom?o.pagerEl=t(o.settings.pagerCustom):(o.pagerEl=t('<div class="bx-pager" />'),o.settings.pagerSelector?t(o.settings.pagerSelector).html(o.pagerEl):o.controls.el.addClass("bx-has-pager").append(o.pagerEl),w()),o.pagerEl.on("click","a",I)},C=function(){o.controls.next=t('<a class="bx-next" href="">'+o.settings.nextText+"</a>"),o.controls.prev=t('<a class="bx-prev" href="">'+o.settings.prevText+"</a>"),o.controls.next.bind("click",z),o.controls.prev.bind("click",y),o.settings.nextSelector&&t(o.settings.nextSelector).append(o.controls.next),o.settings.prevSelector&&t(o.settings.prevSelector).append(o.controls.prev),o.settings.nextSelector||o.settings.prevSelector||(o.controls.directionEl=t('<div class="bx-controls-direction" />'),o.controls.directionEl.append(o.controls.prev).append(o.controls.next),o.controls.el.addClass("bx-has-controls-direction").append(o.controls.directionEl))},E=function(){o.controls.start=t('<div class="bx-controls-auto-item"><a class="bx-start" href="">'+o.settings.startText+"</a></div>"),o.controls.stop=t('<div class="bx-controls-auto-item"><a class="bx-stop" href="">'+o.settings.stopText+"</a></div>"),o.controls.autoEl=t('<div class="bx-controls-auto" />'),o.controls.autoEl.on("click",".bx-start",M),o.controls.autoEl.on("click",".bx-stop",k),o.settings.autoControlsCombine?o.controls.autoEl.append(o.controls.start):o.controls.autoEl.append(o.controls.start).append(o.controls.stop),o.settings.autoControlsSelector?t(o.settings.autoControlsSelector).html(o.controls.autoEl):o.controls.el.addClass("bx-has-controls-auto").append(o.controls.autoEl),A(o.settings.autoStart?"stop":"start")},P=function(){o.children.each(function(e){var i=t(this).find("img:first").attr("title");void 0!=i&&(""+i).length&&t(this).append('<div class="bx-caption"><span>'+i+"</span></div>")})},z=function(t){o.settings.auto&&r.stopAuto(),r.goToNextSlide(),t.preventDefault()},y=function(t){o.settings.auto&&r.stopAuto(),r.goToPrevSlide(),t.preventDefault()},M=function(t){r.startAuto(),t.preventDefault()},k=function(t){r.stopAuto(),t.preventDefault()},I=function(e){o.settings.auto&&r.stopAuto();var i=t(e.currentTarget);if(void 0!==i.attr("data-slide-index")){var s=parseInt(i.attr("data-slide-index"));s!=o.active.index&&r.goToSlide(s),e.preventDefault()}},q=function(e){var i=o.children.length;return"short"==o.settings.pagerType?(o.settings.maxSlides>1&&(i=Math.ceil(o.children.length/o.settings.maxSlides)),void o.pagerEl.html(e+1+o.settings.pagerShortSeparator+i)):(o.pagerEl.find("a").removeClass("active"),void o.pagerEl.each(function(i,s){t(s).find("a").eq(e).addClass("active")}))},D=function(){if(o.settings.infiniteLoop){var t="";0==o.active.index?t=o.children.eq(0).position():o.active.index==x()-1&&o.carousel?t=o.children.eq((x()-1)*m()).position():o.active.index==o.children.length-1&&(t=o.children.eq(o.children.length-1).position()),t&&("horizontal"==o.settings.mode?b(-t.left,"reset",0):"vertical"==o.settings.mode&&b(-t.top,"reset",0))}o.working=!1,o.settings.onSlideAfter(o.children.eq(o.active.index),o.oldIndex,o.active.index)},A=function(t){o.settings.autoControlsCombine?o.controls.autoEl.html(o.controls[t]):(o.controls.autoEl.find("a").removeClass("active"),o.controls.autoEl.find("a:not(.bx-"+t+")").addClass("active"))},W=function(){1==x()?(o.controls.prev.addClass("disabled"),o.controls.next.addClass("disabled")):!o.settings.infiniteLoop&&o.settings.hideControlOnEnd&&(0==o.active.index?(o.controls.prev.addClass("disabled"),o.controls.next.removeClass("disabled")):o.active.index==x()-1?(o.controls.next.addClass("disabled"),o.controls.prev.removeClass("disabled")):(o.controls.prev.removeClass("disabled"),o.controls.next.removeClass("disabled")))},H=function(){if(o.settings.autoDelay>0){setTimeout(r.startAuto,o.settings.autoDelay)}else r.startAuto();o.settings.autoHover&&r.hover(function(){o.interval&&(r.stopAuto(!0),o.autoPaused=!0)},function(){o.autoPaused&&(r.startAuto(!0),o.autoPaused=null)})},L=function(){var e=0;if("next"==o.settings.autoDirection)r.append(o.children.clone().addClass("bx-clone"));else{r.prepend(o.children.clone().addClass("bx-clone"));var i=o.children.first().position();e="horizontal"==o.settings.mode?-i.left:-i.top}b(e,"reset",0),o.settings.pager=!1,o.settings.controls=!1,o.settings.autoControls=!1,o.settings.tickerHover&&!o.usingCSS&&o.viewport.hover(function(){r.stop()},function(){var e=0;o.children.each(function(i){e+="horizontal"==o.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});
15var i=o.settings.speed/e,s="horizontal"==o.settings.mode?"left":"top",n=i*(e-Math.abs(parseInt(r.css(s))));F(n)}),F()},F=function(t){speed=t?t:o.settings.speed;var e={left:0,top:0},i={left:0,top:0};"next"==o.settings.autoDirection?e=r.find(".bx-clone").first().position():i=o.children.first().position();var s="horizontal"==o.settings.mode?-e.left:-e.top,n="horizontal"==o.settings.mode?-i.left:-i.top,a={resetValue:n};b(s,"ticker",speed,a)},N=function(){o.touch={start:{x:0,y:0},end:{x:0,y:0}},o.viewport.bind("touchstart",O)},O=function(t){if(o.working)t.preventDefault();else{o.touch.originalPos=r.position();var e=t.originalEvent;o.touch.start.x=e.changedTouches[0].pageX,o.touch.start.y=e.changedTouches[0].pageY,o.viewport.bind("touchmove",X),o.viewport.bind("touchend",Y)}},X=function(t){var e=t.originalEvent,i=Math.abs(e.changedTouches[0].pageX-o.touch.start.x),s=Math.abs(e.changedTouches[0].pageY-o.touch.start.y);if(3*i>s&&o.settings.preventDefaultSwipeX?t.preventDefault():3*s>i&&o.settings.preventDefaultSwipeY&&t.preventDefault(),"fade"!=o.settings.mode&&o.settings.oneToOneTouch){var n=0;if("horizontal"==o.settings.mode){var r=e.changedTouches[0].pageX-o.touch.start.x;n=o.touch.originalPos.left+r}else{var r=e.changedTouches[0].pageY-o.touch.start.y;n=o.touch.originalPos.top+r}b(n,"reset",0)}},Y=function(t){o.viewport.unbind("touchmove",X);var e=t.originalEvent,i=0;if(o.touch.end.x=e.changedTouches[0].pageX,o.touch.end.y=e.changedTouches[0].pageY,"fade"==o.settings.mode){var s=Math.abs(o.touch.start.x-o.touch.end.x);s>=o.settings.swipeThreshold&&(o.touch.start.x>o.touch.end.x?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto())}else{var s=0;"horizontal"==o.settings.mode?(s=o.touch.end.x-o.touch.start.x,i=o.touch.originalPos.left):(s=o.touch.end.y-o.touch.start.y,i=o.touch.originalPos.top),!o.settings.infiniteLoop&&(0==o.active.index&&s>0||o.active.last&&0>s)?b(i,"reset",200):Math.abs(s)>=o.settings.swipeThreshold?(0>s?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto()):b(i,"reset",200)}o.viewport.unbind("touchend",Y)},V=function(e){if(o.initialized){var i=t(window).width(),s=t(window).height();(a!=i||l!=s)&&(a=i,l=s,r.redrawSlider(),o.settings.onSliderResize.call(r,o.active.index))}};return r.goToSlide=function(e,i){if(!o.working&&o.active.index!=e)if(o.working=!0,o.oldIndex=o.active.index,0>e?o.active.index=x()-1:e>=x()?o.active.index=0:o.active.index=e,o.settings.onSlideBefore(o.children.eq(o.active.index),o.oldIndex,o.active.index),"next"==i?o.settings.onSlideNext(o.children.eq(o.active.index),o.oldIndex,o.active.index):"prev"==i&&o.settings.onSlidePrev(o.children.eq(o.active.index),o.oldIndex,o.active.index),o.active.last=o.active.index>=x()-1,o.settings.pager&&q(o.active.index),o.settings.controls&&W(),"fade"==o.settings.mode)o.settings.adaptiveHeight&&o.viewport.height()!=p()&&o.viewport.animate({height:p()},o.settings.adaptiveHeightSpeed),o.children.filter(":visible").fadeOut(o.settings.speed).css({zIndex:0}),o.children.eq(o.active.index).css("zIndex",o.settings.slideZIndex+1).fadeIn(o.settings.speed,function(){t(this).css("zIndex",o.settings.slideZIndex),D()});else{o.settings.adaptiveHeight&&o.viewport.height()!=p()&&o.viewport.animate({height:p()},o.settings.adaptiveHeightSpeed);var s=0,n={left:0,top:0};if(!o.settings.infiniteLoop&&o.carousel&&o.active.last)if("horizontal"==o.settings.mode){var a=o.children.eq(o.children.length-1);n=a.position(),s=o.viewport.width()-a.outerWidth()}else{var l=o.children.length-o.settings.minSlides;n=o.children.eq(l).position()}else if(o.carousel&&o.active.last&&"prev"==i){var d=1==o.settings.moveSlides?o.settings.maxSlides-m():(x()-1)*m()-(o.children.length-o.settings.maxSlides),a=r.children(".bx-clone").eq(d);n=a.position()}else if("next"==i&&0==o.active.index)n=r.find("> .bx-clone").eq(o.settings.maxSlides).position(),o.active.last=!1;else if(e>=0){var c=e*m();n=o.children.eq(c).position()}if("undefined"!=typeof n){var g="horizontal"==o.settings.mode?-(n.left-s):-n.top;b(g,"slide",o.settings.speed)}}},r.goToNextSlide=function(){if(o.settings.infiniteLoop||!o.active.last){var t=parseInt(o.active.index)+1;r.goToSlide(t,"next")}},r.goToPrevSlide=function(){if(o.settings.infiniteLoop||0!=o.active.index){var t=parseInt(o.active.index)-1;r.goToSlide(t,"prev")}},r.startAuto=function(t){o.interval||(o.interval=setInterval(function(){"next"==o.settings.autoDirection?r.goToNextSlide():r.goToPrevSlide()},o.settings.pause),o.settings.autoControls&&1!=t&&A("stop"))},r.stopAuto=function(t){o.interval&&(clearInterval(o.interval),o.interval=null,o.settings.autoControls&&1!=t&&A("start"))},r.getCurrentSlide=function(){return o.active.index},r.getCurrentSlideElement=function(){return o.children.eq(o.active.index)},r.getSlideCount=function(){return o.children.length},r.redrawSlider=function(){o.children.add(r.find(".bx-clone")).width(u()),o.viewport.css("height",p()),o.settings.ticker||S(),o.active.last&&(o.active.index=x()-1),o.active.index>=x()&&(o.active.last=!0),o.settings.pager&&!o.settings.pagerCustom&&(w(),q(o.active.index))},r.destroySlider=function(){o.initialized&&(o.initialized=!1,t(".bx-clone",this).remove(),o.children.each(function(){void 0!=t(this).data("origStyle")?t(this).attr("style",t(this).data("origStyle")):t(this).removeAttr("style")}),void 0!=t(this).data("origStyle")?this.attr("style",t(this).data("origStyle")):t(this).removeAttr("style"),t(this).unwrap().unwrap(),o.controls.el&&o.controls.el.remove(),o.controls.next&&o.controls.next.remove(),o.controls.prev&&o.controls.prev.remove(),o.pagerEl&&o.settings.controls&&o.pagerEl.remove(),t(".bx-caption",this).remove(),o.controls.autoEl&&o.controls.autoEl.remove(),clearInterval(o.interval),o.settings.responsive&&t(window).unbind("resize",V))},r.reloadSlider=function(t){void 0!=t&&(n=t),r.destroySlider(),d()},d(),this}}(jQuery); 16$(function() { 17 18 var debounce = (function () { 19 return function (fn, time) { 20 var timer, func; 21 func = function() { 22 var args = [].slice.call(arguments, 0); 23 window.clearTimeout(timer); 24 timer = window.setTimeout(function () { 25 window.requestAnimationFrame && window.requestAnimationFrame(function() {
26 fn.apply(null, args); 27 }) || fn.apply(null, args); 28 }, time) 29 }; 30 return func; 31 } 32 }()); 33 34 var throttle = (function() { 35 return function (fn, threshhold, scope) { 36 threshhold || (threshhold = 250); 37 var last, 38 deferTimer, 39 func; 40 func = function () { 41 var context = scope || this; 42 var now = +new Date, 43 args = arguments; 44 if (last && now < last + threshhold) { 45 // hold on to it 46 clearTimeout(deferTimer); 47 deferTimer = setTimeout(function () { 48 last = now; 49 fn.apply(context, args); 50 }, threshhold); 51 } else { 52 last = now; 53 fn.apply(context, args); 54 } 55 }; 56 return func; 57 } 58 }()); 59 60 $('.news-block').each(function() { 61 var $newsblock = $(this), 62 $items = $newsblock.find('.item-outer'), 63 $list = $newsblock.find('.news__list'), 64 $body = $newsblock.find('.body'), 65 $controls = $newsblock.find('.controls'), 66 $pagers = $newsblock.find('.pager-wrap'), 67 options = {}, 68 count, 69 col_arr, pager_arr, controls_arr, 70 bxslider, 71 containerWidth, 72 isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 73 74 if ($newsblock.attr('data-slider') === '1' && $.fn.bxSlider) { 75 76 options.pagerSelector= $newsblock.attr('data-setting-pager_selector'); 77 options.prevSelector = $newsblock.attr('data-setting-prev_selector'); 78 options.nextSelector = $newsblock.attr('data-setting-next_selector'); 79 options.prevText = $newsblock.attr('data-setting-prev_text') || ''; 80 options.nextText = $newsblock.attr('data-setting-next_text') || ''; 81 options.auto = !!parseInt($newsblock.attr('data-setting-auto')); 82 options.controls = !!parseInt($newsblock.attr('data-setting-controls')); 83 options.pager = !!parseInt($newsblock.attr('data-setting-pager').split(',')[0]); 84 options.pause = parseInt($newsblock.attr('data-setting-pause'), 10) || 4000; 85 options.useCSS = isMobile; 86 options.infiniteLoop = true; 87 options.adaptiveHeight = false; 88 options.mode = $newsblock.attr('data-setting-mode') || 'horizontal'; 89 options.touchEnabled = options.mode === 'horizontal'; 90 options.slideMargin = 0; 91 options.maxSlides = parseInt($newsblock.attr('data-setting-count'), 10) || 1; 92 options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides; 93 options.moveSlides = $newsblock.attr('data-setting-move') || 0; 94 95 col_arr = $newsblock.attr('data-setting-columns').split(","); 96 pager_arr = $newsblock.attr('data-setting-pager').split(","); 97 controls_arr = $newsblock.attr('data-setting-controls').split(","); 98 99 if (!options.autoControls && options.auto) { 100 options.onSlideAfter = function() {
101 bxslider.startAuto(); 102 } 103 } 104 105 $items.removeClass('hidden'); 106 if ($list.parent().hasClass('bx-viewport')) { 107 $list.unwrap(); 108 $list.unwrap(); 109 } 110 111 function init(force) { 112 var media_type, 113 body_width = $('body').width(); 114 115 var mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"]; 116 var media_ind, setting_columns, 117 isJustify, space_between; 118 119 var newContainerWidth = $newsblock.width(), itemHeight, viewportHeight; 120 if (!$newsblock.is(':visible')) { 121 if (bxslider) { 122 bxslider.destroySlider(); 123 } 124 return; 125 } 126 if (!force && containerWidth && containerWidth === newContainerWidth) { 127 return; 128 } 129 containerWidth = newContainerWidth; 130 131 if (bxslider) { 132 bxslider.destroySlider(); 133 } 134 135 if (body_width >= 961) { 136 media_type = "screen"; 137 } else if (body_width <= 960 && body_width >= 769) { 138 media_type = "tablet_landscape"; 139 } else if (body_width <= 768 && body_width >= 641) { 140 media_type = "tablet_portrait"; 141 } else if (body_width <= 640 && body_width >= 481) { 142 media_type = "mobile_landscape"; 143 } else if (body_width <= 480) { 144 media_type = "mobile_portrait"; 145 } 146 media_ind = mediaList.indexOf(media_type); 147 count = parseInt($newsblock.attr('data-setting-count'), 10); 148 149 isJustify = $body.css('justify-content') == "space-between" ? true : false; 150 151 $list.width('auto'); 152 $items 153 .attr('style', '') 154 .slice(1).addClass('hidden').end() 155 .width(options.slideWidth = $items.width()) 156 .removeClass('hidden'); 157 158 if (pager_arr.length > 1) { 159 options.pager = pager_arr[0] == false ? false : !!parseInt(pager_arr[media_ind]); 160 } 161 if (controls_arr.length > 1) { 162 options.controls = controls_arr[0] == false ? false : !!parseInt(controls_arr[media_ind]); 163 } 164 165 $(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"}); 166 $newsblock.find(".controls").css({"display": options.controls == true ? "flex" : "none"}); 167 168 if (options.mode === 'vertical') { 169 itemHeight = Math.max.apply(Math, $items.map(function() { 170 return $(this).height() 171 }).get()); 172 $items.css('min-height', itemHeight); 173 viewportHeight = itemHeight * count; 174 } else { 175 setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]); 176 if (setting_columns) { 177 count = setting_columns; 178 } 179 options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width())); 180 } 181 182 if (isJustify) { 183 if (options.maxSlides > 1) { 184 space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1)); 185 space_between = space_between < 0 ? 0 : space_between; 186 } else { 187 space_between = 0; 188 } 189 options.slideMargin = space_between; 190 } 191 192 if ($items.length > options.maxSlides) { 193 $list.css({'justify-content': 'flex-start'}); 194 if (bxslider) { 195 bxslider.reloadSlider(options); 196 } else { 197 $list.data('bxslider', (bxslider = $list.bxSlider(options))); 198 } 199 } else { 200 $list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'nowrap'}); 201 $pagers.hide(); 202 $controls.hide(); 203 } 204 205 if (viewportHeight) { 206 $list.parent().css('min-height', viewportHeight); 207 } 208 if (options.mode === 'horizontal') { 209 var align = {}; 210 switch ($body.css('justify-content')) { 211 case 'flex-end': 212 align['margin-left'] = 'auto'; 213 align['margin-right'] = '0px'; 214 break; 215 case 'center': 216 align['margin-left'] = 'auto'; 217 align['margin-right'] = 'auto'; 218 break; 219 default: 220 align['margin-left'] = '0px'; 221 align['margin-right'] = 'auto'; 222 } 223 $newsblock.find('.bx-wrapper').css(align); 224 } 225 } 226 227 $(window).on('resize', debounce(init, 300)); 228 $(window).on('load', function(){ 229 init(true); 230 }); 231 232 init(); 233 } 234 235 $(window).on('resize', debounce(swipeScrollInit, 300)); 236 swipeScrollInit(); 237 238 function swipeScrollInit() { 239 var $shadowLeft = $newsblock.find(".swipe-shadow-left"); 240 var $shadowRight = $newsblock.find(".swipe-shadow-right"); 241 if ($list.css("overflow-x") == "auto") { 242 var scroll_width = $list.get(0).scrollWidth; 243 var view_width = $list.width(); 244 $shadowLeft.css("pointer-events","none"); 245 $shadowRight.css("pointer-events","none"); 246 247 $list.off('scroll'); 248 $list.on('scroll', throttle(swipeScrollCheack, 200)); 249 250 swipeScrollCheack(); 251 252 function swipeScrollCheack() { 253 var scroll_left = $list.scrollLeft(); 254 255 if (scroll_left > 0) { 256 $shadowLeft.show(); 257 } else { 258 $shadowLeft.hide(); 259 } 260 261 if (scroll_left + view_width >= scroll_width - 1) { 262 $shadowRight.hide(); 263 } else { 264 $shadowRight.show(); 265 } 266 } 267 } else { 268 $shadowLeft.hide(); 269 $shadowRight.hide(); 270 } 271 } 272 273 }); 274}); 275$(function () { 276 $(document).click(function (event) { 277 $('.contacts-block').each(function() { 278 if ($(event.target).closest($(this)).length) { 279 return; 280 } else { 281 $(this).find('.tgl-but').prop("checked", false); 282 $(this).find('.icon').removeClass('active'); 283 } 284 }); 285 }); 286 287 function setMargin($block) { 288 if ($(window).width() > 960) { 289 $block.find(".block-body-drop").css({ 290 "margin-left": "0px" 291 }); 292 } else { 293 var left = $block.offset().left * -1; 294 $block.find(".block-body-drop").css({ 295 "margin-left": left + "px" 296 }); 297 } 298 } 299 300 $('.contacts-block').each(function() { 301 var $block = $(this), 302 allClasses = $block.attr("class").split(" "), 303 mainClass = allClasses[0], 304 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 305 styles = document.styleSheets; 306 307 for(var i = 0; i < styles.length; i++) { 308 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 309 for(var j = 0; j < styles[i].cssRules.length; j++) { 310 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 311 $block.data("fullwidth", 1); 312 setMargin($block); 313 break; 314 } 315 } 316 break; 317 } 318 } 319 }); 320 321 $(window).resize(function() { 322 $('.contacts-block').each(function() { 323 var $block = $(this); 324 if ($block.data("fullwidth") == 1) { 325 setMargin($block); 326 } 327 }); 328 }); 329 330 $('.contacts-block').each(function() { 331 var $block = $(this); 332 $block.find('.icon').click(function() { 333 if ($block.data("fullwidth") == 1) { 334 setMargin($block); 335 } 336 if ($block.find('.tgl-but').prop("checked")) { 337 $(this).removeClass('active'); 338 } else { 339 $(this).addClass('active'); 340 } 341 }); 342 }); 343}); 344$(function () { 345 $(document).click(function (event) { 346 $('.contacts-block').each(function() { 347 if ($(event.target).closest($(this)).length) { 348 return; 349 } else { 350 $(this).find('.tgl-but').prop("checked", false); 351 $(this).find('.icon').removeClass('active'); 352 } 353 }); 354 }); 355 356 function setMargin($block) { 357 if ($(window).width() > 960) { 358 $block.find(".block-body-drop").css({ 359 "margin-left": "0px" 360 }); 361 } else { 362 var left = $block.offset().left * -1; 363 $block.find(".block-body-drop").css({ 364 "margin-left": left + "px" 365 }); 366 } 367 } 368 369 $('.contacts-block').each(function() { 370 var $block = $(this), 371 allClasses = $block.attr("class").split(" "), 372 mainClass = allClasses[0], 373 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 374 styles = document.styleSheets; 375 376 for(var i = 0; i < styles.length; i++) { 377 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 378 for(var j = 0; j < styles[i].cssRules.length; j++) { 379 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 380 $block.data("fullwidth", 1); 381 setMargin($block); 382 break; 383 } 384 } 385 break; 386 } 387 } 388 }); 389 390 $(window).resize(function() { 391 $('.contacts-block').each(function() { 392 var $block = $(this); 393 if ($block.data("fullwidth") == 1) { 394 setMargin($block); 395 } 396 }); 397 }); 398 399 $('.contacts-block').each(function() { 400 var $block = $(this); 401 $block.find('.icon').click(function() { 402 if ($block.data("fullwidth") == 1) { 403 setMargin($block); 404 } 405 if ($block.find('.tgl-but').prop("checked")) { 406 $(this).removeClass('active'); 407 } else { 408 $(this).addClass('active'); 409 } 410 }); 411 }); 412}); 413(function ($, undefined) { 414 415 var $win = $(window); 416 var $doc = $(document); 417 var $grid = $('<div class="grid"></div>'); 418 var $grid2 = $('<div class="grid-2"></div>'); 419 var media = { 420 over: 1024, 421 screen: 960, 422 tl: 768, 423 tp: 640, 424 ml: 480, 425 mp: 0 426 }; 427 428 var init = function (settings) { 429 var $self = $(this), $li; 430 var more_text = $self.data('more-text') || ''; 431 var more_button = $self.find('.more-button'); 432 var ul_mode = $self.find('.menu-scroll > ul'); 433 434 var activate_more_button = { 435 active: false, 436 from: 0, 437 to: 0 438 }; 439 440 if ($self.data('screen-button') == 'more') { 441 if (ul_mode.is('.sub_popup_horizontal') != true) { 442 activate_more_button.active = true; 443 if (media.over > activate_more_button.to) { 444 activate_more_button.to = media.over; 445 } 446 if (media.screen < activate_more_button.from || activate_more_button.from == 0) { 447 activate_more_button.from = media.screen; 448 } 449 } 450 } 451 452 if ($self.data('responsive-tl') == 'button') { 453 if (ul_mode.is('.sub_popup_horizontal') != true) { 454 activate_more_button.active = true; 455 if (media.screen > activate_more_button.to) { 456 activate_more_button.to = media.screen; 457 } 458 if (media.tl < activate_more_button.from || activate_more_button.from == 0) { 459 activate_more_button.from = media.tl; 460 } 461 } 462 } 463 464 if ($self.data('responsive-tp') == 'button') { 465 if (ul_mode.is('.sub_popup_horizontal') != true) { 466 activate_more_button.active = true; 467 if (media.tl > activate_more_button.to) { 468 activate_more_button.to = media.tl; 469 } 470 if (media.tp < activate_more_button.from || activate_more_button.from == 0) { 471 activate_more_button.from = media.tp; 472 } 473 } 474 475 } 476 477 if ($self.data('responsive-ml') == 'button') { 478 if (ul_mode.is('.sub_popup_horizontal') != true) { 479 activate_more_button.active = true; 480 if (media.tp > activate_more_button.to) { 481 activate_more_button.to = media.tp; 482 } 483 if (media.ml < activate_more_button.from || activate_more_button.from == 0) { 484 activate_more_button.from = media.ml; 485 } 486 } 487 } 488 489 var first_level_wrapper = $self.find('.menu-scroll>ul'); 490 491 settings = $.extend({ 492 itemElem: 'li', 493 subMenu: 'ul', 494 hasChildIcon: $self.attr('data-child-icons') 495 }, settings); 496 497 var first_level_items = first_level_wrapper.find('>.menu-item:visible, >.delimiter:visible'); 498 499 $grid.appendTo('body'); 500 $grid2.appendTo('body'); 501 502 if (!more_button.size()) { 503 more_button = $('<li class="more-button"><a><span>' + more_text + '</span></a></li>'); 504 $self.find('.menu-scroll>ul').append(more_button); 505 more_button.attr('data-position', 'bottom right'); 506 } 507 if (!more_button.find('>' + settings.subMenu).size()) { 508 more_button.append('<' + settings.subMenu +'>'); 509 } else { 510 more_button.find('>' + settings.subMenu).html(''); 511 } 512 var cloned = first_level_items.clone(true, true); 513 more_button.find('>' + settings.subMenu).append(cloned); 514 515 $li = $self.find(settings.itemElem + ":has('>" + settings.subMenu + "')").addClass('has_child'); 516 517 $li.add(cloned.filter('.has_child')).each(function () { 518 var $item = $(this), 519 $submenu = $item.children(settings.subMenu), 520 $a = $item.children('a'), 521 $parents = $item.parentsUntil($self.parent()).filter(settings.subMenu), 522 $parent = $parents.first(), 523 level = $parents.length, 524 position = $item.data('position') || (((level == 1 && $self.is('.vertical')) || level > 1) ? 'right top' : 'bottom left'), 525 type = $item.data('type') || 'vertical', 526 trigger = $item.data('trigger') || 'hover', 527 effect = $item.data('effect') || 'none', 528 timer_show, 529 submenu_left = $submenu.css('left'), 530 getParent = $item.closest('ul'), 531 timer_hide, 532 has_touch = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; 533 534 $a.on('click', function(e){ 535 var $this = $(this); 536 if(has_touch && !$submenu.is(':visible') && !$this.data('first_click') || ($this.parent().data('trigger') == 'click' && ($this.attr('href') == '#' || !$this.attr('href')))) { 537 $this.data('first_click', 'true'); 538 e.preventDefault(); 539 } 540 }); 541 542 var childIconLen = $a.find('.has-child-icon').length; 543 544 if (!childIconLen && settings.hasChildIcon == '1') { 545 var childIconTag = $('<em class="has-child-icon"></em>'); 546 $a.append(childIconTag); 547 } 548 549 if (trigger === 'hover') { 550 $item.on('mouseenter', onMouseEnter); 551 $item.on('mouseleave', onMouseLeave); 552 } else if (trigger === 'click') { 553 $submenu.click(function(e) { 554 e.stopPropagation(); 555 }); 556 $item.on('click', onMouseClick); 557 } 558 559 $item.on('hide', function () { 560 hideSub(true); 561 }); 562 563 function onMouseEnter() { 564 clearTimeout(timer_hide); 565 timer_show = setTimeout(function () { 566 showSub(); 567 }, 100); 568 } 569 570 function onMouseLeave() { 571 clearTimeout(timer_show); 572 timer_hide = setTimeout(function () { 573 hideSub(); 574 }, 300); 575 } 576 577 function onMouseClick(e) { 578 e.stopPropagation(); 579 if ($item.data('clicked')) { 580 hideSub(); 581 } else { 582 showSub(); 583 $item.data('clicked', true); 584 } 585 $doc.one('click', function () { 586 $item.triggerHandler('hide'); 587 }); 588 } 589 590 function showSub() { 591 var opts, maxHeight, visible; 592 var childIcon = $a.find('.has-child-icon'); 593 594 visible = $submenu.is(':visible'); 595 596 opts = getPosition(); 597 598 switch (submenu_left) { 599 case '50%': 600 $.extend(true, opts, {'right': 'auto', 'left': '50%', 'align': 'center'}); 601 break; 602 case '0px': 603 $.extend(true, opts, {'right': 'auto', 'left': '0px', 'align': 'left'}); 604 break; 605 case 'auto': 606 $.extend(true, opts, {'right': '0px', 'left': 'auto', 'align': 'right'}); 607 break; 608 } 609 610 if (!visible) { 611 $item.data('opts', opts); 612 613 if (opts.align === 'contain' && level > 1) { 614 if (!$parent.data('height')) { 615 $parent.data('height', $parent.height()); 616 } 617 maxHeight = Math.max($parent.height(), $submenu.height()); 618 $parent.height(maxHeight); 619 $submenu.height(maxHeight); 620 } 621 622 beforeShow(); 623 624 $a.addClass('hover'); 625 626 if (childIcon.length) { 627 childIcon.addClass('hover'); 628 } 629 } 630 631 switch (effect) { 632 case 'fade': 633 if (visible) { 634 $submenu.stop().animate({ 635 opacity: 1 636 }, 'fast'); 637 } else { 638 $submenu.css({ 639 display: 'block', 640 opacity: 0, 641 top: opts.top, 642 left: opts.left 643 }).animate({ 644 opacity: 1 645 }, 'fast'); 646 } 647 break; 648 case 'fade-motion': 649 if (visible) { 650 $submenu.stop().animate({ 651 opacity: 1 652 }, 'fast'); 653 } else { 654 $submenu.css({ 655 display: 'block', 656 opacity: 0, 657 top: opts.top + 10, 658 left: opts.left 659 }).animate({ 660 opacity: 1, 661 top: opts.top 662 }, 'fast'); 663 } 664 break; 665 default: 666 $submenu.css({ 667 top: opts.top, 668 left: opts.left 669 }).show(); 670 } 671 } 672 673 function hideSub(force) { 674 var childIcon = $a.find('.has-child-icon'); 675 676 if (!$submenu.is(':visible')) { 677 return; 678 } 679 680 $item.find('.has_child').each(function () { 681 $(this).triggerHandler('hide'); 682 }); 683 684 $a.removeClass('hover'); 685 686 if (childIcon.length) { 687 childIcon.removeClass('hover'); 688 } 689 690 if (force) { 691 $submenu.stop().hide(); 692 afterHide(); 693 return; 694 } 695 696 switch (effect) { 697 case 'fade': 698 case 'fade-motion': 699 $submenu.stop().animate({ 700 opacity: 0 701 }, {
702 duration: 'fast', 703 complete: function () { 704 $submenu.hide(); 705 afterHide(); 706 } 707 }); 708 break; 709 default: 710 $submenu.hide(); 711 afterHide(); 712 break; 713 } 714 } 715 716 function beforeShow() { 717 var opts = $item.data('opts'), 718 submenuRect, old_css, 719 leftEdge, rightEdge, submenuCenter, parentsLength; 720 721 //$item.siblings('.has_child').each(function () { 722 // $(this).triggerHandler('hide'); 723 //}); 724 725 old_css = { 726 'visibility': $submenu.css('visibility'), 727 'left': $submenu.css('left'), 728 'display': $submenu.css('display') 729 }; 730 731 $submenu.css({ 732 'visibility': 'hidden', 733 'left': opts.left, 734 'display': 'block' 735 }); 736 737 submenuRect = $submenu[0].getBoundingClientRect(); 738 739 $submenu.css({ 740 'visibility': '', 741 'left': '', 742 'display': old_css.display 743 }); 744 745 if ($self.hasClass('horizontal')) { 746 parentsLength = $parents.length - 1; 747 } else { 748 parentsLength = $parents.length; 749 } 750 751 $parents.slice(0, parentsLength).each(function () { 752 var submenuRect = this.getBoundingClientRect(); 753 if (typeof leftEdge === 'undefined' || submenuRect.left < leftEdge) { 754 leftEdge = submenuRect.left; 755 } 756 if (typeof rightEdge === 'undefined' || submenuRect.right > rightEdge) { 757 rightEdge = submenuRect.right; 758 } 759 }); 760 761 submenuCenter = submenuRect.left + submenuRect.width * .5; 762 763 if (leftEdge && rightEdge) { 764 $grid.css({ 765 left: leftEdge, 766 width: rightEdge - leftEdge 767 }); 768 $grid2.css({ 769 left: submenuRect.left, 770 width: submenuRect.width 771 }); 772 if (submenuCenter > leftEdge && submenuCenter < rightEdge) { 773 $parents.slice(1).addClass('blur'); 774 } 775 } 776 } 777 778 function afterHide() { 779 var opts = $item.data('opts'); 780 781 $parents.slice(0,2).removeClass('blur'); 782 783 if (trigger === 'click') $item.data('clicked', false); 784 if (opts.align === 'contain') { 785 $parent.height($parent.data('height')); 786 } 787 } 788 789 function getPosition() { 790 791 var itemRect = $item[0].getBoundingClientRect(), 792 itemPosition, 793 submenuWidth = $submenu.outerWidth(), 794 submenuHeight = $submenu.outerHeight(), 795 winWidth = $win.width(), 796 scrollLeft = $win.scrollLeft(), 797 top, left, side, align; 798 799 side = position.split(' ')[0]; // right, left, top, bottom 800 align = position.split(' ')[1]; // top, bottom, right, left, center, contain 801 802 if (typeof align === 'undefined') { 803 if (side === 'bottom' || side === 'top') { 804 align = 'left'; 805 } 806 if (side === 'right' || side === 'left') { 807 align = 'top'; 808 } 809 } 810 811 switch (side) { 812 case 'top': 813 top = -submenuHeight; 814 switch (align) { 815 case 'left': 816 left = 0; 817 break; 818 case 'center': 819 left = (itemRect.width - submenuWidth) * .5; 820 break; 821 case 'right': 822 left = itemRect.width - submenuWidth; 823 break; 824 } 825 break; 826 case 'bottom': 827 top = itemRect.height; 828 switch (align) { 829 case 'left': 830 left = 0; 831 break; 832 case 'center': 833 left = (itemRect.width - submenuWidth) * .5; 834 break; 835 case 'right': 836 left = itemRect.width - submenuWidth; 837 break; 838 } 839 break; 840 case 'right': 841 left = itemRect.width; 842 switch (align) { 843 case 'top': 844 top = 0; 845 break; 846 case 'center': 847 top = (itemRect.height - submenuHeight) * .5; 848 break; 849 case 'bottom': 850 top = itemRect.height - submenuHeight; 851 break; 852 case 'contain': 853 top = $parent.offset().top - $item.offset().top; 854 break; 855 } 856 break; 857 case 'left': 858 left = -submenuWidth; 859 switch (align) { 860 case 'top': 861 top = 0; 862 break; 863 case 'center': 864 top = (itemRect.height - submenuHeight) * .5; 865 break; 866 case 'bottom': 867 top = itemRect.height - submenuHeight; 868 break; 869 case 'contain': 870 top = $parent.offset().top - $item.offset().top; 871 } 872 break; 873 } 874 875 if ($item.css('position') === 'static' && getParent.is('.sub_popup_horizontal') != true ) { 876 itemPosition = $item.position(); 877 top += itemPosition.top; 878 left += itemPosition.left; 879 } else if (getParent.is('.sub_popup_horizontal') == true) { 880 itemPosition = $item.position(); 881 top += itemPosition.top; 882 left += 0; 883 } 884 885 // determine for submenu positioned out of viewport 886 if (side === 'right' && itemRect.right + submenuWidth > winWidth - scrollLeft && itemRect.left > submenuWidth) { 887 left = left - itemRect.width - submenuWidth; 888 } else if (side === 'left' && submenuWidth > itemRect.left && itemRect.right + submenuWidth < winWidth - scrollLeft) { 889 left = left + itemRect.width + submenuWidth; 890 } 891 892 return { 893 top: top, 894 left: left, 895 side: side,
896 align: align 897 } 898 } 899 }); 900 901 var clss = $self.get(0).classList[0]; 902 var checkPanel = function() { 903 return window.side_panel_controller && 904 typeof window.side_panel_controller.inPanel === 'function' && 905 window.side_panel_controller.inPanel(clss); 906 }; 907 $win.resize(function() { 908 var testA = !checkPanel() && activate_more_button.active; 909 var testB = window.innerWidth <= activate_more_button.to && window.innerWidth > activate_more_button.from; 910 var testC = window.innerWidth >= activate_more_button.from && $self.data('screen-button') == 'more'; 911 912 if (testA && (testB || testC) && !more_button.hasClass('removed')) { 913 var moreButItems = more_button.find('>' + settings.subMenu).children(); 914 moreButItems.show(); 915 first_level_items.css('display', ''); 916 917 more_button.removeClass('disabled').show(); 918 919 var top_el = first_level_items.filter(':visible:first'); 920 if (!top_el.length) { 921 return false; 922 } 923 var firstRect = top_el[0].getBoundingClientRect(); 924 var pos_left = more_button[0].getBoundingClientRect().left; 925 var oldRight = firstRect.right; 926 927 more_button.addClass('disabled').css('display', ''); 928 929 var toHideArr = []; 930 var hideFlag = false; 931 932 first_level_items.each(function(index){ 933 var itemRectRight = this.getBoundingClientRect().right; 934 if (itemRectRight >= pos_left || itemRectRight < oldRight) { 935 toHideArr.push(index); 936 hideFlag = true; 937 } 938 oldRight = itemRectRight; 939 }); 940 941 if (hideFlag) { 942 moreButItems.each(function(ind){ 943 if (ind < toHideArr[0]) { 944 $(this).hide(); 945 } else { 946 $(first_level_items[ind]).hide(); 947 } 948 }); 949 more_button.removeClass('disabled'); 950 } 951 } else { 952 if (!more_button.is('.disabled')) more_button.addClass('disabled'); 953 if (first_level_items.filter(':hidden').size()) first_level_items.show(); 954 } 955 }); 956 957 setTimeout(function() { 958 $win.trigger('resize'); 959 }, 300); 960 }; 961 962 $.fn.wmMenuH = function(settings) { 963 return this.each(function () { 964 init.call(this, settings) 965 }); 966 }; 967 968 $(function() { 969 $('.wm-widget-menu.horizontal').wmMenuH(); 970 }); 971})(jQuery); 972(function ($, undefined) { 973 974 var $win = $(window); 975 //var $doc = $(document); 976 977 var init = function (settings) { 978 var $self = $(this), $li; 979 980 settings = $.extend({ 981 itemElem: 'li', 982 subMenu: 'ul', 983 hasChildIcon: $self.attr('data-child-icons') 984 }, settings); 985 986 $li = $self.find(settings.itemElem + ":has('>" + settings.subMenu + "')").addClass('has_child'); 987 988 if ($self.is('.popup')) { 989 $self.find(settings.itemElem).on('mouseenter', function () { 990 $(this).siblings('.has_child').each(function () { 991 $(this).triggerHandler('hide'); 992 }); 993 }); 994 } 995 996 $li.each(function () { 997 var $item = $(this), 998 $submenu = $item.children(settings.subMenu), 999 $a = $item.children('a'), 1000 $parents = $item.parentsUntil($self.parent()).filter(settings.subMenu), 1001 $parent = $parents.first(), 1002 level = $parents.length, 1003 position = $item.data('position') || ((level == 1 && $self.is('.vertical')) || level > 1) ? 'right top' : 'bottom left', 1004 type = $item.data('type') || 'vertical', 1005 trigger = $item.data('trigger') || $self.is('.dropdown') ? 'click' : 'hover', 1006 effect = $item.data('effect') || 'none', 1007 timer_show, 1008 timer_hide, 1009 has_touch = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; 1010 1011 $a.on('click', function(e){ 1012 var $this = $(this); 1013 if(has_touch && !$submenu.is(':visible') && !$this.data('first_click')) { 1014 $this.data('first_click', 'true'); 1015 e.preventDefault(); 1016 } 1017 }); 1018 1019 var childIconLen = $a.find('.has-child-icon').length; 1020 1021 if (!childIconLen && settings.hasChildIcon == '1') { 1022 var childIconTag = $('<em class="has-child-icon"></em>'); 1023 $a.append(childIconTag); 1024 } 1025 1026 if (trigger === 'hover') { 1027 $item.on('mouseenter', onMouseEnter); 1028 $item.on('mouseleave', onMouseLeave); 1029 } else if (trigger === 'click') { 1030 $submenu.click(function(e) { 1031 e.stopPropagation(); 1032 }); 1033 $item.on('click', '>a', onMouseClick); 1034 } 1035 1036 $item.on('hide', function () { 1037 hideSub(true); 1038 }); 1039 1040 function onMouseEnter() { 1041 clearTimeout(timer_hide); 1042 timer_show = setTimeout(function () { 1043 showSub(); 1044 }, 100); 1045 } 1046 1047 function onMouseLeave() { 1048 clearTimeout(timer_show); 1049 timer_hide = setTimeout(function () { 1050 hideSub(); 1051 }, 300); 1052 } 1053 1054 function onMouseClick(e) { 1055 e.stopPropagation(); 1056 if ($item.data('clicked')) { 1057 hideSub(); 1058 } else { 1059 showSub(); 1060 $item.data('clicked', true); 1061 } 1062 //$doc.one('click', function (e) { 1063 // $item.triggerHandler('hide'); 1064 //}); 1065 return false;
1066 } 1067 1068 function showSub() { 1069 var opts, maxHeight, visible; 1070 var childIcon = $a.find('.has-child-icon'); 1071 1072 visible = $submenu.is(':visible'); 1073 1074 if (!visible) { 1075 opts = getPosition(); 1076 $item.data('opts', opts); 1077 1078 if (opts.align === 'contain' && level > 1) { 1079 if (!$parent.data('height')) { 1080 $parent.data('height', $parent.height()); 1081 } 1082 maxHeight = Math.max($parent.height(), $submenu.height()); 1083 $parent.height(maxHeight); 1084 $submenu.height(maxHeight); 1085 } 1086 1087 beforeShow(); 1088 1089 $a.addClass('hover'); 1090 1091 if (childIcon.length) { 1092 childIcon.addClass('hover'); 1093 } 1094 } 1095 1096 if (opts) { 1097 switch (effect) { 1098 case 'fade': 1099 if (visible) { 1100 $submenu.stop().animate({ 1101 opacity: 1 1102 }, 'fast'); 1103 } else { 1104 $submenu.css({ 1105 display: 'block', 1106 opacity: 0, 1107 top: opts.top, 1108 left: opts.left 1109 }).animate({ 1110 opacity: 1 1111 }, 'fast'); 1112 } 1113 break; 1114 case 'fade-motion': 1115 if (visible) { 1116 $submenu.stop().animate({ 1117 opacity: 1 1118 }, 'fast'); 1119 } else { 1120 $submenu.css({ 1121 display: 'block', 1122 opacity: 0, 1123 top: opts.top + 10, 1124 left: opts.left 1125 }).animate({ 1126 opacity: 1, 1127 top: opts.top 1128 }, 'fast'); 1129 } 1130 break; 1131 default: 1132 $submenu.css({ 1133 top: opts.top, 1134 left: opts.left 1135 }).show(); 1136 } 1137 } 1138 } 1139 1140 function hideSub(force) { 1141 var childIcon = $a.find('.has-child-icon'); 1142 1143 if (!$submenu.is(':visible')) { 1144 return; 1145 } 1146 1147 $item.find('.has_child').each(function () { 1148 $(this).triggerHandler('hide'); 1149 }); 1150 1151 $a.removeClass('hover'); 1152 1153 if (childIcon.length) { 1154 childIcon.removeClass('hover'); 1155 } 1156 1157 if (force) { 1158 $submenu.stop().hide(); 1159 afterHide(); 1160 return; 1161 } 1162 1163 switch (effect) { 1164 case 'fade': 1165 case 'fade-motion': 1166 $submenu.stop().animate({ 1167 opacity: 0 1168 }, { 1169 duration: 'fast', 1170 complete: function () { 1171 $submenu.hide(); 1172 afterHide(); 1173 } 1174 }); 1175 break; 1176 default: 1177 $submenu.hide(); 1178 afterHide(); 1179 break; 1180 } 1181 } 1182 1183 function beforeShow() { 1184 var opts = $item.data('opts'), 1185 submenuRect, old_css, 1186 leftEdge, rightEdge, submenuCenter, parentsLength; 1187 1188 //$item.siblings('.has_child').each(function () { 1189 // $(this).triggerHandler('hide'); 1190 //}); 1191 1192 old_css = { 1193 'visibility': $submenu.css('visibility'), 1194 'left': $submenu.css('left'), 1195 'display': $submenu.css('display') 1196 }; 1197 1198 $submenu.css({ 1199 'visibility': 'hidden', 1200 'left': opts.left, 1201 'display': 'block' 1202 }); 1203 1204 submenuRect = $submenu[0].getBoundingClientRect(); 1205 1206 $submenu.css({ 1207 'visibility': '', 1208 'left': '', 1209 'display': old_css.display 1210 }); 1211 1212 if ($self.hasClass('horizontal')) { 1213 parentsLength = $parents.length - 1; 1214 } else { 1215 parentsLength = $parents.length; 1216 } 1217 1218 $parents.slice(0, parentsLength).each(function () { 1219 var submenuRect = this.getBoundingClientRect(); 1220 if (typeof leftEdge === 'undefined' || submenuRect.left < leftEdge) { 1221 leftEdge = submenuRect.left; 1222 } 1223 if (typeof rightEdge === 'undefined' || submenuRect.right > rightEdge) { 1224 rightEdge = submenuRect.right; 1225 } 1226 }); 1227 1228 submenuCenter = submenuRect.left + submenuRect.width * .5; 1229 1230 if (leftEdge && rightEdge) { 1231 if (submenuCenter > leftEdge && submenuCenter < rightEdge) { 1232 $parents.slice(1).addClass('blur'); 1233 } 1234 } 1235 } 1236 1237 function afterHide() { 1238 var opts = $item.data('opts'); 1239 1240 $parents.slice(0,2).removeClass('blur'); 1241 1242 if (trigger === 'click') $item.data('clicked', false); 1243 if (opts.align === 'contain') { 1244 $parent.height($parent.data('height')); 1245 } 1246 } 1247 1248 function getPosition() { 1249 1250 var itemRect = $item[0].getBoundingClientRect(), 1251 itemPosition, 1252 submenuWidth = $submenu.outerWidth(), 1253 submenuHeight = $submenu.outerHeight(), 1254 winWidth = $win.width(), 1255 scrollLeft = $win.scrollLeft(), 1256 top, left, side, align; 1257 1258 side = position.split(' ')[0]; // right, left, top, bottom 1259 align = position.split(' ')[1]; // top, bottom, right, left, center, contain 1260 1261 if (typeof align === 'undefined') { 1262 if (side === 'bottom' || side === 'top') { 1263 align = 'left'; 1264 } 1265 if (side === 'right' || side === 'left') { 1266 align = 'top'; 1267 } 1268 } 1269 1270 switch (side) { 1271 case 'top': 1272 top = -submenuHeight; 1273 switch (align) { 1274 case 'left': 1275 left = 0; 1276 break; 1277 case 'center': 1278 left = (itemRect.width - submenuWidth) * .5; 1279 break; 1280 case 'right': 1281 left = itemRect.width - submenuWidth; 1282 break; 1283 } 1284 break; 1285 case 'bottom': 1286 top = itemRect.height; 1287 switch (align) { 1288 case 'left': 1289 left = 0; 1290 break; 1291 case 'center': 1292 left = (itemRect.width - submenuWidth) * .5; 1293 break; 1294 case 'right': 1295 left = itemRect.width - submenuWidth; 1296 break; 1297 } 1298 break; 1299 case 'right': 1300 left = itemRect.width; 1301 switch (align) { 1302 case 'top': 1303 top = 0; 1304 break; 1305 case 'center': 1306 top = (itemRect.height - submenuHeight) * .5; 1307 break; 1308 case 'bottom': 1309 top = itemRect.height - submenuHeight; 1310 break; 1311 case 'contain': 1312 top = $parent.offset().top - $item.offset().top; 1313 break; 1314 } 1315 break; 1316 case 'left': 1317 left = -submenuWidth; 1318 switch (align) { 1319 case 'top': 1320 top = 0; 1321 break; 1322 case 'center': 1323 top = (itemRect.height - submenuHeight) * .5; 1324 break; 1325 case 'bottom': 1326 top = itemRect.height - submenuHeight; 1327 break; 1328 case 'contain': 1329 top = $parent.offset().top - $item.offset().top; 1330 } 1331 break; 1332 } 1333 1334 if ($item.css('position') === 'static') { 1335 itemPosition = $item.position(); 1336 top += itemPosition.top; 1337 left += itemPosition.left; 1338 } 1339 1340 // determine for submenu positioned out of viewport 1341 if (side === 'right' && itemRect.right + submenuWidth > winWidth - scrollLeft && itemRect.left > submenuWidth) { 1342 left = left - itemRect.width - submenuWidth; 1343 } else if (side === 'left' && submenuWidth > itemRect.left && itemRect.right + submenuWidth < winWidth - scrollLeft) { 1344 left = left + itemRect.width + submenuWidth; 1345 } 1346 1347 return { 1348 top: top, 1349 left: left, 1350 side: side,
1351 align: align 1352 } 1353 } 1354 }); 1355 }; 1356 1357 $.fn.wmMenuV = function(settings) { 1358 return this.each(function () { 1359 init.call(this, settings) 1360 }); 1361 }; 1362 1363 $(function() { 1364 $('.wm-widget-menu.vertical').wmMenuV(); 1365 }) 1366 1367 1368})(jQuery); 1369$(function () { 1370 1371 $('.accordion-wr').each(function () { 1372 $(this).wm_accordion({ 1373 closeOther: parseInt($(this).data('setting-close')), 1374 speed: parseInt($(this).data('setting-speed')) 1375 }); 1376 }); 1377 1378}); 1379(function ($) { 1380 jQuery.fn.wm_accordion = function (options) { 1381 1382 options = $.extend({ 1383 closeOther: false, 1384 speed: 300 1385 }, options); 1386 1387 var make = function () { 1388 var $ul = $(this); 1389 $ul.find('.accordion-item-title').each(function () { 1390 var $clicked_but; 1391 if ($(this).find('a').length) { 1392 $clicked_but = $(this).find('.icon'); 1393 } else { 1394 $clicked_but = $(this); 1395 } 1396 1397 $clicked_but.click(function () { 1398 var $clicked_li = $(this).closest('.accordion-item'); 1399 var $acTitle = $(this).closest('.accordion-item-title'); 1400 var $acBody = $acTitle.next(); 1401 1402 if (options.closeOther) { 1403 $ul.find('li.opened').not($clicked_li).each(function () { 1404 $(this).find('.icon').removeClass('active'); 1405 $(this).removeClass('opened'); 1406 $(this).find('.accordion-item-drop').slideUp(options.speed); 1407 }); 1408 } 1409 1410 if (!$acBody.is(':animated')) { 1411 $acTitle.find('.icon').toggleClass('active'); 1412 $clicked_li.toggleClass('opened'); 1413 $acBody.slideToggle(options.speed); 1414 } 1415 }); 1416 }); 1417 }; 1418 1419 return this.each(make); 1420 }; 1421})(jQuery); 1422/*! 1423 * jQuery nTabs v1.0.0 1424 * Copyright 2016 Nikita ([email protected]) 1425 * Licensed under the MIT license (http://opensource.org/licenses/MIT) 1426 */ 1427(function(d){"function"===typeof define&&define.amd?define(["jquery"],d):"object"===typeof module&&module.exports?module.exports=function(l,f){void 0===f&&(f="undefined"!==typeof window?require("jquery"):require("jquery")(l));d(f,window,document);return f}:d(jQuery,window,document)})(function(d,l,f,g){function k(a,c){this.element=a;this.options=d.extend({},m,c);this.init()}var m={panelSelector:".panel-item",areaSelector:".area-item",panelActiveClass:"active",areaActiveClass:"active",defaultOpenArea:0, event:"click",effect:"toggle",easing:"swing",duration:400,onBeforeInit:function(){return!0},onAfterInit:function(){return!0},onBeforeOpen:function(){return!0},onAfterOpen:function(){return!0},onBeforeClose:function(){return!0},onAfterClose:function(){return!0}},n={open:{toggle:"show",fade:"fadeIn",slide:"slideDown"},close:{toggle:"hide",fade:"fadeOut",slide:"slideUp"}};k.prototype={_count:0,_effect:function(a){return n[a][this.options.effect]},_openArea:function(a,c,e){var b=this;b.options.onBeforeOpen.call(b, a,c);b.$openItem=c;b.$openArea=a;c.addClass(b.options.panelActiveClass);a[b._effect("open")](b.options.duration,b.options.easing,function(){a.addClass(b.options.areaActiveClass);d.isFunction(e)&&e();b.options.onAfterOpen.call(b,a,c)})},_closeArea:function(a,c,e){var b=this;b.options.onBeforeClose.call(b,a,c);c.removeClass(b.options.panelActiveClass);a[b._effect("close")](b.options.duration,b.options.easing,function(){a.removeClass(b.options.areaActiveClass);d.isFunction(e)&&e();b.options.onAfterClose.call(b,a,c)})},goToArea:function(a){var c=this,e=d(c.element).find(c.options.panelSelector),b=g,h=g;isNaN(a)?(b=d(a),h=e.has('a[href="'+a+'"]')):(b=d(c.element).find(c.options.areaSelector).eq(a),h=e.eq(a));c.$openArea?b.hasClass(c.options.areaActiveClass)||(d(c.$openArea).stop(),e.removeClass(c.options.panelActiveClass),h.addClass(c.options.panelActiveClass),c._closeArea(c.$openArea,c.$openItem,function(){c._openArea(b,h)})):c._openArea(b,h)},rewriteOption:function(a,c){this.options[a]=c},init:function(){var a=this,c={},e=d(a.element),b=e.attr("id"),h=e.find(a.options.panelSelector+"."+a.options.panelActiveClass).first().index();a.options.onBeforeInit.call(a);a.count=++k.prototype._count;b||(b="nTabs_"+a.count,e.attr("id",b));for(var g in m)m.hasOwnProperty(g)&&(b=e.data("nTabs-"+g))&&(c[g]=b);a.options=d.extend({},a.options,c);"toggle"==a.options.effect&&(a.options.duration=0);d(f).on(a.options.event,"#"+e.attr("id")+" "+a.options.panelSelector,function(b){var c=d(this),g=d(l),h=e.find(a.options.areaSelector).parent().offset().top,f=c.find("a:first").attr("href"),f=f&&f.indexOf("#")&&1<f.length?f:c.index();0<h-g.height()-g.scrollTop()&&d("html, body").animate({scrollTop:h},500);a.goToArea(f);b.preventDefault()});!1!==a.options.defaultOpenArea&&a.goToArea(-1<h?h:a.options.defaultOpenArea);a.options.onAfterInit.call(a)},destroy:function(){}};d.fn.nTabs=function(a){var c=arguments;if(a===g||"object"===typeof a)return this.each(function(){d.data(this,"nTabs")||d.data(this,"nTabs",new k(this,a))});if("string"===typeof a&&"_"!==a[0]&&"init"!==a){var e;this.each(function(){var b=d.data(this,"nTabs");
1427b instanceof k&&"function"===typeof b[a]&&(e=b[a].apply(b,Array.prototype.slice.call(c,1)));"destroy"===a&&d.data(this,"nTabs",null)});return e!==g?e:this}};d(function(){d(".nTabs").nTabs()})}); 1428$(function() { 1429 if (window.ymaps) { 1430 ymaps.ready(function () { 1431 $('.widget-type-map[data-center]').each(function () { 1432 var self = $(this); 1433 var id = self.attr('id'); 1434 var data = false; 1435 if (self.find('[type=hidden]').val()) { 1436 data = typeof JSON.parse == 'function' ? JSON.parse(self.find('[type=hidden]').val()) : eval(self.find('[type=hidden]').val()); 1437 } 1438 var params = { 1439 type: self.data('type') || 'yandex#map', 1440 center: self.data('center').split(',').map(function (e) { 1441 return $.trim(e) 1442 }), 1443 zoom: self.data('zoom') || 9, 1444 controls: self.data('controls') ? self.data('controls').split(',').map(function (e) { 1445 return $.trim(e) 1446 }) : [] 1447 }; 1448 var myMap = new ymaps.Map(id, params); 1449 myMap.behaviors.disable('scrollZoom'); 1450 if (data) { 1451 for (var i in data) { 1452 var myPlacemark = new ymaps.Placemark(data[i].point.split(',').map(function (e) { 1453 return $.trim(e); 1454 }), { 1455 iconContent: $('<div>').html(data[i].iconContent).text(), 1456 balloonContent: $('<div>').html(data[i].balloonContent).html() 1457 }, { 1458 preset: data[i].preset 1459 }); 1460 myMap.geoObjects.add(myPlacemark); 1461 } 1462 } 1463 }); 1464 }); 1465 } 1466}); 1467/* 1468 * @license 1469 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 1470 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 1471 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 1472 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 1473 * Code distributed by Google as part of the polymer project is also 1474 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 1475 */ 1476 1477"use strict"; 1478 1479(function (exports) { 1480 1481 function sign(number) { 1482 if (number < 0) 1483 return -1; 1484 if (number > 0) 1485 return 1; 1486 return 0; 1487 } 1488 1489 function Animator(delegate) { 1490 this.delegate = delegate; 1491 this.startTimeStamp = 0; 1492 this.request_ = null; 1493 }; 1494 1495 Animator.prototype.scheduleAnimation = function () { 1496 if (this.request_) 1497 return; 1498 this.request_ = requestAnimationFrame(this.onAnimation_.bind(this)); 1499 }; 1500 1501 Animator.prototype.startAnimation = function () { 1502 this.startTimeStamp = 0; 1503 this.scheduleAnimation(); 1504 }; 1505 1506 Animator.prototype.stopAnimation = function () { 1507 cancelAnimationFrame(this.request_); 1508 this.startTimeStamp = 0; 1509 this.request_ = null; 1510 }; 1511 1512 Animator.prototype.onAnimation_ = function (timeStamp) { 1513 this.request_ = null; 1514 if (!this.startTimeStamp) 1515 this.startTimeStamp = timeStamp; 1516 if (this.delegate.onAnimation(timeStamp)) 1517 this.scheduleAnimation(); 1518 }; 1519 1520 function VelocityTracker() { 1521 this.recentTouchMoves_ = []; 1522 this.velocityX = 0; 1523 this.velocityY = 0; 1524 } 1525 1526 VelocityTracker.kTimeWindow = 50; 1527 1528 VelocityTracker.prototype.pruneHistory_ = function (timeStamp) { 1529 for (var i = 0; i < this.recentTouchMoves_.length; ++i) { 1530 if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) { 1531 this.recentTouchMoves_ = this.recentTouchMoves_.slice(i); 1532 return; 1533 } 1534 } 1535 // All touchmoves are old. 1536 this.recentTouchMoves_ = []; 1537 }; 1538 1539 VelocityTracker.prototype.update_ = function (e) { 1540 this.pruneHistory_(e.timeStamp); 1541 this.recentTouchMoves_.push(e); 1542 1543 var oldestTouchMove = this.recentTouchMoves_[0]; 1544 1545 var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX; 1546 var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY; 1547 var deltaT = e.timeStamp - oldestTouchMove.timeStamp; 1548 1549 if (deltaT > 0) { 1550 this.velocityX = deltaX / deltaT; 1551 this.velocityY = deltaY / deltaT; 1552 } else { 1553 this.velocityX = 0; 1554 this.velocityY = 0; 1555 } 1556 }; 1557 1558 VelocityTracker.prototype.onTouchStart = function (e) { 1559 this.recentTouchMoves_.push(e); 1560 this.velocityX = 0; 1561 this.velocityY = 0; 1562 }; 1563 1564 VelocityTracker.prototype.onTouchMove = function (e) { 1565 this.update_(e); 1566 }; 1567 1568 VelocityTracker.prototype.onTouchEnd = function (e) { 1569 this.update_(e); 1570 this.recentTouchMoves_ = []; 1571 }; 1572 1573 function LinearTimingFunction() { 1574 }; 1575 1576 LinearTimingFunction.prototype.scaleTime = function (fraction) { 1577 return fraction; 1578 }; 1579 1580 function CubicBezierTimingFunction(spec) { 1581 this.map = []; 1582 for (var ii = 0; ii <= 100; ii += 1) { 1583 var i = ii / 100; 1584 this.map.push([ 1585 3 * i * (1 - i) * (1 - i) * spec[0] + 1586 3 * i * i * (1 - i) * spec[2] + i * i * i, 1587 3 * i * (1 - i) * (1 - i) * spec[1] + 1588 3 * i * i * (1 - i) * spec[3] + i * i * i 1589 ]); 1590 } 1591 }; 1592 1593 CubicBezierTimingFunction.prototype.scaleTime = function (fraction) { 1594 var fst = 0; 1595 while (fst !== 100 && fraction > this.map[fst][0]) { 1596 fst += 1; 1597 } 1598 if (fraction === this.map[fst][0] || fst === 0) { 1599 return this.map[fst][1]; 1600 } 1601 var yDiff = this.map[fst][1] - this.map[fst - 1][1]; 1602 var xDiff = this.map[fst][0] - this.map[fst - 1][0]; 1603 var p = (fraction - this.map[fst - 1][0]) / xDiff; 1604 return this.map[fst - 1][1] + p * yDiff; 1605 }; 1606 1607 var presetTimingFunctions = { 1608 'linear': new LinearTimingFunction(), 1609 'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]), 1610 'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]), 1611 'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]), 1612 'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]), 1613 }; 1614 1615 function DrawerController(options) { 1616 this.velocityTracker = new VelocityTracker(); 1617 this.animator = new Animator(this); 1618 1619 this.target = options.target; 1620 this.left = options.left; 1621 this.right = options.right; 1622 this.position = options.position; 1623 1624 this.width = this.right - this.left; 1625 this.curve = presetTimingFunctions[options.curve || 'linear']; 1626 1627 this.willOpenCallback = options.willOpen; 1628 this.didCloseCallback = options.didClose; 1629 this.animateCallback = options.onAnimate; 1630 1631 this.state = DrawerController.kClosed; 1632 1633 this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS; 1634 1635 this.onTouchMove = this.onTouchMove.bind(this); 1636 this.onTouchEnd = this.onTouchEnd.bind(this); 1637 1638 this.target.addEventListener('touchstart', this.onTouchStart.bind(this)); 1639 } 1640 1641 DrawerController.kOpened = 'opened'; 1642 DrawerController.kClosed = 'closed'; 1643 DrawerController.kOpening = 'opening'; 1644 DrawerController.kClosing = 'closing'; 1645 DrawerController.kDragging = 'dragging'; 1646 DrawerController.kFlinging = 'flinging'; 1647 1648 DrawerController.kBaseSettleDurationMS = 246; 1649 DrawerController.kMaxSettleDurationMS = 600; 1650 1651 DrawerController.kMinFlingVelocity = 0.4; // Matches Android framework. 1652 DrawerController.kTouchSlop = 5; // Matches Android framework. 1653 DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop; 1654 1655 DrawerController.prototype.restrictToCurrent = function (offset) { 1656 return Math.max(this.left, Math.min(this.position, offset)); 1657 }; 1658 1659 DrawerController.prototype.restrictToBounds = function (offset) { 1660 return Math.max(this.left, Math.min(this.right, offset)); 1661 }; 1662 1663 DrawerController.prototype.onTouchStart = function (e) { 1664 this.velocityTracker.onTouchStart(e); 1665 1666 var touchX = e.changedTouches[0].clientX; 1667 var touchY = e.changedTouches[0].clientY; 1668 1669 if (this.state != DrawerController.kOpened) { 1670 if (touchX != this.restrictToCurrent(touchX)) 1671 return; 1672 this.state = DrawerController.kDragging; 1673 } 1674 1675 this.animator.stopAnimation(); 1676 this.target.addEventListener('touchmove', this.onTouchMove); 1677 this.target.addEventListener('touchend', this.onTouchEnd); 1678 // TODO(abarth): Handle touchcancel. 1679 1680 this.startX = touchX; 1681 this.startY = touchY; 1682 this.startPosition = this.position; 1683 this.touchBaseX = Math.min(touchX, this.startPosition); 1684 }; 1685 1686 DrawerController.prototype.onTouchMove = function (e) { 1687 this.velocityTracker.onTouchMove(e); 1688 1689 if (this.state == DrawerController.kOpened) { 1690 var deltaX = e.changedTouches[0].clientX - this.startX; 1691 var deltaY = e.changedTouches[0].clientY - this.startY; 1692 1693 if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) { 1694 e.preventDefault(); 1695 return; 1696 } 1697 1698 if (Math.abs(deltaY) > Math.abs(deltaX)) { 1699 this.target.removeEventListener('touchmove', this.onTouchMove); 1700 this.target.removeEventListener('touchend', this.onTouchEnd); 1701 return; 1702 } 1703 1704 this.state = DrawerController.kDragging; 1705 } 1706 1707 e.preventDefault(); 1708 var touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX; 1709 this.position = this.restrictToBounds(this.startPosition + touchDeltaX); 1710 this.animator.scheduleAnimation(); 1711 }; 1712 1713 DrawerController.prototype.onTouchEnd = function (e) { 1714 this.velocityTracker.onTouchEnd(e); 1715 this.target.removeEventListener('touchmove', this.onTouchMove); 1716 this.target.removeEventListener('touchend', this.onTouchEnd); 1717 1718 var velocityX = this.velocityTracker.velocityX; 1719 if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) { 1720 this.fling(velocityX); 1721 } else if (this.isOpen()) { 1722 this.open(); 1723 } else { 1724 this.close(); 1725 } 1726 }; 1727 1728 DrawerController.prototype.openFraction = function () { 1729 var width = this.right - this.left; 1730 var offset = this.position - this.left; 1731 return offset / width; 1732 }; 1733 1734 DrawerController.prototype.isOpen = function () { 1735 return this.openFraction() >= 0.5; 1736 }; 1737 1738 DrawerController.prototype.isOpening = function () { 1739 return this.state == DrawerController.kOpening || 1740 (this.state == DrawerController.kFlinging && this.animationVelocityX > 0); 1741 } 1742 1743 DrawerController.prototype.isClosing = function () { 1744 return this.state == DrawerController.kClosing || 1745 (this.state == DrawerController.kFlinging && this.animationVelocityX < 0); 1746 } 1747 1748 DrawerController.prototype.toggle = function () { 1749 if (this.isOpen()) 1750 this.close(); 1751 else 1752 this.open(); 1753 }; 1754 1755 DrawerController.prototype.open = function () { 1756 if (!this.position) 1757 this.willOpenCallback.call(this.target); 1758 1759 this.animator.stopAnimation(); 1760 this.animationDuration = 400; 1761 this.state = DrawerController.kOpening; 1762 this.animate(); 1763 }; 1764 1765 DrawerController.prototype.close = function () { 1766 this.animator.stopAnimation(); 1767 this.animationDuration = 400; 1768 this.state = DrawerController.kClosing; 1769 this.animate(); 1770 }; 1771 1772 DrawerController.prototype.fling = function (velocityX) { 1773 this.animator.stopAnimation(); 1774 this.animationVelocityX = velocityX; 1775 this.state = DrawerController.kFlinging; 1776 this.animate(); 1777 }; 1778 1779 DrawerController.prototype.animate = function () { 1780 this.positionAnimationBase = this.position; 1781 this.animator.startAnimation(); 1782 }; 1783 1784 DrawerController.prototype.targetPosition = function (deltaT) { 1785 if (this.state == DrawerController.kFlinging) 1786 return this.positionAnimationBase + this.animationVelocityX * deltaT; 1787 var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration); 1788 var animationWidth = this.state == DrawerController.kOpening ? 1789 this.width - this.positionAnimationBase : -this.positionAnimationBase; 1790 return this.positionAnimationBase + targetFraction * animationWidth; 1791 }; 1792 1793 DrawerController.prototype.onAnimation = function (timeStamp) { 1794 if (this.state == DrawerController.kDragging) { 1795 this.animateCallback.call(this.target, this.position); 1796 return false;
1797 } 1798 1799 var deltaT = timeStamp - this.animator.startTimeStamp; 1800 var targetPosition = this.targetPosition(deltaT); 1801 this.position = this.restrictToBounds(targetPosition); 1802 1803 this.animateCallback.call(this.target, this.position); 1804 1805 if (targetPosition <= this.left && this.isClosing()) { 1806 this.state = DrawerController.kClosed; 1807 this.didCloseCallback.call(this.target); 1808 return false; 1809 } 1810 if (targetPosition >= this.right && this.isOpening()) { 1811 this.state = DrawerController.kOpened; 1812 return false; 1813 } 1814 1815 return true; 1816 }; 1817 1818 1819 exports.DrawerController = DrawerController; 1820 1821})(window); 1822 1823document.addEventListener('DOMContentLoaded', function() { 1824 var bodyScrollBarWidth = (function () { 1825 var widthHidden, widthScroll, currentValue, currentPriority; 1826 currentValue = document.body.style.getPropertyValue('overflow'); 1827 currentPriority = document.body.style.getPropertyPriority('overflow'); 1828 document.body.style.setProperty('overflow', 'hidden', 'important'); 1829 widthHidden = document.body.clientWidth; 1830 document.body.style.setProperty('overflow', 'scroll', 'important'); 1831 widthScroll = document.body.clientWidth; 1832 document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority); 1833 return widthHidden - widthScroll; 1834 }()); 1835 var media = { 1836 'tablet-landscape': 960, 1837 'tablet-portrait': 768, 1838 'mobile-landscape': 640, 1839 'mobile-portrait': 480 1840 }; 1841 var side_panel = document.querySelector('.side-panel'); 1842 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; 1843 var layers, elements = {}, comments = {}; 1844 1845 if (!side_panel || side_panel.classList.contains('removed')) { 1846 return; 1847 } 1848 1849 try { 1850 layers = JSON.parse(side_panel.getAttribute('data-layers').replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"')); 1851 } catch(e) { 1852 console.error(e); 1853 } 1854 1855 if (typeof layers !== 'object' || Object.keys(layers).length === 0) { 1856 return; 1857 } 1858 1859 Object.keys(layers).forEach(function(clss) { 1860 elements[clss] = document.querySelector('.' + clss); 1861 comments[clss] = document.createComment(clss); 1862 if (elements[clss]) { 1863 elements[clss].parentNode.insertBefore(comments[clss], elements[clss]); 1864 } else { 1865 delete layers[clss]; 1866 } 1867 }); 1868 1869 side_panel_button = side_panel.querySelector('.side-panel-button'); 1870 side_panel_close = side_panel.querySelector('.side-panel-close'); 1871 side_panel_content = side_panel.querySelector('.side-panel-content'); 1872 side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content; 1873 side_panel_mask = side_panel.querySelector('.side-panel-mask'); 1874 side_panel_top = side_panel.querySelector('.side-panel-top-inner'); 1875 1876 side_panel.classList.remove('hidden'); 1877 side_panel_button.classList.remove('hidden'); 1878 side_panel_button.style.display = 'none'; 1879 side_panel_content.classList.remove('hidden'); 1880 side_panel_content.style.display = 'none'; 1881 side_panel_mask.classList.remove('hidden'); 1882 side_panel_mask.style.display = 'none'; 1883 1884 leftEdge = 0; 1885 rightEdge = parseInt(getComputedStyle(side_panel_content, null).width) + 50; 1886 1887 window.side_panel_controller = side_panel_controller = new DrawerController({ 1888 target: side_panel, 1889 left: leftEdge, 1890 right: rightEdge, 1891 position: 0, 1892 curve: 'ease-in-out', 1893 willOpen: function() { 1894 side_panel_mask.style.display = 'block'; 1895 side_panel_content.style.display = 'block'; 1896 document.body.classList.add('noscroll'); 1897 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 1898 document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent' 1899 } 1900 }, 1901 didClose: function() { 1902 side_panel_mask.style.display = 'none'; 1903 side_panel_content.style.display = 'none'; 1904 document.body.classList.remove('noscroll'); 1905 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 1906 document.body.style.borderRight = '' 1907 } 1908 }, 1909 onAnimate: function(position) { 1910 side_panel_mask.style.opacity = (position ) / rightEdge; 1911 side_panel_content.style.transform = 'translate3d(' + (position - rightEdge) + 'px,0,0)' 1912 } 1913 }); 1914 1915 side_panel_controller.inPanel = function(clss) { 1916 var viewportWidth; 1917 var current_media; 1918 1919 if (typeof clss !== 'string') { 1920 return false;
1921 } 1922 1923 if (clss.charAt(0) === '.') { 1924 clss = clss.slice(1); 1925 } 1926 1927 viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 1928 1929 Object.keys(media).forEach(function(key) { 1930 if (viewportWidth <= media[key]) { 1931 current_media = key; 1932 } 1933 }); 1934 1935 if (typeof current_media === 'undefined') { 1936 current_media = 'screen'; 1937 } 1938 1939 return layers[clss] && layers[clss][current_media]; 1940 }; 1941 1942 side_panel_button.addEventListener('click', function(e) { 1943 e.preventDefault(); 1944 side_panel_controller.toggle(); 1945 return false; 1946 }); 1947 1948 if (side_panel_close) { 1949 side_panel_close.addEventListener('click', function(e) { 1950 e.preventDefault(); 1951 side_panel_controller.close(); 1952 return false; 1953 }); 1954 } 1955 1956 side_panel_mask.addEventListener('click', function() { 1957 side_panel_controller.close(); 1958 return false; 1959 }); 1960 1961 1962 var debounce = (function () { 1963 return function (fn, time) { 1964 var timer, func; 1965 if (window.requestAnimationFrame) { 1966 func = function() { 1967 timer && cancelAnimationFrame(timer); 1968 timer = requestAnimationFrame(fn); 1969 } 1970 } else { 1971 func = function() { 1972 window.clearTimeout(timer); 1973 timer = window.setTimeout(function () { 1974 fn(); 1975 }, time) 1976 }; 1977 } 1978 return func; 1979 } 1980 }()); 1981 1982 function checkSidePanel() { 1983 var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 1984 var current_media; 1985 var emptySide = true; 1986 var emptyTop = true; 1987 1988 if (checkSidePanel.viewportWidth === viewportWidth) { 1989 return; 1990 } 1991 1992 checkSidePanel.viewportWidth = viewportWidth; 1993 1994 Object.keys(media).forEach(function(key) { 1995 if (viewportWidth <= media[key]) { 1996 current_media = key; 1997 } 1998 }); 1999 2000 if (typeof current_media === 'undefined') { 2001 current_media = 'screen'; 2002 } 2003 2004 Object.keys(layers).forEach(function(clss){ 2005 var element, comment; 2006 2007 element = elements[clss]; 2008 comment = comments[clss]; 2009 2010 if (current_media in layers[clss]) { 2011 if (layers[clss][current_media] == 'onTop') { 2012 side_panel_top.appendChild(element); 2013 emptyTop = false; 2014 } else { 2015 side_panel_content_inner.appendChild(element); 2016 emptySide = false;
2017 } 2018 } else { 2019 if (comment) { 2020 comment.parentNode.insertBefore(element, comment); 2021 } 2022 } 2023 }); 2024 2025 if (emptySide) { 2026 side_panel_button.style.display = 'none'; 2027 } else { 2028 side_panel_button.style.display = 'block'; 2029 } 2030 2031 if (!emptyTop || !emptySide) { 2032 side_panel.style.display = 'block'; 2033 } else { 2034 side_panel.style.display = 'none'; 2035 side_panel_controller.close(); 2036 } 2037 } 2038 2039 checkSidePanel = debounce(checkSidePanel, 40); 2040 2041 checkSidePanel(); 2042 window.addEventListener('resize', checkSidePanel); 2043});
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.