This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
molt.W.min.js
4 lines (4 loc) · 4.18 KB
/
molt.W.min.js
1
2
3
4
/*! W 1.2.2 (https://github.com/pyrsmk/W) */
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(c):a[b]=c}(this,"W",function(){function a(){var a,b,c,d,e=[{width:screen.availWidth,height:screen.availHeight},{width:window.outerWidth,height:window.outerHeight},{width:window.innerWidth,height:window.innerHeight}];if(/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&"landscape"==m()?(a=screen.height,b=screen.width):(a=screen.width,b=screen.height),k)return{width:a,height:b};for(c=0,d=e.length;d>c;++c)e[c].note=e[c].width>a||e[c].height>b||!e[c].width||!e[c].height?0:e[c].width<a||e[c].height<b?2+(a-e[c].width)+(b-e[c].height):1;return e.sort(function(a,b){return b.note-a.note}),{width:e[0].width,height:e[0].height}}var b,c,d,e,f=window,g=document,h=g.documentElement,i=[],j=!1,k=!1,l=function(){b=g.createElement("div"),b.style.width="1em",h.appendChild(b),e=b.offsetWidth,e=e?e:16,h.removeChild(b)},m=function(){return"orientation"in window?window.orientation?"landscape":"portrait":h.clientWidth>h.clientHeight?"landscape":"portrait"};return l(),f.addEventListener?"onorientationchange"in f?f.addEventListener("orientationchange",function(){j=!0},!1):f.addEventListener("resize",function(){j=!0},!1):f.attachEvent("onresize",function(){j=!0}),c=g.createElement("b"),c.style.position="absolute",c.style.top="-99em",c.innerHTML="W",h.appendChild(c),d=c.offsetHeight,setInterval(function(){if(b=c.offsetHeight,b!=d&&(j=!0),d=b,j&&h.clientWidth){l();for(var a=0,e=i.length;e>a;++a)i[a]();j=!1}},250),{px2em:function(a){return a/e},getViewportWidth:function(){return a().width},getViewportHeight:function(){return a().height},addListener:function(a){return i.push(a),a},setAbsoluteMode:function(a){k=!!a},getOrientation:function(){return m()}}}());
/*! molt 4.2.2 (https://github.com/pyrsmk/molt) */
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(c):a[b]=c}(this,"molt",function(){var a=[],b={promises:{early:[],eachonce:[],each:[],thenonce:[],then:[]},add:function(a,b){"function"==typeof b&&this.promises[a].push(b)},run:function(a,b){for(var c=0,d=this.promises[a].length;d>c;++c)this.promises[a][c].apply(this,b)}},c=0,d=function(d,e,f){return function(){e.src=d,b.promises.eachonce.length&&(b.run("eachonce",[e,f]),b.promises.eachonce=[]),b.run("each",[e,f]),--c||(b.promises.thenonce.length&&(b.run("thenonce",[a]),b.promises.thenonce=[]),b.run("then",[a]))}},e=function(a){return function(){throw--c,"An error has occured when loading '"+a+"'"}},f=function(){var f,g,h,i,j,k,l,m,n,o,p,q=W.getViewportWidth(),r=W.getViewportHeight(),s=!0;for(c+=a.length,b.run("early",[a]),i=0,j=a.length;j>i;++i){for(m="",k=0,l=a[i].modes.length;l>k;++k)switch(f=a[i].modes[k].mode,g=parseInt(f.substring(0,f.length-1),10),h=f.substring(f.length-1)){case"w":q>=g&&(o=f,m=a[i].modes[k].src);break;case"h":r>=g&&(o=f,m=a[i].modes[k].src);break;default:throw"Invalid '"+f+"' mode encountered"}n=a[i].node,m?(s=!1,p=new Image,p.src=m,p.complete===!0?(n.src=m,d(m,n,o)()):(p.onload=d(m,n,o),p.onerror=e(m)),"visible"!=n.style.visibility&&(n.style.visibility="visible",n.style.width="auto",n.style.height="auto")):"hidden"!=n.style.visibility&&(--c,n.style.visibility="hidden",n.style.width=0,n.style.height=0)}s&&b.run("then")};return function(c){var d,e,g,h,i,j,k,l;for(void 0===c.length&&(c=[c]),W.addListener(f),g=0,h=c.length;h>g;++g){if(l=c[g].attributes,k={node:c[g],modes:[]},l["data-molt-src"])for(d=l["data-molt-src"].value.match(/\{(.+?)\}/)[1].split(/\s*,\s*/),i=0,j=d.length;j>i;++i)e=d[i].split(":"),k.modes.push({mode:e[0],src:l["data-molt-src"].value.replace(/\{.+?\}/,e[1]||e[0])});else for(i=0,j=l.length;j>i;++i)/^data-molt-\d+[wh]$/i.test(l[i].name)&&k.modes.push({mode:l[i].name.substring(10),src:l[i].value});k.modes.sort(function(a,b){return parseInt(a.mode.substring(0,a.mode.length-1),10)-parseInt(b.mode.substring(0,b.mode.length-1),10)}),a.push(k)}var m={early:function(a){return b.add("early",a),m},eachOnce:function(a){return b.add("eachonce",a),m},each:function(a){return b.add("each",a),m},thenOnce:function(a){return b.add("thenonce",a),m},then:function(a){return b.add("then",a),m},start:function(){f()}};return m}}());