Team:Technion-Israel/Technion-Israel-skel-layers.min.js

From 2014.igem.org

Revision as of 14:18, 29 September 2014 by KarenJ (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/* skel-layers.js v1.0 | (c) n33 | n33.co | MIT licensed */

skel.registerPlugin("layers",function(e){function dn(e,r,i){var o,u;this.id=e,this.index=i,this[n]={breakpoints:T,states:T,position:T,side:T,animation:bt,orientation:bt,width:0,height:0,zIndex:this.index,html:"",hidden:H,exclusive:Ht,resetScroll:Ht,resetForms:Ht,swipeToClose:Ht,clickToClose:H},t._.extend(this[n],r),this[W]=t._.newDiv(this[n][It]),this[W].id=e,this[W]._layer=this,this[s]=T,this[tt]=T,this[St]=T,this[Qt]=H,u=t._.cacheElement(this.id,this[W],nt,1),u.onAttach=function(){var e=this.object._layer;e[ut]()||e.init(),e.resume()},u.onDetach=function(){var e=this.object._layer;e.suspend()},this[n].states&&this[n].states!=t._.sd?(o=t._[cn](this[n].states),t._[Wt](o,function(e){t._.addCachedElementToState(o[e],u)})):(this[n].breakpoints?o=t._[cn](this[n].breakpoints):o=t._.breakpointList,t._[Wt](o,function(e){t._.addCachedElementToBreakpoint(o[e],u)}))}var t,n="config",r="_skel_layers_translateOrigin",i="cache",s="$element",o="_skel_layers_translate",u="_skel_layers_resetForms",f="_skel_layers_resume",l="exclusiveLayer",c="activeWrapper",h="_skel_layers_promote",p="moveToInactiveWrapper",d="_skel_layers_demote",v="moveToActiveWrapper",m="setTimeout",g="right",y="bottom",b="useActive",w="deactivate",E="width",S="css",x="scrollTop",T=null,N="center",C="_skel_layers_suspend",k="position",L="prototype",A="left",O="wrapper",M="skel-layers-layer-z-index",_="_skel_layers_init",D="children",P="skel-layers-moved",H=!1,B="inactiveWrapper",j="transform",F=".skel-layers-fixed:not(.skel-layers-moved)",I="length",q="height",R="top",U="deviceType",z="touchstart.lock click.lock scroll.lock",W="element",X="stopPropagation",V='
1){for(t=0;t<this[I];t++)e(this[t])[d]();return e(this)}return n=e(this),n[S](lt,n.data(M)).data(M,""),n},e.fn[Ct]=function(){var t=e(this),n=t.parent(),r=12;n[D]().each(function(){var t=e(this),n=t[Lt]("class");n&&n.match(/(\s+|^)([0-9]+)u(\s+|$)/)&&(r-=parseInt(RegExp.$2))}),r>0&&(t[dt](),t[S](E,(t.data($t)+r)/12*100+"%"))},e.fn[kt]=function(){return e(this).parents()[I]>0},e.fn[dt]=function(){var t=e(this);t[Lt]("class").match(/(\s+|^)([0-9]+)u(\s+|$)/)&&t.data($t,parseInt(RegExp.$2))},e.fn[h]=function(r){var i,s,o;if(this[I]>1){for(i=0;i<this[I];i++)e(this[i])[h](r);return e(this)}return s=e(this),isNaN(o=parseInt(s.data(at)))&&(o=0),s.data(M,s[S](lt))[S](lt,t[n].baseZIndex+o+(r?r:1)),s},e.fn[u]=function(){var t=e(this);return e(this)[Et]("form").each(function(){this.reset()}),t},e.fn[Ut]=function(t,n){return e(this)[S](t,n)[S](Nt+t,Nt+n)[S](G+t,G+n)[S](zt+t,zt+n)[S](Pt+t,Pt+n)},e.fn._skel_layers_xcssProperty=function(t,n){return e(this)[S](t,n)[S](Nt+t,n)[S](G+t,n)[S](zt+t,n)[S](Pt+t,n)},e.fn._skel_layers_xcssValue=function(t,n){return e(this)[S](t,n)[S](t,Nt+n)[S](t,G+n)[S](t,zt+n)[S](t,Pt+n)},dn[L][ht]={none:{activate:function(e){var t=e[n],r=e[s];r[x](0)[h](t.zIndex).show(),t[$]&&r[u](),e[v]()},deactivate:function(e){var t=e[n],r=e[s];r.hide()[d](),e[p]()}},overlayX:{activate:function(e){var r=e[n],i=e[s];i[x](0)[h](r.zIndex)[S](r[nn],Zt+t[Y](t._[b](r[E]))+Gt).show(),r[$]&&i[u](),t[Dt]("x"),e[v](),window[m](function(){i[o]((r[nn]==g?Zt:"")+t[Y](t._[b](r[E])),0)},50)},deactivate:function(e){var i=e[n],o=e[s];o[Et](ln).blur(),o[r](),window[m](function(){t[ct]("x"),e[p](),o[d]().hide()},t[n][xt]+50)}},overlayY:{activate:function(e){var r=e[n],i=e[s];i[x](0)[h](r.zIndex)[S](r[nn],Zt+t[Y](t._[b](r[q]))+Gt).show(),r[$]&&i[u](),t[Dt]("y"),e[v](),window[m](function(){i[o](0,(r[nn]==y?Zt:"")+t[Y](t._[b](r[q])))},50)},deactivate:function(e){var i=e[n],o=e[s];o[Et](ln).blur(),o[r](),window[m](function(){t[ct]("y"),e[p](),o[d]().hide()},t[n][xt]+50)}},pushX:{activate:function(e){var r=e[n],a=e[s],f=t[i][O].add(t[i][c][D]());a[x](0)[S](r[nn],Zt+t[Y](t._[b](r[E]))+Gt).show(),r[$]&&a[u](),f[h](),t[Dt]("x"),e[v](),window[m](function(){a.add(f)[o]((r[nn]==g?Zt:"")+t[Y](t._[b](r[E])),0)},50)},deactivate:function(e){var o=e[n],u=e[s],a=t[i][O].add(t[i][c][D]());u[Et](ln).blur(),u.add(a)[r](),window[m](function(){t[ct]("x"),u.hide(),e[p](),a[d]()},t[n][xt]+50)}},pushY:{activate:function(e){var r=e[n],a=e[s],f=t[i][O].add(t[i][c][D]());a[x](0)[S](r[nn],Zt+t[rn](t._[b](r[q]))+Gt).show(),r[$]&&a[u](),t[Dt]("y"),e[v](),window[m](function(){a.add(f)[o](0,(r[nn]==y?Zt:"")+t[rn](t._[b](r[q])))},50)},deactivate:function(e){var o=e[n],u=e[s],a=t[i][O].add(t[i][c][D]());u[Et](ln).blur(),u.add(a)[r](),window[m](function(){t[ct]("y"),u.hide(),e[p]()},t[n][xt]+50)}},revealX:{activate:function(e){var r=e[n],a=e[s],f=t[i][O].add(t[i][c][D]());a[x](0).show(),r[$]&&a[u](),f[h](),t[Dt]("x"),e[v](),window[m](function(){f[o]((r[nn]==g?Zt:"")+t[Y](t._[b](r[E])),0)},50)},deactivate:function(e){var o=e[n],u=e[s],a=t[i][O].add(t[i][c][D]());u[Et](ln).blur(),a[r](),window[m](function(){t[ct]("x"),u.hide(),a[d](),e[p]()},t[n][xt]+50)}}},dn[L][Tt]={"top-left":{v:R,h:A,side:A},"top-right":{v:R,h:g,side:g},top:{v:R,h:N,side:R},"top-center":{v:R,h:N,side:R},"bottom-left":{v:y,h:A,side:A},"bottom-right":{v:y,h:g,side:g},bottom:{v:y,h:N,side:y},"bottom-center":{v:y,h:N,side:y},left:{v:N,h:A,side:A},"center-left":{v:N,h:A,side:A},right:{v:N,h:g,side:g},"center-right":{v:N,h:g,side:g}},dn[L][wt]=function(){var e,r,o,u;if(this[Qt]){t[i][c][Ot](this[W]);return}e=this[n],r=t._[b](e[ot]),o=this[s],o[S](E,t._[b](e[E]))[S](q,t._[b](e[q])),t._[Kt][U]=="ios"&&e[q]=="100%"&&!e[it]&&o[S](q,"-webkit-calc("+t._[b](e[q])+" + 70px)"),u=this[Tt][e[k]],o[Bt]("skel-layer-"+e[k]).data(ft,e[k]);switch(u.v){case R:o[S](R,0);break;case y:o[S](y,0);break;case N:o[S](R,"50%")[S]("margin-top",Zt+t.getHalf(e[q]))}switch(u.h){case A:o[S](A,0);break;case g:o[S](g,0);break;case N:o[S](A,"50%")[S]("margin-left",Zt+t.getHalf(e[E]))}this[ht][r][wt](this),e[it]&&e.exclusive&&(t[i][Yt][Bt](et),t[i][l]=this),this[Qt]=Ht},dn[L][w]=function(){var e,r;if(!this[Qt]){t[i][B][Ot](this[W]);return}e=this[n],r=t._[b](e[ot]),r in this[ht]||(r=bt),this[ht][r][w](this),e[it]&&e.exclusive&&t[i][l]===this&&(t[i][Yt][Xt](et),t[i][l]=T),this[Qt]=H},dn[L].init=function(){var r=this[n],o=e(this[W]),u=this;o[_](),o[Et](ln).each(function(){t.parseInit(e(this))}),o[Bt]("skel-layer").data(at,this.index)[S](lt,t[n].baseZIndex)[S](k,"fixed")[S]("-ms-overflow-style","-ms-autohiding-scrollbar")[S]("-webkit-overflow-scrolling","touch").hide();switch(r.orientation){case"vertical":o[S]("overflow-y",Ft);break;case"horizontal":o[S](K,Ft);break;case bt:default:}if(!r[k]||!(r[k]in this[Tt]))r[k]="top-left";r[nn]||(r[nn]=this[Tt][r[k]][nn]);if(!r[ot]||typeof r[ot]!="object"&&!(r[ot]in this[ht]))r[ot]=bt;r.clickToClose&&o[Et]("a")[S](st,Vt).on("click.skel-layers",function(r){var i,s,o=e(this);if(o.hasClass("skel-layers-ignore"))return;r[J](),r[X](),u[w]();if(o.hasClass("skel-layers-ignoreHref"))return;i=o[Lt]("href"),s=o[Lt]("target"),typeof i!==gt&&i!=""&&window[m](function(){s=="_blank"&&t._[Kt][U]!="wp"?window.open(i):window.location.href=i},t[n][xt]+10)}),t._[Kt][U]=="ios"&&o[Et]("input,select,textarea").on("focus",function(n){var r=e(this);n[J](),n[X](),window[m](function(){var e=t[i][Q][jt],n=t[i][Q][x]()-e;t[i][Q][x](e),o[x](o[x]()+n),r.hide(),window[m](function(){r.show()},0)},100)}),t._[Kt][_t]&&o.on("touchstart",function(e){u[tt]=e[rt][sn][0].pageX,u[St]=e[rt][sn][0].pageY}).on("touchmove",function(e){var t,n,i,s,a,f,l;if(u[tt]===T||u[St]===T)return;t=u[tt]-e[rt][sn][0].pageX,n=u[St]-e[rt][sn][0].pageY,i=o.outerHeight(),s=o.get(0).scrollHeight-o[x]();if(r[it]&&r.swipeToClose){a=H,f=20,l=50;switch(r[nn]){case A:a=n<f&&n>-1*f&&t>l;break;case g:a=n<f&&n>-1*f&&t<-1*l;break;case R:a=t<f&&t>-1*f&&n>l;break;case y:a=t<f&&t>-1*f&&n<-1*l}if(a)return u[tt]=T,u[St]=T,u[w](),H}if(o[x]()==0&&n<0||s>i-2&&s0)return H}),this[s]=o},dn[L][ut]=function(){return this[s]!==T},dn[L][tn]=function(){return this[s].is(":visible")},dn[L][v]=function(){t[i][c][Ot](this[s])},dn[L][p]=function(){if(!this[s][kt]())return;t[i][B][Ot](this[s])},dn[L].resume=function(r){if(!this[ut]())return;this[s][Et](ln).each(function(){t.parseResume(e(this))}),this[n][it]||this[wt](r)},dn[L].suspend=function(){if(!this[ut]())return;this[s][r](),this[s][Et](ln).each(function(){t.parseSuspend(e(this))}),this[Qt]&&this[w]()},t={cache:{activeWrapper:T,body:T,exclusiveLayer:T,html:T,htmlbody:T,inactiveWrapper:T,layers:{},window:T,wrapper:T},config:{baseZIndex:1e4,layers:{},speed:250,transform:Ht,transformBreakpoints:T,transformTest:T},eventType:en,activate:function(e){t._[Mt](function(){t[i][At][e][wt]()})},deactivate:function(e){t._[Mt](function(){t[i][At][e][w]()})},toggle:function(e){t._[Mt](function(){var n=t[i][At][e];n[tn]()?n[w]():n[wt]()})},getBaseFontSize:function(){return t._[Kt].IEVersion<9?16.5:parseFloat(getComputedStyle(t[i][Yt].get(0)).fontSize)},getHalf:function(e){var t=parseInt(e);return typeof e=="string"&&e.charAt(e[I]-1)=="%"?Math.floor(t/2)+"%":Math.floor(t/2)+Gt},lockView:function(e){t[i][Q][jt]=t[i][Q][x](),t._[Kt][_t]&&t[i][hn][S](on+e,it),t[i][O].on(z,function(e){e[J](),e[X](),t[i][l]&&t[i][l][w]()}),t[i][Q].on(yt,function(e){t[i][l]&&t[i][l][w]()}),t._[Kt][_t]||t[i][Q].on(mt,function(e){t[i][l]&&t[i][l][w]()})},parseInit:function(n){var r,s,o=n.get(0),u=n[Lt]("data-action"),a=n[Lt]("data-args"),c,h;u&&a&&(a=a.split(","));switch(u){case"toggleLayer":case"layerToggle":n[S](st,Vt)[S]("cursor","pointer"),r=function(n){n[J](),n[X]();if(t[i][l])return t[i][l][w](),H;var r=e(this),s=t[i][At][a[0]];s[tn]()?s[w]():s[wt]()},t._[Kt][U]==pn||t._[Kt][U]=="wp"?n.on(en,r):n.on(t.eventType,r);break;case"navList":c=e(an+a[0]),r=c[Et]("a"),s=[],r.each(function(){var t=e(this),n,r;n=Math.max(0,t.parents("li")[I]-1),r=t[Lt]("href"),s.push('<a class="link depth-'+n+'"'+(typeof r!==gt&&r!=""?' href="js/'+r+'"':"")+'>'+t.text()+"</a>")}),s[I]>0&&n[It]("<nav>"+s.join("")+"</nav>");break;case"copyText":c=e(an+a[0]),n[It](c.text());break;case"copyHTML":c=e(an+a[0]),n[It](c[It]());break;case"moveElementContents":c=e(an+a[0]),o[f]=function(){c[D]().each(function(){var t=e(this);n[Ot](t),t[Bt](P)})},o[C]=function(){n[D]().each(function(){var n=e(this);c[Ot](n),n[Xt](P),t.refresh(n)})},o[f]();break;case"moveElement":c=e(an+a[0]),o[f]=function(){e(V+c[Lt]("id")+'" />').insertBefore(c),n[Ot](c),c[Bt](P)},o[C]=function(){e(pt+c[Lt]("id")).replaceWith(c),c[Xt](P),t.refresh(c)},o[f]();break;case"moveCell":c=e(an+a[0]),h=e(an+a[1]),o[f]=function(){e(V+c[Lt]("id")+'" />').insertBefore(c),n[Ot](c),c[S](E,Ft),h&&h[Ct]()},o[C]=function(){e(pt+c[Lt]("id")).replaceWith(c),c[S](E,""),h&&h[S](E,"")},o[f]();break;default:}},parseResume:function(e){var t=e.get(0);t[f]&&t[f]()},parseSuspend:function(e){var t=e.get(0);t[C]&&t[C]()},recalc:function(e,n){var r=t._.parseMeasurement(e),i;switch(r[1]){case"%":i=Math.floor(n*(r[0]/100));break;case"em":i=t.getBaseFontSize()*r[0];break;default:case Gt:i=r[0]}return i},recalcH:function(n){return t.recalc(n,e(window)[q]())},recalcW:function(n){return t.recalc(n,e(window)[E]())},refresh:function(r){var s;t[n][j]&&(r?s=r.filter(F):s=e(F),s[_]()[Jt](t[i][c]))},unlockView:function(e){t._[Kt][_t]&&t[i][hn][S](on+e,Rt),t[i][O].off(z),t[i][Q].off(yt),t._[Kt][_t]||t[i][Q].off(mt)},init:function(){t[n][fn]&&(t[n][j]=t[n][fn]());if(t[n][j]){if(t._[Kt][U]==pn&&t._[Kt].deviceVersion<4||t._[Kt][U]=="wp")t[n][j]=H;t._[Kt].IEVersion<10&&(t[n][j]=H),t[n][qt]&&!t._.hasActive(t._[cn](t[n][qt]))&&(t[n][j]=H)}t.eventType=t._[Kt][_t]?"touchend":en,t.initObjects(),t.initTransforms(),t._[Mt](function(){t.initLayers(),t.initIncludes(),t._.updateState(),t.refresh()})},initIncludes:function(){e(".skel-layers-include").each(function(){t.parseInit(e(this))})},initLayers:function(){var r,s,o,u=1;t._[Wt](t[n][At],function(r){var s;if(!t[n][At][r][It]&&(s=e(an+r))[I]==0)return;o=new dn(r,t[n][At][r],u++),t[i][At][r]=o,s&&(s[D]()[Jt](o[W]),s.remove())})},initObjects:function(){t[i][Q]=e(window),t._[Mt](function(){t[i][It]=e(It),t[i][Yt]=e(Yt),t[i][hn]=e("html,body"),t[i][Yt].wrapInner('<div id="skel-layers-wrapper" />'),t[i][O]=e("#skel-layers-wrapper"),t[i][O][S](k,un)[S](A,"0")[S](g,"0")[S](R,"0")[_](),t[i][B]=e('<div id="skel-layers-inactiveWrapper" />')[Jt](t[i][Yt]),t[i][B][S](q,"100%"),t[i][c]=e('<div id="skel-layers-activeWrapper" />')[Jt](t[i][Yt]),t[i][c][S](k,un),t._[vt](nt,t[i][B][0]),t._[vt]("skel_layers_activeWrapper",t[i][c][0]),t._[vt]("skel_layers_wrapper",t[i][O][0]),e("[autofocus]").focus()})},initTransforms:function(){if(t[n][j])e.fn[r]=function(){return e(this)[o](0,0)},e.fn[o]=function(t,n){return e(this)[S](j,"translate("+t+"px, "+n+"px)")},e.fn[_]=function(){return e(this)[S]("backface-visibility",it)[S]("perspective","500")[Ut]("transition","transform "+t[n][xt]/1e3+"s ease-in-out")};else{var s,u=[];t[i][Q].resize(function(){if(t[n][xt]!=0){var e=t[n][xt];t[n][xt]=0,window[m](function(){t[n][xt]=e,u=[]},e)}}),e.fn[r]=function(){for(var r=0;r<this[I];r++){var s=this[r],o=e(s);u[s.id]&&o.animate(u[s.id],t[n][xt],"swing",function(){t._[Wt](u[s.id],function(e){o[S](e,u[s.id][e])}),t[i][Yt][S](K,Rt),t[i][O][S](E,Ft)[S](Z,0)})}return e(this)},e.fn[o]=function(r,s){var o,f,l,c;r=parseInt(r),s=parseInt(s),r!=0?(t[i][Yt][S](K,it),t[i][O][S](E,t[i][Q][E]())):l=function(){t[i][Yt][S](K,Rt),t[i][O][S](E,Ft)},s<0?t[i][O][S](Z,Math.abs(s)):c=function(){t[i][O][S](Z,0)};for(o=0;o<this[I];o++){var h=this[o],p=e(h),d;if(!u[h.id])if(d=dn[L][Tt][p.data(ft)]){u[h.id]={};switch(d.v){case N:case R:u[h.id][R]=parseInt(p[S](R));break;case y:u[h.id][y]=parseInt(p[S](y))}switch(d.h){case N:case A:u[h.id][A]=parseInt(p[S](A));break;case g:u[h.id][g]=parseInt(p[S](g))}}else d=p[k](),u[h.id]={top:d[R],left:d[A]};a={},t._[Wt](u[h.id],function(e){var n;switch(e){case R:n=t[rn](u[h.id][e])+s;break;case y:n=t[rn](u[h.id][e])-s;break;case A:n=t[Y](u[h.id][e])+r;break;case g:n=t[Y](u[h.id][e])-r}a[e]=n}),p.animate(a,t[n][xt],"swing",function(){l&&l(),c&&c()})}return e(this)},e.fn[_]=function(){return e(this)[S](k,"absolute")}}}},t)}(jQuery));