Skip to content

Commit

Permalink
Fix JS lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andmor- committed Nov 21, 2023
1 parent a8d7e5a commit 819c136
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"globals": {
"Toc": true
"Toc": true,
"once": true
},
"extends": "drupal",
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion js/adminbar-helper.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
18 changes: 8 additions & 10 deletions js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Global utilities.
*
*/
(function($, Drupal) {
(($, Drupal) => {
Drupal.behaviors.clarin_theme_custom = {
attach: function attach(context) {
if (context !== document) {
Expand All @@ -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();
Expand All @@ -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")
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion js/slidenav.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions js/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 819c136

Please sign in to comment.