@alessiofrittoli/web-utils
Version:
Common TypeScript web utilities
1 lines • 660 B
JavaScript
;var urlUtils=require('@alessiofrittoli/url-utils');var c=e=>typeof window<"u"?window.matchMedia(e).matches:false;var s=e=>new Map(e);var M=(e={})=>{let o=Math.max(100,e.width||600),i=Math.max(100,e.height||800),{url:t,context:a}=e,{features:d={}}=e,{left:u=window.screen.width/2-(o/2+10),top:h=window.screen.height/2-(i/2+50),...f}=d,p=s([["popup","yes"],["width",o.toString()],["height",i.toString()],["left",u.toString()],["top",h.toString()]]);Object.entries(f).map(([r,T])=>{p.set(r,T);});let y=Array.from(p).map(r=>r.join("=")).join(",");return window.open(t&&urlUtils.Url.format(t),a,y)};exports.getMediaMatches=c;exports.openBrowserPopUp=M;