UNPKG

shido.dimentions.js

Version:
2 lines 4.26 kB
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";n.r(t);var o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="%c"+e+"%c"+t,o="background: #ef5350; color: #fff; font-weight: bold; padding: 5px;",i="background: #fafafa; color: #888; font-weight: bold; padding: 5px;";console.log(n,o,i)},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="%c"+e+"%c"+t,o="background: #ffc400; color: #fff; font-weight: bold; padding: 5px;",i="background: #fafafa; color: #888; font-weight: bold; padding: 5px;";console.log(n,o,i)};function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}n.d(t,"getHeight",(function(){return f})),n.d(t,"getWidth",(function(){return a}));var u=function(e){return e.replace(/\s/g,"").split(",")},l=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&"window"!=e&&null!==document.querySelector(e)?document.querySelector(e).offsetHeight:e&&"window"==e||"full"==e?window.innerHeight:e&&"wo-top"==e&&null!==document.querySelector("header")?window.innerHeight-document.querySelector("header").offsetHeight:e&&"wo-footer"==e?window.innerHeight-document.querySelector("footer").offsetHeight:e&&"wo-top-footer"==e&&null!==document.querySelector("header")?window.innerHeight-document.querySelector("header").offsetHeight-document.querySelector("footer").offsetHeight:(i("Dimentions","Give me a valid selector dude!"),!1)},c=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&"window"!=e&&null!==document.querySelector(e)?document.querySelector(e).offsetWidth:e&&"window"==e?window.innerWidth:(i("Dimentions","Give me a valid selector dude!"),!1)},d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,d;return t=e,(n=[{key:"setItems",value:function(){document.querySelectorAll("[dimentions-height]").forEach((function(e,t){var n=u(e.getAttribute("dimentions-height")),o=n[0],i="static"===n[1]?"height":"minHeight",r=isNaN(n[2])?0:n[2],d=c("window");d<r&&(e.style[i]="auto"),d>=r&&(e.style[i]=l(o)+"px")}))}},{key:"dimentionsAvailable",value:function(){var e=!0;return document.querySelectorAll("[dimentions-height]").forEach((function(t,n){var r=u(t.getAttribute("dimentions-height")),l=r[0],c=r[1];void 0!==l&&""!==l||(i("Dimentions","Item "+(n+1)+": Empty selector"),e=!1),void 0!==l&&""!==l&&"full"!==l&&"wo-top"!==l&&"wo-footer"!==l&&"wo-top-footer"!==l&&null===document.querySelector(l)&&(o("Dimentions","Item "+(n+1)+": Missing a valid selector"),e=!1),void 0!==c&&""!==c&&"liquid"!==c&&"static"!==c&&(o("Dimentions","Item "+(n+1)+': Is this "liquid" or "static"?'),e=!1)})),e}},{key:"process",value:function(){var e,t=this;this.setItems(),window.addEventListener("load",(function(){t.setItems()})),window.addEventListener("resize",(function(){clearTimeout(e),e=setTimeout((function(){t.setItems()}),250)}),!1)}},{key:"init",value:function(){this.dimentionsAvailable()&&this.process()}}])&&r(t.prototype,n),d&&r(t,d),e}(),f=(t.default=d,l),a=c}]); //# sourceMappingURL=dimentions.min.js.map