-
Notifications
You must be signed in to change notification settings - Fork 17
/
responsive-containers.min.js
5 lines (5 loc) · 2.1 KB
/
responsive-containers.min.js
1
2
3
4
5
(function(e){function q(){if(p){var b=[];if(f.querySelectorAll)b=f.querySelectorAll("[data-squery]");else for(var a=f.getElementsByTagName("*"),c=0,m=a.length;c<m;++c)a[c].getAttribute("data-squery")&&b.push(a[c]);c=0;for(m=b.length;c<m;++c){for(var a=b[c],d=[],e=a.getAttribute("data-squery").split(" "),g=0,i=e.length;g<i;++g){var h=/(.*):([0-9]*)(px|em)=(.*)/.exec(e[g]);h&&d.push(h)}a.cq_rules=a.cq_rules||[];a.cq_rules=a.cq_rules.concat(d);j.push(a)}}}function k(){for(var b=0,a=j.length;b<a;++b){el=
j[b];for(var c=0,e=el.cq_rules.length;c<e;++c){var d=el.cq_rules[c],f=parseInt(d[2]);"em"===d[3]&&(f=n(parseFloat(d[2]),el));var g=el,i=d[4],h=g.cloneNode(!0);h.className=(" "+h.className+" ").replace(" "+i+" "," ");h.style.height=0;h.style.visibility="hidden";h.style.overflow="hidden";h.style.clear="both";i=g.parentNode;i.insertBefore(h,g);g=h.offsetWidth;i.removeChild(h);r[d[1]](g,f)?0>el.className.indexOf(d[4])&&(el.className+=" "+d[4]):(d=el.className.replace(RegExp("(^| )"+d[4]+"( |$)"),"$1"),
d=d.replace(/ $/,""),el.className=d)}}}function l(){if(!o){o=!0;q();k();e.addEventListener&&e.addEventListener("resize",k,!1);var b=n(1,f.body);e.setInterval(function(){var a=n(1,f.body);a!==b&&(k(),b=a)},100)}}var f=e.document,j=[],p=!0,o=!1,r={"min-width":function(b,a){return b>a},"max-width":function(b,a){return b<a}},n=function(b){return function(){var a=Array.prototype.slice.call(arguments);b.memoize=b.memoize||{};return a in b.memoize?b.memoize[a]:b.memoize[a]=b.apply(this,a)}}(function(b,a){var c=
f.createElement("div");c.style.fontSize="1em";c.style.margin="0";c.style.padding="0";c.style.border="none";c.style.width="1em";a.appendChild(c);var e=c.offsetWidth;a.removeChild(c);return Math.round(e*b)});f.addEventListener?(f.addEventListener("DOMContentLoaded",l,!1),e.addEventListener("load",l,!1)):f.attachEvent&&(f.attachEvent("onreadystatechange",l),e.attachEvent("onload",l));e.SelectorQueries={add:function(b,a,c,e){for(var c=/([0-9]*)(px|em)/.exec(c),d=0,f=b.length;d<f;++d){var g=b[d];g.cq_rules=
g.cq_rules||[];g.cq_rules.push([null,a,c[1],c[2],e]);j.push(g)}o&&k()},ignoreDataAttributes:function(){p=!1}}})(this);