diff --git a/js/_i.js b/js/_i.js index 10f673f..ec434e3 100644 --- a/js/_i.js +++ b/js/_i.js @@ -1,11 +1,11 @@ -(function (window, document, navigator) { - const me = document.currentScript; +(function () { + const me = window.document.currentScript; const url = me.getAttribute('data-url'); - const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); + const iOS = !!window.navigator.platform && /iPad|iPhone|iPod/.test(window.navigator.platform); - const vendor = navigator.vendor; - const doNotTrack = navigator.doNotTrack || navigator.msDoNotTrack || window.doNotTrack; + const vendor = window.navigator.vendor; + const doNotTrack = window.navigator.doNotTrack || window.navigator.msDoNotTrack || window.doNotTrack; let tid = !doNotTrack && window.localStorage.getItem('tid'); if (!tid && !doNotTrack) { @@ -13,17 +13,14 @@ window.localStorage.setItem('tid', tid); } - const body = document.body; - const html = document.documentElement; - const SESSION_DATA = { tid, start: Date.now(), end: null, max_scroll: 0, - language: navigator.userLanguage || navigator.language, + language: window.navigator.userLanguage || window.navigator.language, href: window.location.pathname, - referrer: document.referrer, + referrer: window.document.referrer, }; // listen for all the exit events @@ -38,14 +35,14 @@ // scroll tracking window.addEventListener('scroll', function () { const page_height = Math.max( - body.scrollHeight, - body.offsetHeight, - html.clientHeight, - html.scrollHeight, - html.offsetHeight, + window.document.body.scrollHeight, + window.document.body.offsetHeight, + window.document.documentElement.clientHeight, + window.document.documentElement.scrollHeight, + window.document.documentElement.offsetHeight, ); - const viewport_height = Math.max(html.clientHeight, window.innerHeight || 0); + const viewport_height = Math.max(window.document.documentElement.clientHeight, window.innerHeight || 0); const max_scroll = Math.max(SESSION_DATA.max_scroll, window.scrollY); const viewed = max_scroll === 0 ? 0 : Math.round(((max_scroll + viewport_height) / page_height) * 100); @@ -89,4 +86,4 @@ // a hack necessary for Firefox and Safari refresh / back button } } -}(window, document, navigator)); +}()); diff --git a/js/_lightbox.js b/js/_lightbox.js index 65b285a..02ec2f0 100644 --- a/js/_lightbox.js +++ b/js/_lightbox.js @@ -1,6 +1,6 @@ -(function ($) { +$(function () { - $('.lightbox, .gutter').each(function () { + $('.lightbox, .gutter, .tweet-entities').each(function () { $(this).magnificPopup({ delegate: 'a.lb', type: 'image', @@ -13,14 +13,7 @@ gallery: { enabled: true, }, - zoom: { - enabled: true, - duration: 300, // don't foget to change the duration also in CSS - opener: function (element) { - return element.find('img'); - }, - }, }); }); -}(window.jQuery)); +});