From 76696bf6708303b305dd0bf197257a20239f88e9 Mon Sep 17 00:00:00 2001 From: Evgen Tolstoy <tolstoy.13@gmail.com> Date: Tue, 18 Feb 2025 14:21:02 +0200 Subject: [PATCH 1/4] Issue #3443644: Fix eslint warnings --- js/splashify_full_screen.js | 75 +++++++++++++++++++------------------ js/splashify_init.js | 28 +++++++------- js/splashify_lightbox.js | 22 +++++------ js/splashify_redirect.js | 10 ++--- js/splashify_window.js | 10 ++--- 5 files changed, 70 insertions(+), 75 deletions(-) diff --git a/js/splashify_full_screen.js b/js/splashify_full_screen.js index ca787d7..c7bce63 100644 --- a/js/splashify_full_screen.js +++ b/js/splashify_full_screen.js @@ -1,15 +1,16 @@ (function ($) { - Drupal.behaviors.splashifyBehavior.full_screen = - function (context, settings) { - var splash_height = $(window).height(); + Drupal.behaviors.splashifyBehavior.full_screen = function (context, settings) { + const splashHeight = $(window).height(); - $('#splashify', context).once('splashify_open').each(function () { - var $splash = $(this); + $('#splashify', context) + .once('splashify_open') + .each(function () { + const $splash = $(this); // Get the height of the div. Set it as a custom attribute. // Update the height to 0 and then show the div. - $('body').css('margin-top', splash_height); - $splash.attr('originalheight', splash_height + 'px'); + $('body').css('margin-top', splashHeight); + $splash.attr('originalheight', `${splashHeight}px`); $splash.css('position', 'absolute'); $splash.css('display', 'block'); @@ -17,38 +18,38 @@ openSplash($splash); // Track scroll position to destroy splash - $(context).once('splashify_scroll').on('scroll.splash', function () { - var $object = $(this); - var scroll_position = $object.scrollTop(); - if (scroll_position >= splash_height) { - $object.scrollTop(0); - // Destroy the splash div...they scrolled passed it. - var $body = $('body'); - $body.removeClass('splash-active'); - $body.css('margin-top', 0); - $('#splashify', context).css('height', 0); - $object.off('scroll.splash'); - } - }); + $(context) + .once('splashify_scroll') + .on('scroll.splash', function () { + const $object = $(this); + const scrollPosition = $object.scrollTop(); + if (scrollPosition >= splashHeight) { + $object.scrollTop(0); + // Destroy the splash div...they scrolled passed it. + const $body = $('body'); + $body.removeClass('splash-active'); + $body.css('margin-top', 0); + $('#splashify', context).css('height', 0); + $object.off('scroll.splash'); + } + }); }); - // Open the splash div. - function openSplash($splash) { - var $body = $('body'); - $body.addClass('splash-active'); - $body.css('margin-top', $splash.attr('originalheight')); - $('.splash-wrapper').css('height', $splash.attr('originalheight')); - window.scrollTo(0, 0); - } - - // Close the splash div. - function closeSplash() { - var $body = $('body'); - $body.removeClass('splash-active'); - $body.css('margin-top', 0); - $('.splash-wrapper').css('height', 0); - } - + // Open the splash div. + function openSplash($splash) { + const $body = $('body'); + $body.addClass('splash-active'); + $body.css('margin-top', $splash.attr('originalheight')); + $('.splash-wrapper').css('height', $splash.attr('originalheight')); + window.scrollTo(0, 0); } + // Close the splash div. + function closeSplash() { + const $body = $('body'); + $body.removeClass('splash-active'); + $body.css('margin-top', 0); + $('.splash-wrapper').css('height', 0); + } + }; })(jQuery); diff --git a/js/splashify_init.js b/js/splashify_init.js index e129214..e239702 100644 --- a/js/splashify_init.js +++ b/js/splashify_init.js @@ -1,27 +1,27 @@ (function ($) { Drupal.behaviors.splashifyBehavior = { - attach: function (context, settings) { - var jsmode = settings.splashify.mode, - referrer = document.referrer + '', - hostname = window.location.hostname + '', - referrer_check = settings.splashify.referrer_check; + attach(context, settings) { + let jsmode = settings.splashify.mode; + let referrer = document.referrer + ''; + let hostname = window.location.hostname + ''; + let referrerCheck = settings.splashify.referrer_check; - // This updates the referer string by taking out the url parameter from the - // url...which is included from google search results (as an example). - if (referrer.indexOf('?') != -1) { + // This updates the referer string by taking out the URL parameter from the + // URL, which is included from Google search results (as an example). + if (referrer.indexOf('?') !== -1) { referrer = referrer.substr(0, referrer.indexOf('?')); } - // Stop the splash page from show up if on the splash page. Also prevent + + // Stop the splash page from showing up if on the splash page. Also prevent // the splash from showing up from internal links (dependent on the // referrer check settings). - if ((referrer.search(hostname) != -1 && referrer_check)) { + if (referrer.search(hostname) !== -1 && referrerCheck) { return; } - if (typeof Drupal.behaviors.splashifyBehavior[jsmode] != 'undefined') { + if (typeof Drupal.behaviors.splashifyBehavior[jsmode] !== 'undefined') { Drupal.behaviors.splashifyBehavior[jsmode](context, settings); } - } - } - + }, + }; })(jQuery); diff --git a/js/splashify_lightbox.js b/js/splashify_lightbox.js index cd3c0a2..2e7376a 100644 --- a/js/splashify_lightbox.js +++ b/js/splashify_lightbox.js @@ -1,15 +1,13 @@ (function ($) { - Drupal.behaviors.splashifyBehavior.lightbox = - function (context, settings) { - var url = settings.splashify.url; - - $.colorbox({ - transition: 'elastic', - iframe: true, - href: url, - width: settings.splashify.width, - height: settings.splashify.height - }); - } + Drupal.behaviors.splashifyBehavior.lightbox = function (context, settings) { + let url = settings.splashify.url; + $.colorbox({ + transition: 'elastic', + iframe: true, + href: url, + width: settings.splashify.width, + height: settings.splashify.height, + }); + }; })(jQuery); diff --git a/js/splashify_redirect.js b/js/splashify_redirect.js index de974bd..7a7cfc2 100644 --- a/js/splashify_redirect.js +++ b/js/splashify_redirect.js @@ -1,9 +1,7 @@ (function ($) { - Drupal.behaviors.splashifyBehavior.redirect = - function (context, settings) { - var url = settings.splashify.url; - - window.location.replace(url); - } + Drupal.behaviors.splashifyBehavior.redirect = function (context, settings) { + let url = settings.splashify.url; + window.location.replace(url); + }; })(jQuery); diff --git a/js/splashify_window.js b/js/splashify_window.js index 1c97502..db1fcea 100644 --- a/js/splashify_window.js +++ b/js/splashify_window.js @@ -1,9 +1,7 @@ (function ($) { - Drupal.behaviors.splashifyBehavior.window = - function (context, settings) { - var url = settings.splashify.url; - - window.open(url, 'splash', settings.splashify.size); - } + Drupal.behaviors.splashifyBehavior.window = function (context, settings) { + let url = settings.splashify.url; + window.open(url, 'splash', settings.splashify.size); + }; })(jQuery); -- GitLab From 1542a884fbdfc3c60f990dde6aff38a00b9cbb8a Mon Sep 17 00:00:00 2001 From: Evgen Tolstoy <tolstoy.13@gmail.com> Date: Tue, 18 Feb 2025 15:06:24 +0200 Subject: [PATCH 2/4] Issue #3443644: Fix eslint warnings --- js/splashify_full_screen.js | 18 +++++++++--------- js/splashify_init.js | 8 ++++---- js/splashify_lightbox.js | 2 +- js/splashify_redirect.js | 2 +- js/splashify_window.js | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/js/splashify_full_screen.js b/js/splashify_full_screen.js index c7bce63..c28cb9f 100644 --- a/js/splashify_full_screen.js +++ b/js/splashify_full_screen.js @@ -2,6 +2,15 @@ Drupal.behaviors.splashifyBehavior.full_screen = function (context, settings) { const splashHeight = $(window).height(); + // Open the splash div. + function openSplash($splash) { + const $body = $('body'); + $body.addClass('splash-active'); + $body.css('margin-top', $splash.attr('originalheight')); + $('.splash-wrapper').css('height', $splash.attr('originalheight')); + window.scrollTo(0, 0); + } + $('#splashify', context) .once('splashify_open') .each(function () { @@ -35,15 +44,6 @@ }); }); - // Open the splash div. - function openSplash($splash) { - const $body = $('body'); - $body.addClass('splash-active'); - $body.css('margin-top', $splash.attr('originalheight')); - $('.splash-wrapper').css('height', $splash.attr('originalheight')); - window.scrollTo(0, 0); - } - // Close the splash div. function closeSplash() { const $body = $('body'); diff --git a/js/splashify_init.js b/js/splashify_init.js index e239702..de29093 100644 --- a/js/splashify_init.js +++ b/js/splashify_init.js @@ -1,10 +1,10 @@ (function ($) { Drupal.behaviors.splashifyBehavior = { attach(context, settings) { - let jsmode = settings.splashify.mode; - let referrer = document.referrer + ''; - let hostname = window.location.hostname + ''; - let referrerCheck = settings.splashify.referrer_check; + const jsmode = settings.splashify.mode; + const referrer = `${document.referrer}`; + const hostname = `${window.location.hostname}`; + const referrerCheck = settings.splashify.referrer_check; // This updates the referer string by taking out the URL parameter from the // URL, which is included from Google search results (as an example). diff --git a/js/splashify_lightbox.js b/js/splashify_lightbox.js index 2e7376a..6b7638b 100644 --- a/js/splashify_lightbox.js +++ b/js/splashify_lightbox.js @@ -1,6 +1,6 @@ (function ($) { Drupal.behaviors.splashifyBehavior.lightbox = function (context, settings) { - let url = settings.splashify.url; + const url = settings.splashify.url; $.colorbox({ transition: 'elastic', diff --git a/js/splashify_redirect.js b/js/splashify_redirect.js index 7a7cfc2..93a8f61 100644 --- a/js/splashify_redirect.js +++ b/js/splashify_redirect.js @@ -1,6 +1,6 @@ (function ($) { Drupal.behaviors.splashifyBehavior.redirect = function (context, settings) { - let url = settings.splashify.url; + const url = settings.splashify.url; window.location.replace(url); }; diff --git a/js/splashify_window.js b/js/splashify_window.js index db1fcea..cb8aa07 100644 --- a/js/splashify_window.js +++ b/js/splashify_window.js @@ -1,6 +1,6 @@ (function ($) { Drupal.behaviors.splashifyBehavior.window = function (context, settings) { - let url = settings.splashify.url; + const url = settings.splashify.url; window.open(url, 'splash', settings.splashify.size); }; -- GitLab From 6edc8d758e9e35d749039503fdc4a9ff07f3bf7a Mon Sep 17 00:00:00 2001 From: Evgen Tolstoy <tolstoy.13@gmail.com> Date: Tue, 18 Feb 2025 17:44:09 +0200 Subject: [PATCH 3/4] Issue #3443644: Fix eslint warnings --- js/splashify_full_screen.js | 43 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/js/splashify_full_screen.js b/js/splashify_full_screen.js index c28cb9f..667358f 100644 --- a/js/splashify_full_screen.js +++ b/js/splashify_full_screen.js @@ -1,13 +1,25 @@ (function ($) { - Drupal.behaviors.splashifyBehavior.full_screen = function (context, settings) { - const splashHeight = $(window).height(); + Drupal.behaviors.splashifyBehavior.full_screen = function ( + context, + settings, + ) { // Open the splash div. function openSplash($splash) { const $body = $('body'); $body.addClass('splash-active'); - $body.css('margin-top', $splash.attr('originalheight')); - $('.splash-wrapper').css('height', $splash.attr('originalheight')); + + const originalHeight = $splash.attr('originalheight'); + + if (originalHeight) { + $body[0].style.marginTop = `${originalHeight}px`; + + const splashWrapper = document.querySelector('.splash-wrapper'); + if (splashWrapper) { + splashWrapper.style.height = `${originalHeight}px`; + } + } + window.scrollTo(0, 0); } @@ -18,10 +30,10 @@ // Get the height of the div. Set it as a custom attribute. // Update the height to 0 and then show the div. - $('body').css('margin-top', splashHeight); - $splash.attr('originalheight', `${splashHeight}px`); - $splash.css('position', 'absolute'); - $splash.css('display', 'block'); + document.body.style.marginTop = splashHeight; + $splash.setAttribute('originalheight', `${splashHeight}px`); + $splash.style.position = 'absolute'; + $splash.style.display = 'block'; // Open the splash. openSplash($splash); @@ -34,11 +46,16 @@ const scrollPosition = $object.scrollTop(); if (scrollPosition >= splashHeight) { $object.scrollTop(0); - // Destroy the splash div...they scrolled passed it. + // Destroy the splash div, they scrolled passed it. const $body = $('body'); $body.removeClass('splash-active'); - $body.css('margin-top', 0); - $('#splashify', context).css('height', 0); + $body[0].style.marginTop = '0'; + + const splashify = document.getElementById('splashify'); + if (splashify) { + splashify.style.height = '0'; + } + $object.off('scroll.splash'); } }); @@ -48,8 +65,8 @@ function closeSplash() { const $body = $('body'); $body.removeClass('splash-active'); - $body.css('margin-top', 0); - $('.splash-wrapper').css('height', 0); + $body[0].style.marginTop = '0'; + document.querySelector('.splash-wrapper').style.height = '0'; } }; })(jQuery); -- GitLab From 59c6c9e419ec6333368bd07b4e96892e6f13c4f8 Mon Sep 17 00:00:00 2001 From: Evgen Tolstoy <tolstoy.13@gmail.com> Date: Tue, 18 Feb 2025 18:13:25 +0200 Subject: [PATCH 4/4] Issue #3443644: Fix eslint warnings --- js/splashify_full_screen.js | 1 + js/splashify_init.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/js/splashify_full_screen.js b/js/splashify_full_screen.js index 667358f..bd19925 100644 --- a/js/splashify_full_screen.js +++ b/js/splashify_full_screen.js @@ -3,6 +3,7 @@ context, settings, ) { + const splashHeight = $(window).height(); // Open the splash div. function openSplash($splash) { diff --git a/js/splashify_init.js b/js/splashify_init.js index de29093..d12e8b0 100644 --- a/js/splashify_init.js +++ b/js/splashify_init.js @@ -2,7 +2,7 @@ Drupal.behaviors.splashifyBehavior = { attach(context, settings) { const jsmode = settings.splashify.mode; - const referrer = `${document.referrer}`; + let referrer = `${document.referrer}`; const hostname = `${window.location.hostname}`; const referrerCheck = settings.splashify.referrer_check; -- GitLab