diff --git a/.eslintrc.json b/.eslintrc.json index a23d0cc..0827a92 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "globals": { - "Toc": true + "Toc": true, + "once": true }, "extends": "drupal", "rules": { diff --git a/js/adminbar-helper.js b/js/adminbar-helper.js index a1a2bce..8385c1e 100644 --- a/js/adminbar-helper.js +++ b/js/adminbar-helper.js @@ -1,4 +1,4 @@ -(function($, Drupal) { +(($, Drupal) => { // Helper methods for the administration toolbar // - Reposition body and floating menu when user has admin toolbar enabled. Drupal.behaviors.clarin_theme_adminbar_helper = { diff --git a/js/custom.js b/js/custom.js index c059b79..adfa4c8 100644 --- a/js/custom.js +++ b/js/custom.js @@ -3,7 +3,7 @@ * Global utilities. * */ -(function($, Drupal) { +(($, Drupal) => { Drupal.behaviors.clarin_theme_custom = { attach: function attach(context) { if (context !== document) { @@ -14,7 +14,7 @@ $( ".mailchimp-signup-subscribe-form .form-type-email, .path-search .search-form .form-type-search", document - ).each(function() { + ).each(() => { const label = $(this) .find("label") .text(); @@ -24,17 +24,15 @@ }); // Header scroll down arrow function - $(".paragraph--type--header-large .arrow-down", document).click( - function() { - $("html, body").animate({ scrollTop: "+=660px" }, 800); - } - ); + $(".paragraph--type--header-large .arrow-down", document).click(() => { + $("html, body").animate({ scrollTop: "+=660px" }, 800); + }); // Hide tags if there are more than 2 $( ".node--view-mode-teaser-list .field--name-field-tags, .node--view-mode-teaser-big .field--name-field-tags", document - ).each(function() { + ).each(() => { if ($(this).find("li").length > 2) { $(this) .find("ul") @@ -46,14 +44,14 @@ }); // Show tags when clicked on show tags button - $(".show-tags", document).click(function() { + $(".show-tags", document).click(() => { $(this) .parent() .removeClass("hide-more"); }); // Auto select input search box - $("#searchMenuDropdown", document).on("shown.bs.dropdown", function() { + $("#searchMenuDropdown", document).on("shown.bs.dropdown", () => { $("#edit-keys-dropdown", $(this)) .focus() .select(); diff --git a/js/slidenav.js b/js/slidenav.js index 2c68a51..daa6c58 100644 --- a/js/slidenav.js +++ b/js/slidenav.js @@ -1,4 +1,4 @@ -(function($, Drupal) { +(($, Drupal) => { // CLARIN slidenav helper methods for the top navbar menu. The slidenav is only used on screens narrower // than 1200px and when activated in the theme options. // - When the window width is narrower than 1200px, add a click handler to dismiss (slide out) the mobile floating diff --git a/js/toc.js b/js/toc.js index e84bfc1..39d68d8 100644 --- a/js/toc.js +++ b/js/toc.js @@ -3,13 +3,13 @@ * Initialize TOC * */ -(function($, Drupal, once) { +(($, Drupal, once) => { Drupal.behaviors.clarin_theme_toc = { attach: function attach(context) { if (context === document) { $(function initToc() { - var navSelector = "#toc"; - var scopeSelector = "#tocscope"; + const navSelector = "#toc"; + const scopeSelector = "#tocscope"; Toc.init({ $nav: $(once("selectorID", navSelector, context)), $scope: $(once("selectorID", scopeSelector, context))