[openstreetmap/openstreetmap-website] Add social sharing functionality (PR #4985)
Anton Khorev
notifications at github.com
Fri Sep 6 03:49:56 UTC 2024
@AntonKhorev commented on this pull request.
> @@ -0,0 +1,27 @@
+// Opening pop-ups with share URL
+function openShareUrl(url, initialWidth = 640, initialHeight = 480) {
+ if (typeof url !== "string" || !url.startsWith("http")) {
+ console.error("Invalid URL"); // Consider removing this line if console warnings should be avoided.
+ return;
+ }
+
+ const width = Math.max(100, Math.min(screen.width, initialWidth));
+ const height = Math.max(100, Math.min(screen.height, initialHeight));
+
+ const left = (screen.width / 2) - (width / 2);
+ const top = (screen.height * 0.3) - (height / 2);
+ const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`;
+
+ window.open(url, "popup", opts);
Email link only works as expected for me when it's *not* opened with `window.open`.
It works when middle-clicked, or when the event handler is broken because of Turbo + `$(document).ready`.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4985#pullrequestreview-2284593443
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4985/review/2284593443 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240905/3c09c916/attachment.htm>
More information about the rails-dev
mailing list