Skip to content

Commit

Permalink
displaying message when widget is not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Apr 29, 2021
1 parent 5ba7949 commit 7177257
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,32 @@


<script>
jQuery('.twitter-block').delegate('#twitter-widget-0','DOMSubtreeModified propertychange', function() {
//function call to override the base twitter styles
customizeTweetMedia();
});
jQuery('.twitter-block').delegate('#twitter-widget-0', 'DOMSubtreeModified propertychange', function() {
// function call to override the base twitter styles
customizeTweetMedia();
});
var customizeTweetMedia = function() {
//overrides css
var customizeTweetMedia = function() {
jQuery('.twitter-block').find('.twitter-timeline').contents().find('.timeline-Header-title.u-inlineBlock').css('font-size', '18px');
jQuery('.twitter-block').find('.twitter-timeline').contents().find('.timeline-Header-title.u-inlineBlock').children().css('font-size', '18px');
jQuery('.twitter-block').find('.twitter-timeline').contents().find('.timeline-Tweet-text').css({'font-size': '16px', 'font': 'Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;', 'line-height': '1.1'});
jQuery('.twitter-block').find('.twitter-timeline').contents().find('.timeline-Tweet-text').css({
'font-size': '16px',
'font': 'Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;',
'line-height': '1.1'
});
//also call the function on dynamic updates in addition to page load
// also call the function on dynamic updates in addition to page load
jQuery('.twitter-block').find('.twitter-timeline').contents().find('.timeline-TweetList').bind('DOMSubtreeModified propertychange', function() {
customizeTweetMedia(this);
customizeTweetMedia(this);
});
}
};
// checks if the widget hasn't loaded and prints a message after 4 seconds
setTimeout(() => {
if (document.querySelector('#twitter-widget-0') == null) {
console.log("widget probably not loaded");
document.querySelector('.twitter-block').innerHTML = "<p style='font-family: Lato, sans-serif; text-align:center;'><a href='https://twitter.com/tardis_sn'>TARDIS Tweets</a><br>It seems Twitter Widget was not loaded. Please check your internet connection or consider disabling tracking protection if on Firefox. <br>If the problem persists, consider contacting us.</p>";
};
}, 4000);
</script>

0 comments on commit 7177257

Please sign in to comment.