diff --git a/templates/info.html b/templates/info.html index 939fdef9bc755d404b405a9c6617ccef8f713908..2de84f1a2c0d1f1bb9b104a791e3df7b8680e4e2 100644 --- a/templates/info.html +++ b/templates/info.html @@ -8,7 +8,6 @@ {% block content %} <div class="container"> - <div class="row"> <div class="col-12"> <!-- Forecast7.com --> @@ -33,10 +32,8 @@ <div class="card info-card box-shadow"> <div id="twitter"> <a class="twitter-timeline" data-height="600" data-dnt="true" data-theme="light" href="https://twitter.com/Turkukaupunki?ref_src=twsrc%5Etfw">Tweets by Turkukaupunki</a> - <!--<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>--> <script> window.twttr = (function (d, s, id) { - console.log("window.twttr"); var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return; @@ -49,7 +46,6 @@ t.ready = function (f) { t._e.push(f); }; - console.log("window.twttr finished.") return t; }(document, "script", "twitter-wjs")); </script> @@ -73,23 +69,25 @@ {% endblock content %} {% block scripts %} -{{- super() }} + {{- super() }} -<script> + <script> + $(document).ready(function () { + console.log("Document ready."); - $(document).ready(function () { - console.log("Document ready."); + $('#visitTurku').disableExternalLinks(); + $('#twitter').disableExternalLinks(); // in case the widget fails to load disable the link in the container as a placeholder + //$('#forecast7').disableExternalLinks(); // not working, iframes need to die out :) - $('#visitTurku').disableExternalLinks(); //Working - $('#forecast7').disableExternalLinks(); //Not working - $('#twitter').disableExternalLinks(); //Not working - - twttr.ready(function (twttr) { - console.log("twttr.ready"); - //twttr.events.bind('loaded', function () { console.log("twttr loaded."); }); - twttr.events.bind('loaded', function () { $('#twitter').disableExternalLinks(); }); + twttr.ready(function (twttr) { + twttr.events.bind('loaded', function (e) { + e.widgets.forEach(function (w) { + // the twitter widget is loaded in an iframe, contents() is needed because of that + $('#' + w.id).contents().disableExternalLinks(); + }); + }); + }); }); - }); -</script> + </script> -{% endblock scripts %} \ No newline at end of file +{% endblock scripts %} diff --git a/templates/internal/base.html b/templates/internal/base.html index f8e4134acf45b2972100cc7cd9dd06e78155e939..e44323fa5ffd6c223287784eac63cdb853df3eee 100644 --- a/templates/internal/base.html +++ b/templates/internal/base.html @@ -156,7 +156,8 @@ if ({{ (not g.is_kiosk)|tojson|safe }} && !force) return this; - this.on('click', 'a[href^="http"]:not([href*="' + location.hostname + '"])', function (e) { + var target = this; + var handler = function (e) { e.preventDefault(); $link = $(this); $modal = $('#externalLinkModal'); @@ -168,7 +169,9 @@ $(this).removeData('bs.modal'); $modal.find('.externalLinkURI').empty(); }).modal(); - }); + }; + + target.on('click', 'a[href^="http"]:not([href*="' + location.hostname + '"])', handler); return this; };