jQuery(document).ready(function($){
"use strict";
$(".zox-fly-but-click").on('click', function(){
$("#zox-fly-wrap").toggleClass("zox-fly-menu");
$("#zox-fly-wrap").toggleClass("zox-fly-shadow");
$(".zox-fly-but-wrap").toggleClass("zox-fly-open");
$(".zox-fly-fade").toggleClass("zox-fly-fade-trans");
$("#zox-site-main").toggleClass("zox-body-blur");
});
var duration=500;
$('.back-to-top').on('click', function(event){
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
});
document.querySelectorAll('a[href^="#"]').forEach(anchor=> {
anchor.addEventListener('click', function (e){
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
var dummy=document.createElement('input');
var text=window.location.href;
$('.zox-post-soc-copy').click(function(){
document.body.appendChild(dummy);
dummy.value=text;
dummy.select();
document.execCommand ('copy');
document.body.removeChild(dummy);
alert("URL Copied.");
});
$(".zox-search-click").on('click', function(){
$("#zox-search-wrap").toggleClass("zox-search-toggle");
$("#zox-site-main").toggleClass("zox-body-blur");
$("#zox-search-input").focus();
});
$(".zox-soc-stat-click").on('click', function(){
$(".zox-soc-more-stat").toggleClass("zox-soc-more-open");
});
$(".zox-soc-scroll-click").on('click', function(){
$(".zox-soc-more-scroll").toggleClass("zox-soc-more-open");
});
$(".zox-com-click").on('click', function(){
$("#comments").show();
$("#disqus_thread").show();
$("#zox-comments-button").hide();
});
$('.zox-widget-tab-wrap').each(function(){
$(this).find(".zox-tab-col-cont").hide();
$(this).find("ul.zox-widget-tab-head li.zox-widget-tab-act").addClass("active").show();
$(this).find(".zox-tab-col-cont:first").show();
});
$("ul.zox-widget-tab-head li").on('click', function(e){
$(this).parents('.zox-widget-tab-wrap').find("ul.zox-widget-tab-head li").removeClass("active");
$(this).addClass("active");
$(this).parents('.zox-widget-tab-wrap').find(".zox-tab-col-cont").hide();
var activeTab=$(this).find("a").attr("href");
$(this).parents('.zox-widget-tab-wrap').find(activeTab).fadeIn();
e.preventDefault();
});
$("ul.zox-widget-tab-head li a").on('click', function(e){
e.preventDefault();
});
});
(function(jQuery){
var domfocus=false;
var mousefocus=false;
var zoomactive=false;
var tabindexcounter=5000;
var ascrailcounter=2000;
var globalmaxzindex=0;
var $=jQuery;
function getScriptPath(){
var scripts=document.getElementsByTagName('script');
var path=scripts[scripts.length-1].src.split('?')[0];
return (path.split('/').length>0) ? path.split('/').slice(0,-1).join('/')+'/':'';
}
var scriptpath=getScriptPath();
var vendors=['ms','moz','webkit','o'];
var setAnimationFrame=window.requestAnimationFrame||false;
var clearAnimationFrame=window.cancelAnimationFrame||false;
if(!setAnimationFrame){
for(var vx in vendors){
var v=vendors[vx];
if(!setAnimationFrame) setAnimationFrame=window[v+'RequestAnimationFrame'];
if(!clearAnimationFrame) clearAnimationFrame=window[v+'CancelAnimationFrame']||window[v+'CancelRequestAnimationFrame'];
}}
var clsMutationObserver=window.MutationObserver||window.WebKitMutationObserver||false;
var _globaloptions={
zindex:"auto",
cursoropacitymin:0,
cursoropacitymax:1,
cursorcolor:"#424242",
cursorwidth:"5px",
cursorborder:"1px solid #fff",
cursorborderradius:"5px",
scrollspeed:60,
mousescrollstep:8*3,
touchbehavior:false,
hwacceleration:true,
usetransition:true,
boxzoom:false,
dblclickzoom:true,
gesturezoom:true,
grabcursorenabled:true,
autohidemode:true,
background:"",
iframeautoresize:true,
cursorminheight:32,
preservenativescrolling:true,
railoffset:false,
bouncescroll:true,
spacebarenabled:true,
railpadding:{top:0,right:0,left:0,bottom:0},
disableoutline:true,
horizrailenabled:true,
railalign:"right",
railvalign:"bottom",
enabletranslate3d:true,
enablemousewheel:true,
enablekeyboard:true,
smoothscroll:true,
sensitiverail:true,
enablemouselockapi:true,
cursorfixedheight:false,
directionlockdeadzone:6,
hidecursordelay:400,
nativeparentscrolling:true,
enablescrollonselection:true,
overflowx:true,
overflowy:true,
cursordragspeed:0.3,
rtlmode:false,
cursordragontouch:false,
oneaxismousemode:"auto"
}
var browserdetected=false;
var getBrowserDetection=function(){
if(browserdetected) return browserdetected;
var domtest=document.createElement('DIV');
var d={};
d.haspointerlock="pointerLockElement" in document||"mozPointerLockElement" in document||"webkitPointerLockElement" in document;
d.isopera=("opera" in window);
d.isopera12=(d.isopera&&("getUserMedia" in navigator));
d.isoperamini=(Object.prototype.toString.call(window.operamini)==="[object OperaMini]");
d.isie=(("all" in document)&&("attachEvent" in domtest)&&!d.isopera);
d.isieold=(d.isie&&!("msInterpolationMode" in domtest.style));
d.isie7=d.isie&&!d.isieold&&(!("documentMode" in document)||(document.documentMode==7));
d.isie8=d.isie&&("documentMode" in document)&&(document.documentMode==8);
d.isie9=d.isie&&("performance" in window)&&(document.documentMode>=9);
d.isie10=d.isie&&("performance" in window)&&(document.documentMode>=10);
d.isie9mobile=/iemobile.9/i.test(navigator.userAgent);
if(d.isie9mobile) d.isie9=false;
d.isie7mobile=(!d.isie9mobile&&d.isie7)&&/iemobile/i.test(navigator.userAgent);
d.ismozilla=("MozAppearance" in domtest.style);
d.iswebkit=("WebkitAppearance" in domtest.style);
d.ischrome=("chrome" in window);
d.ischrome22=(d.ischrome&&d.haspointerlock);
d.ischrome26=(d.ischrome&&("transition" in domtest.style));
d.cantouch=("ontouchstart" in document.documentElement)||("ontouchstart" in window);
d.hasmstouch=(window.navigator.msPointerEnabled||false);
d.ismac=/^mac$/i.test(navigator.platform);
d.isios=(d.cantouch&&/iphone|ipad|ipod/i.test(navigator.platform));
d.isios4=((d.isios)&&!("seal" in Object));
d.isandroid=(/android/i.test(navigator.userAgent));
d.trstyle=false;
d.hastransform=false;
d.hastranslate3d=false;
d.transitionstyle=false;
d.hastransition=false;
d.transitionend=false;
var check=['transform','msTransform','webkitTransform','MozTransform','OTransform'];
for(var a=0;a<check.length;a++){
if(typeof domtest.style[check[a]]!="undefined"){
d.trstyle=check[a];
break;
}}
d.hastransform=(d.trstyle!=false);
if(d.hastransform){
domtest.style[d.trstyle]="translate3d(1px,2px,3px)";
d.hastranslate3d=/translate3d/.test(domtest.style[d.trstyle]);
}
d.transitionstyle=false;
d.prefixstyle='';
d.transitionend=false;
var check=['transition','webkitTransition','MozTransition','OTransition','OTransition','msTransition','KhtmlTransition'];
var prefix=['','-webkit-','-moz-','-o-','-o','-ms-','-khtml-'];
var evs=['transitionend','webkitTransitionEnd','transitionend','otransitionend','oTransitionEnd','msTransitionEnd','KhtmlTransitionEnd'];
for(var a=0;a<check.length;a++){
if(check[a] in domtest.style){
d.transitionstyle=check[a];
d.prefixstyle=prefix[a];
d.transitionend=evs[a];
break;
}}
if(d.ischrome26){
d.prefixstyle=prefix[1];
}
d.hastransition=(d.transitionstyle);
function detectCursorGrab(){
var lst=['-moz-grab','-webkit-grab','grab'];
if((d.ischrome&&!d.ischrome22)||d.isie) lst=[];
for(var a=0;a<lst.length;a++){
var p=lst[a];
domtest.style['cursor']=p;
if(domtest.style['cursor']==p) return p;
}
return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';  // thank you google for custom cursor!
}
d.cursorgrabvalue=detectCursorGrab();
d.hasmousecapture=("setCapture" in domtest);
d.hasMutationObserver=(clsMutationObserver!==false);
domtest=null;
browserdetected=d;
return d;
}
var NiceScrollClass=function(myopt,me){
var self=this;
this.version='3.5.0 BETA5';
this.name='nicescroll';
this.me=me;
this.opt={
doc:$("body"),
win:false
};
$.extend(this.opt,_globaloptions);
this.opt.snapbackspeed=80;
if(myopt||false){
for(var a in self.opt){
if(typeof myopt[a]!="undefined") self.opt[a]=myopt[a];
}}
this.doc=self.opt.doc;
this.iddoc=(this.doc&&this.doc[0])?this.doc[0].id||'':'';
this.ispage=/BODY|HTML/.test((self.opt.win)?self.opt.win[0].nodeName:this.doc[0].nodeName);
this.haswrapper=(self.opt.win!==false);
this.win=self.opt.win||(this.ispage?$(window):this.doc);
this.docscroll=(this.ispage&&!this.haswrapper)?$(window):this.win;
this.body=$("body");
this.viewport=false;
this.isfixed=false;
this.iframe=false;
this.isiframe=((this.doc[0].nodeName=='IFRAME')&&(this.win[0].nodeName=='IFRAME'));
this.istextarea=(this.win[0].nodeName=='TEXTAREA');
this.forcescreen=false;
this.canshowonmouseevent=(self.opt.autohidemode!="scroll");
this.onmousedown=false;
this.onmouseup=false;
this.onmousemove=false;
this.onmousewheel=false;
this.onkeypress=false;
this.ongesturezoom=false;
this.onclick=false;
this.onscrollstart=false;
this.onscrollend=false;
this.onscrollcancel=false;
this.onzoomin=false;
this.onzoomout=false;
this.view=false;
this.page=false;
this.scroll={x:0,y:0};
this.scrollratio={x:0,y:0};
this.cursorheight=20;
this.scrollvaluemax=0;
this.checkrtlmode=false;
this.scrollrunning=false;
this.scrollmom=false;
this.observer=false;
this.observerremover=false;
do {
this.id="ascrail"+(ascrailcounter++);
} while (document.getElementById(this.id));
this.rail=false;
this.cursor=false;
this.cursorfreezed=false;
this.selectiondrag=false;
this.zoom=false;
this.zoomactive=false;
this.hasfocus=false;
this.hasmousefocus=false;
this.visibility=true;
this.locked=false;
this.hidden=false;
this.cursoractive=true;
this.overflowx=self.opt.overflowx;
this.overflowy=self.opt.overflowy;
this.nativescrollingarea=false;
this.checkarea=0;
this.events=[];
this.saved={};
this.delaylist={};
this.synclist={};
this.lastdeltax=0;
this.lastdeltay=0;
this.detected=getBrowserDetection();
var cap=$.extend({},this.detected);
this.canhwscroll=(cap.hastransform&&self.opt.hwacceleration);
this.ishwscroll=(this.canhwscroll&&self.haswrapper);
this.istouchcapable=false;
if(cap.cantouch&&cap.ischrome&&!cap.isios&&!cap.isandroid){
this.istouchcapable=true;
cap.cantouch=false;
}
if(cap.cantouch&&cap.ismozilla&&!cap.isios&&!cap.isandroid){
this.istouchcapable=true;
cap.cantouch=false;
}
if(!self.opt.enablemouselockapi){
cap.hasmousecapture=false;
cap.haspointerlock=false;
}
this.delayed=function(name,fn,tm,lazy){
var dd=self.delaylist[name];
var nw=(new Date()).getTime();
if(!lazy&&dd&&dd.tt) return false;
if(dd&&dd.tt) clearTimeout(dd.tt);
if(dd&&dd.last+tm>nw&&!dd.tt){
self.delaylist[name]={
last:nw+tm,
tt:setTimeout(function(){self.delaylist[name].tt=0;fn.call();},tm)
}}
else if(!dd||!dd.tt){
self.delaylist[name]={
last:nw,
tt:0
}
setTimeout(function(){fn.call();},0);
}};
this.debounced=function(name,fn,tm){
var dd=self.delaylist[name];
var nw=(new Date()).getTime();
self.delaylist[name]=fn;
if(!dd){
setTimeout(function(){var fn=self.delaylist[name];self.delaylist[name]=false;fn.call();},tm);
}}
this.synched=function(name,fn){
function requestSync(){
if(self.onsync) return;
setAnimationFrame(function(){
self.onsync=false;
for(name in self.synclist){
var fn=self.synclist[name];
if(fn) fn.call(self);
self.synclist[name]=false;
}});
self.onsync=true;
};
self.synclist[name]=fn;
requestSync();
return name;
};
this.unsynched=function(name){
if(self.synclist[name]) self.synclist[name]=false;
}
this.css=function(el,pars){
for(var n in pars){
self.saved.css.push([el,n,el.css(n)]);
el.css(n,pars[n]);
}};
this.scrollTop=function(val){
return (typeof val=="undefined") ? self.getScrollTop():self.setScrollTop(val);
};
this.scrollLeft=function(val){
return (typeof val=="undefined") ? self.getScrollLeft():self.setScrollLeft(val);
};
BezierClass=function(st,ed,spd,p1,p2,p3,p4){
this.st=st;
this.ed=ed;
this.spd=spd;
this.p1=p1||0;
this.p2=p2||1;
this.p3=p3||0;
this.p4=p4||1;
this.ts=(new Date()).getTime();
this.df=this.ed-this.st;
};
BezierClass.prototype={
B2:function(t){ return 3*t*t*(1-t) },
B3:function(t){ return 3*t*(1-t)*(1-t) },
B4:function(t){ return (1-t)*(1-t)*(1-t) },
getNow:function(){
var nw=(new Date()).getTime();
var pc=1-((nw-this.ts)/this.spd);
var bz=this.B2(pc) + this.B3(pc) + this.B4(pc);
return (pc<0) ? this.ed:this.st+Math.round(this.df*bz);
},
update:function(ed,spd){
this.st=this.getNow();
this.ed=ed;
this.spd=spd;
this.ts=(new Date()).getTime();
this.df=this.ed-this.st;
return this;
}};
if(this.ishwscroll){
this.doc.translate={x:0,y:0,tx:"0px",ty:"0px"};
if(cap.hastranslate3d&&cap.isios) this.doc.css("-webkit-backface-visibility","hidden");  // prevent flickering http://stackoverflow.com/questions/3461441/
function getMatrixValues(){
var tr=self.doc.css(cap.trstyle);
if(tr&&(tr.substr(0,6)=="matrix")){
return tr.replace(/^.*\((.*)\)$/g, "$1").replace(/px/g,'').split(/, +/);
}
return false;
}
this.getScrollTop=function(last){
if(!last){
var mtx=getMatrixValues();
if(mtx) return (mtx.length==16) ? -mtx[13]:-mtx[5];
if(self.timerscroll&&self.timerscroll.bz) return self.timerscroll.bz.getNow();
}
return self.doc.translate.y;
};
this.getScrollLeft=function(last){
if(!last){
var mtx=getMatrixValues();
if(mtx) return (mtx.length==16) ? -mtx[12]:-mtx[4];
if(self.timerscroll&&self.timerscroll.bh) return self.timerscroll.bh.getNow();
}
return self.doc.translate.x;
};
if(document.createEvent){
this.notifyScrollEvent=function(el){
var e=document.createEvent("UIEvents");
e.initUIEvent("scroll", false, true, window, 1);
el.dispatchEvent(e);
};}
else if(document.fireEvent){
this.notifyScrollEvent=function(el){
var e=document.createEventObject();
el.fireEvent("onscroll");
e.cancelBubble=true;
};}else{
this.notifyScrollEvent=function(el,add){};}
if(cap.hastranslate3d&&self.opt.enabletranslate3d){
this.setScrollTop=function(val,silent){
self.doc.translate.y=val;
self.doc.translate.ty=(val*-1)+"px";
self.doc.css(cap.trstyle,"translate3d("+self.doc.translate.tx+","+self.doc.translate.ty+",0px)");
if(!silent) self.notifyScrollEvent(self.win[0]);
};
this.setScrollLeft=function(val,silent){
self.doc.translate.x=val;
self.doc.translate.tx=(val*-1)+"px";
self.doc.css(cap.trstyle,"translate3d("+self.doc.translate.tx+","+self.doc.translate.ty+",0px)");
if(!silent) self.notifyScrollEvent(self.win[0]);
};}else{
this.setScrollTop=function(val,silent){
self.doc.translate.y=val;
self.doc.translate.ty=(val*-1)+"px";
self.doc.css(cap.trstyle,"translate("+self.doc.translate.tx+","+self.doc.translate.ty+")");
if(!silent) self.notifyScrollEvent(self.win[0]);
};
this.setScrollLeft=function(val,silent){
self.doc.translate.x=val;
self.doc.translate.tx=(val*-1)+"px";
self.doc.css(cap.trstyle,"translate("+self.doc.translate.tx+","+self.doc.translate.ty+")");
if(!silent) self.notifyScrollEvent(self.win[0]);
};}}else{
this.getScrollTop=function(){
return self.docscroll.scrollTop();
};
this.setScrollTop=function(val){
return self.docscroll.scrollTop(val);
};
this.getScrollLeft=function(){
return self.docscroll.scrollLeft();
};
this.setScrollLeft=function(val){
return self.docscroll.scrollLeft(val);
};}
this.getTarget=function(e){
if(!e) return false;
if(e.target) return e.target;
if(e.srcElement) return e.srcElement;
return false;
};
this.hasParent=function(e,id){
if(!e) return false;
var el=e.target||e.srcElement||e||false;
while (el&&el.id!=id){
el=el.parentNode||false;
}
return (el!==false);
};
function getZIndex(){
var dom=self.win;
if("zIndex" in dom) return dom.zIndex();
while (dom.length>0){
if(dom[0].nodeType==9) return false;
var zi=dom.css('zIndex');
if(!isNaN(zi)&&zi!=0) return parseInt(zi);
dom=dom.parent();
}
return false;
};
var _convertBorderWidth={"thin":1,"medium":3,"thick":5};
function getWidthToPixel(dom,prop,chkheight){
var wd=dom.css(prop);
var px=parseFloat(wd);
if(isNaN(px)){
px=_convertBorderWidth[wd]||0;
var brd=(px==3) ? ((chkheight)?(self.win.outerHeight() - self.win.innerHeight()):(self.win.outerWidth() - self.win.innerWidth())):1;
if(self.isie8&&px) px+=1;
return (brd) ? px:0;
}
return px;
};
this.getOffset=function(){
if(self.isfixed) return {top:parseFloat(self.win.css('top')),left:parseFloat(self.win.css('left'))};
if(!self.viewport) return self.win.offset();
var ww=self.win.offset();
var vp=self.viewport.offset();
return {top:ww.top-vp.top+self.viewport.scrollTop(),left:ww.left-vp.left+self.viewport.scrollLeft()};};
this.updateScrollBar=function(len){
if(self.ishwscroll){
self.rail.css({height:self.win.innerHeight()});
if(self.railh) self.railh.css({width:self.win.innerWidth()});
}else{
var wpos=self.getOffset();
var pos={top:wpos.top,left:wpos.left};
pos.top+=getWidthToPixel(self.win,'border-top-width',true);
var brd=(self.win.outerWidth() - self.win.innerWidth())/2;
pos.left+=(self.rail.align) ? self.win.outerWidth() - getWidthToPixel(self.win,'border-right-width') - self.rail.width:getWidthToPixel(self.win,'border-left-width');
var off=self.opt.railoffset;
if(off){
if(off.top) pos.top+=off.top;
if(self.rail.align&&off.left) pos.left+=off.left;
}
if(!self.locked) self.rail.css({top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
if(self.zoom){
self.zoom.css({top:pos.top+1,left:(self.rail.align==1) ? pos.left-20:pos.left+self.rail.width+4});
}
if(self.railh&&!self.locked){
var pos={top:wpos.top,left:wpos.left};
var y=(self.railh.align) ? pos.top + getWidthToPixel(self.win,'border-top-width',true) + self.win.innerHeight() - self.railh.height:pos.top + getWidthToPixel(self.win,'border-top-width',true);
var x=pos.left + getWidthToPixel(self.win,'border-left-width');
self.railh.css({top:y,left:x,width:self.railh.width});
}}
};
this.doRailClick=function(e,dbl,hr){
var fn,pg,cur,pos;
if(self.locked) return;
self.cancelEvent(e);
if(dbl){
fn=(hr) ? self.doScrollLeft:self.doScrollTop;
cur=(hr) ? ((e.pageX - self.railh.offset().left - (self.cursorwidth/2)) * self.scrollratio.x):((e.pageY - self.rail.offset().top - (self.cursorheight/2)) * self.scrollratio.y);
fn(cur);
}else{
fn=(hr) ? self.doScrollLeftBy:self.doScrollBy;
cur=(hr) ? self.scroll.x:self.scroll.y;
pos=(hr) ? e.pageX - self.railh.offset().left:e.pageY - self.rail.offset().top;
pg=(hr) ? self.view.w:self.view.h;
(cur>=pos) ? fn(pg):fn(-pg);
}}
self.hasanimationframe=(setAnimationFrame);
self.hascancelanimationframe=(clearAnimationFrame);
if(!self.hasanimationframe){
setAnimationFrame=function(fn){return setTimeout(fn,15-Math.floor((+new Date)/1000)%16)};
clearAnimationFrame=clearInterval;
}
else if(!self.hascancelanimationframe) clearAnimationFrame=function(){self.cancelAnimationFrame=true};
this.init=function(){
self.saved.css=[];
if(cap.isie7mobile) return true;
if(cap.isoperamini) return true;
if(cap.hasmstouch) self.css((self.ispage)?$("html"):self.win,{'-ms-touch-action':'none'});
self.zindex="auto";
if(!self.ispage&&self.opt.zindex=="auto"){
self.zindex=getZIndex()||"auto";
}else{
self.zindex=self.opt.zindex;
}
if(!self.ispage&&self.zindex!="auto"){
if(self.zindex>globalmaxzindex) globalmaxzindex=self.zindex;
}
if(self.isie&&self.zindex==0&&self.opt.zindex=="auto"){
self.zindex="auto";
}
if(!self.ispage||(!cap.cantouch&&!cap.isieold&&!cap.isie9mobile)){
var cont=self.docscroll;
if(self.ispage) cont=(self.haswrapper)?self.win:self.doc;
if(!cap.isie9mobile) self.css(cont,{'overflow-y':'hidden'});
if(self.ispage&&cap.isie7){
if(self.doc[0].nodeName=='BODY') self.css($("html"),{'overflow-y':'hidden'});
else if(self.doc[0].nodeName=='HTML') self.css($("body"),{'overflow-y':'hidden'});
}
if(cap.isios&&!self.ispage&&!self.haswrapper) self.css($("body"),{"-webkit-overflow-scrolling":"touch"});
var cursor=$(document.createElement('div'));
cursor.css({
position:"relative",top:0,"float":"right",width:self.opt.cursorwidth,height:"0px",
'background-color':self.opt.cursorcolor,
border:self.opt.cursorborder,
'background-clip':'padding-box',
'-webkit-border-radius':self.opt.cursorborderradius,
'-moz-border-radius':self.opt.cursorborderradius,
'border-radius':self.opt.cursorborderradius
});
cursor.hborder=parseFloat(cursor.outerHeight() - cursor.innerHeight());
self.cursor=cursor;
var rail=$(document.createElement('div'));
rail.attr('id',self.id);
rail.addClass('nicescroll-rails');
var v,a,kp=["left","right"];  //"top","bottom"
for(var n in kp){
a=kp[n];
v=self.opt.railpadding[a];
(v) ? rail.css("padding-"+a,v+"px"):self.opt.railpadding[a]=0;
}
rail.append(cursor);
rail.width=Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth()) + self.opt.railpadding['left'] + self.opt.railpadding['right'];
rail.css({width:rail.width+"px",'zIndex':self.zindex,"background":self.opt.background,cursor:"default"});
rail.visibility=true;
rail.scrollable=true;
rail.align=(self.opt.railalign=="left") ? 0:1;
self.rail=rail;
self.rail.drag=false;
var zoom=false;
if(self.opt.boxzoom&&!self.ispage&&!cap.isieold){
zoom=document.createElement('div');
self.bind(zoom,"click",self.doZoom);
self.zoom=$(zoom);
self.zoom.css({"cursor":"pointer",'z-index':self.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
if(self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
if(cap.cantouch&&self.opt.gesturezoom){
self.ongesturezoom=function(e){
if(e.scale>1.5) self.doZoomIn(e);
if(e.scale<0.8) self.doZoomOut(e);
return self.cancelEvent(e);
};
self.bind(self.win,"gestureend",self.ongesturezoom);
}}
self.railh=false;
if(self.opt.horizrailenabled){
self.css(cont,{'overflow-x':'hidden'});
var cursor=$(document.createElement('div'));
cursor.css({
position:"relative",top:0,height:self.opt.cursorwidth,width:"0px",
'background-color':self.opt.cursorcolor,
border:self.opt.cursorborder,
'background-clip':'padding-box',
'-webkit-border-radius':self.opt.cursorborderradius,
'-moz-border-radius':self.opt.cursorborderradius,
'border-radius':self.opt.cursorborderradius
});
cursor.wborder=parseFloat(cursor.outerWidth() - cursor.innerWidth());
self.cursorh=cursor;
var railh=$(document.createElement('div'));
railh.attr('id',self.id+'-hr');
railh.addClass('nicescroll-rails');
railh.height=Math.max(parseFloat(self.opt.cursorwidth),cursor.outerHeight());
railh.css({height:railh.height+"px",'zIndex':self.zindex,"background":self.opt.background});
railh.append(cursor);
railh.visibility=true;
railh.scrollable=true;
railh.align=(self.opt.railvalign=="top") ? 0:1;
self.railh=railh;
self.railh.drag=false;
}
if(self.ispage){
rail.css({position:"fixed",top:"0px",height:"100%"});
(rail.align) ? rail.css({right:"0px"}):rail.css({left:"0px"});
self.body.append(rail);
if(self.railh){
railh.css({position:"fixed",left:"0px",width:"100%"});
(railh.align) ? railh.css({bottom:"0px"}):railh.css({top:"0px"});
self.body.append(railh);
}}else{
if(self.ishwscroll){
if(self.win.css('position')=='static') self.css(self.win,{'position':'relative'});
var bd=(self.win[0].nodeName=='HTML') ? self.body:self.win;
if(self.zoom){
self.zoom.css({position:"absolute",top:1,right:0,"margin-right":rail.width+4});
bd.append(self.zoom);
}
rail.css({position:"absolute",top:0});
(rail.align) ? rail.css({right:0}):rail.css({left:0});
bd.append(rail);
if(railh){
railh.css({position:"absolute",left:0,bottom:0});
(railh.align) ? railh.css({bottom:0}):railh.css({top:0});
bd.append(railh);
}}else{
self.isfixed=(self.win.css("position")=="fixed");
var rlpos=(self.isfixed) ? "fixed":"absolute";
if(!self.isfixed) self.viewport=self.getViewport(self.win[0]);
if(self.viewport){
self.body=self.viewport;
if((/relative|absolute/.test(self.viewport.css("position")))==false) self.css(self.viewport,{"position":"relative"});
}
rail.css({position:rlpos});
if(self.zoom) self.zoom.css({position:rlpos});
self.updateScrollBar();
self.body.append(rail);
if(self.zoom) self.body.append(self.zoom);
if(self.railh){
railh.css({position:rlpos});
self.body.append(railh);
}}
if(cap.isios) self.css(self.win,{'-webkit-tap-highlight-color':'rgba(0,0,0,0)','-webkit-touch-callout':'none'});
if(cap.isie&&self.opt.disableoutline) self.win.attr("hideFocus","true");
if(cap.iswebkit&&self.opt.disableoutline) self.win.css({"outline":"none"});
}
if(self.opt.autohidemode===false){
self.autohidedom=false;
self.rail.css({opacity:self.opt.cursoropacitymax});
if(self.railh) self.railh.css({opacity:self.opt.cursoropacitymax});
}
else if(self.opt.autohidemode===true){
self.autohidedom=$().add(self.rail);
if(cap.isie8) self.autohidedom=self.autohidedom.add(self.cursor);
if(self.railh) self.autohidedom=self.autohidedom.add(self.railh);
if(self.railh&&cap.isie8) self.autohidedom=self.autohidedom.add(self.cursorh);
}
else if(self.opt.autohidemode=="scroll"){
self.autohidedom=$().add(self.rail);
if(self.railh) self.autohidedom=self.autohidedom.add(self.railh);
}
else if(self.opt.autohidemode=="cursor"){
self.autohidedom=$().add(self.cursor);
if(self.railh) self.autohidedom=self.autohidedom.add(self.cursorh);
}
else if(self.opt.autohidemode=="hidden"){
self.autohidedom=false;
self.hide();
self.locked=false;
}
if(cap.isie9mobile){
self.scrollmom=new ScrollMomentumClass2D(self);
/*
var trace=function(msg){
var db=$("#debug");
if(isNaN(msg)&&(typeof msg!="string")){
var x=[];
for(var a in msg){
x.push(a+":"+msg[a]);
}
msg="{"+x.join(",")+"}";
}
if(db.children().length>0){
db.children().eq(0).before("<div>"+msg+"</div>");
}else{
db.append("<div>"+msg+"</div>");
}}
window.onerror=function(msg,url,ln){
trace("ERR: "+msg+" at "+ln);
}
*/
self.onmangotouch=function(e){
var py=self.getScrollTop();
var px=self.getScrollLeft();
if((py==self.scrollmom.lastscrolly)&&(px==self.scrollmom.lastscrollx)) return true;
var dfy=py-self.mangotouch.sy;
var dfx=px-self.mangotouch.sx;
var df=Math.round(Math.sqrt(Math.pow(dfx,2)+Math.pow(dfy,2)));
if(df==0) return;
var dry=(dfy<0)?-1:1;
var drx=(dfx<0)?-1:1;
var tm=+new Date();
if(self.mangotouch.lazy) clearTimeout(self.mangotouch.lazy);
if(((tm-self.mangotouch.tm)>80)||(self.mangotouch.dry!=dry)||(self.mangotouch.drx!=drx)){
self.scrollmom.stop();
self.scrollmom.reset(px,py);
self.mangotouch.sy=py;
self.mangotouch.ly=py;
self.mangotouch.sx=px;
self.mangotouch.lx=px;
self.mangotouch.dry=dry;
self.mangotouch.drx=drx;
self.mangotouch.tm=tm;
}else{
self.scrollmom.stop();
self.scrollmom.update(self.mangotouch.sx-dfx,self.mangotouch.sy-dfy);
var gap=tm - self.mangotouch.tm;
self.mangotouch.tm=tm;
var ds=Math.max(Math.abs(self.mangotouch.ly-py),Math.abs(self.mangotouch.lx-px));
self.mangotouch.ly=py;
self.mangotouch.lx=px;
if(ds>2){
self.mangotouch.lazy=setTimeout(function(){
self.mangotouch.lazy=false;
self.mangotouch.dry=0;
self.mangotouch.drx=0;
self.mangotouch.tm=0;
self.scrollmom.doMomentum(30);
},100);
}}
}
var top=self.getScrollTop();
var lef=self.getScrollLeft();
self.mangotouch={sy:top,ly:top,dry:0,sx:lef,lx:lef,drx:0,lazy:false,tm:0};
self.bind(self.docscroll,"scroll",self.onmangotouch);
}else{
if(cap.cantouch||self.istouchcapable||self.opt.touchbehavior||cap.hasmstouch){
self.scrollmom=new ScrollMomentumClass2D(self);
self.ontouchstart=function(e){
if(e.pointerType&&e.pointerType!=2) return false;
if(!self.locked){
if(cap.hasmstouch){
var tg=(e.target) ? e.target:false;
while (tg){
var nc=$(tg).getNiceScroll();
if((nc.length>0)&&(nc[0].me==self.me)) break;
if(nc.length>0) return false;
if((tg.nodeName=='DIV')&&(tg.id==self.id)) break;
tg=(tg.parentNode) ? tg.parentNode:false;
}}
self.cancelScroll();
var tg=self.getTarget(e);
if(tg){
var skp=(/INPUT/i.test(tg.nodeName))&&(/range/i.test(tg.type));
if(skp) return self.stopPropagation(e);
}
if(!("clientX" in e)&&("changedTouches" in e)){
e.clientX=e.changedTouches[0].clientX;
e.clientY=e.changedTouches[0].clientY;
}
if(self.forcescreen){
var le=e;
var e={"original":(e.original)?e.original:e};
e.clientX=le.screenX;
e.clientY=le.screenY;
}
self.rail.drag={x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop(),sl:self.getScrollLeft(),pt:2,dl:false};
if(self.ispage||!self.opt.directionlockdeadzone){
self.rail.drag.dl="f";
}else{
var view={
w:$(window).width(),
h:$(window).height()
};
var page={
w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
}
var maxh=Math.max(0,page.h - view.h);
var maxw=Math.max(0,page.w - view.w);
if(!self.rail.scrollable&&self.railh.scrollable) self.rail.drag.ck=(maxh>0) ? "v":false;
else if(self.rail.scrollable&&!self.railh.scrollable) self.rail.drag.ck=(maxw>0) ? "h":false;
else self.rail.drag.ck=false;
if(!self.rail.drag.ck) self.rail.drag.dl="f";
}
if(self.opt.touchbehavior&&self.isiframe&&cap.isie){
var wp=self.win.position();
self.rail.drag.x+=wp.left;
self.rail.drag.y+=wp.top;
}
self.hasmoving=false;
self.lastmouseup=false;
self.scrollmom.reset(e.clientX,e.clientY);
if(!cap.cantouch&&!this.istouchcapable&&!cap.hasmstouch){
var ip=(tg)?/INPUT|SELECT|TEXTAREA/i.test(tg.nodeName):false;
if(!ip){
if(!self.ispage&&cap.hasmousecapture) tg.setCapture();
return (self.opt.touchbehavior) ? self.cancelEvent(e):self.stopPropagation(e);
}
if(/SUBMIT|CANCEL|BUTTON/i.test($(tg).attr('type'))){
pc={"tg":tg,"click":false};
self.preventclick=pc;
}}
}};
self.ontouchend=function(e){
if(e.pointerType&&e.pointerType!=2) return false;
if(self.rail.drag&&(self.rail.drag.pt==2)){
self.scrollmom.doMomentum();
self.rail.drag=false;
if(self.hasmoving){
self.hasmoving=false;
self.lastmouseup=true;
self.hideCursor();
if(cap.hasmousecapture) document.releaseCapture();
if(!cap.cantouch) return self.cancelEvent(e);
}}
};
var moveneedoffset=(self.opt.touchbehavior&&self.isiframe&&!cap.hasmousecapture);
self.ontouchmove=function(e,byiframe){
if(e.pointerType&&e.pointerType!=2) return false;
if(self.rail.drag&&(self.rail.drag.pt==2)){
if(cap.cantouch&&(typeof e.original=="undefined")) return true;
self.hasmoving=true;
if(self.preventclick&&!self.preventclick.click){
self.preventclick.click=self.preventclick.tg.onclick||false;
self.preventclick.tg.onclick=self.onpreventclick;
}
var ev=$.extend({"original":e},e);
e=ev;
if(("changedTouches" in e)){
e.clientX=e.changedTouches[0].clientX;
e.clientY=e.changedTouches[0].clientY;
}
if(self.forcescreen){
var le=e;
var e={"original":(e.original)?e.original:e};
e.clientX=le.screenX;
e.clientY=le.screenY;
}
var ofx=ofy=0;
if(moveneedoffset&&!byiframe){
var wp=self.win.position();
ofx=-wp.left;
ofy=-wp.top;
}
var fy=e.clientY + ofy;
var my=(fy-self.rail.drag.y);
var fx=e.clientX + ofx;
var mx=(fx-self.rail.drag.x);
var ny=self.rail.drag.st-my;
if(self.ishwscroll&&self.opt.bouncescroll){
if(ny<0){
ny=Math.round(ny/2);
}
else if(ny>self.page.maxh){
ny=self.page.maxh+Math.round((ny-self.page.maxh)/2);
}}else{
if(ny<0){ny=0;fy=0}
if(ny>self.page.maxh){ny=self.page.maxh;fy=0}}
if(self.railh&&self.railh.scrollable){
var nx=self.rail.drag.sl-mx;
if(self.ishwscroll&&self.opt.bouncescroll){
if(nx<0){
nx=Math.round(nx/2);
}
else if(nx>self.page.maxw){
nx=self.page.maxw+Math.round((nx-self.page.maxw)/2);
}}else{
if(nx<0){nx=0;fx=0}
if(nx>self.page.maxw){nx=self.page.maxw;fx=0}}
}
var grabbed=false;
if(self.rail.drag.dl){
grabbed=true;
if(self.rail.drag.dl=="v") nx=self.rail.drag.sl;
else if(self.rail.drag.dl=="h") ny=self.rail.drag.st;
}else{
var ay=Math.abs(my);
var ax=Math.abs(mx);
var dz=self.opt.directionlockdeadzone;
if(self.rail.drag.ck=="v"){
if(ay>dz&&(ax<=(ay*0.3))){
self.rail.drag=false;
return true;
}
else if(ax>dz){
self.rail.drag.dl="f";
$("body").scrollTop($("body").scrollTop());
}}
else if(self.rail.drag.ck=="h"){
if(ax>dz&&(ay<=(ax*0.3))){
self.rail.drag=false;
return true;
}
else if(ay>dz){
self.rail.drag.dl="f";
$("body").scrollLeft($("body").scrollLeft());
}}
}
self.synched("touchmove",function(){
if(self.rail.drag&&(self.rail.drag.pt==2)){
if(self.prepareTransition) self.prepareTransition(0);
if(self.rail.scrollable) self.setScrollTop(ny);
self.scrollmom.update(fx,fy);
if(self.railh&&self.railh.scrollable){
self.setScrollLeft(nx);
self.showCursor(ny,nx);
}else{
self.showCursor(ny);
}
if(cap.isie10) document.selection.clear();
}});
if(cap.ischrome&&self.istouchcapable) grabbed=false;
if(grabbed) return self.cancelEvent(e);
}};}
self.onmousedown=function(e,hronly){
if(self.rail.drag&&self.rail.drag.pt!=1) return;
if(self.locked) return self.cancelEvent(e);
self.cancelScroll();
self.rail.drag={x:e.clientX,y:e.clientY,sx:self.scroll.x,sy:self.scroll.y,pt:1,hr:(!!hronly)};
var tg=self.getTarget(e);
if(!self.ispage&&cap.hasmousecapture) tg.setCapture();
if(self.isiframe&&!cap.hasmousecapture){
self.saved["csspointerevents"]=self.doc.css("pointer-events");
self.css(self.doc,{"pointer-events":"none"});
}
return self.cancelEvent(e);
};
self.onmouseup=function(e){
if(self.rail.drag){
if(cap.hasmousecapture) document.releaseCapture();
if(self.isiframe&&!cap.hasmousecapture) self.doc.css("pointer-events",self.saved["csspointerevents"]);
if(self.rail.drag.pt!=1)return;
self.rail.drag=false;
return self.cancelEvent(e);
}};
self.onmousemove=function(e){
if(self.rail.drag){
if(self.rail.drag.pt!=1)return;
if(cap.ischrome&&e.which==0) return self.onmouseup(e);
self.cursorfreezed=true;
if(self.rail.drag.hr){
self.scroll.x=self.rail.drag.sx + (e.clientX-self.rail.drag.x);
if(self.scroll.x<0) self.scroll.x=0;
var mw=self.scrollvaluemaxw;
if(self.scroll.x>mw) self.scroll.x=mw;
}else{
self.scroll.y=self.rail.drag.sy + (e.clientY-self.rail.drag.y);
if(self.scroll.y<0) self.scroll.y=0;
var my=self.scrollvaluemax;
if(self.scroll.y>my) self.scroll.y=my;
}
self.synched('mousemove',function(){
if(self.rail.drag&&(self.rail.drag.pt==1)){
self.showCursor();
if(self.rail.drag.hr) self.doScrollLeft(Math.round(self.scroll.x*self.scrollratio.x),self.opt.cursordragspeed);
else self.doScrollTop(Math.round(self.scroll.y*self.scrollratio.y),self.opt.cursordragspeed);
}});
return self.cancelEvent(e);
}
};
if(cap.cantouch||self.opt.touchbehavior){
self.onpreventclick=function(e){
if(self.preventclick){
self.preventclick.tg.onclick=self.preventclick.click;
self.preventclick=false;
return self.cancelEvent(e);
}}
self.bind(self.win,"mousedown",self.ontouchstart);
self.onclick=(cap.isios) ? false:function(e){
if(self.lastmouseup){
self.lastmouseup=false;
return self.cancelEvent(e);
}else{
return true;
}};
if(self.opt.grabcursorenabled&&cap.cursorgrabvalue){
self.css((self.ispage)?self.doc:self.win,{'cursor':cap.cursorgrabvalue});
self.css(self.rail,{'cursor':cap.cursorgrabvalue});
}}else{
function checkSelectionScroll(e){
if(!self.selectiondrag) return;
if(e){
var ww=self.win.outerHeight();
var df=(e.pageY - self.selectiondrag.top);
if(df>0&&df<ww) df=0;
if(df>=ww) df-=ww;
self.selectiondrag.df=df;
}
if(self.selectiondrag.df==0) return;
var rt=-Math.floor(self.selectiondrag.df/6)*2;
self.doScrollBy(rt);
self.debounced("doselectionscroll",function(){checkSelectionScroll()},50);
}
if("getSelection" in document){
self.hasTextSelected=function(){
return (document.getSelection().rangeCount>0);
}}
else if("selection" in document){
self.hasTextSelected=function(){
return (document.selection.type!="None");
}}else{
self.hasTextSelected=function(){
return false;
}}
self.onselectionstart=function(e){
if(self.ispage) return;
self.selectiondrag=self.win.offset();
}
self.onselectionend=function(e){
self.selectiondrag=false;
}
self.onselectiondrag=function(e){
if(!self.selectiondrag) return;
if(self.hasTextSelected()) self.debounced("selectionscroll",function(){checkSelectionScroll(e)},250);
}}
if(cap.hasmstouch){
self.css(self.rail,{'-ms-touch-action':'none'});
self.css(self.cursor,{'-ms-touch-action':'none'});
self.bind(self.win,"MSPointerDown",self.ontouchstart);
self.bind(document,"MSPointerUp",self.ontouchend);
self.bind(document,"MSPointerMove",self.ontouchmove);
self.bind(self.cursor,"MSGestureHold",function(e){e.preventDefault()});
self.bind(self.cursor,"contextmenu",function(e){e.preventDefault()});
}
if(this.istouchcapable){
self.bind(self.win,"touchstart",self.ontouchstart);
self.bind(document,"touchend",self.ontouchend);
self.bind(document,"touchcancel",self.ontouchend);
self.bind(document,"touchmove",self.ontouchmove);
}
self.bind(self.cursor,"mousedown",self.onmousedown);
self.bind(self.cursor,"mouseup",self.onmouseup);
if(self.railh){
self.bind(self.cursorh,"mousedown",function(e){self.onmousedown(e,true)});
self.bind(self.cursorh,"mouseup",function(e){
if(self.rail.drag&&self.rail.drag.pt==2) return;
self.rail.drag=false;
self.hasmoving=false;
self.hideCursor();
if(cap.hasmousecapture) document.releaseCapture();
return self.cancelEvent(e);
});
}
if(self.opt.cursordragontouch||!cap.cantouch&&!self.opt.touchbehavior){
self.rail.css({"cursor":"default"});
self.railh&&self.railh.css({"cursor":"default"});
self.jqbind(self.rail,"mouseenter",function(){
if(self.canshowonmouseevent) self.showCursor();
self.rail.active=true;
});
self.jqbind(self.rail,"mouseleave",function(){
self.rail.active=false;
if(!self.rail.drag) self.hideCursor();
});
if(self.opt.sensitiverail){
self.bind(self.rail,"click",function(e){self.doRailClick(e,false,false)});
self.bind(self.rail,"dblclick",function(e){self.doRailClick(e,true,false)});
self.bind(self.cursor,"click",function(e){self.cancelEvent(e)});
self.bind(self.cursor,"dblclick",function(e){self.cancelEvent(e)});
}
if(self.railh){
self.jqbind(self.railh,"mouseenter",function(){
if(self.canshowonmouseevent) self.showCursor();
self.rail.active=true;
});
self.jqbind(self.railh,"mouseleave",function(){
self.rail.active=false;
if(!self.rail.drag) self.hideCursor();
});
if(self.opt.sensitiverail){
self.bind(self.railh, "click", function(e){self.doRailClick(e,false,true)});
self.bind(self.railh, "dblclick", function(e){self.doRailClick(e, true, true) });
self.bind(self.cursorh, "click", function (e){ self.cancelEvent(e) });
self.bind(self.cursorh, "dblclick", function (e){ self.cancelEvent(e) });
}}
}
if(!cap.cantouch&&!self.opt.touchbehavior){
self.bind((cap.hasmousecapture)?self.win:document,"mouseup",self.onmouseup);
self.bind(document,"mousemove",self.onmousemove);
if(self.onclick) self.bind(document,"click",self.onclick);
if(!self.ispage&&self.opt.enablescrollonselection){
self.bind(self.win[0],"mousedown",self.onselectionstart);
self.bind(document,"mouseup",self.onselectionend);
self.bind(self.cursor,"mouseup",self.onselectionend);
if(self.cursorh) self.bind(self.cursorh,"mouseup",self.onselectionend);
self.bind(document,"mousemove",self.onselectiondrag);
}
if(self.zoom){
self.jqbind(self.zoom,"mouseenter",function(){
if(self.canshowonmouseevent) self.showCursor();
self.rail.active=true;
});
self.jqbind(self.zoom,"mouseleave",function(){
self.rail.active=false;
if(!self.rail.drag) self.hideCursor();
});
}}else{
self.bind((cap.hasmousecapture)?self.win:document,"mouseup",self.ontouchend);
self.bind(document,"mousemove",self.ontouchmove);
if(self.onclick) self.bind(document,"click",self.onclick);
if(self.opt.cursordragontouch){
self.bind(self.cursor,"mousedown",self.onmousedown);
self.bind(self.cursor,"mousemove",self.onmousemove);
self.cursorh&&self.bind(self.cursorh,"mousedown",self.onmousedown);
self.cursorh&&self.bind(self.cursorh,"mousemove",self.onmousemove);
}}
if(self.opt.enablemousewheel){
if(!self.isiframe) self.bind((cap.isie&&self.ispage) ? document:self.win  ,"mousewheel",self.onmousewheel);
self.bind(self.rail,"mousewheel",self.onmousewheel);
if(self.railh) self.bind(self.railh,"mousewheel",self.onmousewheelhr);
}
if(!self.ispage&&!cap.cantouch&&!(/HTML|BODY/.test(self.win[0].nodeName))){
if(!self.win.attr("tabindex")) self.win.attr({"tabindex":tabindexcounter++});
self.jqbind(self.win,"focus",function(e){
domfocus=(self.getTarget(e)).id||true;
self.hasfocus=true;
if(self.canshowonmouseevent) self.noticeCursor();
});
self.jqbind(self.win,"blur",function(e){
domfocus=false;
self.hasfocus=false;
});
self.jqbind(self.win,"mouseenter",function(e){
mousefocus=(self.getTarget(e)).id||true;
self.hasmousefocus=true;
if(self.canshowonmouseevent) self.noticeCursor();
});
self.jqbind(self.win,"mouseleave",function(){
mousefocus=false;
self.hasmousefocus=false;
});
};}
self.onkeypress=function(e){
if(self.locked&&self.page.maxh==0) return true;
e=(e) ? e:window.e;
var tg=self.getTarget(e);
if(tg&&/INPUT|TEXTAREA|SELECT|OPTION/.test(tg.nodeName)){
var tp=tg.getAttribute('type')||tg.type||false;
if((!tp)||!(/submit|button|cancel/i.tp)) return true;
}
if(self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)){
var key=e.keyCode;
if(self.locked&&key!=27) return self.cancelEvent(e);
var ctrl=e.ctrlKey||false;
var shift=e.shiftKey||false;
var ret=false;
switch (key){
case 38:
case 63233:
self.doScrollBy(24*3);
ret=true;
break;
case 40:
case 63235:
self.doScrollBy(-24*3);
ret=true;
break;
case 37:
case 63232:
if(self.railh){
(ctrl) ? self.doScrollLeft(0):self.doScrollLeftBy(24*3);
ret=true;
}
break;
case 39:
case 63234:
if(self.railh){
(ctrl) ? self.doScrollLeft(self.page.maxw):self.doScrollLeftBy(-24*3);
ret=true;
}
break;
case 33:
case 63276:
self.doScrollBy(self.view.h);
ret=true;
break;
case 34:
case 63277:
self.doScrollBy(-self.view.h);
ret=true;
break;
case 36:
case 63273:
(self.railh&&ctrl) ? self.doScrollPos(0,0):self.doScrollTo(0);
ret=true;
break;
case 35:
case 63275:
(self.railh&&ctrl) ? self.doScrollPos(self.page.maxw,self.page.maxh):self.doScrollTo(self.page.maxh);
ret=true;
break;
case 32:
if(self.opt.spacebarenabled){
(shift) ? self.doScrollBy(self.view.h):self.doScrollBy(-self.view.h);
ret=true;
}
break;
case 27:
if(self.zoomactive){
self.doZoom();
ret=true;
}
break;
}
if(ret) return self.cancelEvent(e);
}};
if(self.opt.enablekeyboard) self.bind(document,(cap.isopera&&!cap.isopera12)?"keypress":"keydown",self.onkeypress);
self.bind(window,'resize',self.lazyResize);
self.bind(window,'orientationchange',self.lazyResize);
self.bind(window,"load",self.lazyResize);
if(cap.ischrome&&!self.ispage&&!self.haswrapper){
var tmp=self.win.attr("style");
var ww=parseFloat(self.win.css("width"))+1;
self.win.css('width',ww);
self.synched("chromefix",function(){self.win.attr("style",tmp)});
}
self.onAttributeChange=function(e){
self.lazyResize(250);
}
if(!self.ispage&&!self.haswrapper){
if(clsMutationObserver!==false){
self.observer=new clsMutationObserver(function(mutations){
mutations.forEach(self.onAttributeChange);
});
self.observer.observe(self.win[0],{childList: true, characterData: false, attributes: true, subtree: false});
self.observerremover=new clsMutationObserver(function(mutations){
mutations.forEach(function(mo){
if(mo.removedNodes.length>0){
for (var dd in mo.removedNodes){
if(mo.removedNodes[dd]==self.win[0]) return self.remove();
}}
});
});
self.observerremover.observe(self.win[0].parentNode,{childList: true, characterData: false, attributes: false, subtree: false});
}else{
self.bind(self.win,(cap.isie&&!cap.isie9)?"propertychange":"DOMAttrModified",self.onAttributeChange);
if(cap.isie9) self.win[0].attachEvent("onpropertychange",self.onAttributeChange);
self.bind(self.win,"DOMNodeRemoved",function(e){
if(e.target==self.win[0]) self.remove();
});
}}
if(!self.ispage&&self.opt.boxzoom) self.bind(window,"resize",self.resizeZoom);
if(self.istextarea) self.bind(self.win,"mouseup",self.lazyResize);
self.checkrtlmode=true;
self.lazyResize(30);
}
if(this.doc[0].nodeName=='IFRAME'){
function oniframeload(e){
self.iframexd=false;
try {
var doc='contentDocument' in this ? this.contentDocument:this.contentWindow.document;
var a=doc.domain;
} catch(e){self.iframexd=true;doc=false};
if(self.iframexd){
if("console" in window) console.log('NiceScroll error: policy restriced iframe');
return true;
}
self.forcescreen=true;
if(self.isiframe){
self.iframe={
"doc":$(doc),
"html":self.doc.contents().find('html')[0],
"body":self.doc.contents().find('body')[0]
};
self.getContentSize=function(){
return {
w:Math.max(self.iframe.html.scrollWidth,self.iframe.body.scrollWidth),
h:Math.max(self.iframe.html.scrollHeight,self.iframe.body.scrollHeight)
}}
self.docscroll=$(self.iframe.body);//$(this.contentWindow);
}
if(!cap.isios&&self.opt.iframeautoresize&&!self.isiframe){
self.win.scrollTop(0);
self.doc.height("");
var hh=Math.max(doc.getElementsByTagName('html')[0].scrollHeight,doc.body.scrollHeight);
self.doc.height(hh);
}
self.lazyResize(30);
if(cap.isie7) self.css($(self.iframe.html),{'overflow-y':'hidden'});
self.css($(self.iframe.body),{'overflow-y':'hidden'});
if(cap.isios&&self.haswrapper){
self.css($(doc.body),{'-webkit-transform':'translate3d(0,0,0)'});// avoid iFrame content clipping - thanks to http://blog.derraab.com/2012/04/02/avoid-iframe-content-clipping-with-css-transform-on-ios/
console.log(1);
}
if('contentWindow' in this){
self.bind(this.contentWindow,"scroll",self.onscroll);
}else{
self.bind(doc,"scroll",self.onscroll);
}
if(self.opt.enablemousewheel){
self.bind(doc,"mousewheel",self.onmousewheel);
}
if(self.opt.enablekeyboard) self.bind(doc,(cap.isopera)?"keypress":"keydown",self.onkeypress);
if(cap.cantouch||self.opt.touchbehavior){
self.bind(doc,"mousedown",self.ontouchstart);
self.bind(doc,"mousemove",function(e){self.ontouchmove(e,true)});
if(self.opt.grabcursorenabled&&cap.cursorgrabvalue) self.css($(doc.body),{'cursor':cap.cursorgrabvalue});
}
self.bind(doc,"mouseup",self.ontouchend);
if(self.zoom){
if(self.opt.dblclickzoom) self.bind(doc,'dblclick',self.doZoom);
if(self.ongesturezoom) self.bind(doc,"gestureend",self.ongesturezoom);
}};
if(this.doc[0].readyState&&this.doc[0].readyState=="complete"){
setTimeout(function(){oniframeload.call(self.doc[0],false)},500);
}
self.bind(this.doc,"load",oniframeload);
}};
this.showCursor=function(py,px){
if(self.cursortimeout){
clearTimeout(self.cursortimeout);
self.cursortimeout=0;
}
if(!self.rail) return;
if(self.autohidedom){
self.autohidedom.stop().css({opacity:self.opt.cursoropacitymax});
self.cursoractive=true;
}
if(!self.rail.drag||self.rail.drag.pt!=1){
if((typeof py!="undefined")&&(py!==false)){
self.scroll.y=Math.round(py * 1/self.scrollratio.y);
}
if(typeof px!="undefined"){
self.scroll.x=Math.round(px * 1/self.scrollratio.x);
}}
self.cursor.css({height:self.cursorheight,top:self.scroll.y});
if(self.cursorh){
(!self.rail.align&&self.rail.visibility) ? self.cursorh.css({width:self.cursorwidth,left:self.scroll.x+self.rail.width}):self.cursorh.css({width:self.cursorwidth,left:self.scroll.x});
self.cursoractive=true;
}
if(self.zoom) self.zoom.stop().css({opacity:self.opt.cursoropacitymax});
};
this.hideCursor=function(tm){
if(self.cursortimeout) return;
if(!self.rail) return;
if(!self.autohidedom) return;
self.cursortimeout=setTimeout(function(){
if(!self.rail.active||!self.showonmouseevent){
self.autohidedom.stop().animate({opacity:self.opt.cursoropacitymin});
if(self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
self.cursoractive=false;
}
self.cursortimeout=0;
},tm||self.opt.hidecursordelay);
};
this.noticeCursor=function(tm,py,px){
self.showCursor(py,px);
if(!self.rail.active) self.hideCursor(tm);
};
this.getContentSize =
(self.ispage) ?
function(){
return {
w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
}}
: (self.haswrapper) ?
function(){
return {
w:self.doc.outerWidth()+parseInt(self.win.css('paddingLeft'))+parseInt(self.win.css('paddingRight')),
h:self.doc.outerHeight()+parseInt(self.win.css('paddingTop'))+parseInt(self.win.css('paddingBottom'))
}}
: function(){
return {
w:self.docscroll[0].scrollWidth,
h:self.docscroll[0].scrollHeight
}};
this.onResize=function(e,page){
if(!self.win) return false;
if(!self.haswrapper&&!self.ispage){
if(self.win.css('display')=='none'){
if(self.visibility) self.hideRail().hideRailHr();
return false;
}else{
if(!self.hidden&&!self.visibility) self.showRail().showRailHr();
}}
var premaxh=self.page.maxh;
var premaxw=self.page.maxw;
var preview={h:self.view.h,w:self.view.w};
self.view={
w:(self.ispage) ? self.win.width():parseInt(self.win[0].clientWidth),
h:(self.ispage) ? self.win.height():parseInt(self.win[0].clientHeight)
};
self.page=(page) ? page:self.getContentSize();
self.page.maxh=Math.max(0,self.page.h - self.view.h);
self.page.maxw=Math.max(0,self.page.w - self.view.w);
if((self.page.maxh==premaxh)&&(self.page.maxw==premaxw)&&(self.view.w==preview.w)){
if(!self.ispage){
var pos=self.win.offset();
if(self.lastposition){
var lst=self.lastposition;
if((lst.top==pos.top)&&(lst.left==pos.left)) return self;
}
self.lastposition=pos;
}else{
return self;
}}
if(self.page.maxh==0){
self.hideRail();
self.scrollvaluemax=0;
self.scroll.y=0;
self.scrollratio.y=0;
self.cursorheight=0;
self.setScrollTop(0);
self.rail.scrollable=false;
}else{
self.rail.scrollable=true;
}
if(self.page.maxw==0){
self.hideRailHr();
self.scrollvaluemaxw=0;
self.scroll.x=0;
self.scrollratio.x=0;
self.cursorwidth=0;
self.setScrollLeft(0);
self.railh.scrollable=false;
}else{
self.railh.scrollable=true;
}
self.locked=(self.page.maxh==0)&&(self.page.maxw==0);
if(self.locked){
if(!self.ispage) self.updateScrollBar(self.view);
return false;
}
if(!self.hidden&&!self.visibility){
self.showRail().showRailHr();
}
else if(!self.hidden&&!self.railh.visibility) self.showRailHr();
if(self.istextarea&&self.win.css('resize')&&self.win.css('resize')!='none') self.view.h-=20;
self.cursorheight=Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
self.cursorheight=(self.opt.cursorfixedheight) ? self.opt.cursorfixedheight:Math.max(self.opt.cursorminheight,self.cursorheight);
self.cursorwidth=Math.min(self.view.w,Math.round(self.view.w * (self.view.w / self.page.w)));
self.cursorwidth=(self.opt.cursorfixedheight) ? self.opt.cursorfixedheight:Math.max(self.opt.cursorminheight,self.cursorwidth);
self.scrollvaluemax=self.view.h-self.cursorheight-self.cursor.hborder;
if(self.railh){
self.railh.width=(self.page.maxh>0) ? (self.view.w-self.rail.width):self.view.w;
self.scrollvaluemaxw=self.railh.width-self.cursorwidth-self.cursorh.wborder;
}
if(self.checkrtlmode&&self.railh){
self.checkrtlmode=false;
if(self.opt.rtlmode&&self.scroll.x==0) self.setScrollLeft(self.page.maxw);
}
if(!self.ispage) self.updateScrollBar(self.view);
self.scrollratio={
x:(self.page.maxw/self.scrollvaluemaxw),
y:(self.page.maxh/self.scrollvaluemax)
};
var sy=self.getScrollTop();
if(sy>self.page.maxh){
self.doScrollTop(self.page.maxh);
}else{
self.scroll.y=Math.round(self.getScrollTop() * (1/self.scrollratio.y));
self.scroll.x=Math.round(self.getScrollLeft() * (1/self.scrollratio.x));
if(self.cursoractive) self.noticeCursor();
}
if(self.scroll.y&&(self.getScrollTop()==0)) self.doScrollTo(Math.floor(self.scroll.y*self.scrollratio.y));
return self;
};
this.resize=self.onResize;
this.lazyResize=function(tm){
tm=(isNaN(tm)) ? 30:tm;
self.delayed('resize',self.resize,tm);
return self;
}
function _modernWheelEvent(dom,name,fn,bubble){
self._bind(dom,name,function(e){
var  e=(e) ? e:window.event;
var event={
original: e,
target: e.target||e.srcElement,
type: "wheel",
deltaMode: e.type=="MozMousePixelScroll" ? 0:1,
deltaX: 0,
deltaZ: 0,
preventDefault: function(){
e.preventDefault ? e.preventDefault():e.returnValue=false;
return false;
},
stopImmediatePropagation: function(){
(e.stopImmediatePropagation) ? e.stopImmediatePropagation():e.cancelBubble=true;
}};
if(name=="mousewheel"){
event.deltaY=- 1/40 * e.wheelDelta;
e.wheelDeltaX&&(event.deltaX=- 1/40 * e.wheelDeltaX);
}else{
event.deltaY=e.detail;
}
return fn.call(dom,event);
},bubble);
};
this._bind=function(el,name,fn,bubble){
self.events.push({e:el,n:name,f:fn,b:bubble,q:false});
if(el.addEventListener){
el.addEventListener(name,fn,bubble||false);
}
else if(el.attachEvent){
el.attachEvent("on"+name,fn);
}else{
el["on"+name]=fn;
}};
this.jqbind=function(dom,name,fn){
self.events.push({e:dom,n:name,f:fn,q:true});
$(dom).bind(name,fn);
}
this.bind=function(dom,name,fn,bubble){
var el=("jquery" in dom) ? dom[0]:dom;
if(name=='mousewheel'){
if("onwheel" in self.win){
self._bind(el,"wheel",fn,bubble||false);
}else{
var wname=(typeof document.onmousewheel!="undefined") ? "mousewheel":"DOMMouseScroll";
_modernWheelEvent(el,wname,fn,bubble||false);
if(wname=="DOMMouseScroll") _modernWheelEvent(el,"MozMousePixelScroll",fn,bubble||false);
}}
else if(el.addEventListener){
if(cap.cantouch&&/mouseup|mousedown|mousemove/.test(name)){
var tt=(name=='mousedown')?'touchstart':(name=='mouseup')?'touchend':'touchmove';
self._bind(el,tt,function(e){
if(e.touches){
if(e.touches.length<2){var ev=(e.touches.length)?e.touches[0]:e;ev.original=e;fn.call(this,ev);}}
else if(e.changedTouches){var ev=e.changedTouches[0];ev.original=e;fn.call(this,ev);}},bubble||false);
}
self._bind(el,name,fn,bubble||false);
if(cap.cantouch&&name=="mouseup") self._bind(el,"touchcancel",fn,bubble||false);
}else{
self._bind(el,name,function(e){
e=e||window.event||false;
if(e){
if(e.srcElement) e.target=e.srcElement;
}
if(!("pageY" in e)){
e.pageX=e.clientX + document.documentElement.scrollLeft;
e.pageY=e.clientY + document.documentElement.scrollTop;
}
return ((fn.call(el,e)===false)||bubble===false) ? self.cancelEvent(e):true;
});
}};
this._unbind=function(el,name,fn,bub){
if(el.removeEventListener){
el.removeEventListener(name,fn,bub);
}
else if(el.detachEvent){
el.detachEvent('on'+name,fn);
}else{
el['on'+name]=false;
}};
this.unbindAll=function(){
for(var a=0;a<self.events.length;a++){
var r=self.events[a];
(r.q) ? r.e.unbind(r.n,r.f):self._unbind(r.e,r.n,r.f,r.b);
}};
this.cancelEvent=function(e){
var e=(e.original) ? e.original:(e) ? e:window.event||false;
if(!e) return false;
if(e.preventDefault) e.preventDefault();
if(e.stopPropagation) e.stopPropagation();
if(e.preventManipulation) e.preventManipulation();
e.cancelBubble=true;
e.cancel=true;
e.returnValue=false;
return false;
};
this.stopPropagation=function(e){
var e=(e.original) ? e.original:(e) ? e:window.event||false;
if(!e) return false;
if(e.stopPropagation) return e.stopPropagation();
if(e.cancelBubble) e.cancelBubble=true;
return false;
}
this.showRail=function(){
if((self.page.maxh!=0)&&(self.ispage||self.win.css('display')!='none')){
self.visibility=true;
self.rail.visibility=true;
self.rail.css('display','block');
}
return self;
};
this.showRailHr=function(){
if(!self.railh) return self;
if((self.page.maxw!=0)&&(self.ispage||self.win.css('display')!='none')){
self.railh.visibility=true;
self.railh.css('display','block');
}
return self;
};
this.hideRail=function(){
self.visibility=false;
self.rail.visibility=false;
self.rail.css('display','none');
return self;
};
this.hideRailHr=function(){
if(!self.railh) return self;
self.railh.visibility=false;
self.railh.css('display','none');
return self;
};
this.show=function(){
self.hidden=false;
self.locked=false;
return self.showRail().showRailHr();
};
this.hide=function(){
self.hidden=true;
self.locked=true;
return self.hideRail().hideRailHr();
};
this.toggle=function(){
return (self.hidden) ? self.show():self.hide();
};
this.remove=function(){
self.stop();
if(self.cursortimeout) clearTimeout(self.cursortimeout);
self.doZoomOut();
self.unbindAll();
if(cap.isie9) self.win[0].detachEvent("onpropertychange",self.onAttributeChange);
if(self.observer!==false) self.observer.disconnect();
if(self.observerremover!==false) self.observerremover.disconnect();
self.events=null;
if(self.cursor){
self.cursor.remove();
}
if(self.cursorh){
self.cursorh.remove();
}
if(self.rail){
self.rail.remove();
}
if(self.railh){
self.railh.remove();
}
if(self.zoom){
self.zoom.remove();
}
for(var a=0;a<self.saved.css.length;a++){
var d=self.saved.css[a];
d[0].css(d[1],(typeof d[2]=="undefined") ? '':d[2]);
}
self.saved=false;
self.me.data('__nicescroll','');
var lst=$.nicescroll;
lst.each(function(i){
if(!this) return;
if(this.id===self.id){
delete lst[i];
for(var b=++i;b<lst.length;b++,i++) lst[i]=lst[b];
lst.length--;
if(lst.length) delete lst[lst.length];
}});
for (var i in self){
self[i]=null;
delete self[i];
}
self=null;
};
this.scrollstart=function(fn){
this.onscrollstart=fn;
return self;
}
this.scrollend=function(fn){
this.onscrollend=fn;
return self;
}
this.scrollcancel=function(fn){
this.onscrollcancel=fn;
return self;
}
this.zoomin=function(fn){
this.onzoomin=fn;
return self;
}
this.zoomout=function(fn){
this.onzoomout=fn;
return self;
}
this.isScrollable=function(e){
var dom=(e.target) ? e.target:e;
if(dom.nodeName=='OPTION') return true;
while (dom&&(dom.nodeType==1)&&!(/BODY|HTML/.test(dom.nodeName))){
var dd=$(dom);
var ov=dd.css('overflowY')||dd.css('overflowX')||dd.css('overflow')||'';
if(/scroll|auto/.test(ov)) return (dom.clientHeight!=dom.scrollHeight);
dom=(dom.parentNode) ? dom.parentNode:false;
}
return false;
};
this.getViewport=function(me){
var dom=(me&&me.parentNode) ? me.parentNode:false;
while (dom&&(dom.nodeType==1)&&!(/BODY|HTML/.test(dom.nodeName))){
var dd=$(dom);
var ov=dd.css('overflowY')||dd.css('overflowX')||dd.css('overflow')||'';
if((/scroll|auto/.test(ov))&&(dom.clientHeight!=dom.scrollHeight)) return dd;
if(dd.getNiceScroll().length>0) return dd;
dom=(dom.parentNode) ? dom.parentNode:false;
}
return false;
};
function execScrollWheel(e,hr,chkscroll){
var px,py;
var rt=1;
if(e.deltaMode==0){
px=-Math.floor(e.deltaX*(self.opt.mousescrollstep/(18*3)));
py=-Math.floor(e.deltaY*(self.opt.mousescrollstep/(18*3)));
}
else if(e.deltaMode==1){
px=-Math.floor(e.deltaX*self.opt.mousescrollstep);
py=-Math.floor(e.deltaY*self.opt.mousescrollstep);
}
if(hr&&self.opt.oneaxismousemode&&(px==0)&&py){
px=py;
py=0;
}
if(px){
if(self.scrollmom){self.scrollmom.stop()}
self.lastdeltax+=px;
self.debounced("mousewheelx",function(){var dt=self.lastdeltax;self.lastdeltax=0;if(!self.rail.drag){self.doScrollLeftBy(dt)}},120);
}
if(py){
if(self.opt.nativeparentscrolling&&chkscroll&&!self.ispage&&!self.zoomactive){
if(py<0){
if(self.getScrollTop()>=self.page.maxh) return true;
}else{
if(self.getScrollTop()<=0) return true;
}}
if(self.scrollmom){self.scrollmom.stop()}
self.lastdeltay+=py;
self.debounced("mousewheely",function(){var dt=self.lastdeltay;self.lastdeltay=0;if(!self.rail.drag){self.doScrollBy(dt)}},120);
}
e.stopImmediatePropagation();
return e.preventDefault();
};
this.onmousewheel=function(e){
if(self.locked){
self.debounced("checkunlock",self.resize,250);
return true;
}
if(self.rail.drag) return self.cancelEvent(e);
if(self.opt.oneaxismousemode=="auto"&&e.deltaX!=0) self.opt.oneaxismousemode=false;
if(self.opt.oneaxismousemode&&e.deltaX==0){
if(!self.rail.scrollable){
if(self.railh&&self.railh.scrollable){
return self.onmousewheelhr(e);
}else{
return true;
}}
}
var nw=+(new Date());
var chk=false;
if(self.opt.preservenativescrolling&&((self.checkarea+600)<nw)){
self.nativescrollingarea=self.isScrollable(e);
chk=true;
}
self.checkarea=nw;
if(self.nativescrollingarea) return true;
var ret=execScrollWheel(e,false,chk);
if(ret) self.checkarea=0;
return ret;
};
this.onmousewheelhr=function(e){
if(self.locked||!self.railh.scrollable) return true;
if(self.rail.drag) return self.cancelEvent(e);
var nw=+(new Date());
var chk=false;
if(self.opt.preservenativescrolling&&((self.checkarea+600)<nw)){
self.nativescrollingarea=self.isScrollable(e);
chk=true;
}
self.checkarea=nw;
if(self.nativescrollingarea) return true;
if(self.locked) return self.cancelEvent(e);
return execScrollWheel(e,true,chk);
};
this.stop=function(){
self.cancelScroll();
if(self.scrollmon) self.scrollmon.stop();
self.cursorfreezed=false;
self.scroll.y=Math.round(self.getScrollTop() * (1/self.scrollratio.y));
self.noticeCursor();
return self;
};
this.getTransitionSpeed=function(dif){
var sp=Math.round(self.opt.scrollspeed*10);
var ex=Math.min(sp,Math.round((dif / 20) * self.opt.scrollspeed));
return (ex>20) ? ex:0;
}
if(!self.opt.smoothscroll){
this.doScrollLeft=function(x,spd){
var y=self.getScrollTop();
self.doScrollPos(x,y,spd);
}
this.doScrollTop=function(y,spd){
var x=self.getScrollLeft();
self.doScrollPos(x,y,spd);
}
this.doScrollPos=function(x,y,spd){
var nx=(x>self.page.maxw) ? self.page.maxw:x;
if(nx<0) nx=0;
var ny=(y>self.page.maxh) ? self.page.maxh:y;
if(ny<0) ny=0;
self.synched('scroll',function(){
self.setScrollTop(ny);
self.setScrollLeft(nx);
});
}
this.cancelScroll=function(){};}
else if(self.ishwscroll&&cap.hastransition&&self.opt.usetransition){
this.prepareTransition=function(dif,istime){
var ex=(istime) ? ((dif>20)?dif:0):self.getTransitionSpeed(dif);
var trans=(ex) ? cap.prefixstyle+'transform '+ex+'ms ease-out':'';
if(!self.lasttransitionstyle||self.lasttransitionstyle!=trans){
self.lasttransitionstyle=trans;
self.doc.css(cap.transitionstyle,trans);
}
return ex;
};
this.doScrollLeft=function(x,spd){
var y=(self.scrollrunning) ? self.newscrolly:self.getScrollTop();
self.doScrollPos(x,y,spd);
}
this.doScrollTop=function(y,spd){
var x=(self.scrollrunning) ? self.newscrollx:self.getScrollLeft();
self.doScrollPos(x,y,spd);
}
this.doScrollPos=function(x,y,spd){
var py=self.getScrollTop();
var px=self.getScrollLeft();
if(((self.newscrolly-py)*(y-py)<0)||((self.newscrollx-px)*(x-px)<0)) self.cancelScroll();
if(self.opt.bouncescroll==false){
if(y<0) y=0;
else if(y>self.page.maxh) y=self.page.maxh;
if(x<0) x=0;
else if(x>self.page.maxw) x=self.page.maxw;
}
if(self.scrollrunning&&x==self.newscrollx&&y==self.newscrolly) return false;
self.newscrolly=y;
self.newscrollx=x;
self.newscrollspeed=spd||false;
if(self.timer) return false;
self.timer=setTimeout(function(){
var top=self.getScrollTop();
var lft=self.getScrollLeft();
var dst={};
dst.x=x-lft;
dst.y=y-top;
dst.px=lft;
dst.py=top;
var dd=Math.round(Math.sqrt(Math.pow(dst.x,2)+Math.pow(dst.y,2)));
var ms=(self.newscrollspeed&&self.newscrollspeed>1) ? self.newscrollspeed:self.getTransitionSpeed(dd);
if(self.newscrollspeed&&self.newscrollspeed<=1) ms*=self.newscrollspeed;
self.prepareTransition(ms,true);
if(self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
if(ms>0){
if(!self.scrollrunning&&self.onscrollstart){
var info={"type":"scrollstart","current":{"x":lft,"y":top},"request":{"x":x,"y":y},"end":{"x":self.newscrollx,"y":self.newscrolly},"speed":ms};
self.onscrollstart.call(self,info);
}
if(cap.transitionend){
if(!self.scrollendtrapped){
self.scrollendtrapped=true;
self.bind(self.doc,cap.transitionend,self.onScrollEnd,false);
}}else{
if(self.scrollendtrapped) clearTimeout(self.scrollendtrapped);
self.scrollendtrapped=setTimeout(self.onScrollEnd,ms);
}
var py=top;
var px=lft;
self.timerscroll={
bz: new BezierClass(py,self.newscrolly,ms,0,0,0.58,1),
bh: new BezierClass(px,self.newscrollx,ms,0,0,0.58,1)
};
if(!self.cursorfreezed) self.timerscroll.tm=setInterval(function(){self.showCursor(self.getScrollTop(),self.getScrollLeft())},60);
}
self.synched("doScroll-set",function(){
self.timer=0;
if(self.scrollendtrapped) self.scrollrunning=true;
self.setScrollTop(self.newscrolly);
self.setScrollLeft(self.newscrollx);
if(!self.scrollendtrapped) self.onScrollEnd();
});
},50);
};
this.cancelScroll=function(){
if(!self.scrollendtrapped) return true;
var py=self.getScrollTop();
var px=self.getScrollLeft();
self.scrollrunning=false;
if(!cap.transitionend) clearTimeout(cap.transitionend);
self.scrollendtrapped=false;
self._unbind(self.doc,cap.transitionend,self.onScrollEnd);
self.prepareTransition(0);
self.setScrollTop(py);
if(self.railh) self.setScrollLeft(px);
if(self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
self.timerscroll=false;
self.cursorfreezed=false;
self.showCursor(py,px);
return self;
};
this.onScrollEnd=function(){
if(self.scrollendtrapped) self._unbind(self.doc,cap.transitionend,self.onScrollEnd);
self.scrollendtrapped=false;
self.prepareTransition(0);
if(self.timerscroll&&self.timerscroll.tm) clearInterval(self.timerscroll.tm);
self.timerscroll=false;
var py=self.getScrollTop();
var px=self.getScrollLeft();
self.setScrollTop(py);
if(self.railh) self.setScrollLeft(px);
self.noticeCursor(false,py,px);
self.cursorfreezed=false;
if(py<0) py=0
else if(py>self.page.maxh) py=self.page.maxh;
if(px<0) px=0
else if(px>self.page.maxw) px=self.page.maxw;
if((py!=self.newscrolly)||(px!=self.newscrollx)) return self.doScrollPos(px,py,self.opt.snapbackspeed);
if(self.onscrollend&&self.scrollrunning){
var info={"type":"scrollend","current":{"x":px,"y":py},"end":{"x":self.newscrollx,"y":self.newscrolly}};
self.onscrollend.call(self,info);
}
self.scrollrunning=false;
};}else{
this.doScrollLeft=function(x,spd){
var y=(self.scrollrunning) ? self.newscrolly:self.getScrollTop();
self.doScrollPos(x,y,spd);
}
this.doScrollTop=function(y,spd){
var x=(self.scrollrunning) ? self.newscrollx:self.getScrollLeft();
self.doScrollPos(x,y,spd);
}
this.doScrollPos=function(x,y,spd){
var y=((typeof y=="undefined")||(y===false)) ? self.getScrollTop(true):y;
if((self.timer)&&(self.newscrolly==y)&&(self.newscrollx==x)) return true;
if(self.timer) clearAnimationFrame(self.timer);
self.timer=0;
var py=self.getScrollTop();
var px=self.getScrollLeft();
if(((self.newscrolly-py)*(y-py)<0)||((self.newscrollx-px)*(x-px)<0)) self.cancelScroll();
self.newscrolly=y;
self.newscrollx=x;
if(!self.bouncescroll||!self.rail.visibility){
if(self.newscrolly<0){
self.newscrolly=0;
}
else if(self.newscrolly>self.page.maxh){
self.newscrolly=self.page.maxh;
}}
if(!self.bouncescroll||!self.railh.visibility){
if(self.newscrollx<0){
self.newscrollx=0;
}
else if(self.newscrollx>self.page.maxw){
self.newscrollx=self.page.maxw;
}}
self.dst={};
self.dst.x=x-px;
self.dst.y=y-py;
self.dst.px=px;
self.dst.py=py;
var dst=Math.round(Math.sqrt(Math.pow(self.dst.x,2)+Math.pow(self.dst.y,2)));
self.dst.ax=self.dst.x / dst;
self.dst.ay=self.dst.y / dst;
var pa=0;
var pe=dst;
if(self.dst.x==0){
pa=py;
pe=y;
self.dst.ay=1;
self.dst.py=0;
}else if(self.dst.y==0){
pa=px;
pe=x;
self.dst.ax=1;
self.dst.px=0;
}
var ms=self.getTransitionSpeed(dst);
if(spd&&spd<=1) ms*=spd;
if(ms>0){
self.bzscroll=(self.bzscroll) ? self.bzscroll.update(pe,ms):new BezierClass(pa,pe,ms,0,1,0,1);
}else{
self.bzscroll=false;
}
if(self.timer) return;
if((py==self.page.maxh&&y>=self.page.maxh)||(px==self.page.maxw&&x>=self.page.maxw)) self.checkContentSize();
var sync=1;
function scrolling(){
if(self.cancelAnimationFrame) return true;
self.scrollrunning=true;
sync=1-sync;
if(sync) return (self.timer=setAnimationFrame(scrolling)||1);
var done=0;
var sc=sy=self.getScrollTop();
if(self.dst.ay){
sc=(self.bzscroll) ? self.dst.py + (self.bzscroll.getNow()*self.dst.ay):self.newscrolly;
var dr=sc-sy;
if((dr<0&&sc<self.newscrolly)||(dr>0&&sc>self.newscrolly)) sc=self.newscrolly;
self.setScrollTop(sc);
if(sc==self.newscrolly) done=1;
}else{
done=1;
}
var scx=sx=self.getScrollLeft();
if(self.dst.ax){
scx=(self.bzscroll) ? self.dst.px + (self.bzscroll.getNow()*self.dst.ax):self.newscrollx;
var dr=scx-sx;
if((dr<0&&scx<self.newscrollx)||(dr>0&&scx>self.newscrollx)) scx=self.newscrollx;
self.setScrollLeft(scx);
if(scx==self.newscrollx) done+=1;
}else{
done+=1;
}
if(done==2){
self.timer=0;
self.cursorfreezed=false;
self.bzscroll=false;
self.scrollrunning=false;
if(sc<0) sc=0;
else if(sc>self.page.maxh) sc=self.page.maxh;
if(scx<0) scx=0;
else if(scx>self.page.maxw) scx=self.page.maxw;
if((scx!=self.newscrollx)||(sc!=self.newscrolly)) self.doScrollPos(scx,sc);
else {
if(self.onscrollend){
var info={"type":"scrollend","current":{"x":sx,"y":sy},"end":{"x":self.newscrollx,"y":self.newscrolly}};
self.onscrollend.call(self,info);
}}
}else{
self.timer=setAnimationFrame(scrolling)||1;
}};
self.cancelAnimationFrame=false;
self.timer=1;
if(self.onscrollstart&&!self.scrollrunning){
var info={"type":"scrollstart","current":{"x":px,"y":py},"request":{"x":x,"y":y},"end":{"x":self.newscrollx,"y":self.newscrolly},"speed":ms};
self.onscrollstart.call(self,info);
}
scrolling();
if((py==self.page.maxh&&y>=py)||(px==self.page.maxw&&x>=px)) self.checkContentSize();
self.noticeCursor();
};
this.cancelScroll=function(){
if(self.timer) clearAnimationFrame(self.timer);
self.timer=0;
self.bzscroll=false;
self.scrollrunning=false;
return self;
};}
this.doScrollBy=function(stp,relative){
var ny=0;
if(relative){
ny=Math.floor((self.scroll.y-stp)*self.scrollratio.y)
}else{
var sy=(self.timer) ? self.newscrolly:self.getScrollTop(true);
ny=sy-stp;
}
if(self.bouncescroll){
var haf=Math.round(self.view.h/2);
if(ny<-haf) ny=-haf
else if(ny>(self.page.maxh+haf)) ny=(self.page.maxh+haf);
}
self.cursorfreezed=false;
py=self.getScrollTop(true);
if(ny<0&&py<=0) return self.noticeCursor();
else if(ny>self.page.maxh&&py>=self.page.maxh){
self.checkContentSize();
return self.noticeCursor();
}
self.doScrollTop(ny);
};
this.doScrollLeftBy=function(stp,relative){
var nx=0;
if(relative){
nx=Math.floor((self.scroll.x-stp)*self.scrollratio.x)
}else{
var sx=(self.timer) ? self.newscrollx:self.getScrollLeft(true);
nx=sx-stp;
}
if(self.bouncescroll){
var haf=Math.round(self.view.w/2);
if(nx<-haf) nx=-haf
else if(nx>(self.page.maxw+haf)) nx=(self.page.maxw+haf);
}
self.cursorfreezed=false;
px=self.getScrollLeft(true);
if(nx<0&&px<=0) return self.noticeCursor();
else if(nx>self.page.maxw&&px>=self.page.maxw) return self.noticeCursor();
self.doScrollLeft(nx);
};
this.doScrollTo=function(pos,relative){
var ny=(relative) ? Math.round(pos*self.scrollratio.y):pos;
if(ny<0) ny=0
else if(ny>self.page.maxh) ny=self.page.maxh;
self.cursorfreezed=false;
self.doScrollTop(pos);
};
this.checkContentSize=function(){
var pg=self.getContentSize();
if((pg.h!=self.page.h)||(pg.w!=self.page.w)) self.resize(false,pg);
};
self.onscroll=function(e){
if(self.rail.drag) return;
if(!self.cursorfreezed){
self.synched('scroll',function(){
self.scroll.y=Math.round(self.getScrollTop() * (1/self.scrollratio.y));
if(self.railh) self.scroll.x=Math.round(self.getScrollLeft() * (1/self.scrollratio.x));
self.noticeCursor();
});
}};
self.bind(self.docscroll,"scroll",self.onscroll);
this.doZoomIn=function(e){
if(self.zoomactive) return;
self.zoomactive=true;
self.zoomrestore={
style:{}};
var lst=['position','top','left','zIndex','backgroundColor','marginTop','marginBottom','marginLeft','marginRight'];
var win=self.win[0].style;
for(var a in lst){
var pp=lst[a];
self.zoomrestore.style[pp]=(typeof win[pp]!="undefined") ? win[pp]:'';
}
self.zoomrestore.style.width=self.win.css('width');
self.zoomrestore.style.height=self.win.css('height');
self.zoomrestore.padding={
w:self.win.outerWidth()-self.win.width(),
h:self.win.outerHeight()-self.win.height()
};
if(cap.isios4){
self.zoomrestore.scrollTop=$(window).scrollTop();
$(window).scrollTop(0);
}
self.win.css({
"position":(cap.isios4)?"absolute":"fixed",
"top":0,
"left":0,
"z-index":globalmaxzindex+100,
"margin":"0px"
});
var bkg=self.win.css("backgroundColor");
if(bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor","#fff");
self.rail.css({"z-index":globalmaxzindex+101});
self.zoom.css({"z-index":globalmaxzindex+102});
self.zoom.css('backgroundPosition','0px -18px');
self.resizeZoom();
if(self.onzoomin) self.onzoomin.call(self);
return self.cancelEvent(e);
};
this.doZoomOut=function(e){
if(!self.zoomactive) return;
self.zoomactive=false;
self.win.css("margin","");
self.win.css(self.zoomrestore.style);
if(cap.isios4){
$(window).scrollTop(self.zoomrestore.scrollTop);
}
self.rail.css({"z-index":self.zindex});
self.zoom.css({"z-index":self.zindex});
self.zoomrestore=false;
self.zoom.css('backgroundPosition','0px 0px');
self.onResize();
if(self.onzoomout) self.onzoomout.call(self);
return self.cancelEvent(e);
};
this.doZoom=function(e){
return (self.zoomactive) ? self.doZoomOut(e):self.doZoomIn(e);
};
this.resizeZoom=function(){
if(!self.zoomactive) return;
var py=self.getScrollTop();
self.win.css({
width:$(window).width()-self.zoomrestore.padding.w+"px",
height:$(window).height()-self.zoomrestore.padding.h+"px"
});
self.onResize();
self.setScrollTop(Math.min(self.page.maxh,py));
};
this.init();
$.nicescroll.push(this);
};
var ScrollMomentumClass2D=function(nc){
var self=this;
this.nc=nc;
this.lastx=0;
this.lasty=0;
this.speedx=0;
this.speedy=0;
this.lasttime=0;
this.steptime=0;
this.snapx=false;
this.snapy=false;
this.demulx=0;
this.demuly=0;
this.lastscrollx=-1;
this.lastscrolly=-1;
this.chkx=0;
this.chky=0;
this.timer=0;
this.time=function(){
return +new Date();
};
this.reset=function(px,py){
self.stop();
var now=self.time();
self.steptime=0;
self.lasttime=now;
self.speedx=0;
self.speedy=0;
self.lastx=px;
self.lasty=py;
self.lastscrollx=-1;
self.lastscrolly=-1;
};
this.update=function(px,py){
var now=self.time();
self.steptime=now - self.lasttime;
self.lasttime=now;
var dy=py - self.lasty;
var dx=px - self.lastx;
var sy=self.nc.getScrollTop();
var sx=self.nc.getScrollLeft();
var newy=sy + dy;
var newx=sx + dx;
self.snapx=(newx<0)||(newx>self.nc.page.maxw);
self.snapy=(newy<0)||(newy>self.nc.page.maxh);
self.speedx=dx;
self.speedy=dy;
self.lastx=px;
self.lasty=py;
};
this.stop=function(){
self.nc.unsynched("domomentum2d");
if(self.timer) clearTimeout(self.timer);
self.timer=0;
self.lastscrollx=-1;
self.lastscrolly=-1;
};
this.doSnapy=function(nx,ny){
var snap=false;
if(ny<0){
ny=0;
snap=true;
}
else if(ny>self.nc.page.maxh){
ny=self.nc.page.maxh;
snap=true;
}
if(nx<0){
nx=0;
snap=true;
}
else if(nx>self.nc.page.maxw){
nx=self.nc.page.maxw;
snap=true;
}
if(snap) self.nc.doScrollPos(nx,ny,self.nc.opt.snapbackspeed);
};
this.doMomentum=function(gp){
var t=self.time();
var l=(gp) ? t+gp:self.lasttime;
var sl=self.nc.getScrollLeft();
var st=self.nc.getScrollTop();
var pageh=self.nc.page.maxh;
var pagew=self.nc.page.maxw;
self.speedx=(pagew>0) ? Math.min(60,self.speedx):0;
self.speedy=(pageh>0) ? Math.min(60,self.speedy):0;
var chk=l&&(t - l) <=60;
if((st<0)||(st>pageh)||(sl<0)||(sl>pagew)) chk=false;
var sy=(self.speedy&&chk) ? self.speedy:false;
var sx=(self.speedx&&chk) ? self.speedx:false;
if(sy||sx){
var tm=Math.max(16,self.steptime);
if(tm>50){
var xm=tm/50;
self.speedx*=xm;
self.speedy*=xm;
tm=50;
}
self.demulxy=0;
self.lastscrollx=self.nc.getScrollLeft();
self.chkx=self.lastscrollx;
self.lastscrolly=self.nc.getScrollTop();
self.chky=self.lastscrolly;
var nx=self.lastscrollx;
var ny=self.lastscrolly;
var onscroll=function(){
var df=((self.time()-t)>600) ? 0.04:0.02;
if(self.speedx){
nx=Math.floor(self.lastscrollx - (self.speedx*(1-self.demulxy)));
self.lastscrollx=nx;
if((nx<0)||(nx>pagew)) df=0.10;
}
if(self.speedy){
ny=Math.floor(self.lastscrolly - (self.speedy*(1-self.demulxy)));
self.lastscrolly=ny;
if((ny<0)||(ny>pageh)) df=0.10;
}
self.demulxy=Math.min(1,self.demulxy+df);
self.nc.synched("domomentum2d",function(){
if(self.speedx){
var scx=self.nc.getScrollLeft();
if(scx!=self.chkx) self.stop();
self.chkx=nx;
self.nc.setScrollLeft(nx);
}
if(self.speedy){
var scy=self.nc.getScrollTop();
if(scy!=self.chky) self.stop();
self.chky=ny;
self.nc.setScrollTop(ny);
}
if(!self.timer){
self.nc.hideCursor();
self.doSnapy(nx,ny);
}});
if(self.demulxy<1){
self.timer=setTimeout(onscroll,tm);
}else{
self.stop();
self.nc.hideCursor();
self.doSnapy(nx,ny);
}};
onscroll();
}else{
self.doSnapy(self.nc.getScrollLeft(),self.nc.getScrollTop());
}}
};
var _scrollTop=jQuery.fn.scrollTop;
jQuery.cssHooks["pageYOffset"]={
get: function(elem,computed,extra){
var nice=$.data(elem,'__nicescroll')||false;
return (nice&&nice.ishwscroll) ? nice.getScrollTop():_scrollTop.call(elem);
},
set: function(elem,value){
var nice=$.data(elem,'__nicescroll')||false;
(nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)):_scrollTop.call(elem,value);
return this;
}};
/*
$.fx.step["scrollTop"]=function(fx){
$.cssHooks["scrollTop"].set(fx.elem, fx.now + fx.unit);
};
*/
jQuery.fn.scrollTop=function(value){
if(typeof value=="undefined"){
var nice=(this[0]) ? $.data(this[0],'__nicescroll')||false:false;
return (nice&&nice.ishwscroll) ? nice.getScrollTop():_scrollTop.call(this);
}else{
return this.each(function(){
var nice=$.data(this,'__nicescroll')||false;
(nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)):_scrollTop.call($(this),value);
});
}}
var _scrollLeft=jQuery.fn.scrollLeft;
$.cssHooks.pageXOffset={
get: function(elem,computed,extra){
var nice=$.data(elem,'__nicescroll')||false;
return (nice&&nice.ishwscroll) ? nice.getScrollLeft():_scrollLeft.call(elem);
},
set: function(elem,value){
var nice=$.data(elem,'__nicescroll')||false;
(nice&&nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)):_scrollLeft.call(elem,value);
return this;
}};
/*
$.fx.step["scrollLeft"]=function(fx){
$.cssHooks["scrollLeft"].set(fx.elem, fx.now + fx.unit);
};
*/
jQuery.fn.scrollLeft=function(value){
if(typeof value=="undefined"){
var nice=(this[0]) ? $.data(this[0],'__nicescroll')||false:false;
return (nice&&nice.ishwscroll) ? nice.getScrollLeft():_scrollLeft.call(this);
}else{
return this.each(function(){
var nice=$.data(this,'__nicescroll')||false;
(nice&&nice.ishwscroll) ? nice.setScrollLeft(parseInt(value)):_scrollLeft.call($(this),value);
});
}}
var NiceScrollArray=function(doms){
var self=this;
this.length=0;
this.name="nicescrollarray";
this.each=function(fn){
for(var a=0,i=0;a<self.length;a++) fn.call(self[a],i++);
return self;
};
this.push=function(nice){
self[self.length]=nice;
self.length++;
};
this.eq=function(idx){
return self[idx];
};
if(doms){
for(a=0;a<doms.length;a++){
var nice=$.data(doms[a],'__nicescroll')||false;
if(nice){
this[this.length]=nice;
this.length++;
}};}
return this;
};
function mplex(el,lst,fn){
for(var a=0;a<lst.length;a++) fn(el,lst[a]);
};
mplex(
NiceScrollArray.prototype,
['show','hide','toggle','onResize','resize','remove','stop','doScrollPos'],
function(e,n){
e[n]=function(){
var args=arguments;
return this.each(function(){
this[n].apply(this,args);
});
};}
);
jQuery.fn.getNiceScroll=function(index){
if(typeof index=="undefined"){
return new NiceScrollArray(this);
}else{
var nice=this[index]&&$.data(this[index],'__nicescroll')||false;
return nice;
}};
jQuery.extend(jQuery.expr[':'], {
nicescroll: function(a){
return ($.data(a,'__nicescroll'))?true:false;
}});
$.fn.niceScroll=function(wrapper,opt){
if(typeof opt=="undefined"){
if((typeof wrapper=="object")&&!("jquery" in wrapper)){
opt=wrapper;
wrapper=false;
}}
var ret=new NiceScrollArray();
if(typeof opt=="undefined") opt={};
if(wrapper||false){
opt.doc=$(wrapper);
opt.win=$(this);
}
var docundef = !("doc" in opt);
if(!docundef&&!("win" in opt)) opt.win=$(this);
this.each(function(){
var nice=$(this).data('__nicescroll')||false;
if(!nice){
opt.doc=(docundef) ? $(this):opt.doc;
nice=new NiceScrollClass(opt,$(this));
$(this).data('__nicescroll',nice);
}
ret.push(nice);
});
return (ret.length==1) ? ret[0]:ret;
};
window.NiceScroll={
getjQuery:function(){return jQuery}};
if(!$.nicescroll){
$.nicescroll=new NiceScrollArray();
$.nicescroll.options=_globaloptions;
}})(jQuery);
(function (global, factory){
typeof exports==='object'&&typeof module!=='undefined' ? module.exports=factory() :
typeof define==='function'&&define.amd ? define(factory) :
(global.retinajs=factory());
}(this, (function (){ 'use strict';
var hasWindow=typeof window!=='undefined';
var environment=Math.round(hasWindow ? window.devicePixelRatio||1:1);
var srcReplace=/(\.[A-z]{3,4}\/?(\?.*)?)$/;
var inlineReplace=/url\(('|")?([^)'"]+)('|")?\)/i;
var selector='[data-rjs]';
var processedAttr='data-rjs-processed';
function arrayify(object){
return Array.prototype.slice.call(object);
}
function chooseCap(cap){
var numericCap=parseInt(cap, 10);
if(environment < numericCap){
return environment;
}else{
return numericCap;
}}
function forceOriginalDimensions(image){
if(!image.hasAttribute('data-no-resize')){
if(image.offsetWidth===0&&image.offsetHeight===0){
image.setAttribute('width', image.naturalWidth);
image.setAttribute('height', image.naturalHeight);
}else{
image.setAttribute('width', image.offsetWidth);
image.setAttribute('height', image.offsetHeight);
}}
return image;
}
function setSourceIfAvailable(image, retinaURL){
var imgType=image.nodeName.toLowerCase();
var testImage=document.createElement('img');
testImage.addEventListener('load', function (){
if(imgType==='img'){
forceOriginalDimensions(image).setAttribute('src', retinaURL);
}else{
image.style.backgroundImage='url(' + retinaURL + ')';
}});
testImage.setAttribute('src', retinaURL);
image.setAttribute(processedAttr, true);
}
function dynamicSwapImage(image, src){
var rjs=arguments.length > 2&&arguments[2]!==undefined ? arguments[2]:1;
var cap=chooseCap(rjs);
if(src&&cap > 1){
var newSrc=src.replace(srcReplace, '@' + cap + 'x$1');
setSourceIfAvailable(image, newSrc);
}}
function manualSwapImage(image, src, hdsrc){
if(environment > 1){
setSourceIfAvailable(image, hdsrc);
}}
function getImages(images){
if(!images){
return typeof document!=='undefined' ? arrayify(document.querySelectorAll(selector)):[];
}else{
return typeof images.forEach==='function' ? images:arrayify(images);
}}
function cleanBgImg(img){
return img.style.backgroundImage.replace(inlineReplace, '$2');
}
function retina(images){
getImages(images).forEach(function (img){
if(!img.getAttribute(processedAttr)){
var isImg=img.nodeName.toLowerCase()==='img';
var src=isImg ? img.getAttribute('src'):cleanBgImg(img);
var rjs=img.getAttribute('data-rjs');
var rjsIsNumber = !isNaN(parseInt(rjs, 10));
if(rjs===null){
return;
}
if(rjsIsNumber){
dynamicSwapImage(img, src, rjs);
}else{
manualSwapImage(img, src, rjs);
}}
});
}
if(hasWindow){
window.addEventListener('load', function (){
retina();
});
window.retinajs=retina;
}
return retina;
})));
;(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e,t){"use strict";e.infinitescroll=function(n,r,i){this.element=e(i);if(!this._create(n,r)){this.failed=true}};e.infinitescroll.defaults={loading:{finished:t,finishedMsg:"<em>Congratulations, you've reached the end of the internet.</em>",img:"data:image/gif;base64,R0lGODlh3AATAPQeAPDy+MnQ6LW/4N3h8MzT6rjC4sTM5r/I5NHX7N7j8c7U6tvg8OLl8uXo9Ojr9b3G5MfP6Ovu9tPZ7PT1+vX2+tbb7vf4+8/W69jd7rC73vn5/O/x+K243ai02////wAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQECgD/ACwAAAAA3AATAAAF/6AnjmRpnmiqr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0ZsgjZg+oPQLi7dUcNXi0LOJw1pgNtB7XG6CBy+U75SYfPTSQAgZTNUDnQHt67wnbZyvwLgKiMN3oCZB3C76tdewpLFgIP2C88rbi4Y+QT3+8S5USMICZXWj1pkEDeUU3lOYGB3alSoEiMIjgX4WlgNF2EibIwQIXauWXSRg2SAOHIU5IIIMoZkhhWiJaiFVbKo6AQEgQXrTAazO1JhkBrBG3Y2Y6EsUhaGn95hprSN0oWpFE7rhkeaQBchGOEWnwEmc0uKWZj0LeuNV3W4Y2lZHFlQCSRjTIl8uZ+kG5HU/3sRlnTG2ytyadytnD3HrmuRcSn+0h1dycexIK1KCjYaCnjCCVqOFFJTZ5GkUUjESWaUIKU2lgCmAKKQIUjHapXRKE+t2og1VgankNYnohqKJ2CmKplso6GKz7WYCgqxeuyoF8u9IQAgA7",msg:null,msgText:"<em>Loading the next set of posts...</em>",selector:null,speed:"fast",start:t},state:{isDuringAjax:false,isInvalidPage:false,isDestroyed:false,isDone:false,isPaused:false,isBeyondMaxPage:false,currPage:1},debug:false,behavior:t,binder:e(window),nextSelector:"div.navigation a:first",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:t,dataType:"html",appendCallback:true,bufferPx:40,errorCallback:function(){},infid:0,pixelsFromNavToBottom:t,path:t,prefill:false,maxPage:t};e.infinitescroll.prototype={_binding:function(n){var r=this,i=r.options;i.v="2.0b2.120520";if(!!i.behavior&&this["_binding_"+i.behavior]!==t){this["_binding_"+i.behavior].call(this);return}if(n!=="bind"&&n!=="unbind"){this._debug("Binding value  "+n+" not valid");return false}if(n==="unbind"){this.options.binder.unbind("smartscroll.infscr."+r.options.infid)}else{this.options.binder[n]("smartscroll.infscr."+r.options.infid,function(){r.scroll()})}this._debug("Binding",n)},_create:function(r,i){var s=e.extend(true,{},e.infinitescroll.defaults,r);this.options=s;var o=e(window);var u=this;if(!u._validate(r)){return false}var a=e(s.nextSelector).attr("href");if(!a){this._debug("Navigation selector not found");return false}s.path=s.path||this._determinepath(a);s.contentSelector=s.contentSelector||this.element;s.loading.selector=s.loading.selector||s.contentSelector;s.loading.msg=s.loading.msg||e('<div id="infscr-loading"><img alt="Loading..." src="'+s.loading.img+'" /><div>'+s.loading.msgText+"</div></div>");(new Image).src=s.loading.img;if(s.pixelsFromNavToBottom===t){s.pixelsFromNavToBottom=e(document).height()-e(s.navSelector).offset().top;this._debug("pixelsFromNavToBottom: "+s.pixelsFromNavToBottom)}var f=this;s.loading.start=s.loading.start||function(){e(s.navSelector).hide();s.loading.msg.appendTo(s.loading.selector).show(s.loading.speed,e.proxy(function(){this.beginAjax(s)},f))};s.loading.finished=s.loading.finished||function(){if(!s.state.isBeyondMaxPage)s.loading.msg.fadeOut(s.loading.speed)};s.callback=function(n,r,u){if(!!s.behavior&&n["_callback_"+s.behavior]!==t){n["_callback_"+s.behavior].call(e(s.contentSelector)[0],r,u)}if(i){i.call(e(s.contentSelector)[0],r,s,u)}if(s.prefill){o.bind("resize.infinite-scroll",n._prefill)}};if(r.debug){if(Function.prototype.bind&&(typeof console==="object"||typeof console==="function")&&typeof console.log==="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.call(console[e],console)},Function.prototype.bind)}}this._setup();if(s.prefill){this._prefill()}return true},_prefill:function(){function i(){return e(n.options.contentSelector).height()<=r.height()}var n=this;var r=e(window);this._prefill=function(){if(i()){n.scroll()}r.bind("resize.infinite-scroll",function(){if(i()){r.unbind("resize.infinite-scroll");n.scroll()}})};this._prefill()},_debug:function(){if(true!==this.options.debug){return}if(typeof console!=="undefined"&&typeof console.log==="function"){if(Array.prototype.slice.call(arguments).length===1&&typeof Array.prototype.slice.call(arguments)[0]==="string"){console.log(Array.prototype.slice.call(arguments).toString())}else{console.log(Array.prototype.slice.call(arguments))}}else if(!Function.prototype.bind&&typeof console!=="undefined"&&typeof console.log==="object"){Function.prototype.call.call(console.log,console,Array.prototype.slice.call(arguments))}},_determinepath:function(n){var r=this.options;if(!!r.behavior&&this["_determinepath_"+r.behavior]!==t){return this["_determinepath_"+r.behavior].call(this,n)}if(!!r.pathParse){this._debug("pathParse manual");return r.pathParse(n,this.options.state.currPage+1)}else if(n.match(/^(.*?)\b2\b(.*?$)/)){n=n.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else if(n.match(/^(.*?)2(.*?$)/)){if(n.match(/^(.*?page=)2(\/.*|$)/)){n=n.match(/^(.*?page=)2(\/.*|$)/).slice(1);return n}n=n.match(/^(.*?)2(.*?$)/).slice(1)}else{if(n.match(/^(.*?page=)1(\/.*|$)/)){n=n.match(/^(.*?page=)1(\/.*|$)/).slice(1);return n}else{this._debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");r.state.isInvalidPage=true}}this._debug("determinePath",n);return n},_error:function(n){var r=this.options;if(!!r.behavior&&this["_error_"+r.behavior]!==t){this["_error_"+r.behavior].call(this,n);return}if(n!=="destroy"&&n!=="end"){n="unknown"}this._debug("Error",n);if(n==="end"||r.state.isBeyondMaxPage){this._showdonemsg()}r.state.isDone=true;r.state.currPage=1;r.state.isPaused=false;r.state.isBeyondMaxPage=false;this._binding("unbind")},_loadcallback:function(r,i,s){var o=this.options,u=this.options.callback,a=o.state.isDone?"done":!o.appendCallback?"no-append":"append",f;if(!!o.behavior&&this["_loadcallback_"+o.behavior]!==t){this["_loadcallback_"+o.behavior].call(this,r,i);return}switch(a){case"done":this._showdonemsg();return false;case"no-append":if(o.dataType==="html"){i="<div>"+i+"</div>";i=e(i).find(o.itemSelector)}if(i.length===0){return this._error("end")}break;case"append":var l=r.children();if(l.length===0){return this._error("end")}f=document.createDocumentFragment();while(r[0].firstChild){f.appendChild(r[0].firstChild)}this._debug("contentSelector",e(o.contentSelector)[0]);e(o.contentSelector)[0].appendChild(f);i=l.get();break}o.loading.finished.call(e(o.contentSelector)[0],o);if(o.animate){var c=e(window).scrollTop()+e(o.loading.msg).height()+o.extraScrollPx+"px";e("html,body").animate({scrollTop:c},800,function(){o.state.isDuringAjax=false})}if(!o.animate){o.state.isDuringAjax=false}u(this,i,s);if(o.prefill){this._prefill()}},_nearbottom:function(){var r=this.options,i=0+e(document).height()-r.binder.scrollTop()-e(window).height();if(!!r.behavior&&this["_nearbottom_"+r.behavior]!==t){return this["_nearbottom_"+r.behavior].call(this)}this._debug("math:",i,r.pixelsFromNavToBottom);return i-r.bufferPx<r.pixelsFromNavToBottom},_pausing:function(n){var r=this.options;if(!!r.behavior&&this["_pausing_"+r.behavior]!==t){this["_pausing_"+r.behavior].call(this,n);return}if(n!=="pause"&&n!=="resume"&&n!==null){this._debug("Invalid argument. Toggling pause value instead")}n=n&&(n==="pause"||n==="resume")?n:"toggle";switch(n){case"pause":r.state.isPaused=true;break;case"resume":r.state.isPaused=false;break;case"toggle":r.state.isPaused=!r.state.isPaused;break}this._debug("Paused",r.state.isPaused);return false},_setup:function(){var n=this.options;if(!!n.behavior&&this["_setup_"+n.behavior]!==t){this["_setup_"+n.behavior].call(this);return}this._binding("bind");return false},_showdonemsg:function(){var r=this.options;if(!!r.behavior&&this["_showdonemsg_"+r.behavior]!==t){this["_showdonemsg_"+r.behavior].call(this);return}r.loading.msg.find("img").hide().parent().find("div").html(r.loading.finishedMsg).animate({opacity:1},2e3,function(){e(this).parent().fadeOut(r.loading.speed)});r.errorCallback.call(e(r.contentSelector)[0],"done")},_validate:function(n){for(var r in n){if(r.indexOf&&r.indexOf("Selector")>-1&&e(n[r]).length===0){this._debug("Your "+r+" found no elements.");return false}}return true},bind:function(){this._binding("bind")},destroy:function(){this.options.state.isDestroyed=true;this.options.loading.finished();return this._error("destroy")},pause:function(){this._pausing("pause")},resume:function(){this._pausing("resume")},beginAjax:function(r){var i=this,s=r.path,o,u,a,f;r.state.currPage++;if(r.maxPage!==t&&r.state.currPage>r.maxPage){r.state.isBeyondMaxPage=true;this.destroy();return}o=e(r.contentSelector).is("table, tbody")?e("<tbody/>"):e("<div/>");u=typeof s==="function"?s(r.state.currPage):s.join(r.state.currPage);i._debug("heading into ajax",u);a=r.dataType==="html"||r.dataType==="json"?r.dataType:"html+callback";if(r.appendCallback&&r.dataType==="html"){a+="+callback"}switch(a){case"html+callback":i._debug("Using HTML via .load() method");o.load(u+" "+r.itemSelector,t,function(t){i._loadcallback(o,t,u)});break;case"html":i._debug("Using "+a.toUpperCase()+" via $.ajax() method");e.ajax({url:u,dataType:r.dataType,complete:function(t,n){f=typeof t.isResolved!=="undefined"?t.isResolved():n==="success"||n==="notmodified";if(f){i._loadcallback(o,t.responseText,u)}else{i._error("end")}}});break;case"json":i._debug("Using "+a.toUpperCase()+" via $.ajax() method");e.ajax({dataType:"json",type:"GET",url:u,success:function(e,n,s){f=typeof s.isResolved!=="undefined"?s.isResolved():n==="success"||n==="notmodified";if(r.appendCallback){if(r.template!==t){var a=r.template(e);o.append(a);if(f){i._loadcallback(o,a)}else{i._error("end")}}else{i._debug("template must be defined.");i._error("end")}}else{if(f){i._loadcallback(o,e,u)}else{i._error("end")}}},error:function(){i._debug("JSON ajax request failed.");i._error("end")}});break}},retrieve:function(r){r=r||null;var i=this,s=i.options;if(!!s.behavior&&this["retrieve_"+s.behavior]!==t){this["retrieve_"+s.behavior].call(this,r);return}if(s.state.isDestroyed){this._debug("Instance is destroyed");return false}s.state.isDuringAjax=true;s.loading.start.call(e(s.contentSelector)[0],s)},scroll:function(){var n=this.options,r=n.state;if(!!n.behavior&&this["scroll_"+n.behavior]!==t){this["scroll_"+n.behavior].call(this);return}if(r.isDuringAjax||r.isInvalidPage||r.isDone||r.isDestroyed||r.isPaused){return}if(!this._nearbottom()){return}this.retrieve()},toggle:function(){this._pausing()},unbind:function(){this._binding("unbind")},update:function(n){if(e.isPlainObject(n)){this.options=e.extend(true,this.options,n)}}};e.fn.infinitescroll=function(n,r){var i=typeof n;switch(i){case"string":var s=Array.prototype.slice.call(arguments,1);this.each(function(){var t=e.data(this,"infinitescroll");if(!t){return false}if(!e.isFunction(t[n])||n.charAt(0)==="_"){return false}t[n].apply(t,s)});break;case"object":this.each(function(){var t=e.data(this,"infinitescroll");if(t){t.update(n)}else{t=new e.infinitescroll(n,r,this);if(!t.failed){e.data(this,"infinitescroll",t)}}});break}return this};var n=e.event,r;n.special.smartscroll={setup:function(){e(this).bind("scroll",n.special.smartscroll.handler)},teardown:function(){e(this).unbind("scroll",n.special.smartscroll.handler)},handler:function(t,n){var i=this,s=arguments;t.type="smartscroll";if(r){clearTimeout(r)}r=setTimeout(function(){e(i).trigger("smartscroll",s)},n==="execAsap"?0:100)}};e.fn.smartscroll=function(e){return e?this.bind("smartscroll",e):this.trigger("smartscroll",["execAsap"])}});
window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode&&"a"!==E.activeElement.tagName.toLowerCase())return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o<i;o++)(n=d[o]).addEventListener("touchstart",a),n.addEventListener("click",a)}}function l(e){var t,n,d=g(b.temporaryFormId);d&&h&&(g(b.parentIdFieldId).value="0",t=d.textContent,d.parentNode.replaceChild(h,d),this.style.display="none",n=(d=(d=g(b.commentReplyTitleId))&&d.firstChild)&&d.nextSibling,d&&d.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),d.textContent=t),e.preventDefault())}function a(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,d=m(n,"belowelement"),o=m(n,"commentid"),i=m(n,"respondelement"),r=m(n,"postid"),n=m(n,"replyto")||t;d&&o&&i&&r&&!1===v.addComment.moveForm(d,o,i,r,n)&&e.preventDefault()}function o(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void d()}function m(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return r&&"loading"!==E.readyState?t():r&&v.addEventListener("DOMContentLoaded",t,!1),{init:d,moveForm:function(e,t,n,d,o){var i,r,l,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===o&&(o=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),d&&y&&(y.value=d),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=o),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],r=!1,"getComputedStyle"in v?l=v.getComputedStyle(i):E.documentElement.currentStyle&&(l=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===l.visibility)&&(r=!0),"hidden"!==i.type&&!i.disabled&&!r){i.focus();break}}catch(e){}return!1}}}}(window);
(function(window, document){
'use strict';
if('IntersectionObserver' in window &&
'IntersectionObserverEntry' in window &&
'intersectionRatio' in window.IntersectionObserverEntry.prototype){
if(!('isIntersecting' in window.IntersectionObserverEntry.prototype)){
Object.defineProperty(window.IntersectionObserverEntry.prototype,
'isIntersecting', {
get: function (){
return this.intersectionRatio > 0;
}});
}
return;
}
var registry=[];
function IntersectionObserverEntry(entry){
this.time=entry.time;
this.target=entry.target;
this.rootBounds=entry.rootBounds;
this.boundingClientRect=entry.boundingClientRect;
this.intersectionRect=entry.intersectionRect||getEmptyRect();
this.isIntersecting = !!entry.intersectionRect;
var targetRect=this.boundingClientRect;
var targetArea=targetRect.width * targetRect.height;
var intersectionRect=this.intersectionRect;
var intersectionArea=intersectionRect.width * intersectionRect.height;
if(targetArea){
this.intersectionRatio=Number((intersectionArea / targetArea).toFixed(4));
}else{
this.intersectionRatio=this.isIntersecting ? 1:0;
}}
function IntersectionObserver(callback, opt_options){
var options=opt_options||{};
if(typeof callback!='function'){
throw new Error('callback must be a function');
}
if(options.root&&options.root.nodeType!=1){
throw new Error('root must be an Element');
}
this._checkForIntersections=throttle(
this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
this._callback=callback;
this._observationTargets=[];
this._queuedEntries=[];
this._rootMarginValues=this._parseRootMargin(options.rootMargin);
this.thresholds=this._initThresholds(options.threshold);
this.root=options.root||null;
this.rootMargin=this._rootMarginValues.map(function(margin){
return margin.value + margin.unit;
}).join(' ');
}
IntersectionObserver.prototype.THROTTLE_TIMEOUT=100;
IntersectionObserver.prototype.POLL_INTERVAL=null;
IntersectionObserver.prototype.USE_MUTATION_OBSERVER=true;
IntersectionObserver.prototype.observe=function(target){
var isTargetAlreadyObserved=this._observationTargets.some(function(item){
return item.element==target;
});
if(isTargetAlreadyObserved){
return;
}
if(!(target&&target.nodeType==1)){
throw new Error('target must be an Element');
}
this._registerInstance();
this._observationTargets.push({element: target, entry: null});
this._monitorIntersections();
this._checkForIntersections();
};
IntersectionObserver.prototype.unobserve=function(target){
this._observationTargets =
this._observationTargets.filter(function(item){
return item.element!=target;
});
if(!this._observationTargets.length){
this._unmonitorIntersections();
this._unregisterInstance();
}};
IntersectionObserver.prototype.disconnect=function(){
this._observationTargets=[];
this._unmonitorIntersections();
this._unregisterInstance();
};
IntersectionObserver.prototype.takeRecords=function(){
var records=this._queuedEntries.slice();
this._queuedEntries=[];
return records;
};
IntersectionObserver.prototype._initThresholds=function(opt_threshold){
var threshold=opt_threshold||[0];
if(!Array.isArray(threshold)) threshold=[threshold];
return threshold.sort().filter(function(t, i, a){
if(typeof t!='number'||isNaN(t)||t < 0||t > 1){
throw new Error('threshold must be a number between 0 and 1 inclusively');
}
return t!==a[i - 1];
});
};
IntersectionObserver.prototype._parseRootMargin=function(opt_rootMargin){
var marginString=opt_rootMargin||'0px';
var margins=marginString.split(/\s+/).map(function(margin){
var parts=/^(-?\d*\.?\d+)(px|%)$/.exec(margin);
if(!parts){
throw new Error('rootMargin must be specified in pixels or percent');
}
return {value: parseFloat(parts[1]), unit: parts[2]};});
margins[1]=margins[1]||margins[0];
margins[2]=margins[2]||margins[0];
margins[3]=margins[3]||margins[1];
return margins;
};
IntersectionObserver.prototype._monitorIntersections=function(){
if(!this._monitoringIntersections){
this._monitoringIntersections=true;
if(this.POLL_INTERVAL){
this._monitoringInterval=setInterval(
this._checkForIntersections, this.POLL_INTERVAL);
}else{
addEvent(window, 'resize', this._checkForIntersections, true);
addEvent(document, 'scroll', this._checkForIntersections, true);
if(this.USE_MUTATION_OBSERVER&&'MutationObserver' in window){
this._domObserver=new MutationObserver(this._checkForIntersections);
this._domObserver.observe(document, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
}}
}};
IntersectionObserver.prototype._unmonitorIntersections=function(){
if(this._monitoringIntersections){
this._monitoringIntersections=false;
clearInterval(this._monitoringInterval);
this._monitoringInterval=null;
removeEvent(window, 'resize', this._checkForIntersections, true);
removeEvent(document, 'scroll', this._checkForIntersections, true);
if(this._domObserver){
this._domObserver.disconnect();
this._domObserver=null;
}}
};
IntersectionObserver.prototype._checkForIntersections=function(){
var rootIsInDom=this._rootIsInDom();
var rootRect=rootIsInDom ? this._getRootRect():getEmptyRect();
this._observationTargets.forEach(function(item){
var target=item.element;
var targetRect=getBoundingClientRect(target);
var rootContainsTarget=this._rootContainsTarget(target);
var oldEntry=item.entry;
var intersectionRect=rootIsInDom&&rootContainsTarget &&
this._computeTargetAndRootIntersection(target, rootRect);
var newEntry=item.entry=new IntersectionObserverEntry({
time: now(),
target: target,
boundingClientRect: targetRect,
rootBounds: rootRect,
intersectionRect: intersectionRect
});
if(!oldEntry){
this._queuedEntries.push(newEntry);
}else if(rootIsInDom&&rootContainsTarget){
if(this._hasCrossedThreshold(oldEntry, newEntry)){
this._queuedEntries.push(newEntry);
}}else{
if(oldEntry&&oldEntry.isIntersecting){
this._queuedEntries.push(newEntry);
}}
}, this);
if(this._queuedEntries.length){
this._callback(this.takeRecords(), this);
}};
IntersectionObserver.prototype._computeTargetAndRootIntersection =
function(target, rootRect){
if(window.getComputedStyle(target).display=='none') return;
var targetRect=getBoundingClientRect(target);
var intersectionRect=targetRect;
var parent=getParentNode(target);
var atRoot=false;
while (!atRoot){
var parentRect=null;
var parentComputedStyle=parent.nodeType==1 ?
window.getComputedStyle(parent):{};
if(parentComputedStyle.display=='none') return;
if(parent==this.root||parent==document){
atRoot=true;
parentRect=rootRect;
}else{
if(parent!=document.body &&
parent!=document.documentElement &&
parentComputedStyle.overflow!='visible'){
parentRect=getBoundingClientRect(parent);
}}
if(parentRect){
intersectionRect=computeRectIntersection(parentRect, intersectionRect);
if(!intersectionRect) break;
}
parent=getParentNode(parent);
}
return intersectionRect;
};
IntersectionObserver.prototype._getRootRect=function(){
var rootRect;
if(this.root){
rootRect=getBoundingClientRect(this.root);
}else{
var html=document.documentElement;
var body=document.body;
rootRect={
top: 0,
left: 0,
right: html.clientWidth||body.clientWidth,
width: html.clientWidth||body.clientWidth,
bottom: html.clientHeight||body.clientHeight,
height: html.clientHeight||body.clientHeight
};}
return this._expandRectByRootMargin(rootRect);
};
IntersectionObserver.prototype._expandRectByRootMargin=function(rect){
var margins=this._rootMarginValues.map(function(margin, i){
return margin.unit=='px' ? margin.value :
margin.value * (i % 2 ? rect.width:rect.height) / 100;
});
var newRect={
top: rect.top - margins[0],
right: rect.right + margins[1],
bottom: rect.bottom + margins[2],
left: rect.left - margins[3]
};
newRect.width=newRect.right - newRect.left;
newRect.height=newRect.bottom - newRect.top;
return newRect;
};
IntersectionObserver.prototype._hasCrossedThreshold =
function(oldEntry, newEntry){
var oldRatio=oldEntry&&oldEntry.isIntersecting ?
oldEntry.intersectionRatio||0:-1;
var newRatio=newEntry.isIntersecting ?
newEntry.intersectionRatio||0:-1;
if(oldRatio===newRatio) return;
for (var i=0; i < this.thresholds.length; i++){
var threshold=this.thresholds[i];
if(threshold==oldRatio||threshold==newRatio ||
threshold < oldRatio!==threshold < newRatio){
return true;
}}
};
IntersectionObserver.prototype._rootIsInDom=function(){
return !this.root||containsDeep(document, this.root);
};
IntersectionObserver.prototype._rootContainsTarget=function(target){
return containsDeep(this.root||document, target);
};
IntersectionObserver.prototype._registerInstance=function(){
if(registry.indexOf(this) < 0){
registry.push(this);
}};
IntersectionObserver.prototype._unregisterInstance=function(){
var index=registry.indexOf(this);
if(index!=-1) registry.splice(index, 1);
};
function now(){
return window.performance&&performance.now&&performance.now();
}
function throttle(fn, timeout){
var timer=null;
return function (){
if(!timer){
timer=setTimeout(function(){
fn();
timer=null;
}, timeout);
}};}
function addEvent(node, event, fn, opt_useCapture){
if(typeof node.addEventListener=='function'){
node.addEventListener(event, fn, opt_useCapture||false);
}
else if(typeof node.attachEvent=='function'){
node.attachEvent('on' + event, fn);
}}
function removeEvent(node, event, fn, opt_useCapture){
if(typeof node.removeEventListener=='function'){
node.removeEventListener(event, fn, opt_useCapture||false);
}
else if(typeof node.detatchEvent=='function'){
node.detatchEvent('on' + event, fn);
}}
function computeRectIntersection(rect1, rect2){
var top=Math.max(rect1.top, rect2.top);
var bottom=Math.min(rect1.bottom, rect2.bottom);
var left=Math.max(rect1.left, rect2.left);
var right=Math.min(rect1.right, rect2.right);
var width=right - left;
var height=bottom - top;
return (width >=0&&height >=0)&&{
top: top,
bottom: bottom,
left: left,
right: right,
width: width,
height: height
};}
function getBoundingClientRect(el){
var rect;
try {
rect=el.getBoundingClientRect();
} catch (err){
}
if(!rect) return getEmptyRect();
if(!(rect.width&&rect.height)){
rect={
top: rect.top,
right: rect.right,
bottom: rect.bottom,
left: rect.left,
width: rect.right - rect.left,
height: rect.bottom - rect.top
};}
return rect;
}
function getEmptyRect(){
return {
top: 0,
bottom: 0,
left: 0,
right: 0,
width: 0,
height: 0
};}
function containsDeep(parent, child){
var node=child;
while (node){
if(node==parent) return true;
node=getParentNode(node);
}
return false;
}
function getParentNode(node){
var parent=node.parentNode;
if(parent&&parent.nodeType==11&&parent.host){
return parent.host;
}
if(parent&&parent.assignedSlot){
return parent.assignedSlot.parentNode;
}
return parent;
}
window.IntersectionObserver=IntersectionObserver;
window.IntersectionObserverEntry=IntersectionObserverEntry;
}(window, document));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";
var g="undefined"!=typeof document&&document.documentMode,f={rootMargin:"0px",threshold:0,load:function(t){if("picture"===t.nodeName.toLowerCase()){var e=t.querySelector("img"),r=!1;null===e&&(e=document.createElement("img"),r=!0),g&&t.getAttribute("data-iesrc")&&(e.src=t.getAttribute("data-iesrc")),t.getAttribute("data-alt")&&(e.alt=t.getAttribute("data-alt")),r&&t.append(e)}if("video"===t.nodeName.toLowerCase()&&!t.getAttribute("data-src")&&t.children){for(var a=t.children,o=void 0,i=0;i<=a.length-1;i++)(o=a[i].getAttribute("data-src"))&&(a[i].src=o);t.load()}t.getAttribute("data-poster")&&(t.poster=t.getAttribute("data-poster")),t.getAttribute("data-src")&&(t.src=t.getAttribute("data-src")),t.getAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"));var n=",";if(t.getAttribute("data-background-delimiter")&&(n=t.getAttribute("data-background-delimiter")),t.getAttribute("data-background-image"))t.style.backgroundImage="url('"+t.getAttribute("data-background-image").split(n).join("'),url('")+"')";else if(t.getAttribute("data-background-image-set")){var d=t.getAttribute("data-background-image-set").split(n),u=d[0].substr(0,d[0].indexOf(" "))||d[0];
u=-1===u.indexOf("url(")?"url("+u+")":u,1===d.length?t.style.backgroundImage=u:t.setAttribute("style",(t.getAttribute("style")||"")+"background-image: "+u+"; background-image: -webkit-image-set("+d+"); background-image: image-set("+d+")")}t.getAttribute("data-toggle-class")&&t.classList.toggle(t.getAttribute("data-toggle-class"))},loaded:function(){}};function A(t){t.setAttribute("data-loaded",!0)}var m=function(t){return"true"===t.getAttribute("data-loaded")},v=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;return t instanceof Element?[t]:t instanceof NodeList?t:e.querySelectorAll(t)};return function(){var r,a,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:".lozad",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=Object.assign({},f,t),i=e.root,n=e.rootMargin,d=e.threshold,u=e.load,g=e.loaded,s=void 0;"undefined"!=typeof window&&window.IntersectionObserver&&(s=new IntersectionObserver((r=u,a=g,function(t,e){t.forEach(function(t){(0<t.intersectionRatio||t.isIntersecting)&&(e.unobserve(t.target),m(t.target)||(r(t.target),A(t.target),a(t.target)))})}),{root:i,rootMargin:n,threshold:d}));for(var c,l=v(o,i),b=0;b<l.length;b++)(c=l[b]).getAttribute("data-placeholder-background")&&(c.style.background=c.getAttribute("data-placeholder-background"));return{observe:function(){for(var t=v(o,i),e=0;e<t.length;e++)m(t[e])||(s?s.observe(t[e]):(u(t[e]),A(t[e]),g(t[e])))},triggerLoad:function(t){m(t)||(u(t),A(t),g(t))},observer:s}}});