UNPKG

@mornya/react-social-libs

Version:

The project of React.js Social Share and Widget modules.

66 lines (65 loc) 1.86 kB
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; function openWindow(href, name, width, height) { if (width === void 0) { width = 0; } if (height === void 0) { height = 0; } var win; if (width && height) { var params = [ "width=".concat(width, "px"), "height=".concat(height, "px"), "left=".concat((window.screen.width - width) / 2, "px"), "top=".concat((window.screen.height - height) / 2, "px"), ].join(','); win = window.open(href, name, params); } else { win = window.open(href, name); } if (win === null) { window.location.href = href; } else if (win !== undefined) { win.focus(); return win; } else { window.location.href = href; } return null; } export function openShareWindow(href, name, size) { if (size === void 0) { size = []; } return new Promise(function (resolve) { var winName = "__sns_share_".concat(name, "__"); var win; if (size.length === 2) { var _a = __read(size, 2), width = _a[0], height = _a[1]; win = openWindow(href, winName, width, height); } else { win = openWindow(href, winName); } if (win) { win.focus(); } else { window.location.href = href; } resolve(); }); }