popup-centered
Version:
The little function for open window popup on center display
8 lines (7 loc) • 1.63 kB
JavaScript
/*!
* popup-centered v1.2.0
* (c) Nikita Nafranets <eddimensi@gmail.com>
* Released under the MIT License.
*/
var popupCentered=function(){"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}var n=function(e){return e?"yes":"no"};function t(e){var t={};return Object.defineProperty(t,"toString",{value:function(){var e=this;return Object.keys(this).map(function(n){return n+"="+e[n]}).join(",")},writable:!1,enumerable:!1}),Object.keys(e).reduce(function(o,i){return"boolean"==typeof e[i]?t[i]=n(e[i]):t[i]=e[i],t},t)}var o=function(){return{screenLeft:void 0!==window.screenLeft?window.screenLeft:window.screenX,screenTop:void 0!==window.screenTop?window.screenTop:window.screenY}},i=function(){return{windowWidth:window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,windowHeight:window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height}},r=function(e,n,t){return e/2-n/2+t};return function(n,c,u,d){var w=o(),f=w.screenLeft,s=w.screenTop,l=i(),h=l.windowWidth,m=l.windowHeight,p=null;"number"==typeof u&&"number"==typeof d&&(p=t({width:u,height:d,left:r(h,u,f),top:r(m,d,s),scrollbars:!0})),"object"===e(u)&&(p=t(Object.assign({},{left:r(h,u.width,f),top:r(m,u.height,s)},u)));var y=window.open(n,c,p.toString());return window.focus&&y&&y.focus(),y}}();
//# sourceMappingURL=index.iife.min.js.map