Skip to content
Snippets Groups Projects
Commit 17cb3828 authored by Markus Willman's avatar Markus Willman
Browse files

fix twitter widget link disabling, weather is still not working

parent 63db86c1
Branches
No related tags found
No related merge requests found
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<!-- Forecast7.com --> <!-- Forecast7.com -->
...@@ -33,10 +32,8 @@ ...@@ -33,10 +32,8 @@
<div class="card info-card box-shadow"> <div class="card info-card box-shadow">
<div id="twitter"> <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> <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> <script>
window.twttr = (function (d, s, id) { window.twttr = (function (d, s, id) {
console.log("window.twttr");
var js, fjs = d.getElementsByTagName(s)[0], var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {}; t = window.twttr || {};
if (d.getElementById(id)) return; if (d.getElementById(id)) return;
...@@ -49,7 +46,6 @@ ...@@ -49,7 +46,6 @@
t.ready = function (f) { t.ready = function (f) {
t._e.push(f); t._e.push(f);
}; };
console.log("window.twttr finished.")
return t; return t;
}(document, "script", "twitter-wjs")); }(document, "script", "twitter-wjs"));
</script> </script>
...@@ -76,18 +72,20 @@ ...@@ -76,18 +72,20 @@
{{- super() }} {{- super() }}
<script> <script>
$(document).ready(function () { $(document).ready(function () {
console.log("Document ready."); console.log("Document ready.");
$('#visitTurku').disableExternalLinks(); //Working $('#visitTurku').disableExternalLinks();
$('#forecast7').disableExternalLinks(); //Not working $('#twitter').disableExternalLinks(); // in case the widget fails to load disable the link in the container as a placeholder
$('#twitter').disableExternalLinks(); //Not working //$('#forecast7').disableExternalLinks(); // not working, iframes need to die out :)
twttr.ready(function (twttr) { twttr.ready(function (twttr) {
console.log("twttr.ready"); twttr.events.bind('loaded', function (e) {
//twttr.events.bind('loaded', function () { console.log("twttr loaded."); }); e.widgets.forEach(function (w) {
twttr.events.bind('loaded', function () { $('#twitter').disableExternalLinks(); }); // the twitter widget is loaded in an iframe, contents() is needed because of that
$('#' + w.id).contents().disableExternalLinks();
});
});
}); });
}); });
</script> </script>
......
...@@ -156,7 +156,8 @@ ...@@ -156,7 +156,8 @@
if ({{ (not g.is_kiosk)|tojson|safe }} && !force) if ({{ (not g.is_kiosk)|tojson|safe }} && !force)
return this; return this;
this.on('click', 'a[href^="http"]:not([href*="' + location.hostname + '"])', function (e) { var target = this;
var handler = function (e) {
e.preventDefault(); e.preventDefault();
$link = $(this); $link = $(this);
$modal = $('#externalLinkModal'); $modal = $('#externalLinkModal');
...@@ -168,7 +169,9 @@ ...@@ -168,7 +169,9 @@
$(this).removeData('bs.modal'); $(this).removeData('bs.modal');
$modal.find('.externalLinkURI').empty(); $modal.find('.externalLinkURI').empty();
}).modal(); }).modal();
}); };
target.on('click', 'a[href^="http"]:not([href*="' + location.hostname + '"])', handler);
return this; return this;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment