").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each(["get","post"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Nn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Mn(Mn(e,b.ajaxSettings),t):Mn(b.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,p=b.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?b(f):b.event,h=b.Deferred(),g=b.Callbacks("once memory"),m=p.statusCode||{},y={},v={},x=0,T="canceled",N={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else N.always(e[N.status]);return this},abort:function(e){var t=e||T;return l&&l.abort(t),k(0,t),this}};if(h.promise(N).complete=g.add,N.success=N.done,N.error=N.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=b.trim(p.dataType||"*").toLowerCase().match(w)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?80:443))==(mn[3]||("http:"===mn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=b.param(p.data,p.traditional)),qn(An,p,n,N),2===x)return N;u=p.global,u&&0===b.active++&&b.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Cn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(b.lastModified[o]&&N.setRequestHeader("If-Modified-Since",b.lastModified[o]),b.etag[o]&&N.setRequestHeader("If-None-Match",b.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&N.setRequestHeader("Content-Type",p.contentType),N.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)N.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,N,p)===!1||2===x))return N.abort();T="abort";for(i in{success:1,error:1,complete:1})N[i](p[i]);if(l=qn(jn,p,n,N)){N.readyState=1,u&&d.trigger("ajaxSend",[N,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){N.abort("timeout")},p.timeout));try{x=1,l.send(y,k)}catch(C){if(!(2>x))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||"",N.readyState=e>0?4:0,r&&(w=_n(p,N,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=N.getResponseHeader("Last-Modified"),T&&(b.lastModified[o]=T),T=N.getResponseHeader("etag"),T&&(b.etag[o]=T)),204===e?(c=!0,C="nocontent"):304===e?(c=!0,C="notmodified"):(c=Fn(p,w),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C="error",0>e&&(e=0))),N.status=e,N.statusText=(n||C)+"",c?h.resolveWith(f,[y,C,N]):h.rejectWith(f,[N,C,v]),N.statusCode(m),m=t,u&&d.trigger(c?"ajaxSuccess":"ajaxError",[N,p,c?y:v]),g.fireWith(f,[N,C]),u&&(d.trigger("ajaxComplete",[N,p]),--b.active||b.event.trigger("ajaxStop")))}return N},getScript:function(e,n){return b.get(e,t,n,"script")},getJSON:function(e,t,n){return b.get(e,t,n,"json")}});function _n(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while("*"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+" "+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function Fn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if("*"!==r){if("*"!==l&&l!==r){if(i=a[l+" "+r]||a["* "+r],!i)for(n in a)if(o=n.split(" "),o[1]===r&&(i=a[l+" "+o[0]]||a["* "+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e["throws"])t=i(t);else try{t=i(t)}catch(c){return{state:"parsererror",error:i?c:"No conversion from "+l+" to "+r}}}l=r}return{state:"success",data:t}}b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return b.globalEval(e),e}}}),b.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),b.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=o.head||b("head")[0]||o.documentElement;return{send:function(t,i){n=o.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var On=[],Bn=/(=)\?(?=&|$)|\?\?/;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=On.pop()||b.expando+"_"+vn++;return this[e]=!0,e}}),b.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=b.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||b.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,On.push(o)),s&&b.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=b.ajaxSettings.xhr(),b.support.cors=!!Rn&&"withCredentials"in Rn,Rn=b.support.ajax=!!Rn,Rn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,$n&&delete Pn[a]),i)4!==u.readyState&&u.abort();else{p={},s=u.status,l=u.getAllResponseHeaders(),"string"==typeof u.responseText&&(p.text=u.responseText);try{c=u.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,l)},n.async?4===u.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},b(e).unload($n)),Pn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+x+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=Yn.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(b.cssNumber[e]?"":"px"),"px"!==r&&s){s=b.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,b.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=b.now()}function Zn(e,t){b.each(t,function(t,n){var r=(Qn[t]||[]).concat(Qn["*"]),i=0,o=r.length;for(;o>i;i++)if(r[i].call(e,t,n))return})}function er(e,t,n){var r,i,o=0,a=Gn.length,s=b.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;for(;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:b.extend({},t),opts:b.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=b.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(tr(c,l.opts.specialEasing);a>o;o++)if(r=Gn[o].call(l,e,c,l.opts))return r;return Zn(l,c),b.isFunction(l.opts.start)&&l.opts.start.call(e,l),b.fx.timer(b.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function tr(e,t){var n,r,i,o,a;for(i in e)if(r=b.camelCase(i),o=t[r],n=e[i],b.isArray(n)&&(o=n[1],n=e[i]=n[0]),i!==r&&(e[r]=n,delete e[i]),a=b.cssHooks[r],a&&"expand"in a){n=a.expand(n),delete e[r];for(i in n)i in e||(e[i]=n[i],t[i]=o)}else t[r]=o}b.Animation=b.extend(er,{tweener:function(e,t){b.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,u,l,c,p,f=this,d=e.style,h={},g=[],m=e.nodeType&&nn(e);n.queue||(c=b._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,p=c.empty.fire,c.empty.fire=function(){c.unqueued||p()}),c.unqueued++,f.always(function(){f.always(function(){c.unqueued--,b.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],"inline"===b.css(e,"display")&&"none"===b.css(e,"float")&&(b.support.inlineBlockNeedsLayout&&"inline"!==un(e.nodeName)?d.zoom=1:d.display="inline-block")),n.overflow&&(d.overflow="hidden",b.support.shrinkWrapBlocks||f.always(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(i in t)if(a=t[i],Vn.exec(a)){if(delete t[i],u=u||"toggle"===a,a===(m?"hide":"show"))continue;g.push(i)}if(o=g.length){s=b._data(e,"fxshow")||b._data(e,"fxshow",{}),"hidden"in s&&(m=s.hidden),u&&(s.hidden=!m),m?b(e).show():f.done(function(){b(e).hide()}),f.done(function(){var t;b._removeData(e,"fxshow");for(t in h)b.style(e,t,h[t])});for(i=0;o>i;i++)r=g[i],l=f.createTween(r,m?s[r]:0),h[r]=s[r]||b.style(e,r),r in s||(s[r]=l.start,m&&(l.end=l.start,l.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}b.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(b.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?b.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=b.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){b.fx.step[e.prop]?b.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[b.cssProps[e.prop]]||b.cssHooks[e.prop])?b.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},b.each(["toggle","show","hide"],function(e,t){var n=b.fn[t];b.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),b.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=b.isEmptyObject(e),o=b.speed(t,n,r),a=function(){var t=er(this,b.extend({},e),o);a.finish=function(){t.stop(!0)},(i||b._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=b.timers,a=b._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&b.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=b._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=b.timers,a=r?r.length:0;for(n.finish=!0,b.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}b.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){b.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),b.speed=function(e,t,n){var r=e&&"object"==typeof e?b.extend({},e):{complete:n||!n&&t||b.isFunction(e)&&e,duration:e,easing:n&&t||t&&!b.isFunction(t)&&t};return r.duration=b.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in b.fx.speeds?b.fx.speeds[r.duration]:b.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){b.isFunction(r.old)&&r.old.call(this),r.queue&&b.dequeue(this,r.queue)},r},b.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},b.timers=[],b.fx=rr.prototype.init,b.fx.tick=function(){var e,n=b.timers,r=0;for(Xn=b.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||b.fx.stop(),Xn=t},b.fx.timer=function(e){e()&&b.timers.push(e)&&b.fx.start()},b.fx.interval=13,b.fx.start=function(){Un||(Un=setInterval(b.fx.tick,b.fx.interval))},b.fx.stop=function(){clearInterval(Un),Un=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fx.step={},b.expr&&b.expr.filters&&(b.expr.filters.animated=function(e){return b.grep(b.timers,function(t){return e===t.elem}).length}),b.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){b.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,b.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},b.offset={setOffset:function(e,t,n){var r=b.css(e,"position");"static"===r&&(e.style.position="relative");var i=b(e),o=i.offset(),a=b.css(e,"top"),s=b.css(e,"left"),u=("absolute"===r||"fixed"===r)&&b.inArray("auto",[a,s])>-1,l={},c={},p,f;u?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),b.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(l.top=t.top-o.top+p),null!=t.left&&(l.left=t.left-o.left+f),"using"in t?t.using.call(e,l):i.css(l)}},b.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===b.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),b.nodeName(e[0],"html")||(n=e.offset()),n.top+=b.css(e[0],"borderTopWidth",!0),n.left+=b.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-b.css(r,"marginTop",!0),left:t.left-n.left-b.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||o.documentElement;while(e&&!b.nodeName(e,"html")&&"static"===b.css(e,"position"))e=e.offsetParent;return e||o.documentElement})}}),b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);b.fn[e]=function(i){return b.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?b(a).scrollLeft():o,r?o:b(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return b.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}b.each({Height:"height",Width:"width"},function(e,n){b.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){b.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return b.access(this,function(n,r,i){var o;return b.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?b.css(n,r,s):b.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=b,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return b})})(window);
// source --> https://trp2016.trparchives.com/wp-content/themes/trp2016/lib/js/iscroll.js
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) { window.setTimeout(callback, 1000 / 60); };
var utils = (function () {
var me = {};
var _elementStyle = document.createElement('div').style;
var _vendor = (function () {
var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
transform,
i = 0,
l = vendors.length;
for ( ; i < l; i++ ) {
transform = vendors[i] + 'ransform';
if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
}
return false;
})();
function _prefixStyle (style) {
if ( _vendor === false ) return false;
if ( _vendor === '' ) return style;
return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
}
me.getTime = Date.now || function getTime () { return new Date().getTime(); };
me.extend = function (target, obj) {
for ( var i in obj ) {
target[i] = obj[i];
}
};
me.addEvent = function (el, type, fn, capture) {
el.addEventListener(type, fn, !!capture);
};
me.removeEvent = function (el, type, fn, capture) {
el.removeEventListener(type, fn, !!capture);
};
me.prefixPointerEvent = function (pointerEvent) {
return window.MSPointerEvent ?
'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
pointerEvent;
};
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration;
deceleration = deceleration === undefined ? 0.0006 : deceleration;
destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
if ( destination < lowerMargin ) {
destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
distance = Math.abs(destination - current);
duration = distance / speed;
} else if ( destination > 0 ) {
destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
distance = Math.abs(current) + destination;
duration = distance / speed;
}
return {
destination: Math.round(destination),
duration: duration
};
};
var _transform = _prefixStyle('transform');
me.extend(me, {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});
// This should find all Android browsers lower than build 535.19 (both stock browser and webview)
me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
me.extend(me.style = {}, {
transform: _transform,
transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
transitionDuration: _prefixStyle('transitionDuration'),
transitionDelay: _prefixStyle('transitionDelay'),
transformOrigin: _prefixStyle('transformOrigin')
});
me.hasClass = function (e, c) {
var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
return re.test(e.className);
};
me.addClass = function (e, c) {
if ( me.hasClass(e, c) ) {
return;
}
var newclass = e.className.split(' ');
newclass.push(c);
e.className = newclass.join(' ');
};
me.removeClass = function (e, c) {
if ( !me.hasClass(e, c) ) {
return;
}
var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
e.className = e.className.replace(re, ' ');
};
me.offset = function (el) {
var left = -el.offsetLeft,
top = -el.offsetTop;
// jshint -W084
while (el = el.offsetParent) {
left -= el.offsetLeft;
top -= el.offsetTop;
}
// jshint +W084
return {
left: left,
top: top
};
};
me.preventDefaultException = function (el, exceptions) {
for ( var i in exceptions ) {
if ( exceptions[i].test(el[i]) ) {
return true;
}
}
return false;
};
me.extend(me.eventType = {}, {
touchstart: 1,
touchmove: 1,
touchend: 1,
mousedown: 2,
mousemove: 2,
mouseup: 2,
pointerdown: 3,
pointermove: 3,
pointerup: 3,
MSPointerDown: 3,
MSPointerMove: 3,
MSPointerUp: 3
});
me.extend(me.ease = {}, {
quadratic: {
style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
fn: function (k) {
return k * ( 2 - k );
}
},
circular: {
style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
fn: function (k) {
return Math.sqrt( 1 - ( --k * k ) );
}
},
back: {
style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
fn: function (k) {
var b = 4;
return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
}
},
bounce: {
style: '',
fn: function (k) {
if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
return 7.5625 * k * k;
} else if ( k < ( 2 / 2.75 ) ) {
return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
} else if ( k < ( 2.5 / 2.75 ) ) {
return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
} else {
return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
}
}
},
elastic: {
style: '',
fn: function (k) {
var f = 0.22,
e = 0.4;
if ( k === 0 ) { return 0; }
if ( k == 1 ) { return 1; }
return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
}
}
});
me.tap = function (e, eventName) {
var ev = document.createEvent('Event');
ev.initEvent(eventName, true, true);
ev.pageX = e.pageX;
ev.pageY = e.pageY;
e.target.dispatchEvent(ev);
};
me.click = function (e) {
var target = e.target,
ev;
if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
target.screenX, target.screenY, target.clientX, target.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
0, null);
ev._constructed = true;
target.dispatchEvent(ev);
}
};
return me;
})();
function IScroll (el, options) {
this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
this.scroller = this.wrapper.children[0];
this.scrollerStyle = this.scroller.style; // cache style for better performance
this.options = {
resizeScrollbars: true,
mouseWheelSpeed: 20,
snapThreshold: 0.334,
// INSERT POINT: OPTIONS
startX: 0,
startY: 0,
scrollY: true,
directionLockThreshold: 5,
momentum: true,
bounce: true,
bounceTime: 600,
bounceEasing: '',
preventDefault: true,
preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
HWCompositing: true,
useTransition: true,
useTransform: true
};
for ( var i in options ) {
this.options[i] = options[i];
}
// Normalize options
this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
this.options.useTransition = utils.hasTransition && this.options.useTransition;
this.options.useTransform = utils.hasTransform && this.options.useTransform;
this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
// If you want eventPassthrough I have to lock one of the axes
this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
// With eventPassthrough we also need lockDirection mechanism
this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
if ( this.options.tap === true ) {
this.options.tap = 'tap';
}
if ( this.options.shrinkScrollbars == 'scale' ) {
this.options.useTransition = false;
}
this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
// INSERT POINT: NORMALIZATION
// Some defaults
this.x = 0;
this.y = 0;
this.directionX = 0;
this.directionY = 0;
this._events = {};
// INSERT POINT: DEFAULTS
this._init();
this.refresh();
this.scrollTo(this.options.startX, this.options.startY);
this.enable();
}
IScroll.prototype = {
version: '5.1.3',
_init: function () {
this._initEvents();
if ( this.options.scrollbars || this.options.indicators ) {
this._initIndicators();
}
if ( this.options.mouseWheel ) {
this._initWheel();
}
if ( this.options.snap ) {
this._initSnap();
}
if ( this.options.keyBindings ) {
this._initKeys();
}
// INSERT POINT: _init
},
destroy: function () {
this._initEvents(true);
this._execEvent('destroy');
},
_transitionEnd: function (e) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this.isInTransition = false;
this._execEvent('scrollEnd');
}
},
_start: function (e) {
// React to left mouse button only
if ( utils.eventType[e.type] != 1 ) {
if ( e.button !== 0 ) {
return;
}
}
if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
return;
}
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}
var point = e.touches ? e.touches[0] : e,
pos;
this.initiated = utils.eventType[e.type];
this.moved = false;
this.distX = 0;
this.distY = 0;
this.directionX = 0;
this.directionY = 0;
this.directionLocked = 0;
this._transitionTime();
this.startTime = utils.getTime();
if ( this.options.useTransition && this.isInTransition ) {
this.isInTransition = false;
pos = this.getComputedPosition();
this._translate(Math.round(pos.x), Math.round(pos.y));
this._execEvent('scrollEnd');
} else if ( !this.options.useTransition && this.isAnimating ) {
this.isAnimating = false;
this._execEvent('scrollEnd');
}
this.startX = this.x;
this.startY = this.y;
this.absStartX = this.x;
this.absStartY = this.y;
this.pointX = point.pageX;
this.pointY = point.pageY;
this._execEvent('beforeScrollStart');
},
_move: function (e) {
if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
return;
}
if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
e.preventDefault();
}
var point = e.touches ? e.touches[0] : e,
deltaX = point.pageX - this.pointX,
deltaY = point.pageY - this.pointY,
timestamp = utils.getTime(),
newX, newY,
absDistX, absDistY;
this.pointX = point.pageX;
this.pointY = point.pageY;
this.distX += deltaX;
this.distY += deltaY;
absDistX = Math.abs(this.distX);
absDistY = Math.abs(this.distY);
// We need to move at least 10 pixels for the scrolling to initiate
if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
return;
}
// If you are scrolling in one direction lock the other
if ( !this.directionLocked && !this.options.freeScroll ) {
if ( absDistX > absDistY + this.options.directionLockThreshold ) {
this.directionLocked = 'h'; // lock horizontally
} else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
this.directionLocked = 'v'; // lock vertically
} else {
this.directionLocked = 'n'; // no lock
}
}
if ( this.directionLocked == 'h' ) {
if ( this.options.eventPassthrough == 'vertical' ) {
e.preventDefault();
} else if ( this.options.eventPassthrough == 'horizontal' ) {
this.initiated = false;
return;
}
deltaY = 0;
} else if ( this.directionLocked == 'v' ) {
if ( this.options.eventPassthrough == 'horizontal' ) {
e.preventDefault();
} else if ( this.options.eventPassthrough == 'vertical' ) {
this.initiated = false;
return;
}
deltaX = 0;
}
deltaX = this.hasHorizontalScroll ? deltaX : 0;
deltaY = this.hasVerticalScroll ? deltaY : 0;
newX = this.x + deltaX;
newY = this.y + deltaY;
// Slow down if outside of the boundaries
if ( newX > 0 || newX < this.maxScrollX ) {
newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
}
if ( newY > 0 || newY < this.maxScrollY ) {
newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
}
this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
if ( !this.moved ) {
this._execEvent('scrollStart');
}
this.moved = true;
this._translate(newX, newY);
/* REPLACE START: _move */
if ( timestamp - this.startTime > 300 ) {
this.startTime = timestamp;
this.startX = this.x;
this.startY = this.y;
}
/* REPLACE END: _move */
},
_end: function (e) {
if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
return;
}
if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}
var point = e.changedTouches ? e.changedTouches[0] : e,
momentumX,
momentumY,
duration = utils.getTime() - this.startTime,
newX = Math.round(this.x),
newY = Math.round(this.y),
distanceX = Math.abs(newX - this.startX),
distanceY = Math.abs(newY - this.startY),
time = 0,
easing = '';
this.isInTransition = 0;
this.initiated = 0;
this.endTime = utils.getTime();
// reset if we are outside of the boundaries
if ( this.resetPosition(this.options.bounceTime) ) {
return;
}
this.scrollTo(newX, newY); // ensures that the last position is rounded
// we scrolled less than 10 pixels
if ( !this.moved ) {
if ( this.options.tap ) {
utils.tap(e, this.options.tap);
}
if ( this.options.click ) {
utils.click(e);
}
this._execEvent('scrollCancel');
return;
}
if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
this._execEvent('flick');
return;
}
// start momentum animation if needed
if ( this.options.momentum && duration < 300 ) {
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
newX = momentumX.destination;
newY = momentumY.destination;
time = Math.max(momentumX.duration, momentumY.duration);
this.isInTransition = 1;
}
if ( this.options.snap ) {
var snap = this._nearestSnap(newX, newY);
this.currentPage = snap;
time = this.options.snapSpeed || Math.max(
Math.max(
Math.min(Math.abs(newX - snap.x), 1000),
Math.min(Math.abs(newY - snap.y), 1000)
), 300);
newX = snap.x;
newY = snap.y;
this.directionX = 0;
this.directionY = 0;
easing = this.options.bounceEasing;
}
// INSERT POINT: _end
if ( newX != this.x || newY != this.y ) {
// change easing function when scroller goes out of the boundaries
if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
easing = utils.ease.quadratic;
}
this.scrollTo(newX, newY, time, easing);
return;
}
this._execEvent('scrollEnd');
},
_resize: function () {
var that = this;
clearTimeout(this.resizeTimeout);
this.resizeTimeout = setTimeout(function () {
that.refresh();
}, this.options.resizePolling);
},
resetPosition: function (time) {
var x = this.x,
y = this.y;
time = time || 0;
if ( !this.hasHorizontalScroll || this.x > 0 ) {
x = 0;
} else if ( this.x < this.maxScrollX ) {
x = this.maxScrollX;
}
if ( !this.hasVerticalScroll || this.y > 0 ) {
y = 0;
} else if ( this.y < this.maxScrollY ) {
y = this.maxScrollY;
}
if ( x == this.x && y == this.y ) {
return false;
}
this.scrollTo(x, y, time, this.options.bounceEasing);
return true;
},
disable: function () {
this.enabled = false;
},
enable: function () {
this.enabled = true;
},
refresh: function () {
var rf = this.wrapper.offsetHeight; // Force reflow
this.wrapperWidth = this.wrapper.clientWidth;
this.wrapperHeight = this.wrapper.clientHeight;
/* REPLACE START: refresh */
this.scrollerWidth = this.scroller.offsetWidth;
this.scrollerHeight = this.scroller.offsetHeight;
this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
/* REPLACE END: refresh */
this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
if ( !this.hasHorizontalScroll ) {
this.maxScrollX = 0;
this.scrollerWidth = this.wrapperWidth;
}
if ( !this.hasVerticalScroll ) {
this.maxScrollY = 0;
this.scrollerHeight = this.wrapperHeight;
}
this.endTime = 0;
this.directionX = 0;
this.directionY = 0;
this.wrapperOffset = utils.offset(this.wrapper);
this._execEvent('refresh');
this.resetPosition();
// INSERT POINT: _refresh
},
on: function (type, fn) {
if ( !this._events[type] ) {
this._events[type] = [];
}
this._events[type].push(fn);
},
off: function (type, fn) {
if ( !this._events[type] ) {
return;
}
var index = this._events[type].indexOf(fn);
if ( index > -1 ) {
this._events[type].splice(index, 1);
}
},
_execEvent: function (type) {
if ( !this._events[type] ) {
return;
}
var i = 0,
l = this._events[type].length;
if ( !l ) {
return;
}
for ( ; i < l; i++ ) {
this._events[type][i].apply(this, [].slice.call(arguments, 1));
}
},
scrollBy: function (x, y, time, easing) {
x = this.x + x;
y = this.y + y;
time = time || 0;
this.scrollTo(x, y, time, easing);
},
scrollTo: function (x, y, time, easing) {
easing = easing || utils.ease.circular;
this.isInTransition = this.options.useTransition && time > 0;
if ( !time || (this.options.useTransition && easing.style) ) {
this._transitionTimingFunction(easing.style);
this._transitionTime(time);
this._translate(x, y);
} else {
this._animate(x, y, time, easing.fn);
}
},
scrollToElement: function (el, time, offsetX, offsetY, easing) {
el = el.nodeType ? el : this.scroller.querySelector(el);
if ( !el ) {
return;
}
var pos = utils.offset(el);
pos.left -= this.wrapperOffset.left;
pos.top -= this.wrapperOffset.top;
// if offsetX/Y are true we center the element to the screen
if ( offsetX === true ) {
offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
}
if ( offsetY === true ) {
offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
}
pos.left -= offsetX || 0;
pos.top -= offsetY || 0;
pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
this.scrollTo(pos.left, pos.top, time, easing);
},
_transitionTime: function (time) {
time = time || 0;
this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}
if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
this.indicators[i].transitionTime(time);
}
}
// INSERT POINT: _transitionTime
},
_transitionTimingFunction: function (easing) {
this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
this.indicators[i].transitionTimingFunction(easing);
}
}
// INSERT POINT: _transitionTimingFunction
},
_translate: function (x, y) {
if ( this.options.useTransform ) {
/* REPLACE START: _translate */
this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
/* REPLACE END: _translate */
} else {
x = Math.round(x);
y = Math.round(y);
this.scrollerStyle.left = x + 'px';
this.scrollerStyle.top = y + 'px';
}
this.x = x;
this.y = y;
if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
this.indicators[i].updatePosition();
}
}
// INSERT POINT: _translate
},
_initEvents: function (remove) {
var eventType = remove ? utils.removeEvent : utils.addEvent,
target = this.options.bindToWrapper ? this.wrapper : window;
eventType(window, 'orientationchange', this);
eventType(window, 'resize', this);
if ( this.options.click ) {
eventType(this.wrapper, 'click', this, true);
}
if ( !this.options.disableMouse ) {
eventType(this.wrapper, 'mousedown', this);
eventType(target, 'mousemove', this);
eventType(target, 'mousecancel', this);
eventType(target, 'mouseup', this);
}
if ( utils.hasPointer && !this.options.disablePointer ) {
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
eventType(target, utils.prefixPointerEvent('pointermove'), this);
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
eventType(target, utils.prefixPointerEvent('pointerup'), this);
}
if ( utils.hasTouch && !this.options.disableTouch ) {
eventType(this.wrapper, 'touchstart', this);
eventType(target, 'touchmove', this);
eventType(target, 'touchcancel', this);
eventType(target, 'touchend', this);
}
eventType(this.scroller, 'transitionend', this);
eventType(this.scroller, 'webkitTransitionEnd', this);
eventType(this.scroller, 'oTransitionEnd', this);
eventType(this.scroller, 'MSTransitionEnd', this);
},
getComputedPosition: function () {
var matrix = window.getComputedStyle(this.scroller, null),
x, y;
if ( this.options.useTransform ) {
matrix = matrix[utils.style.transform].split(')')[0].split(', ');
x = +(matrix[12] || matrix[4]);
y = +(matrix[13] || matrix[5]);
} else {
x = +matrix.left.replace(/[^-\d.]/g, '');
y = +matrix.top.replace(/[^-\d.]/g, '');
}
return { x: x, y: y };
},
_initIndicators: function () {
var interactive = this.options.interactiveScrollbars,
customStyle = typeof this.options.scrollbars != 'string',
indicators = [],
indicator;
var that = this;
this.indicators = [];
if ( this.options.scrollbars ) {
// Vertical scrollbar
if ( this.options.scrollY ) {
indicator = {
el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeScrollbars,
shrink: this.options.shrinkScrollbars,
fade: this.options.fadeScrollbars,
listenX: false
};
this.wrapper.appendChild(indicator.el);
indicators.push(indicator);
}
// Horizontal scrollbar
if ( this.options.scrollX ) {
indicator = {
el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeScrollbars,
shrink: this.options.shrinkScrollbars,
fade: this.options.fadeScrollbars,
listenY: false
};
this.wrapper.appendChild(indicator.el);
indicators.push(indicator);
}
}
if ( this.options.indicators ) {
// TODO: check concat compatibility
indicators = indicators.concat(this.options.indicators);
}
for ( var i = indicators.length; i--; ) {
this.indicators.push( new Indicator(this, indicators[i]) );
}
// TODO: check if we can use array.map (wide compatibility and performance issues)
function _indicatorsMap (fn) {
for ( var i = that.indicators.length; i--; ) {
fn.call(that.indicators[i]);
}
}
if ( this.options.fadeScrollbars ) {
this.on('scrollEnd', function () {
_indicatorsMap(function () {
this.fade();
});
});
this.on('scrollCancel', function () {
_indicatorsMap(function () {
this.fade();
});
});
this.on('scrollStart', function () {
_indicatorsMap(function () {
this.fade(1);
});
});
this.on('beforeScrollStart', function () {
_indicatorsMap(function () {
this.fade(1, true);
});
});
}
this.on('refresh', function () {
_indicatorsMap(function () {
this.refresh();
});
});
this.on('destroy', function () {
_indicatorsMap(function () {
this.destroy();
});
delete this.indicators;
});
},
_initWheel: function () {
utils.addEvent(this.wrapper, 'wheel', this);
utils.addEvent(this.wrapper, 'mousewheel', this);
utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
this.on('destroy', function () {
utils.removeEvent(this.wrapper, 'wheel', this);
utils.removeEvent(this.wrapper, 'mousewheel', this);
utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
});
},
_wheel: function (e) {
if ( !this.enabled ) {
return;
}
e.preventDefault();
e.stopPropagation();
var wheelDeltaX, wheelDeltaY,
newX, newY,
that = this;
if ( this.wheelTimeout === undefined ) {
that._execEvent('scrollStart');
}
// Execute the scrollEnd event after 400ms the wheel stopped scrolling
clearTimeout(this.wheelTimeout);
this.wheelTimeout = setTimeout(function () {
that._execEvent('scrollEnd');
that.wheelTimeout = undefined;
}, 400);
if ( 'deltaX' in e ) {
if (e.deltaMode === 1) {
wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed;
wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed;
} else {
wheelDeltaX = -e.deltaX;
wheelDeltaY = -e.deltaY;
}
} else if ( 'wheelDeltaX' in e ) {
wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
} else if ( 'wheelDelta' in e ) {
wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
} else if ( 'detail' in e ) {
wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
} else {
return;
}
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;
if ( !this.hasVerticalScroll ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
if ( this.options.snap ) {
newX = this.currentPage.pageX;
newY = this.currentPage.pageY;
if ( wheelDeltaX > 0 ) {
newX--;
} else if ( wheelDeltaX < 0 ) {
newX++;
}
if ( wheelDeltaY > 0 ) {
newY--;
} else if ( wheelDeltaY < 0 ) {
newY++;
}
this.goToPage(newX, newY);
return;
}
newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
if ( newX > 0 ) {
newX = 0;
} else if ( newX < this.maxScrollX ) {
newX = this.maxScrollX;
}
if ( newY > 0 ) {
newY = 0;
} else if ( newY < this.maxScrollY ) {
newY = this.maxScrollY;
}
this.scrollTo(newX, newY, 0);
// INSERT POINT: _wheel
},
_initSnap: function () {
this.currentPage = {};
if ( typeof this.options.snap == 'string' ) {
this.options.snap = this.scroller.querySelectorAll(this.options.snap);
}
this.on('refresh', function () {
var i = 0, l,
m = 0, n,
cx, cy,
x = 0, y,
stepX = this.options.snapStepX || this.wrapperWidth,
stepY = this.options.snapStepY || this.wrapperHeight,
el;
this.pages = [];
if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
return;
}
if ( this.options.snap === true ) {
cx = Math.round( stepX / 2 );
cy = Math.round( stepY / 2 );
while ( x > -this.scrollerWidth ) {
this.pages[i] = [];
l = 0;
y = 0;
while ( y > -this.scrollerHeight ) {
this.pages[i][l] = {
x: Math.max(x, this.maxScrollX),
y: Math.max(y, this.maxScrollY),
width: stepX,
height: stepY,
cx: x - cx,
cy: y - cy
};
y -= stepY;
l++;
}
x -= stepX;
i++;
}
} else {
el = this.options.snap;
l = el.length;
n = -1;
for ( ; i < l; i++ ) {
if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
m = 0;
n++;
}
if ( !this.pages[m] ) {
this.pages[m] = [];
}
x = Math.max(-el[i].offsetLeft, this.maxScrollX);
y = Math.max(-el[i].offsetTop, this.maxScrollY);
cx = x - Math.round(el[i].offsetWidth / 2);
cy = y - Math.round(el[i].offsetHeight / 2);
this.pages[m][n] = {
x: x,
y: y,
width: el[i].offsetWidth,
height: el[i].offsetHeight,
cx: cx,
cy: cy
};
if ( x > this.maxScrollX ) {
m++;
}
}
}
this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
// Update snap threshold if needed
if ( this.options.snapThreshold % 1 === 0 ) {
this.snapThresholdX = this.options.snapThreshold;
this.snapThresholdY = this.options.snapThreshold;
} else {
this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
}
});
this.on('flick', function () {
var time = this.options.snapSpeed || Math.max(
Math.max(
Math.min(Math.abs(this.x - this.startX), 1000),
Math.min(Math.abs(this.y - this.startY), 1000)
), 300);
this.goToPage(
this.currentPage.pageX + this.directionX,
this.currentPage.pageY + this.directionY,
time
);
});
},
_nearestSnap: function (x, y) {
if ( !this.pages.length ) {
return { x: 0, y: 0, pageX: 0, pageY: 0 };
}
var i = 0,
l = this.pages.length,
m = 0;
// Check if we exceeded the snap threshold
if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
Math.abs(y - this.absStartY) < this.snapThresholdY ) {
return this.currentPage;
}
if ( x > 0 ) {
x = 0;
} else if ( x < this.maxScrollX ) {
x = this.maxScrollX;
}
if ( y > 0 ) {
y = 0;
} else if ( y < this.maxScrollY ) {
y = this.maxScrollY;
}
for ( ; i < l; i++ ) {
if ( x >= this.pages[i][0].cx ) {
x = this.pages[i][0].x;
break;
}
}
l = this.pages[i].length;
for ( ; m < l; m++ ) {
if ( y >= this.pages[0][m].cy ) {
y = this.pages[0][m].y;
break;
}
}
if ( i == this.currentPage.pageX ) {
i += this.directionX;
if ( i < 0 ) {
i = 0;
} else if ( i >= this.pages.length ) {
i = this.pages.length - 1;
}
x = this.pages[i][0].x;
}
if ( m == this.currentPage.pageY ) {
m += this.directionY;
if ( m < 0 ) {
m = 0;
} else if ( m >= this.pages[0].length ) {
m = this.pages[0].length - 1;
}
y = this.pages[0][m].y;
}
return {
x: x,
y: y,
pageX: i,
pageY: m
};
},
goToPage: function (x, y, time, easing) {
easing = easing || this.options.bounceEasing;
if ( x >= this.pages.length ) {
x = this.pages.length - 1;
} else if ( x < 0 ) {
x = 0;
}
if ( y >= this.pages[x].length ) {
y = this.pages[x].length - 1;
} else if ( y < 0 ) {
y = 0;
}
var posX = this.pages[x][y].x,
posY = this.pages[x][y].y;
time = time === undefined ? this.options.snapSpeed || Math.max(
Math.max(
Math.min(Math.abs(posX - this.x), 1000),
Math.min(Math.abs(posY - this.y), 1000)
), 300) : time;
this.currentPage = {
x: posX,
y: posY,
pageX: x,
pageY: y
};
this.scrollTo(posX, posY, time, easing);
},
next: function (time, easing) {
var x = this.currentPage.pageX,
y = this.currentPage.pageY;
x++;
if ( x >= this.pages.length && this.hasVerticalScroll ) {
x = 0;
y++;
}
this.goToPage(x, y, time, easing);
},
prev: function (time, easing) {
var x = this.currentPage.pageX,
y = this.currentPage.pageY;
x--;
if ( x < 0 && this.hasVerticalScroll ) {
x = 0;
y--;
}
this.goToPage(x, y, time, easing);
},
_initKeys: function (e) {
// default key bindings
var keys = {
pageUp: 33,
pageDown: 34,
end: 35,
home: 36,
left: 37,
up: 38,
right: 39,
down: 40
};
var i;
// if you give me characters I give you keycode
if ( typeof this.options.keyBindings == 'object' ) {
for ( i in this.options.keyBindings ) {
if ( typeof this.options.keyBindings[i] == 'string' ) {
this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
}
}
} else {
this.options.keyBindings = {};
}
for ( i in keys ) {
this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
}
utils.addEvent(window, 'keydown', this);
this.on('destroy', function () {
utils.removeEvent(window, 'keydown', this);
});
},
_key: function (e) {
if ( !this.enabled ) {
return;
}
var snap = this.options.snap, // we are using this alot, better to cache it
newX = snap ? this.currentPage.pageX : this.x,
newY = snap ? this.currentPage.pageY : this.y,
now = utils.getTime(),
prevTime = this.keyTime || 0,
acceleration = 0.250,
pos;
if ( this.options.useTransition && this.isInTransition ) {
pos = this.getComputedPosition();
this._translate(Math.round(pos.x), Math.round(pos.y));
this.isInTransition = false;
}
this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
switch ( e.keyCode ) {
case this.options.keyBindings.pageUp:
if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
newX += snap ? 1 : this.wrapperWidth;
} else {
newY += snap ? 1 : this.wrapperHeight;
}
break;
case this.options.keyBindings.pageDown:
if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
newX -= snap ? 1 : this.wrapperWidth;
} else {
newY -= snap ? 1 : this.wrapperHeight;
}
break;
case this.options.keyBindings.end:
newX = snap ? this.pages.length-1 : this.maxScrollX;
newY = snap ? this.pages[0].length-1 : this.maxScrollY;
break;
case this.options.keyBindings.home:
newX = 0;
newY = 0;
break;
case this.options.keyBindings.left:
newX += snap ? -1 : 5 + this.keyAcceleration>>0;
break;
case this.options.keyBindings.up:
newY += snap ? 1 : 5 + this.keyAcceleration>>0;
break;
case this.options.keyBindings.right:
newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
break;
case this.options.keyBindings.down:
newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
break;
default:
return;
}
if ( snap ) {
this.goToPage(newX, newY);
return;
}
if ( newX > 0 ) {
newX = 0;
this.keyAcceleration = 0;
} else if ( newX < this.maxScrollX ) {
newX = this.maxScrollX;
this.keyAcceleration = 0;
}
if ( newY > 0 ) {
newY = 0;
this.keyAcceleration = 0;
} else if ( newY < this.maxScrollY ) {
newY = this.maxScrollY;
this.keyAcceleration = 0;
}
this.scrollTo(newX, newY, 0);
this.keyTime = now;
},
_animate: function (destX, destY, duration, easingFn) {
var that = this,
startX = this.x,
startY = this.y,
startTime = utils.getTime(),
destTime = startTime + duration;
function step () {
var now = utils.getTime(),
newX, newY,
easing;
if ( now >= destTime ) {
that.isAnimating = false;
that._translate(destX, destY);
if ( !that.resetPosition(that.options.bounceTime) ) {
that._execEvent('scrollEnd');
}
return;
}
now = ( now - startTime ) / duration;
easing = easingFn(now);
newX = ( destX - startX ) * easing + startX;
newY = ( destY - startY ) * easing + startY;
that._translate(newX, newY);
if ( that.isAnimating ) {
rAF(step);
}
}
this.isAnimating = true;
step();
},
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
break;
case 'orientationchange':
case 'resize':
this._resize();
break;
case 'transitionend':
case 'webkitTransitionEnd':
case 'oTransitionEnd':
case 'MSTransitionEnd':
this._transitionEnd(e);
break;
case 'wheel':
case 'DOMMouseScroll':
case 'mousewheel':
this._wheel(e);
break;
case 'keydown':
this._key(e);
break;
case 'click':
if ( !e._constructed ) {
e.preventDefault();
e.stopPropagation();
}
break;
}
}
};
function createDefaultScrollbar (direction, interactive, type) {
var scrollbar = document.createElement('div'),
indicator = document.createElement('div');
if ( type === true ) {
scrollbar.style.cssText = 'position:absolute;z-index:9999';
indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
}
indicator.className = 'iScrollIndicator';
if ( direction == 'h' ) {
if ( type === true ) {
scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
indicator.style.height = '100%';
}
scrollbar.className = 'iScrollHorizontalScrollbar';
} else {
if ( type === true ) {
scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
indicator.style.width = '100%';
}
scrollbar.className = 'iScrollVerticalScrollbar';
}
scrollbar.style.cssText += ';overflow:hidden';
if ( !interactive ) {
scrollbar.style.pointerEvents = 'none';
}
scrollbar.appendChild(indicator);
return scrollbar;
}
function Indicator (scroller, options) {
this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
this.wrapperStyle = this.wrapper.style;
this.indicator = this.wrapper.children[0];
this.indicatorStyle = this.indicator.style;
this.scroller = scroller;
this.options = {
listenX: true,
listenY: true,
interactive: false,
resize: true,
defaultScrollbars: false,
shrink: false,
fade: false,
speedRatioX: 0,
speedRatioY: 0
};
for ( var i in options ) {
this.options[i] = options[i];
}
this.sizeRatioX = 1;
this.sizeRatioY = 1;
this.maxPosX = 0;
this.maxPosY = 0;
if ( this.options.interactive ) {
if ( !this.options.disableTouch ) {
utils.addEvent(this.indicator, 'touchstart', this);
utils.addEvent(window, 'touchend', this);
}
if ( !this.options.disablePointer ) {
utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this);
}
if ( !this.options.disableMouse ) {
utils.addEvent(this.indicator, 'mousedown', this);
utils.addEvent(window, 'mouseup', this);
}
}
if ( this.options.fade ) {
this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
this.wrapperStyle.opacity = '0';
}
}
Indicator.prototype = {
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
break;
}
},
destroy: function () {
if ( this.options.interactive ) {
utils.removeEvent(this.indicator, 'touchstart', this);
utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
utils.removeEvent(this.indicator, 'mousedown', this);
utils.removeEvent(window, 'touchmove', this);
utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
utils.removeEvent(window, 'mousemove', this);
utils.removeEvent(window, 'touchend', this);
utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this);
utils.removeEvent(window, 'mouseup', this);
}
if ( this.options.defaultScrollbars ) {
this.wrapper.parentNode.removeChild(this.wrapper);
}
},
_start: function (e) {
var point = e.touches ? e.touches[0] : e;
e.preventDefault();
e.stopPropagation();
this.transitionTime();
this.initiated = true;
this.moved = false;
this.lastPointX = point.pageX;
this.lastPointY = point.pageY;
this.startTime = utils.getTime();
if ( !this.options.disableTouch ) {
utils.addEvent(window, 'touchmove', this);
}
if ( !this.options.disablePointer ) {
utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this);
}
if ( !this.options.disableMouse ) {
utils.addEvent(window, 'mousemove', this);
}
this.scroller._execEvent('beforeScrollStart');
},
_move: function (e) {
var point = e.touches ? e.touches[0] : e,
deltaX, deltaY,
newX, newY,
timestamp = utils.getTime();
if ( !this.moved ) {
this.scroller._execEvent('scrollStart');
}
this.moved = true;
deltaX = point.pageX - this.lastPointX;
this.lastPointX = point.pageX;
deltaY = point.pageY - this.lastPointY;
this.lastPointY = point.pageY;
newX = this.x + deltaX;
newY = this.y + deltaY;
this._pos(newX, newY);
// INSERT POINT: indicator._move
e.preventDefault();
e.stopPropagation();
},
_end: function (e) {
if ( !this.initiated ) {
return;
}
this.initiated = false;
e.preventDefault();
e.stopPropagation();
utils.removeEvent(window, 'touchmove', this);
utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
utils.removeEvent(window, 'mousemove', this);
if ( this.scroller.options.snap ) {
var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
var time = this.options.snapSpeed || Math.max(
Math.max(
Math.min(Math.abs(this.scroller.x - snap.x), 1000),
Math.min(Math.abs(this.scroller.y - snap.y), 1000)
), 300);
if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
this.scroller.directionX = 0;
this.scroller.directionY = 0;
this.scroller.currentPage = snap;
this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
}
}
if ( this.moved ) {
this.scroller._execEvent('scrollEnd');
}
},
transitionTime: function (time) {
time = time || 0;
this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
if ( !time && utils.isBadAndroid ) {
this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
}
},
transitionTimingFunction: function (easing) {
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
},
refresh: function () {
this.transitionTime();
if ( this.options.listenX && !this.options.listenY ) {
this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
} else if ( this.options.listenY && !this.options.listenX ) {
this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
} else {
this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
}
if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
utils.addClass(this.wrapper, 'iScrollBothScrollbars');
utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '8px';
} else {
this.wrapper.style.bottom = '8px';
}
}
} else {
utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '2px';
} else {
this.wrapper.style.bottom = '2px';
}
}
}
var r = this.wrapper.offsetHeight; // force refresh
if ( this.options.listenX ) {
this.wrapperWidth = this.wrapper.clientWidth;
if ( this.options.resize ) {
this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
this.indicatorStyle.width = this.indicatorWidth + 'px';
} else {
this.indicatorWidth = this.indicator.clientWidth;
}
this.maxPosX = this.wrapperWidth - this.indicatorWidth;
if ( this.options.shrink == 'clip' ) {
this.minBoundaryX = -this.indicatorWidth + 8;
this.maxBoundaryX = this.wrapperWidth - 8;
} else {
this.minBoundaryX = 0;
this.maxBoundaryX = this.maxPosX;
}
this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
}
if ( this.options.listenY ) {
this.wrapperHeight = this.wrapper.clientHeight;
if ( this.options.resize ) {
this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
this.indicatorStyle.height = this.indicatorHeight + 'px';
} else {
this.indicatorHeight = this.indicator.clientHeight;
}
this.maxPosY = this.wrapperHeight - this.indicatorHeight;
if ( this.options.shrink == 'clip' ) {
this.minBoundaryY = -this.indicatorHeight + 8;
this.maxBoundaryY = this.wrapperHeight - 8;
} else {
this.minBoundaryY = 0;
this.maxBoundaryY = this.maxPosY;
}
this.maxPosY = this.wrapperHeight - this.indicatorHeight;
this.sizeRatioY = this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY / this.scroller.maxScrollY));
}
this.updatePosition();
},
updatePosition: function () {
var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
if ( !this.options.ignoreBoundaries ) {
if ( x < this.minBoundaryX ) {
if ( this.options.shrink == 'scale' ) {
this.width = Math.max(this.indicatorWidth + x, 8);
this.indicatorStyle.width = this.width + 'px';
}
x = this.minBoundaryX;
} else if ( x > this.maxBoundaryX ) {
if ( this.options.shrink == 'scale' ) {
this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
this.indicatorStyle.width = this.width + 'px';
x = this.maxPosX + this.indicatorWidth - this.width;
} else {
x = this.maxBoundaryX;
}
} else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
this.width = this.indicatorWidth;
this.indicatorStyle.width = this.width + 'px';
}
if ( y < this.minBoundaryY ) {
if ( this.options.shrink == 'scale' ) {
this.height = Math.max(this.indicatorHeight + y * 3, 8);
this.indicatorStyle.height = this.height + 'px';
}
y = this.minBoundaryY;
} else if ( y > this.maxBoundaryY ) {
if ( this.options.shrink == 'scale' ) {
this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
this.indicatorStyle.height = this.height + 'px';
y = this.maxPosY + this.indicatorHeight - this.height;
} else {
y = this.maxBoundaryY;
}
} else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
this.height = this.indicatorHeight;
this.indicatorStyle.height = this.height + 'px';
}
}
this.x = x;
this.y = y;
if ( this.scroller.options.useTransform ) {
this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
} else {
this.indicatorStyle.left = x + 'px';
this.indicatorStyle.top = y + 'px';
}
},
_pos: function (x, y) {
if ( x < 0 ) {
x = 0;
} else if ( x > this.maxPosX ) {
x = this.maxPosX;
}
if ( y < 0 ) {
y = 0;
} else if ( y > this.maxPosY ) {
y = this.maxPosY;
}
x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
this.scroller.scrollTo(x, y);
},
fade: function (val, hold) {
if ( hold && !this.visible ) {
return;
}
clearTimeout(this.fadeTimeout);
this.fadeTimeout = null;
var time = val ? 250 : 500,
delay = val ? 0 : 300;
val = val ? '1' : '0';
this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
this.fadeTimeout = setTimeout((function (val) {
this.wrapperStyle.opacity = val;
this.visible = +val;
}).bind(this, val), delay);
}
};
IScroll.utils = utils;
if ( typeof module != 'undefined' && module.exports ) {
module.exports = IScroll;
} else {
window.IScroll = IScroll;
}
})(window, document, Math);
// source --> https://trp2016.trparchives.com/wp-content/themes/trp2016/lib/js/drawer/drawer.min.js
/*!
* jquery-drawer v3.1.0
* Flexible drawer menu using jQuery, iScroll and CSS.
* http://git.blivesta.com/drawer
* License : MIT
* Author : blivesta
(http://blivesta.com/)
*/
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var t="drawer",n="undefined"!=typeof document.ontouchstart,s={init:function(n){return n=e.extend({iscroll:{mouseWheel:!0,preventDefault:!1},showOverlay:!0},n),s.settings={state:!1,"class":{nav:"drawer-nav",toggle:"drawer-toggle",overlay:"drawer-overlay",open:"drawer-open",close:"drawer-close",dropdown:"drawer-dropdown"},events:{opened:"drawer.opened",closed:"drawer.closed"},dropdownEvents:{opened:"shown.bs.dropdown",closed:"hidden.bs.dropdown"}},this.each(function(){var o=this,r=e(this),a=r.data(t);if(!a){n=e.extend({},n),r.data(t,{options:n});var i=new IScroll("."+s.settings["class"].nav,n.iscroll);n.showOverlay&&s.addOverlay.call(o),e("."+s.settings["class"].toggle).on("click."+t,function(){return s.toggle.call(o),i.refresh()}),e(window).resize(function(){return s.close.call(o),i.refresh()}),e("."+s.settings["class"].dropdown).on(s.settings.dropdownEvents.opened+" "+s.settings.dropdownEvents.closed,function(){return i.refresh()})}})},addOverlay:function(){var t=e(this),n=e("").addClass(s.settings["class"].overlay+" "+s.settings["class"].toggle);return t.append(n)},toggle:function(){var e=this;return s.settings.state?s.close.call(e):s.open.call(e)},open:function(o){var r=e(this);return o=r.data(t).options,n&&r.on("touchmove."+t,function(e){e.preventDefault()}),r.removeClass(s.settings["class"].close).addClass(s.settings["class"].open).css({overflow:"hidden"}).drawerCallback(function(){s.settings.state=!0,r.trigger(s.settings.events.opened)})},close:function(o){var r=e(this);return o=r.data(t).options,n&&r.off("touchmove."+t),r.removeClass(s.settings["class"].open).addClass(s.settings["class"].close).css({overflow:"auto"}).drawerCallback(function(){s.settings.state=!1,r.trigger(s.settings.events.closed)})},destroy:function(){return this.each(function(){var n=e(this);e(window).off("."+t),n.removeData(t)})}};e.fn.drawerCallback=function(t){var n="transitionend webkitTransitionEnd";return this.each(function(){var s=e(this);s.on(n,function(){return s.off(n),t.call(this)})})},e.fn.drawer=function(n){return s[n]?s[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?void e.error("Method "+n+" does not exist on jQuery."+t):s.init.apply(this,arguments)}});
// source --> https://trp2016.trparchives.com/wp-content/themes/trp2016/lib/js/jquery.heightLine.js
/*!--------------------------------------------------------------------------*
*
* jquery.heightLine.js 1.0.0
*
* MIT-style license.
*
* 2013 Kazuma Nishihata
* http://www.to-r.net
*
*--------------------------------------------------------------------------*/
;(function($){
$.fn.heightLine = function(){
var target = this,fontSizeChangeTimer,windowResizeId= Math.random();
var heightLineObj = {
op : {
"maxWidth" : 10000,
"minWidth" : 0,
"fontSizeCheck" : false
},
setOption : function(op){
this.op = $.extend(this.op,op);
},
destroy : function(){
target.css("height","");
},
create : function(op){
var self = this,
maxHeight = 0,
windowWidth = $(window).width();
self.setOption(op);
if( windowWidth<=self.op.maxWidth && windowWidth>=self.op.minWidth ){
target.each(function(){
if($(this).outerHeight()>maxHeight){
maxHeight = $(this).outerHeight();
}
}).each(function(){
var height = maxHeight
- parseInt($(this).css("padding-top"))
- parseInt($(this).css("padding-bottom"));
$(this).height(height);
});
}
},
refresh : function(op){
this.destroy();
this.create(op);
},
removeEvent :function(){
$(window).off("resize."+windowResizeId);
target.off("destroy refresh");
clearInterval(fontSizeChangeTimer);
}
}
if(typeof arguments[0] === "string" && arguments[0] === "destroy"){
target.trigger("destroy");
}else if(typeof arguments[0] === "string" && arguments[0] === "refresh"){
target.trigger("refresh");
}else{
heightLineObj["create"](arguments[0]);
$(window).on("resize."+windowResizeId,function(){
heightLineObj["refresh"]();
});
target.on("destroy",function(){
heightLineObj["removeEvent"]();
heightLineObj["destroy"]();
}).on("refresh",function(){
heightLineObj["refresh"]();
});
if(heightLineObj.op.fontSizeCheck){
if($("#fontSizeChange").length<=0){
var fontSizeChange = $("
").css({
width:0,
height:"1em",
position:"absolute",
left:0,
top:0
}).appendTo("body");
}
var defaultFontSize = $("#fontSizeChange").height();
fontSizeChangeTimer = setInterval(function(){
if(defaultFontSize != $("#fontSizeChange").height()){
heightLineObj["refresh"]();
}
},100);
}
}
return target;
}
})(jQuery);
// source --> https://trp2016.trparchives.com/wp-content/themes/trp2016/lib/js/boxer/jquery.fs.boxer.js
/*
* Boxer v3.3.0 - 2015-04-04
* A jQuery plugin for displaying images, videos or content in a modal overlay. Part of the Formstone Library.
* http://classic.formstone.it/boxer/
*
* Copyright 2015 Ben Plum; MIT Licensed
*/
;(function ($, window) {
"use strict";
var $body = null,
data = {},
trueMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test((window.navigator.userAgent||window.navigator.vendor||window.opera)),
transitionEvent,
transitionSupported;
/**
* @options
* @param callback [function] <$.noop> "Funciton called after opening instance"
* @param customClass [string] <''> "Class applied to instance"
* @param extensions [array] <"jpg", "sjpg", "jpeg", "png", "gif"> "Image type extensions"
* @param fixed [boolean]
"Flag for fixed positioning"
* @param formatter [function] <$.noop> "Caption format function"
* @param labels.close [string] <'Close'> "Close button text"
* @param labels.count [string] <'of'> "Gallery count separator text"
* @param labels.next [string] <'Next'> "Gallery control text"
* @param labels.previous [string] <'Previous'> "Gallery control text"
* @param margin [int] <50> "Margin used when sizing (single side)"
* @param minHeight [int] <100> "Minimum height of modal"
* @param minWidth [int] <100> "Minimum width of modal"
* @param mobile [boolean] "Flag to force 'mobile' rendering"
* @param opacity [number] <0.75> "Overlay target opacity"
* @param retina [boolean] "Use 'retina' sizing (half's natural sizes)"
* @param requestKey [string] <'boxer'> "GET variable for ajax / iframe requests"
* @param top [int] <0> "Target top position; over-rides centering"
* @param videoRadio [number] <0.5625> "Video height / width ratio (9 / 16 = 0.5625)"
* @param videoWidth [int] <600> "Video target width"
*/
var options = {
callback: $.noop,
customClass: "",
extensions: [ "jpg", "sjpg", "jpeg", "png", "gif" ],
fixed: false,
formatter: $.noop,
labels: {
close: "Close",
count: "of",
next: "Next",
previous: "Previous"
},
margin: 50,
minHeight: 100,
minWidth: 100,
mobile: false,
opacity: 0.75,
retina: false,
requestKey: "boxer",
top: 0,
videoRatio: 0.5625,
videoWidth: 600
};
/**
* @events
* @event open.boxer "Modal opened; triggered on window"
* @event close.boxer "Modal closed; triggered on window"
*/
var pub = {
/**
* @method
* @name close
* @description Closes active instance of plugin
* @example $.boxer("close");
*/
close: function() {
if (typeof data.$boxer !== "undefined") {
data.$boxer.off(".boxer");
data.$overlay.trigger("click");
}
},
/**
* @method
* @name defaults
* @description Sets default plugin options
* @param opts [object] <{}> "Options object"
* @example $.boxer("defaults", opts);
*/
defaults: function(opts) {
options = $.extend(options, opts || {});
return (typeof this === 'object') ? $(this) : false;
},
/**
* @method
* @name destroy
* @description Removes plugin bindings
* @example $(".target").boxer("destroy");
*/
destroy: function() {
return $(this).off(".boxer");
},
/**
* @method
* @name resize
* @description Triggers resize of instance
* @example $.boxer("resize");
* @param height [int | false] "Target height or false to auto size"
* @param width [int | false] "Target width or false to auto size"
*/
resize: function(e) {
if (typeof data.$boxer !== "undefined") {
if (typeof e !== "object") {
data.targetHeight = arguments[0];
data.targetWidth = arguments[1];
}
if (data.type === "element") {
sizeContent(data.$content.find(">:first-child"));
} else if (data.type === "image") {
sizeImage();
} else if (data.type === "video") {
sizeVideo();
}
size();
}
return $(this);
}
};
/**
* @method private
* @name init
* @description Initializes plugin
* @param opts [object] "Initialization options"
*/
function init(opts) {
options.formatter = formatCaption;
$body = $("body");
transitionEvent = getTransitionEvent();
transitionSupported = (transitionEvent !== false);
// no transitions :(
if (!transitionSupported) {
transitionEvent = "transitionend.boxer";
}
return $(this).on("click.boxer", $.extend({}, options, opts || {}), build);
}
/**
* @method private
* @name build
* @description Builds target instance
* @param e [object] "Event data"
*/
function build(e) {
if (typeof data.$boxer === "undefined") {
// Check target type
var $target = $(this),
$object = e.data.$object,
source = ($target[0].href) ? $target[0].href || "" : "",
hash = ($target[0].hash) ? $target[0].hash || "" : "",
sourceParts = source.toLowerCase().split(".").pop().split(/\#|\?/),
extension = sourceParts[0],
type = $target.data("boxer-type") || "",
isImage = ( (type === "image") || ($.inArray(extension, e.data.extensions) > -1 || source.substr(0, 10) === "data:image") ),
isVideo = ( source.indexOf("youtube.com/embed") > -1 || source.indexOf("player.vimeo.com/video") > -1 ),
isUrl = ( (type === "url") || (!isImage && !isVideo && source.substr(0, 4) === "http" && !hash) ),
isElement = ( (type === "element") || (!isImage && !isVideo && !isUrl && (hash.substr(0, 1) === "#")) ),
isObject = ( (typeof $object !== "undefined") );
if (isElement) {
source = hash;
}
// Check if boxer is already active, retain default click
if ($("#boxer").length > 1 || !(isImage || isVideo || isUrl || isElement || isObject)) {
return;
}
// Kill event
killEvent(e);
// Cache internal data
data = $.extend({}, {
$window: $(window),
$body: $("body"),
$target: $target,
$object: $object,
visible: false,
resizeTimer: null,
touchTimer: null,
gallery: {
active: false
},
isMobile: (trueMobile || e.data.mobile),
isAnimating: true,
oldContentHeight: 0,
oldContentWidth: 0
}, e.data);
// Double the margin
data.margin *= 2;
if (isImage) {
data.type = "image";
} else if (isVideo) {
data.type = "video";
} else {
data.type = "element";
}
if (isImage || isVideo) {
// Check for gallery
var id = data.$target.data("gallery") || data.$target.attr("rel"); // backwards compatibility
if (typeof id !== "undefined" && id !== false) {
data.gallery.active = true;
data.gallery.id = id;
data.gallery.$items = $("a[data-gallery= " + data.gallery.id + "], a[rel= " + data.gallery.id + "]"); // backwards compatibility
data.gallery.index = data.gallery.$items.index(data.$target);
data.gallery.total = data.gallery.$items.length - 1;
}
}
// Assemble HTML
var html = '';
if (!data.isMobile) {
html += '';
}
html += '';
html += '
' + data.labels.close + '';
html += '
';
html += '
';
html += '
';
if (isImage || isVideo) {
html += '
'; //container, content, boxer
// Modify Dom
data.$body.append(html);
// Cache jquery objects
data.$overlay = $("#boxer-overlay");
data.$boxer = $("#boxer");
data.$container = data.$boxer.find(".boxer-container");
data.$content = data.$boxer.find(".boxer-content");
data.$meta = data.$boxer.find(".boxer-meta");
data.$position = data.$boxer.find(".boxer-position");
data.$caption = data.$boxer.find(".boxer-caption");
data.$controls = data.$boxer.find(".boxer-control");
data.paddingVertical = (!data.isMobile) ? (parseInt(data.$boxer.css("paddingTop"), 10) + parseInt(data.$boxer.css("paddingBottom"), 10)) : (data.$boxer.find(".boxer-close").outerHeight() / 2);
data.paddingHorizontal = (!data.isMobile) ? (parseInt(data.$boxer.css("paddingLeft"), 10) + parseInt(data.$boxer.css("paddingRight"), 10)) : 0;
data.contentHeight = data.$boxer.outerHeight() - data.paddingVertical;
data.contentWidth = data.$boxer.outerWidth() - data.paddingHorizontal;
data.controlHeight = data.$controls.outerHeight();
// Center
center();
// Update gallery
if (data.gallery.active) {
updateControls();
}
// Bind events
data.$window.on("resize.boxer", pub.resize)
.on("keydown.boxer", onKeypress);
data.$body.on("touchstart.boxer click.boxer", "#boxer-overlay, #boxer .boxer-close", onClose)
.on("touchmove.boxer", killEvent);
if (data.gallery.active) {
data.$boxer.on("touchstart.boxer click.boxer", ".boxer-control", advanceGallery);
}
data.$boxer.on(transitionEvent, function(e) {
killEvent(e);
if ($(e.target).is(data.$boxer)) {
data.$boxer.off(transitionEvent);
if (isImage) {
loadImage(source);
} else if (isVideo) {
loadVideo(source);
} else if (isUrl) {
loadURL(source);
} else if (isElement) {
cloneElement(source);
} else if (isObject) {
appendObject(data.$object);
} else {
$.error("BOXER: '" + source + "' is not valid.");
}
}
});
$body.addClass("boxer-open");
if (!transitionSupported) {
data.$boxer.trigger(transitionEvent);
}
if (isObject) {
return data.$boxer;
}
}
}
/**
* @method private
* @name onClose
* @description Closes active instance
* @param e [object] "Event data"
*/
function onClose(e) {
killEvent(e);
if (typeof data.$boxer !== "undefined") {
data.$boxer.on(transitionEvent, function(e) {
killEvent(e);
if ($(e.target).is(data.$boxer)) {
data.$boxer.off(transitionEvent);
data.$overlay.remove();
data.$boxer.remove();
// reset data
data = {};
}
}).addClass("animating");
$body.removeClass("boxer-open");
if (!transitionSupported) {
data.$boxer.trigger(transitionEvent);
}
clearTimer(data.resizeTimer);
// Clean up
data.$window.off("resize.boxer")
.off("keydown.boxer");
data.$body.off(".boxer")
.removeClass("boxer-open");
if (data.gallery.active) {
data.$boxer.off(".boxer");
}
if (data.isMobile) {
if (data.type === "image" && data.gallery.active) {
data.$container.off(".boxer");
}
}
data.$window.trigger("close.boxer");
}
}
/**
* @method private
* @name open
* @description Opens active instance
*/
function open() {
var position = calculatePosition(),
durration = data.isMobile ? 0 : data.duration;
if (!data.isMobile) {
data.$controls.css({
marginTop: ((data.contentHeight - data.controlHeight - data.metaHeight) / 2)
});
}
if (!data.visible && data.isMobile && data.gallery.active) {
data.$content.on("touchstart.boxer", ".boxer-image", onTouchStart);
}
if (data.isMobile || data.fixed) {
data.$body.addClass("boxer-open");
}
data.$boxer.on(transitionEvent, function(e) {
killEvent(e);
if ($(e.target).is(data.$boxer)) {
data.$boxer.off(transitionEvent);
data.$container.on(transitionEvent, function(e) {
killEvent(e);
if ($(e.target).is(data.$container)) {
data.$container.off(transitionEvent);
data.$boxer.removeClass("animating");
data.isAnimating = false;
}
});
data.$boxer.removeClass("loading");
if (!transitionSupported) {
data.$content.trigger(transitionEvent);
}
data.visible = true;
// Fire callback + event
data.callback.apply(data.$boxer);
data.$window.trigger("open.boxer");
// Start preloading
if (data.gallery.active) {
preloadGallery();
}
}
});
if (!data.isMobile) {
data.$boxer.css({
height: data.contentHeight + data.paddingVertical,
width: data.contentWidth + data.paddingHorizontal,
top: (!data.fixed) ? position.top : 0
});
}
// Trigger event in case the content size hasn't changed
var contentHasChanged = (data.oldContentHeight !== data.contentHeight || data.oldContentWidth !== data.contentWidth);
if (data.isMobile || !transitionSupported || !contentHasChanged) {
data.$boxer.trigger(transitionEvent);
}
// Track content size changes
data.oldContentHeight = data.contentHeight;
data.oldContentWidth = data.contentWidth;
}
/**
* @method private
* @name size
* @description Sizes active instance
*/
function size() {
if (data.visible && !data.isMobile) {
var position = calculatePosition();
data.$controls.css({
marginTop: ((data.contentHeight - data.controlHeight - data.metaHeight) / 2)
});
data.$boxer.css({
height: data.contentHeight + data.paddingVertical,
width: data.contentWidth + data.paddingHorizontal,
top: (!data.fixed) ? position.top : 0
});
}
}
/**
* @method private
* @name center
* @description Centers instance
*/
function center() {
var position = calculatePosition();
data.$boxer.css({
top: (!data.fixed) ? position.top : 0
});
}
/**
* @method private
* @name calculatePosition
* @description Calculates positions
* @return [object] "Object containing top and left positions"
*/
function calculatePosition() {
if (data.isMobile) {
return {
left: 0,
top: 0
};
}
var pos = {
left: (data.$window.width() - data.contentWidth - data.paddingHorizontal) / 2,
top: (data.top <= 0) ? ((data.$window.height() - data.contentHeight - data.paddingVertical) / 2) : data.top
};
if (data.fixed !== true) {
pos.top += data.$window.scrollTop();
}
return pos;
}
/**
* @method private
* @name formatCaption
* @description Formats caption
* @param $target [jQuery object] "Target element"
*/
function formatCaption($target) {
var title = $target.attr("title");
return (title !== undefined && title.trim() !== "") ? '
' + title.trim() + '
' : "";
}
/**
* @method private
* @name loadImage
* @description Loads source image
* @param source [string] "Source image URL"
*/
function loadImage(source) {
// Cache current image
data.$image = $("
![]()
");
data.$image.load(function() {
data.$image.off("load, error");
var naturalSize = calculateNaturalSize(data.$image);
data.naturalHeight = naturalSize.naturalHeight;
data.naturalWidth = naturalSize.naturalWidth;
if (data.retina) {
data.naturalHeight /= 2;
data.naturalWidth /= 2;
}
data.$content.prepend(data.$image);
if (data.$caption.html() === "") {
data.$caption.hide();
} else {
data.$caption.show();
}
// Size content to be sure it fits the viewport
sizeImage();
open();
}).error(loadError)
.attr("src", source)
.addClass("boxer-image");
// If image has already loaded into cache, trigger load event
if (data.$image[0].complete || data.$image[0].readyState === 4) {
data.$image.trigger("load");
}
}
/**
* @method private
* @name sizeImage
* @description Sizes image to fit in viewport
* @param count [int] "Number of resize attempts"
*/
function sizeImage() {
var count = 0;
data.windowHeight = data.viewportHeight = data.$window.height() - data.paddingVertical;
data.windowWidth = data.viewportWidth = data.$window.width() - data.paddingHorizontal;
data.contentHeight = Infinity;
data.contentWidth = Infinity;
data.imageMarginTop = 0;
data.imageMarginLeft = 0;
while (data.contentHeight > data.viewportHeight && count < 2) {
data.imageHeight = (count === 0) ? data.naturalHeight : data.$image.outerHeight();
data.imageWidth = (count === 0) ? data.naturalWidth : data.$image.outerWidth();
data.metaHeight = (count === 0) ? 0 : data.metaHeight;
if (count === 0) {
data.ratioHorizontal = data.imageHeight / data.imageWidth;
data.ratioVertical = data.imageWidth / data.imageHeight;
data.isWide = (data.imageWidth > data.imageHeight);
}
// Double check min and max
if (data.imageHeight < data.minHeight) {
data.minHeight = data.imageHeight;
}
if (data.imageWidth < data.minWidth) {
data.minWidth = data.imageWidth;
}
if (data.isMobile) {
// Get meta height before sizing
data.$meta.css({
width: data.windowWidth
});
data.metaHeight = data.$meta.outerHeight(true);
// Content match viewport
data.contentHeight = data.viewportHeight - data.paddingVertical;
data.contentWidth = data.viewportWidth - data.paddingHorizontal;
fitImage();
data.imageMarginTop = (data.contentHeight - data.targetImageHeight - data.metaHeight) / 2;
data.imageMarginLeft = (data.contentWidth - data.targetImageWidth) / 2;
} else {
// Viewport should match window, less margin, padding and meta
if (count === 0) {
data.viewportHeight -= (data.margin + data.paddingVertical);
data.viewportWidth -= (data.margin + data.paddingHorizontal);
}
data.viewportHeight -= data.metaHeight;
fitImage();
data.contentHeight = data.targetImageHeight;
data.contentWidth = data.targetImageWidth;
}
// Modify DOM
data.$meta.css({
width: data.contentWidth
});
data.$image.css({
height: data.targetImageHeight,
width: data.targetImageWidth,
marginTop: data.imageMarginTop,
marginLeft: data.imageMarginLeft
});
if (!data.isMobile) {
data.metaHeight = data.$meta.outerHeight(true);
data.contentHeight += data.metaHeight;
}
count ++;
}
}
/**
* @method private
* @name fitImage
* @description Calculates target image size
*/
function fitImage() {
var height = (!data.isMobile) ? data.viewportHeight : data.contentHeight - data.metaHeight,
width = (!data.isMobile) ? data.viewportWidth : data.contentWidth;
if (data.isWide) {
//WIDE
data.targetImageWidth = width;
data.targetImageHeight = data.targetImageWidth * data.ratioHorizontal;
if (data.targetImageHeight > height) {
data.targetImageHeight = height;
data.targetImageWidth = data.targetImageHeight * data.ratioVertical;
}
} else {
//TALL
data.targetImageHeight = height;
data.targetImageWidth = data.targetImageHeight * data.ratioVertical;
if (data.targetImageWidth > width) {
data.targetImageWidth = width;
data.targetImageHeight = data.targetImageWidth * data.ratioHorizontal;
}
}
// MAX
if (data.targetImageWidth > data.imageWidth || data.targetImageHeight > data.imageHeight) {
data.targetImageHeight = data.imageHeight;
data.targetImageWidth = data.imageWidth;
}
// MIN
if (data.targetImageWidth < data.minWidth || data.targetImageHeight < data.minHeight) {
if (data.targetImageWidth < data.minWidth) {
data.targetImageWidth = data.minWidth;
data.targetImageHeight = data.targetImageWidth * data.ratioHorizontal;
} else {
data.targetImageHeight = data.minHeight;
data.targetImageWidth = data.targetImageHeight * data.ratioVertical;
}
}
}
/**
* @method private
* @name loadVideo
* @description Loads source video
* @param source [string] "Source video URL"
*/
function loadVideo(source) {
data.$videoWrapper = $('
');
data.$video = $('
');
data.$video.attr("src", source)
.addClass("boxer-video")
.prependTo(data.$videoWrapper);
data.$content.prepend(data.$videoWrapper);
sizeVideo();
open();
}
/**
* @method private
* @name sizeVideo
* @description Sizes video to fit in viewport
*/
function sizeVideo() {
// Set initial vars
data.windowHeight = data.viewportHeight = data.contentHeight = data.$window.height() - data.paddingVertical;
data.windowWidth = data.viewportWidth = data.contentWidth = data.$window.width() - data.paddingHorizontal;
data.videoMarginTop = 0;
data.videoMarginLeft = 0;
if (data.isMobile) {
data.$meta.css({
width: data.windowWidth
});
data.metaHeight = data.$meta.outerHeight(true);
data.viewportHeight -= data.metaHeight;
data.targetVideoWidth = data.viewportWidth;
data.targetVideoHeight = data.targetVideoWidth * data.videoRatio;
if (data.targetVideoHeight > data.viewportHeight) {
data.targetVideoHeight = data.viewportHeight;
data.targetVideoWidth = data.targetVideoHeight / data.videoRatio;
}
data.videoMarginTop = (data.viewportHeight - data.targetVideoHeight) / 2;
data.videoMarginLeft = (data.viewportWidth - data.targetVideoWidth) / 2;
} else {
data.viewportHeight = data.windowHeight - data.margin;
data.viewportWidth = data.windowWidth - data.margin;
data.targetVideoWidth = (data.videoWidth > data.viewportWidth) ? data.viewportWidth : data.videoWidth;
if (data.targetVideoWidth < data.minWidth) {
data.targetVideoWidth = data.minWidth;
}
data.targetVideoHeight = data.targetVideoWidth * data.videoRatio;
data.contentHeight = data.targetVideoHeight;
data.contentWidth = data.targetVideoWidth;
}
// Update dom
data.$meta.css({
width: data.contentWidth
});
data.$videoWrapper.css({
height: data.targetVideoHeight,
width: data.targetVideoWidth,
marginTop: data.videoMarginTop,
marginLeft: data.videoMarginLeft
});
if (!data.isMobile) {
data.metaHeight = data.$meta.outerHeight(true);
data.contentHeight = data.targetVideoHeight + data.metaHeight;
}
}
/**
* @method private
* @name preloadGallery
* @description Preloads previous and next images in gallery for faster rendering
* @param e [object] "Event Data"
*/
function preloadGallery(e) {
var source = '';
if (data.gallery.index > 0) {
source = data.gallery.$items.eq(data.gallery.index - 1).attr("href");
if (source.indexOf("youtube.com/embed") < 0 && source.indexOf("player.vimeo.com/video") < 0) {
$('

');
}
}
if (data.gallery.index < data.gallery.total) {
source = data.gallery.$items.eq(data.gallery.index + 1).attr("href");
if (source.indexOf("youtube.com/embed") < 0 && source.indexOf("player.vimeo.com/video") < 0) {
$('

');
}
}
}
/**
* @method private
* @name advanceGallery
* @description Advances gallery base on direction
* @param e [object] "Event Data"
*/
function advanceGallery(e) {
killEvent(e);
var $control = $(this);
if (!data.isAnimating && !$control.hasClass("disabled")) {
data.isAnimating = true;
data.gallery.index += ($control.hasClass("next")) ? 1 : -1;
if (data.gallery.index > data.gallery.total) {
data.gallery.index = data.gallery.total;
}
if (data.gallery.index < 0) {
data.gallery.index = 0;
}
data.$container.on(transitionEvent, function(e) {
killEvent(e);
if ($(e.target).is(data.$container)) {
data.$container.off(transitionEvent);
if (typeof data.$image !== 'undefined') {
data.$image.remove();
}
if (typeof data.$videoWrapper !== 'undefined') {
data.$videoWrapper.remove();
}
data.$target = data.gallery.$items.eq(data.gallery.index);
data.$caption.html(data.formatter.apply(data.$body, [data.$target]));
data.$position.find(".current").html(data.gallery.index + 1);
var source = data.$target.attr("href"),
isVideo = ( source.indexOf("youtube.com/embed") > -1 || source.indexOf("player.vimeo.com/video") > -1 );
if (isVideo) {
loadVideo(source);
} else {
loadImage(source);
}
updateControls();
}
});
data.$boxer.addClass("loading animating");
if (!transitionSupported) {
data.$content.trigger(transitionEvent);
}
}
}
/**
* @method private
* @name updateControls
* @description Updates gallery control states
*/
function updateControls() {
data.$controls.removeClass("disabled");
if (data.gallery.index === 0) {
data.$controls.filter(".previous").addClass("disabled");
}
if (data.gallery.index === data.gallery.total) {
data.$controls.filter(".next").addClass("disabled");
}
}
/**
* @method private
* @name onKeypress
* @description Handles keypress in gallery
* @param e [object] "Event data"
*/
function onKeypress(e) {
if (data.gallery.active && (e.keyCode === 37 || e.keyCode === 39)) {
killEvent(e);
data.$controls.filter((e.keyCode === 37) ? ".previous" : ".next").trigger("click");
} else if (e.keyCode === 27) {
data.$boxer.find(".boxer-close").trigger("click");
}
}
/**
* @method private
* @name cloneElement
* @description Clones target inline element
* @param id [string] "Target element id"
*/
function cloneElement(id) {
var $clone = $(id).find(">:first-child").clone();
appendObject($clone);
}
/**
* @method private
* @name loadURL
* @description Load URL into iframe
* @param source [string] "Target URL"
*/
function loadURL(source) {
source = source + ((source.indexOf("?") > -1) ? "&"+options.requestKey+"=true" : "?"+options.requestKey+"=true");
var $iframe = $('
');
appendObject($iframe);
}
/**
* @method private
* @name appendObject
* @description Appends and sizes object
* @param $object [jQuery Object] "Object to append"
*/
function appendObject($object) {
data.$content.append($object);
sizeContent($object);
open();
}
/**
* @method private
* @name sizeContent
* @description Sizes jQuery object to fir in viewport
* @param $object [jQuery Object] "Object to size"
*/
function sizeContent($object) {
data.windowHeight = data.$window.height() - data.paddingVertical;
data.windowWidth = data.$window.width() - data.paddingHorizontal;
data.objectHeight = $object.outerHeight(true);
data.objectWidth = $object.outerWidth(true);
data.targetHeight = data.targetHeight || data.$target.data("boxer-height");
data.targetWidth = data.targetWidth || data.$target.data("boxer-width");
data.maxHeight = (data.windowHeight < 0) ? options.minHeight : data.windowHeight;
data.isIframe = $object.is("iframe");
data.objectMarginTop = 0;
data.objectMarginLeft = 0;
if (!data.isMobile) {
data.windowHeight -= data.margin;
data.windowWidth -= data.margin;
}
data.contentHeight = (data.targetHeight !== undefined) ? data.targetHeight : (data.isIframe || data.isMobile) ? data.windowHeight : data.objectHeight;
data.contentWidth = (data.targetWidth !== undefined) ? data.targetWidth : (data.isIframe || data.isMobile) ? data.windowWidth : data.objectWidth;
if ((data.isIframe || data.isObject) && data.isMobile) {
data.contentHeight = data.windowHeight;
data.contentWidth = data.windowWidth;
} else if (data.isObject) {
data.contentHeight = (data.contentHeight > data.windowHeight) ? data.windowHeight : data.contentHeight;
data.contentWidth = (data.contentWidth > data.windowWidth) ? data.windowWidth : data.contentWidth;
}
}
/**
* @method private
* @name loadError
* @description Error when resource fails to load
* @param e [object] "Event data"
*/
function loadError(e) {
var $error = $('
');
// Clean up
data.type = "element";
data.$meta.remove();
data.$image.off("load, error");
appendObject($error);
}
/**
* @method private
* @name onTouchStart
* @description Handle touch start event
* @param e [object] "Event data"
*/
function onTouchStart(e) {
killEvent(e);
clearTimer(data.touchTimer);
if (!data.isAnimating) {
var touch = (typeof e.originalEvent.targetTouches !== "undefined") ? e.originalEvent.targetTouches[0] : null;
data.xStart = (touch) ? touch.pageX : e.clientX;
data.leftPosition = 0;
data.touchMax = Infinity;
data.touchMin = -Infinity;
data.edge = data.contentWidth * 0.25;
if (data.gallery.index === 0) {
data.touchMax = 0;
}
if (data.gallery.index === data.gallery.total) {
data.touchMin = 0;
}
data.$boxer.on("touchmove.boxer", onTouchMove)
.one("touchend.boxer", onTouchEnd);
}
}
/**
* @method private
* @name onTouchMove
* @description Handles touchmove event
* @param e [object] "Event data"
*/
function onTouchMove(e) {
var touch = (typeof e.originalEvent.targetTouches !== "undefined") ? e.originalEvent.targetTouches[0] : null;
data.delta = data.xStart - ((touch) ? touch.pageX : e.clientX);
// Only prevent event if trying to swipe
if (data.delta > 20) {
killEvent(e);
}
data.canSwipe = true;
var newLeft = -data.delta;
if (newLeft < data.touchMin) {
newLeft = data.touchMin;
data.canSwipe = false;
}
if (newLeft > data.touchMax) {
newLeft = data.touchMax;
data.canSwipe = false;
}
data.$image.css({ transform: "translate3D("+newLeft+"px,0,0)" });
data.touchTimer = startTimer(data.touchTimer, 300, function() { onTouchEnd(e); });
}
/**
* @method private
* @name onTouchEnd
* @description Handles touchend event
* @param e [object] "Event data"
*/
function onTouchEnd(e) {
killEvent(e);
clearTimer(data.touchTimer);
data.$boxer.off("touchmove.boxer touchend.boxer");
if (data.delta) {
data.$boxer.addClass("animated");
data.swipe = false;
if (data.canSwipe && (data.delta > data.edge || data.delta < -data.edge)) {
data.swipe = true;
if (data.delta <= data.leftPosition) {
data.$image.css({ transform: "translate3D("+(data.contentWidth)+"px,0,0)" });
} else {
data.$image.css({ transform: "translate3D("+(-data.contentWidth)+"px,0,0)" });
}
} else {
data.$image.css({ transform: "translate3D(0,0,0)" });
}
if (data.swipe) {
data.$controls.filter( (data.delta <= data.leftPosition) ? ".previous" : ".next" ).trigger("click");
}
startTimer(data.resetTimer, data.duration, function() {
data.$boxer.removeClass("animated");
});
}
}
/**
* @method private
* @name calculateNaturalSize
* @description Determines natural size of target image
* @param $img [jQuery object] "Source image object"
* @return [object | boolean] "Object containing natural height and width values or false"
*/
function calculateNaturalSize($img) {
var node = $img[0],
img = new Image();
if (typeof node.naturalHeight !== "undefined") {
return {
naturalHeight: node.naturalHeight,
naturalWidth: node.naturalWidth
};
} else {
if (node.tagName.toLowerCase() === 'img') {
img.src = node.src;
return {
naturalHeight: img.height,
naturalWidth: img.width
};
}
}
return false;
}
/**
* @method private
* @name killEvent
* @description Prevents default and stops propagation on event
* @param e [object] "Event data"
*/
function killEvent(e) {
if (e.preventDefault) {
e.stopPropagation();
e.preventDefault();
}
}
/**
* @method private
* @name startTimer
* @description Starts an internal timer
* @param timer [int] "Timer ID"
* @param time [int] "Time until execution"
* @param callback [int] "Function to execute"
*/
function startTimer(timer, time, callback) {
clearTimer(timer);
return setTimeout(callback, time);
}
/**
* @method private
* @name clearTimer
* @description Clears an internal timer
* @param timer [int] "Timer ID"
*/
function clearTimer(timer) {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
/**
* @method private
* @name getTransitionEvent
* @description Retuns a properly prefixed transitionend event
* @return [string] "Properly prefixed event"
*/
function getTransitionEvent() {
var transitions = {
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
/* 'MSTransitionEnd': 'msTransition', */
/* 'msTransition': 'MSTransitionEnd' */
'OTransition': 'oTransitionEnd',
'transition': 'transitionend'
},
test = document.createElement('div');
for (var type in transitions) {
if (transitions.hasOwnProperty(type) && type in test.style) {
return transitions[type];
}
}
return false;
}
$.fn.boxer = function(method) {
if (pub[method]) {
return pub[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return init.apply(this, arguments);
}
return this;
};
$.boxer = function($target, opts) {
if (pub[$target]) {
return pub[$target].apply(window, Array.prototype.slice.call(arguments, 1));
} else {
if ($target instanceof $) {
return build.apply(window, [{ data: $.extend({
$object: $target
}, options, opts || {}) }]);
}
}
};
})(jQuery, window);
// source --> https://trp2016.trparchives.com/wp-content/themes/trp2016/lib/js/imgLiquid.js
/*!
imgLiquid v0.9.944 / 03-05-2013
jQuery plugin to resize images to fit in a container.
Copyright (c) 2012 Alejandro Emparan (karacas) @krc_ale
Dual licensed under the MIT and GPL licenses
https://github.com/karacas/imgLiquid
**/
/*
ex:
$('.imgLiquid').imgLiquid({fill:true});
// OPTIONS:
> js:
fill: true,
verticalAlign: // 'center' // 'top' // 'bottom' // '50%' // '10%'
horizontalAlign: // 'center' // 'left' // 'right' // '50%' // '10%'
> CallBacks:
onStart: function(){},
onFinish: function(){},
onItemStart: function(index, container, img){},
onItemFinish: function(index, container, img){}
> hml5 data attr (overwrite all)
data-imgLiquid-fill='true'
data-imgLiquid-horizontalAlign='center'
data-imgLiquid-verticalAlign='center'
*/
//
var imgLiquid = imgLiquid || {VER: '0.9.944'};
imgLiquid.bgs_Available = false;
imgLiquid.bgs_CheckRunned = false;
imgLiquid.injectCss = '.imgLiquid img {visibility:hidden}';
(function ($) {
// ___________________________________________________________________
function checkBgsIsavailable() {
if (imgLiquid.bgs_CheckRunned) return;
else imgLiquid.bgs_CheckRunned = true;
var spanBgs = $('
');
$('body').append(spanBgs);
!function () {
var bgs_Check = spanBgs[0];
if (!bgs_Check || !window.getComputedStyle) return;
var compStyle = window.getComputedStyle(bgs_Check, null);
if (!compStyle || !compStyle.backgroundSize) return;
imgLiquid.bgs_Available = (compStyle.backgroundSize === 'cover');
}();
spanBgs.remove();
}
// ___________________________________________________________________
$.fn.extend({
imgLiquid: function (options) {
this.defaults = {
fill: true,
verticalAlign: 'center', // 'top' // 'bottom' // '50%' // '10%'
horizontalAlign: 'center', // 'left' // 'right' // '50%' // '10%'
useBackgroundSize: true,
useDataHtmlAttr: true,
responsive: true, /* Only for use with BackgroundSize false (or old browsers) */
delay: 0, /* Only for use with BackgroundSize false (or old browsers) */
fadeInTime: 0, /* Only for use with BackgroundSize false (or old browsers) */
removeBoxBackground: true, /* Only for use with BackgroundSize false (or old browsers) */
hardPixels: true, /* Only for use with BackgroundSize false (or old browsers) */
responsiveCheckTime: 500, /* Only for use with BackgroundSize false (or old browsers) */ /* time to check div resize */
timecheckvisibility: 500, /* Only for use with BackgroundSize false (or old browsers) */ /* time to recheck if visible/loaded */
// CALLBACKS
onStart: null, // no-params
onFinish: null, // no-params
onItemStart: null, // params: (index, container, img )
onItemFinish: null, // params: (index, container, img )
onItemError: null // params: (index, container, img )
};
checkBgsIsavailable();
var imgLiquidRoot = this;
// Extend global settings
this.options = options;
this.settings = $.extend({}, this.defaults, this.options);
// CallBack
if (this.settings.onStart) this.settings.onStart();
// ___________________________________________________________________
return this.each(function ($i) {
// MAIN >> each for image
var settings = imgLiquidRoot.settings,
$imgBoxCont = $(this),
$img = $('img:first',$imgBoxCont);
if (!$img.length) {onError(); return;}
// Extend settings
if (!$img.data('imgLiquid_settings')) {
// First time
settings = $.extend({}, imgLiquidRoot.settings, getSettingsOverwrite());
} else {
// Recall
// Remove Classes
$imgBoxCont.removeClass('imgLiquid_error').removeClass('imgLiquid_ready');
settings = $.extend({}, $img.data('imgLiquid_settings'), imgLiquidRoot.options);
}
$img.data('imgLiquid_settings', settings);
// Start CallBack
if (settings.onItemStart) settings.onItemStart($i, $imgBoxCont, $img); /* << CallBack */
// Process
if (imgLiquid.bgs_Available && settings.useBackgroundSize)
processBgSize();
else
processOldMethod();
// END MAIN <<
// ___________________________________________________________________
function processBgSize() {
// Check change img src
if ($imgBoxCont.css('background-image').indexOf(encodeURI($img.attr('src'))) === -1) {
// Change
$imgBoxCont.css({'background-image': 'url("' + encodeURI($img.attr('src')) + '")'});
}
$imgBoxCont.css({
'background-size': (settings.fill) ? 'cover' : 'contain',
'background-position': (settings.horizontalAlign + ' ' + settings.verticalAlign).toLowerCase(),
'background-repeat': 'no-repeat'
});
$('a:first', $imgBoxCont).css({
'display': 'block',
'width': '100%',
'height': '100%'
});
$('img', $imgBoxCont).css({'display': 'none'});
if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
$imgBoxCont.addClass('imgLiquid_bgSize');
$imgBoxCont.addClass('imgLiquid_ready');
checkFinish();
}
// ___________________________________________________________________
function processOldMethod() {
// Check change img src
if ($img.data('oldSrc') && $img.data('oldSrc') !== $img.attr('src')) {
/* Clone & Reset img */
var $imgCopy = $img.clone().removeAttr('style');
$imgCopy.data('imgLiquid_settings', $img.data('imgLiquid_settings'));
$img.parent().prepend($imgCopy);
$img.remove();
$img = $imgCopy;
$img[0].width = 0;
// Bug ie with > if (!$img[0].complete && $img[0].width) onError();
setTimeout(processOldMethod, 10);
return;
}
// Reproceess?
if ($img.data('imgLiquid_oldProcessed')) {
makeOldProcess(); return;
}
// Set data
$img.data('imgLiquid_oldProcessed', false);
$img.data('oldSrc', $img.attr('src'));
// Hide others images
$('img:not(:first)', $imgBoxCont).css('display', 'none');
// CSSs
$imgBoxCont.css({'overflow': 'hidden'});
$img.fadeTo(0, 0).removeAttr('width').removeAttr('height').css({
'visibility': 'visible',
'max-width': 'none',
'max-height': 'none',
'width': 'auto',
'height': 'auto',
'display': 'block'
});
// CheckErrors
$img.on('error', onError);
$img[0].onerror = onError;
// loop until load
function onLoad() {
if ($img.data('imgLiquid_error') || $img.data('imgLiquid_loaded') || $img.data('imgLiquid_oldProcessed')) return;
if ($imgBoxCont.is(':visible') && $img[0].complete && $img[0].width > 0 && $img[0].height > 0) {
$img.data('imgLiquid_loaded', true);
setTimeout(makeOldProcess, $i * settings.delay);
} else {
setTimeout(onLoad, settings.timecheckvisibility);
}
}
onLoad();
checkResponsive();
}
// ___________________________________________________________________
function checkResponsive() {
/* Only for oldProcessed method (background-size dont need) */
if (!settings.responsive && !$img.data('imgLiquid_oldProcessed')) return;
if (!$img.data('imgLiquid_settings')) return;
settings = $img.data('imgLiquid_settings');
$imgBoxCont.actualSize = $imgBoxCont.get(0).offsetWidth + ($imgBoxCont.get(0).offsetHeight / 10000);
if ($imgBoxCont.sizeOld && $imgBoxCont.actualSize !== $imgBoxCont.sizeOld) makeOldProcess();
$imgBoxCont.sizeOld = $imgBoxCont.actualSize;
setTimeout(checkResponsive, settings.responsiveCheckTime);
}
// ___________________________________________________________________
function onError() {
$img.data('imgLiquid_error', true);
$imgBoxCont.addClass('imgLiquid_error');
if (settings.onItemError) settings.onItemError($i, $imgBoxCont, $img); /* << CallBack */
checkFinish();
}
// ___________________________________________________________________
function getSettingsOverwrite() {
var SettingsOverwrite = {};
if (imgLiquidRoot.settings.useDataHtmlAttr) {
var dif = $imgBoxCont.attr('data-imgLiquid-fill'),
ha = $imgBoxCont.attr('data-imgLiquid-horizontalAlign'),
va = $imgBoxCont.attr('data-imgLiquid-verticalAlign');
if (dif === 'true' || dif === 'false') SettingsOverwrite.fill = Boolean (dif === 'true');
if (ha !== undefined && (ha === 'left' || ha === 'center' || ha === 'right' || ha.indexOf('%') !== -1)) SettingsOverwrite.horizontalAlign = ha;
if (va !== undefined && (va === 'top' || va === 'bottom' || va === 'center' || va.indexOf('%') !== -1)) SettingsOverwrite.verticalAlign = va;
}
if (imgLiquid.isIE && imgLiquidRoot.settings.ieFadeInDisabled) SettingsOverwrite.fadeInTime = 0; //ie no anims
return SettingsOverwrite;
}
// ___________________________________________________________________
function makeOldProcess() { /* Only for old browsers, or useBackgroundSize seted false */
// Calculate size
var w, h, wn, hn, ha, va, hdif, vdif,
margT = 0,
margL = 0,
$imgCW = $imgBoxCont.width(),
$imgCH = $imgBoxCont.height();
// Save original sizes
if ($img.data('owidth') === undefined) $img.data('owidth', $img[0].width);
if ($img.data('oheight') === undefined) $img.data('oheight', $img[0].height);
// Compare ratio
if (settings.fill === ($imgCW / $imgCH) >= ($img.data('owidth') / $img.data('oheight'))) {
w = '100%';
h = 'auto';
wn = Math.floor($imgCW);
hn = Math.floor($imgCW * ($img.data('oheight') / $img.data('owidth')));
} else {
w = 'auto';
h = '100%';
wn = Math.floor($imgCH * ($img.data('owidth') / $img.data('oheight')));
hn = Math.floor($imgCH);
}
// Align X
ha = settings.horizontalAlign.toLowerCase();
hdif = $imgCW - wn;
if (ha === 'left') margL = 0;
if (ha === 'center') margL = hdif * 0.5;
if (ha === 'right') margL = hdif;
if (ha.indexOf('%') !== -1){
ha = parseInt (ha.replace('%',''), 10);
if (ha > 0) margL = hdif * ha * 0.01;
}
// Align Y
va = settings.verticalAlign.toLowerCase();
vdif = $imgCH - hn;
if (va === 'top') margT = 0;
if (va === 'center') margT = vdif * 0.5;
if (va === 'bottom') margT = vdif;
if (va.indexOf('%') !== -1){
va = parseInt (va.replace('%',''), 10);
if (va > 0) margT = vdif * va * 0.01;
}
// Add Css
if (settings.hardPixels) {w = wn; h = hn;}
$img.css({
'width': w,
'height': h,
'margin-left': Math.floor(margL),
'margin-top': Math.floor(margT)
});
// FadeIn > Only first time
if (!$img.data('imgLiquid_oldProcessed')) {
$img.fadeTo(settings.fadeInTime, 1);
$img.data('imgLiquid_oldProcessed', true);
if (settings.removeBoxBackground) $imgBoxCont.css('background-image', 'none');
$imgBoxCont.addClass('imgLiquid_nobgSize');
$imgBoxCont.addClass('imgLiquid_ready');
}
if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
checkFinish();
}
// ___________________________________________________________________
function checkFinish() { /* Check callBack */
if ($i === imgLiquidRoot.length - 1) if (imgLiquidRoot.settings.onFinish) imgLiquidRoot.settings.onFinish();
}
});
}
});
})(jQuery);
// Inject css styles ______________________________________________________
!function () {
var css = imgLiquid.injectCss,
head = document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}();