X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f8b04635a79cf23a30ae1c80029d8c33f34f8424..a1a3b2c87e53c095d43bb9835590dc525122a062:/app/assets/javascripts/social_share_button.js diff --git a/app/assets/javascripts/social_share_button.js b/app/assets/javascripts/social_share_button.js index 34db84758..b118c1d3b 100644 --- a/app/assets/javascripts/social_share_button.js +++ b/app/assets/javascripts/social_share_button.js @@ -1,15 +1,15 @@ -function openShareUrl(url, initialWidth = 640, initialHeight = 480) { - const width = Math.max(100, Math.min(screen.width, initialWidth)); - const height = Math.max(100, Math.min(screen.height, initialHeight)); +$(document).ready(function () { + function openShareUrl(url, initialWidth = 640, initialHeight = 480) { + const width = Math.max(100, Math.min(screen.width, initialWidth)); + const height = Math.max(100, Math.min(screen.height, initialHeight)); - const left = screenLeft + ((outerWidth - width) / 2); - const top = screenTop + ((outerHeight - height) / 2); - const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`; + const left = screenLeft + ((outerWidth - width) / 2); + const top = screenTop + ((outerHeight - height) / 2); + const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`; - window.open(url, "popup", opts); -} + window.open(url, "popup", opts); + } -$(document).ready(function () { $(".ssb-icon").on("click", function (e) { const shareUrl = $(this).attr("href"); if (!shareUrl.startsWith("mailto:")) { @@ -18,4 +18,3 @@ $(document).ready(function () { } }); }); -