@openpass/openpass-js-sdk
Version:
OpenPass SSO JavaScript SDK
28 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLargeBreakpoint = exports.windowOpenPopupWithPercentage = exports.windowOpenPopup = void 0;
const windowOpenPopup = (url, name, width, height) => {
const winLeft = (window.outerWidth - width) / 2 + window.screenX;
const winTop = (window.outerHeight - height) / 2 + window.screenY;
const appearance = `scrollbars=yes,resizable=yes,toolbar=no,top=${winTop},left=${winLeft},width=${width},height=${height}`;
return window.open(url, name, appearance);
};
exports.windowOpenPopup = windowOpenPopup;
const windowOpenPopupWithPercentage = (url, name, sizePercentage) => {
if (sizePercentage === 100) {
const appearance = `scrollbars=yes,resizable=yes,toolbar=no,top=${window.screenY},left=${window.screenX},width=${window.outerWidth},height=${window.outerHeight}`;
return window.open(url, name, appearance);
}
const height = calculatePercentage(window.innerWidth, sizePercentage);
const width = calculatePercentage(window.innerWidth, sizePercentage);
return (0, exports.windowOpenPopup)(url, name, width, height);
};
exports.windowOpenPopupWithPercentage = windowOpenPopupWithPercentage;
const isLargeBreakpoint = () => {
return window.matchMedia("screen and (min-width:960px)").matches;
};
exports.isLargeBreakpoint = isLargeBreakpoint;
const calculatePercentage = (amount, percent) => {
return (amount * percent) / 100;
};
//# sourceMappingURL=window.js.map