/* Añadir class según breakpoint al body */ var breakpoint = (function(body) { let bp_cur = ""; var bp_dom = { get: function (o) { var obj = Object.create(this); obj.element = (typeof o == "object") ? o : document.createElement(o); return obj; }, app: function (o) { var obj = bp_dom.get(o); this.element.prepend(obj.element); return obj; }, att: function (k, v) { this.element.setAttribute(k, v); return this; }, cls: function (c) { this.element.className = c; return this; }, }; var bp_szs = ['xs', 'sm', 'md', 'lg', 'xl']; var bp_obj = {"xs": "d-block d-sm-inline", "sm": "d-sm-block d-md-inline", "md": "d-md-block d-lg-inline", "lg": "d-lg-block d-xl-inline", "xl": "d-xl-block" }; var bp_ele = bp_dom.get(body).app('div').att('style','display:none;').att('id','bp_check'); for (const [key, val] of Object.entries(bp_obj)) { bp_ele.app('span').cls(key+' '+val); } function isBlock(size){ return (getComputedStyle(document.querySelector('#bp_check .'+size)).display == 'block'); } function bp_checkCurrent(){ body.classList.remove(...bp_szs); for (const [key, val] of Object.entries(bp_obj)) { if( isBlock(key) ) bp_cur = key; breakpoint = key; } body.classList.add(bp_cur); } bp_checkCurrent(); window.onresize = bp_checkCurrent; return bp_cur; }(document.body));