From 242bf8d8c0eb3ed79295e9208b14f1768814bfe4 Mon Sep 17 00:00:00 2001 From: bchanx Date: Thu, 21 Nov 2013 02:46:11 -0800 Subject: [PATCH] Fix browser events for IE --- slidr.js | 31 +++++++++++++--------- slidr.min.js | 75 ++++++++++++++++++++++++++-------------------------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/slidr.js b/slidr.js index 238b99b..a72442f 100644 --- a/slidr.js +++ b/slidr.js @@ -286,6 +286,15 @@ data: 'data-slidr-' + cls, id: function(_, css) { return css ? 'aside[id="' + _.id + '-' + cls + '"]' : _.id + '-' + cls; } } + }, + + // Sanitize events for IE. + sanitize: function(e) { + e = e || window.event; + if (!e.target) e.target = e.srcElement; + if (!e.currentTarget) e.currentTarget = e.srcElement; + if (!e.which && e.keyCode) e.which = e.keyCode; + return e; } }; @@ -567,11 +576,7 @@ // On click callback. onclick: function(_) { - return function handler(e) { - e = e || window.event; - if (!e.target) e.target = e.srcElement; - actions.slide(_, getattr(e.target, controls.cls.data)); - } + return function handler(e) { actions.slide(_, getattr(browser.sanitize(e).target, controls.cls.data)); }; }, // Update controls. @@ -644,11 +649,7 @@ // On click callback. onclick: function(_) { - return function handler(e) { - e = e || window.event; - if (!e.target) e.target = e.srcElement; - actions.slide(_, getattr(e.target, breadcrumbs.cls.data)); - } + return function handler(e) { actions.slide(_, getattr(browser.sanitize(e).target, breadcrumbs.cls.data)); }; }, // Breadcrumb offsets. @@ -927,16 +928,17 @@ return c; }, - // Track mouseover/mouseleave events. + // Track mouseenter/mouseleave events. track: function(el) { - bind(el, 'mouseover', function(e) { nav.mouse.add(e.currentTarget.id); }); - bind(el, 'mouseleave', function(e) { nav.mouse.remove(e.currentTarget.id); }); + bind(el, 'mouseenter', function(e) { nav.mouse.add(browser.sanitize(e).currentTarget.id); }); + bind(el, 'mouseleave', function(e) { nav.mouse.remove(browser.sanitize(e).currentTarget.id); }); } }, // Keyboard events. keyboard: (function() { bind(document, 'keydown', function(e) { + e = browser.sanitize(e); if (nav.mouse.current() && e.which <= 40 && e.which >= 37) { var c = INSTANCES[nav.mouse.current()]; var dir = null; @@ -954,10 +956,12 @@ var start = {}; var delta = {}; bind(_.slidr, 'touchstart', function(e) { + e = browser.sanitize(e); start = { x: e.touches[0].pageX, y: e.touches[0].pageY, time: +new Date }; delta = { x: 0, y: 0, duration: 0 }; }); bind(_.slidr, 'touchmove', function(e) { + e = browser.sanitize(e); if (e.touches.length > 1 || e.scale && e.scale !== 1) return; delta.x = e.touches[0].pageX - start.x; delta.y = e.touches[0].pageY - start.y; @@ -966,6 +970,7 @@ stop(e); }); bind(_.slidr, 'touchend', function(e) { + e = browser.sanitize(e); if (Number(+new Date - start.time) < 250) { var dx = Math.abs(delta.x); var dy = Math.abs(delta.y); diff --git a/slidr.min.js b/slidr.min.js index b9f3809..a1a9cbe 100644 --- a/slidr.min.js +++ b/slidr.min.js @@ -5,40 +5,41 @@ * * Copyright (c) 2013 Brian Chan (bchanx.com) */ -function B(){function F(a,b,c){var d={id:a,a:b,e:null,controls:null,d:c,t:!1,u:!1,start:null,c:null,p:null,P:{},H:{},B:{},h:{up:null,down:null,left:null,right:null}};return{start:function(a){q.start(d,a);return this},canSlide:function(a){return q.J(d,a)},slide:function(a){q.o(d,a);return this},add:function(a,b,c,e){q.add(d,a,b,c,e);return this},auto:function(a,b,c){q.start(d,c);q.p(d,a||5E3,b||"right");return this},stop:function(){q.stop(d);return this},timing:function(a,b){a&&a.constructor===Object? -d.d.timing=y(d.d.timing,a):"string"===typeof a&&"string"===typeof b&&(d.d.timing[a]=b);return this},breadcrumbs:function(){q.e(d);return this},controls:function(a){q.controls(d,a);return this}}}function C(a,b){var c=a,d;for(d in b){if(!c||!c.hasOwnProperty(b[d]))return null;c=c[b[d]]}return c===a?null:c}function y(){for(var a={},b=0,c;c=arguments[b];b++)for(var d in c)a[d]=c[d];return a}function v(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;cg&&c.push(f),"rm"===b&&0<=g&&c.splice(g,1);a.className=c.join(" ");return a}function A(a){return a.replace(/[\s'"]/gi,"").split("").sort().join("")}function h(a,b){if("string"===typeof b){var c=document.defaultView?document.defaultView.getComputedStyle(a): -a.currentStyle,d=c[e.m(b)];d||"opacity"!==b||(d=c.filter?c.filter.split("=")[1].replace(")",""):"1");return d?(c=d.slice(0,-2),"px"===d.slice(-2)&&!isNaN(parseInt(c))&&0>=c.search("px")?parseInt(c):d):"none"}for(d in b)e.m(d)&&(a.style[e.m(d)]=b[d]);return a}function w(a,b,c){"string"===typeof b&&(b=[b]);for(var d=0,f;f=b[d];d++)f="click"===f&&"ontouchstart"in window?"touchend":a.attachEvent?"on"+f:f,a.attachEvent?a.attachEvent(f,c):a.addEventListener(f,c)}function D(a){a=a||window.event;a.cancelBubble= -!0;a.returnValue=!1;a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault()}var e={G:["webkit","Moz","ms","O"],j:{},Z:{},k:function(){e.supports("filter")&&!e.supports("opacity")?e.k=function(){return!0}:e.k=function(){return!1};return e.k()},ba:document.getElementsByTagName("html")[0].style,styleSheet:function(){var a=x("style",{type:"text/css"});document.getElementsByTagName("head")[0].appendChild(a);return a.sheet||a.styleSheet}(),cssRules:function(){e.cssRules=function(){return e.styleSheet.cssRules|| -e.styleSheet.rules};return e.cssRules()},insertRule:function(a){e.insertRule=e.styleSheet.insertRule?function(a){e.styleSheet.insertRule(a,e.cssRules().length)}:function(a){var c=a.split(" {");2===c.length&&(a=c[0],c=E(c[1].replace(/;?\s?}$/g,"")),a&&c&&e.styleSheet.addRule(a,c))};e.insertRule(a)},R:function(a,b,c){a=A(a);for(var d=0,f,g;f=e.cssRules()[d];d++)if(g=A(f.name||f.selectorText||f.cssText.split(" {")[0]||""),g===a){if(c||A(f.cssText)===A(b))return;e.styleSheet.deleteRule(d);break}e.insertRule(b)}, -U:function(a,b){var c=[a,"{"],d;for(d in b)e.m(d,!0)&&c.push(e.m(d,!0)+":"+b[d]+";");c.push("}");return c.join(" ")},f:function(a,b,c){e.R(a,e.U(a,b),c)},K:function(a,b){var c=e.m("animation",!0);if(c&&!e.Z[a]){var c=["@"+(3===c.split("-").length?"-"+c.split("-")[1]+"-":"")+"keyframes "+a+" {"],d;for(d in b)c.push(e.U(d+"%",b[d]));c.push("}");e.R(a,c.join(" "));e.Z[a]=!0}},m:function(a,b){if(!(a in e.j)){for(var c=a.split("-"),d=0,f;f=c[d];d++)c[d]=f[0].toUpperCase()+f.toLowerCase().slice(1);f=c.join(""); -f=f[0].toLowerCase()+f.slice(1);if(void 0!==e.ba[f])e.j[a]={q:a,V:f};else for(f=c.join(""),d=0;dv(t.S,b)||!s.ca[b]?"none":b},get:function(a,b,c,d){return C(a.H,[b,"in"===c?l.O(d):d])},set:function(a,b,c,d){d=t.I(a,d);a.H[b]||(a.H[b]={});return a.H[b][c]=d},apply:function(a,b,c,d,f){if(f=f||t.get(a,b,c,d))p.update(a,b,c),s.w(a,b,f,c,d)}},l={C:"left up top right down bottom".split(" "),F:function(a){return 0<= -v(l.C,a)},O:function(a){var b=l.C.length;return l.F(a)?l.C[(v(l.C,a)+b/2)%b]:null},get:function(a){for(var b=[],c=1,d;void 0!==(d=arguments[c++]);b.push(d));return C(a.P,b)},display:function(a){!a.u&&l.get(a,a.start)&&(a.c=a.start,p.create(a),k.create(a),s.D(a,a.c,"fade"),s.w(a,a.c,"fade","in"),a.u=!0,q.controls(a,a.d.controls),a.d.breadcrumbs&&q.e(a))},o:function(a,b){return l.F(b)?l.go(a,l.get(a,a.c,b),b,b):l.ka(a,b)},ka:function(a,b){if(b&&b!==a.c&&l.get(a,b)){var c=a.B[a.c],d=a.B[b],f=c.xd.x?"left":null,d=c.yd.y?"down":null,c=t.get(a,a.c,"out",f)?f:t.get(a,a.c,"out",d)?d:null,f=t.get(a,b,"in",f)?f:t.get(a,b,"in",d)?d:null;l.go(a,b,c,f,c?null:"fade",f?null:"fade")}},go:function(a,b,c,d,f,g){return a.c&&b?(t.apply(a,b,"in",d,g),t.apply(a,a.c,"out",c,f),a.c=b,k.update(a),!0):!1},find:function(a,b){for(var c=b?[]:{},d=0,f,g;f=a.a.childNodes[d];d++)(g=f&&f.getAttribute?f.getAttribute("data-slidr"):null)&&(b&&0>v(c,g)?c.push(g):g in c||(c[g]=f));return c},I:function(a, -b,c,d,f,g){if(!b||b.constructor!==Array)return!1;for(var e=0,m,h,p,k,n,q,r,s;m=b[e];e++)if(!(m in d)||l.get(a,m)&&(h=b[e-1]||null,p=b[e+1]||null,k=l.get(a,m,f),n=l.get(a,m,g),q=l.get(a,p,f),r=t.get(a,m,"out",f),s=t.get(a,m,"out",g),n&&p&&n!=p||k&&h&&k!=h||q&&q!=m||h&&r&&r!=c||p&&s&&s!=c))return!1;return!0},add:function(a,b,c,d,f,g){for(var e=0,m;m=b[e];e++){a.P[m]=a.P[m]||{};var h=l.get(a,m);h.s=d[m];b[e-1]&&(h[f]=b[e-1],t.set(a,m,f,c));b[e+1]&&(h[g]=b[e+1],t.set(a,m,g,c));s.D(a,m,c);a.start=a.start? -a.start:m}a.t&&(a.u?p.create(a):l.display(a));return!0}},k={b:e.T("control"),types:["border","corner","none"],valid:function(a){return 0<=v(k.types,a)},create:function(a){if(a.a&&!a.controls){a.controls=h(u(x("aside",{id:k.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)","z-index":"0",visibility:"hidden","pointer-events":"none"});for(var b in a.h){var c=a.h,d=b,f=u(x("div"),"add",k.b.h,b);f&&f.setAttribute&&f.setAttribute(k.b.data,b);c[d]=f;a.controls.appendChild(a.h[b])}k.q(a); -a.a.appendChild(a.controls);w(a.controls,"click",k.onclick(a))}},q:function(a){e.f(k.b.n,{position:"absolute",bottom:"0",right:"0",padding:"10px","box-sizing":"border-box",width:"75px",height:"75px",transform:"translateZ(9998px)"},!0);e.f(k.b.n+".disabled",{transform:"translateZ(0px) !important"},!0);e.f(k.b.n+".breadcrumbs",{left:"0",right:"auto"},!0);e.f(k.b.n+".border",{width:"100%",height:"100%"},!0);e.f(k.b.v,{position:"absolute","pointer-events":"auto",cursor:"pointer",transition:"opacity 0.2s linear"}, -!0);var b={opacity:"0.05",cursor:"auto"};e.k()&&(b.display="none");e.f(k.b.v+".disabled",b,!0);for(var c in a.h){var b="left"===c||"right"===c,d="up"===c?"top":"down"===c?"bottom":c,f=b?"top":"left",g={width:b?"22px":"16px",height:b?"16px":"22px","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none","user-select":"none"};g[d]="0";g[f]="50%";g["margin-"+f]="-8px";e.f(k.b.v+"."+c,g,!0);g={width:"0",height:"0",content:'""',position:"absolute",border:"8px solid transparent"};g["border-"+l.O(d)+ -"-width"]="12px";g["border-"+d+"-width"]="10px";g["border-"+l.O(d)+"-color"]=a.d.theme;g[d]="0";g[f]="50%";g["margin-"+f]="-8px";e.f(k.b.id(a,!0)+" ."+k.b.h+"."+c+":after",g,!0);d={};d[b?"height":"width"]="100%";d[f]="0";d["margin-"+f]="0";e.f(k.b.n+".border ."+k.b.h+"."+c,d,!0)}},onclick:function(a){return function(b){b=b||window.event;b.target||(b.target=b.srcElement);q.o(a,b.target&&b.target.getAttribute?b.target.getAttribute(k.b.data):null)}},update:function(a){for(var b in a.h)u(a.h[b],q.J(a, -b)?"rm":"add","disabled")}},p={b:e.T("breadcrumbs"),D:function(a){a.a&&!a.e&&(a.e=h(u(x("aside",{id:p.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)","z-index":"0","pointer-events":"none",visibility:"hidden"}),p.q(a),a.a.appendChild(a.e),w(a.e,"click",p.onclick(a)))},q:function(a){e.f(p.b.n,{position:"absolute",bottom:"0",right:"0",padding:"10px","box-sizing":"border-box",transform:"translateZ(9999px)"},!0);e.f(p.b.n+".disabled",{transform:"translateZ(0px) !important"},!0);e.f(p.b.v, -{padding:"0","font-size":"0","line-height":"0"},!0);e.f(p.b.v+" li",{width:"10px",height:"10px",display:"inline-block",margin:"3px","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none","user-select":"none"},!0);e.f(p.b.id(a,!0)+" ."+p.b.h+" li.normal",{"border-radius":"100%",border:"1px "+a.d.theme+" solid",cursor:"pointer","pointer-events":"auto"},!0);e.f(p.b.id(a,!0)+" ."+p.b.h+" li.active",{width:"12px",height:"12px",margin:"2px","background-color":a.d.theme},!0)},onclick:function(a){return function(b){b= -b||window.event;b.target||(b.target=b.srcElement);q.o(a,b.target&&b.target.getAttribute?b.target.getAttribute(p.b.data):null)}},N:{right:{x:1,y:0},up:{x:0,y:1},left:{x:-1,y:0},down:{x:0,y:-1}},find:function(a,b,c,d,f,e){if(d){b[d]||(b[d]={x:f,y:e},fc.x.max&&(c.x.max=f),ec.y.max&&(c.y.max=e));d=l.get(a,d);for(var h in p.N)d[h]&&!b[d[h]]&&p.find(a,b,c,d[h],f+p.N[h].x,e+p.N[h].y)}},update:function(a,b,c){u(a.B[b].s,"in"===c?"add":"rm","active")},create:function(a){p.D(a); -if(a.e){var b={},c={x:{min:0,max:0},y:{min:0,max:0}};p.find(a,b,c,a.start,0,0);c.x.M=0-c.x.min;c.y.M=0-c.y.min;var d={},f;for(f in b)b[f].x+=c.x.M,b[f].y+=c.y.M,d[b[f].x+","+b[f].y]=f;for(var e=c.y.max-c.y.min+1,c=c.x.max-c.x.min+1;a.e.firstChild;)a.e.removeChild(a.e.firstChild);f=u(x("ul"),"add",p.b.h);for(var h=x("li"),e=e-1,m;0<=e;e--){m=f.cloneNode(!1);for(var l=0,k,n;l=a.which&&37<=a.which){var b=z[r.g.c()],c=null;40===a.which&&b.canSlide("down")?c="down": -39===a.which&&b.canSlide("right")?c="right":38===a.which&&b.canSlide("up")?c="up":37===a.which&&b.canSlide("left")&&(c="left");c&&b.slide(c)&&D(a)}})}(),la:function(a){var b,c,d,e,g,h;w(a.a,"touchstart",function(a){b=a.touches[0].pageX;c=a.touches[0].pageY;d=+new Date;h=g=e=0});w(a.a,"touchmove",function(a){1(Math.abs(e)+Math.abs(g))/h||D(a))});w(a.a,"touchend",function(b){if(250>Number(+new Date- -d)){var c=Math.abs(e),h=Math.abs(g),l=20e?"right":"left",p=0>g?"down":"up";(c=l&&k?c>h?n:p:l?n:k?p:null)&&q.o(a,c);D(b)}})}},q={start:function(a,b){if(!a.t&&a.a){var c=h(a.a,"display"),d=h(a.a,"position"),e=h(a.a,"opacity");h(a.a,{visibility:"visible",opacity:e,filter:"alpha(opacity="+100*e+")",display:"inline-block"===c||"inline"===c?"inline-block":"block",position:"static"===d?"relative":d,overflow:a.d.overflow?h(a.a,"overflow"):"hidden",transition:"height 0.05s ease-out, width 0.05s ease-out", -"tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none"});a.start||q.add(a,a.d.direction,l.find(a,!0),a.d.transition);l.get(a,b)&&(a.start=b);l.display(a);n.fa(a);s.W(a,a.a);a.d.keyboard&&r.g.ma(a.a);a.d.touch&&r.la(a);a.t=!0;k.update(a)}},J:function(a,b){return a.t&&b&&(l.F(b)?!!l.get(a,a.c,b):!!l.get(a,b))},o:function(a,b){q.J(a,b)&&l.o(a,b)},add:function(a,b,c,d,e){if(a.a){d=t.I(a,d);var g=l.find(a),h="horizontal"===b||"h"===b?"left":"up",k="horizontal"===b||"h"===b?"right":"down";l.I(a, -c,d,g,h,k)||e?l.add(a,c,d,g,h,k):console.warn("[Slidr] Error adding ["+b+"] slides for ["+a.id+"].")}},p:function(a,b,c){a.t&&l.F(c)&&(q.stop(a),a.p=setInterval(function(){l.o(a,c)},b))},stop:function(a){a.t&&a.p&&(clearInterval(a.p),a.p=null)},e:function(a){if(a.e&&a.u){var b="0"===h(a.e,"opacity")?"in":"out";s.w(a,null,"fade",b,null,a.e,"3","none");a.controls&&u(a.controls,"in"===b?"add":"rm","breadcrumbs")}},controls:function(a,b){if(a.controls&&a.u){k.valid(b)||(b=null);var c="hidden"===h(a.controls, -"visibility"),d=b&&"none"!==b?"in":"out";"out"===d&&c||("border"===b?u(a.controls,"add","border"):"corner"===b&&u(a.controls,"rm","border"),s.w(a,null,"fade",d,null,a.controls,"2","none"))}}};setInterval(function b(){var c,d,f;for(f in n.i)if(d=n.i[f],c=d.src,!e.k()&&!(document.contains?document.contains(c.a):document.compareDocumentPosition&&document.compareDocumentPosition(c.a)&16))delete n.i[f],delete z[c.id];else if("hidden"===h(c.a,"visibility"))n.i[f].L=n.$(c,0,d.r.A),n.i[f].Q=n.aa(c,0,d.r.A); -else if(l.get(c,c.c)){var g=l.get(c,c.c).s,k=h(g,"height"),m=h(g,"width");e.k()&&("auto"===k&&g.offsetHeight&&(k=g.offsetHeight),"auto"===m&&g.offsetWidth&&(m=g.offsetWidth));"auto"!==k&&(k+=n.ia(g));"auto"!==m&&(m+=n.oa(g));d.r.height&&d.L!=k&&(n.i[f].L=n.$(c,k,d.r.A));d.r.width&&d.Q!=m&&(n.i[f].Q=n.aa(c,m,d.r.A))}return b}(),250);var z={},H={breadcrumbs:!1,controls:"border",direction:"horizontal",fade:!0,keyboard:!1,overflow:!1,theme:"#fff",timing:{},touch:!1,transition:"linear"},I={none:"none", -fade:"0.4s ease-out",linear:"0.6s ease-out",cube:"1s cubic-bezier(0.15, 0.9, 0.25, 1)"};return{version:function(){return"0.3.0"},transitions:function(){return t.S.slice(0)},create:function(b,c){var d=document.getElementById(b);if(d){var e=y(H,c||{});e.timing=y(I,e.timing);z[b]=z[b]||new F(b,d,e);return z[b]}console.warn("[Slidr] Could not find element with id ["+b+"].")}}}"object"===typeof exports?module.exports=B():"function"===typeof define&&define.amd?define(B):this.slidr=B(); +function D(){function H(a,b,c){var d={id:a,a:b,e:null,controls:null,d:c,u:!1,v:!1,start:null,c:null,q:null,Q:{},I:{},C:{},h:{up:null,down:null,left:null,right:null}};return{start:function(a){r.start(d,a);return this},canSlide:function(a){return r.K(d,a)},slide:function(a){r.p(d,a);return this},add:function(a,b,c,e){r.add(d,a,b,c,e);return this},auto:function(a,b,c){r.start(d,c);r.q(d,a||5E3,b||"right");return this},stop:function(){r.stop(d);return this},timing:function(a,b){a&&a.constructor===Object? +d.d.timing=z(d.d.timing,a):"string"===typeof a&&"string"===typeof b&&(d.d.timing[a]=b);return this},breadcrumbs:function(){r.e(d);return this},controls:function(a){r.controls(d,a);return this}}}function E(a,b){var c=a,d;for(d in b){if(!c||!c.hasOwnProperty(b[d]))return null;c=c[b[d]]}return c===a?null:c}function z(){for(var a={},b=0,c;c=arguments[b];b++)for(var d in c)a[d]=c[d];return a}function w(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;ce&&c.push(f),"rm"===b&&0<=e&&c.splice(e,1);a.className=c.join(" ");return a}function B(a){return a.replace(/[\s'"]/gi,"").split("").sort().join("")}function C(a,b){return a&&a.getAttribute?a.getAttribute(b):null}function h(a,b){if("string"=== +typeof b){var c=document.defaultView?document.defaultView.getComputedStyle(a):a.currentStyle,d=c[e.n(b)];d||"opacity"!==b||(d=c.filter?c.filter.split("=")[1].replace(")",""):"1");return d?(c=d.slice(0,-2),"px"===d.slice(-2)&&!isNaN(parseInt(c))&&0>=c.search("px")?parseInt(c):d):"none"}for(d in b)e.n(d)&&(a.style[e.n(d)]=b[d]);return a}function x(a,b,c){"string"===typeof b&&(b=[b]);for(var d=0,f;f=b[d];d++)f="click"===f&&"ontouchstart"in window?"touchend":a.attachEvent?"on"+f:f,a.attachEvent?a.attachEvent(f, +c):a.addEventListener(f,c)}function F(a){a=a||window.event;a.cancelBubble=!0;a.returnValue=!1;a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault()}var e={H:["webkit","Moz","ms","O"],j:{},$:{},k:function(){e.supports("filter")&&!e.supports("opacity")?e.k=function(){return!0}:e.k=function(){return!1};return e.k()},ca:document.getElementsByTagName("html")[0].style,styleSheet:function(){var a=y("style",{type:"text/css"});document.getElementsByTagName("head")[0].appendChild(a);return a.sheet|| +a.styleSheet}(),cssRules:function(){e.cssRules=function(){return e.styleSheet.cssRules||e.styleSheet.rules};return e.cssRules()},insertRule:function(a){e.insertRule=e.styleSheet.insertRule?function(a){e.styleSheet.insertRule(a,e.cssRules().length)}:function(a){var c=a.split(" {");2===c.length&&(a=c[0],c=G(c[1].replace(/;?\s?}$/g,"")),a&&c&&e.styleSheet.addRule(a,c))};e.insertRule(a)},S:function(a,b,c){a=B(a);for(var d=0,f,g;f=e.cssRules()[d];d++)if(g=B(f.name||f.selectorText||f.cssText.split(" {")[0]|| +""),g===a){if(c||B(f.cssText)===B(b))return;e.styleSheet.deleteRule(d);break}e.insertRule(b)},V:function(a,b){var c=[a,"{"],d;for(d in b)e.n(d,!0)&&c.push(e.n(d,!0)+":"+b[d]+";");c.push("}");return c.join(" ")},f:function(a,b,c){e.S(a,e.V(a,b),c)},L:function(a,b){var c=e.n("animation",!0);if(c&&!e.$[a]){var c=["@"+(3===c.split("-").length?"-"+c.split("-")[1]+"-":"")+"keyframes "+a+" {"],d;for(d in b)c.push(e.V(d+"%",b[d]));c.push("}");e.S(a,c.join(" "));e.$[a]=!0}},n:function(a,b){if(!(a in e.j)){for(var c= +a.split("-"),d=0,f;f=c[d];d++)c[d]=f[0].toUpperCase()+f.toLowerCase().slice(1);f=c.join("");f=f[0].toLowerCase()+f.slice(1);if(void 0!==e.ca[f])e.j[a]={r:a,W:f};else for(f=c.join(""),d=0;dw(u.T,b)||!t.da[b]?"none":b},get:function(a, +b,c,d){return E(a.I,[b,"in"===c?k.P(d):d])},set:function(a,b,c,d){d=u.J(a,d);a.I[b]||(a.I[b]={});return a.I[b][c]=d},apply:function(a,b,c,d,f){if(f=f||u.get(a,b,c,d))q.update(a,b,c),t.A(a,b,f,c,d)}},k={D:"left up top right down bottom".split(" "),G:function(a){return 0<=w(k.D,a)},P:function(a){var b=k.D.length;return k.G(a)?k.D[(w(k.D,a)+b/2)%b]:null},get:function(a){for(var b=[],c=1,d;void 0!==(d=arguments[c++]);b.push(d));return E(a.Q,b)},display:function(a){!a.v&&k.get(a,a.start)&&(a.c=a.start, +q.create(a),n.create(a),t.F(a,a.c,"fade"),t.A(a,a.c,"fade","in"),a.v=!0,r.controls(a,a.d.controls),a.d.breadcrumbs&&r.e(a))},p:function(a,b){return k.G(b)?k.go(a,k.get(a,a.c,b),b,b):k.la(a,b)},la:function(a,b){if(b&&b!==a.c&&k.get(a,b)){var c=a.C[a.c],d=a.C[b],f=c.xd.x?"left":null,d=c.yd.y?"down":null,c=u.get(a,a.c,"out",f)?f:u.get(a,a.c,"out",d)?d:null,f=u.get(a,b,"in",f)?f:u.get(a,b,"in",d)?d:null;k.go(a,b,c,f,c?null:"fade",f?null:"fade")}},go:function(a,b,c,d,f,e){return a.c&& +b?(u.apply(a,b,"in",d,e),u.apply(a,a.c,"out",c,f),a.c=b,n.update(a),!0):!1},find:function(a,b){for(var c=b?[]:{},d=0,f,e;f=a.a.childNodes[d];d++)(e=C(f,"data-slidr"))&&(b&&0>w(c,e)?c.push(e):e in c||(c[e]=f));return c},J:function(a,b,c,d,f,e){if(!b||b.constructor!==Array)return!1;for(var l=0,m,h,q,n,p,r,s,t;m=b[l];l++)if(!(m in d)||k.get(a,m)&&(h=b[l-1]||null,q=b[l+1]||null,n=k.get(a,m,f),p=k.get(a,m,e),r=k.get(a,q,f),s=u.get(a,m,"out",f),t=u.get(a,m,"out",e),p&&q&&p!=q||n&&h&&n!=h||r&&r!=m||h&&s&& +s!=c||q&&t&&t!=c))return!1;return!0},add:function(a,b,c,d,f,e){for(var l=0,m;m=b[l];l++){a.Q[m]=a.Q[m]||{};var h=k.get(a,m);h.t=d[m];b[l-1]&&(h[f]=b[l-1],u.set(a,m,f,c));b[l+1]&&(h[e]=b[l+1],u.set(a,m,e,c));t.F(a,m,c);a.start=a.start?a.start:m}a.u&&(a.v?q.create(a):k.display(a));return!0}},n={b:e.U("control"),types:["border","corner","none"],valid:function(a){return 0<=w(n.types,a)},create:function(a){if(a.a&&!a.controls){a.controls=h(v(y("aside",{id:n.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)", +"z-index":"0",visibility:"hidden","pointer-events":"none"});for(var b in a.h){var c=a.h,d=b,f=v(y("div"),"add",n.b.h,b);f&&f.setAttribute&&f.setAttribute(n.b.data,b);c[d]=f;a.controls.appendChild(a.h[b])}n.r(a);a.a.appendChild(a.controls);x(a.controls,"click",n.onclick(a))}},r:function(a){e.f(n.b.o,{position:"absolute",bottom:"0",right:"0",padding:"10px","box-sizing":"border-box",width:"75px",height:"75px",transform:"translateZ(9998px)"},!0);e.f(n.b.o+".disabled",{transform:"translateZ(0px) !important"}, +!0);e.f(n.b.o+".breadcrumbs",{left:"0",right:"auto"},!0);e.f(n.b.o+".border",{width:"100%",height:"100%"},!0);e.f(n.b.w,{position:"absolute","pointer-events":"auto",cursor:"pointer",transition:"opacity 0.2s linear"},!0);var b={opacity:"0.05",cursor:"auto"};e.k()&&(b.display="none");e.f(n.b.w+".disabled",b,!0);for(var c in a.h){var b="left"===c||"right"===c,d="up"===c?"top":"down"===c?"bottom":c,f=b?"top":"left",g={width:b?"22px":"16px",height:b?"16px":"22px","tap-highlight-color":"rgba(0, 0, 0, 0)", +"touch-callout":"none","user-select":"none"};g[d]="0";g[f]="50%";g["margin-"+f]="-8px";e.f(n.b.w+"."+c,g,!0);g={width:"0",height:"0",content:'""',position:"absolute",border:"8px solid transparent"};g["border-"+k.P(d)+"-width"]="12px";g["border-"+d+"-width"]="10px";g["border-"+k.P(d)+"-color"]=a.d.theme;g[d]="0";g[f]="50%";g["margin-"+f]="-8px";e.f(n.b.id(a,!0)+" ."+n.b.h+"."+c+":after",g,!0);d={};d[b?"height":"width"]="100%";d[f]="0";d["margin-"+f]="0";e.f(n.b.o+".border ."+n.b.h+"."+c,d,!0)}},onclick:function(a){return function(b){r.p(a, +C(e.m(b).target,n.b.data))}},update:function(a){for(var b in a.h)v(a.h[b],r.K(a,b)?"rm":"add","disabled")}},q={b:e.U("breadcrumbs"),F:function(a){a.a&&!a.e&&(a.e=h(v(y("aside",{id:q.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)","z-index":"0","pointer-events":"none",visibility:"hidden"}),q.r(a),a.a.appendChild(a.e),x(a.e,"click",q.onclick(a)))},r:function(a){e.f(q.b.o,{position:"absolute",bottom:"0",right:"0",padding:"10px","box-sizing":"border-box",transform:"translateZ(9999px)"}, +!0);e.f(q.b.o+".disabled",{transform:"translateZ(0px) !important"},!0);e.f(q.b.w,{padding:"0","font-size":"0","line-height":"0"},!0);e.f(q.b.w+" li",{width:"10px",height:"10px",display:"inline-block",margin:"3px","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none","user-select":"none"},!0);e.f(q.b.id(a,!0)+" ."+q.b.h+" li.normal",{"border-radius":"100%",border:"1px "+a.d.theme+" solid",cursor:"pointer","pointer-events":"auto"},!0);e.f(q.b.id(a,!0)+" ."+q.b.h+" li.active",{width:"12px", +height:"12px",margin:"2px","background-color":a.d.theme},!0)},onclick:function(a){return function(b){r.p(a,C(e.m(b).target,q.b.data))}},O:{right:{x:1,y:0},up:{x:0,y:1},left:{x:-1,y:0},down:{x:0,y:-1}},find:function(a,b,c,d,f,e){if(d){b[d]||(b[d]={x:f,y:e},fc.x.max&&(c.x.max=f),ec.y.max&&(c.y.max=e));d=k.get(a,d);for(var l in q.O)d[l]&&!b[d[l]]&&q.find(a,b,c,d[l],f+q.O[l].x,e+q.O[l].y)}},update:function(a,b,c){v(a.C[b].t,"in"===c?"add":"rm","active")}, +create:function(a){q.F(a);if(a.e){var b={},c={x:{min:0,max:0},y:{min:0,max:0}};q.find(a,b,c,a.start,0,0);c.x.N=0-c.x.min;c.y.N=0-c.y.min;var d={},f;for(f in b)b[f].x+=c.x.N,b[f].y+=c.y.N,d[b[f].x+","+b[f].y]=f;for(var e=c.y.max-c.y.min+1,c=c.x.max-c.x.min+1;a.e.firstChild;)a.e.removeChild(a.e.firstChild);f=v(y("ul"),"add",q.b.h);for(var l=y("li"),e=e-1,m;0<=e;e--){m=f.cloneNode(!1);for(var h=0,k,n;h=a.which&&37<=a.which){var b=A[s.g.c()],c=null;40===a.which&&b.canSlide("down")? +c="down":39===a.which&&b.canSlide("right")?c="right":38===a.which&&b.canSlide("up")?c="up":37===a.which&&b.canSlide("left")&&(c="left");c&&b.slide(c)&&F(a)}})}(),ma:function(a){var b,c,d,f,g,h;x(a.a,"touchstart",function(a){a=e.m(a);b=a.touches[0].pageX;c=a.touches[0].pageY;d=+new Date;h=g=f=0});x(a.a,"touchmove",function(a){a=e.m(a);1(Math.abs(f)+Math.abs(g))/h||F(a))});x(a.a,"touchend", +function(b){b=e.m(b);if(250>Number(+new Date-d)){var c=Math.abs(f),h=Math.abs(g),k=20f?"right":"left",p=0>g?"down":"up";(c=k&&l?c>h?n:p:k?n:l?p:null)&&r.p(a,c);F(b)}})}},r={start:function(a,b){if(!a.u&&a.a){var c=h(a.a,"display"),d=h(a.a,"position"),e=h(a.a,"opacity");h(a.a,{visibility:"visible",opacity:e,filter:"alpha(opacity="+100*e+")",display:"inline-block"===c||"inline"===c?"inline-block":"block",position:"static"===d?"relative":d,overflow:a.d.overflow?h(a.a,"overflow"):"hidden", +transition:"height 0.05s ease-out, width 0.05s ease-out","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none"});a.start||r.add(a,a.d.direction,k.find(a,!0),a.d.transition);k.get(a,b)&&(a.start=b);k.display(a);p.ga(a);t.X(a,a.a);a.d.keyboard&&s.g.na(a.a);a.d.touch&&s.ma(a);a.u=!0;n.update(a)}},K:function(a,b){return a.u&&b&&(k.G(b)?!!k.get(a,a.c,b):!!k.get(a,b))},p:function(a,b){r.K(a,b)&&k.p(a,b)},add:function(a,b,c,d,e){if(a.a){d=u.J(a,d);var g=k.find(a),h="horizontal"===b||"h"===b?"left": +"up",m="horizontal"===b||"h"===b?"right":"down";k.J(a,c,d,g,h,m)||e?k.add(a,c,d,g,h,m):console.warn("[Slidr] Error adding ["+b+"] slides for ["+a.id+"].")}},q:function(a,b,c){a.u&&k.G(c)&&(r.stop(a),a.q=setInterval(function(){k.p(a,c)},b))},stop:function(a){a.u&&a.q&&(clearInterval(a.q),a.q=null)},e:function(a){if(a.e&&a.v){var b="0"===h(a.e,"opacity")?"in":"out";t.A(a,null,"fade",b,null,a.e,"3","none");a.controls&&v(a.controls,"in"===b?"add":"rm","breadcrumbs")}},controls:function(a,b){if(a.controls&& +a.v){n.valid(b)||(b=null);var c="hidden"===h(a.controls,"visibility"),d=b&&"none"!==b?"in":"out";"out"===d&&c||("border"===b?v(a.controls,"add","border"):"corner"===b&&v(a.controls,"rm","border"),t.A(a,null,"fade",d,null,a.controls,"2","none"))}}};setInterval(function b(){var c,d,f;for(f in p.i)if(d=p.i[f],c=d.src,!e.k()&&!(document.contains?document.contains(c.a):document.compareDocumentPosition&&document.compareDocumentPosition(c.a)&16))delete p.i[f],delete A[c.id];else if("hidden"===h(c.a,"visibility"))p.i[f].M= +p.aa(c,0,d.s.B),p.i[f].R=p.ba(c,0,d.s.B);else if(k.get(c,c.c)){var g=k.get(c,c.c).t,l=h(g,"height"),m=h(g,"width");e.k()&&("auto"===l&&g.offsetHeight&&(l=g.offsetHeight),"auto"===m&&g.offsetWidth&&(m=g.offsetWidth));"auto"!==l&&(l+=p.ja(g));"auto"!==m&&(m+=p.pa(g));d.s.height&&d.M!=l&&(p.i[f].M=p.aa(c,l,d.s.B));d.s.width&&d.R!=m&&(p.i[f].R=p.ba(c,m,d.s.B))}return b}(),250);var A={},J={breadcrumbs:!1,controls:"border",direction:"horizontal",fade:!0,keyboard:!1,overflow:!1,theme:"#fff",timing:{},touch:!1, +transition:"linear"},K={none:"none",fade:"0.4s ease-out",linear:"0.6s ease-out",cube:"1s cubic-bezier(0.15, 0.9, 0.25, 1)"};return{version:function(){return"0.3.0"},transitions:function(){return u.T.slice(0)},create:function(b,c){var d=document.getElementById(b);if(d){var e=z(J,c||{});e.timing=z(K,e.timing);A[b]=A[b]||new H(b,d,e);return A[b]}console.warn("[Slidr] Could not find element with id ["+b+"].")}}} +"object"===typeof exports?module.exports=D():"function"===typeof define&&define.amd?define(D):this.slidr=D();