From 59103d96ab3c36a7dffb4ed90813cc724ebdc0b8 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Sat, 5 Oct 2019 17:42:21 +0200 Subject: [PATCH] refactor: remove empty expressions --- js/foundation.abide.js | 8 ++++---- js/foundation.accordion.js | 2 +- js/foundation.dropdown.js | 9 +++++---- js/foundation.responsiveAccordionTabs.js | 14 +++++++------- js/foundation.util.box.js | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/js/foundation.abide.js b/js/foundation.abide.js index 7fbd9df8d..949c09877 100644 --- a/js/foundation.abide.js +++ b/js/foundation.abide.js @@ -293,7 +293,7 @@ class Abide extends Plugin { if (typeof errorId === 'undefined') { errorId = GetYoDigits(6, 'abide-error'); $error.attr('id', errorId); - }; + } $el.attr('aria-describedby', errorId); } @@ -304,7 +304,7 @@ class Abide extends Plugin { if (typeof elemId === 'undefined') { elemId = GetYoDigits(6, 'abide-input'); $el.attr('id', elemId); - }; + } // For each label targeting $el, set [for] if it is not set. $labels.each((i, label) => { @@ -608,7 +608,7 @@ class Abide extends Plugin { valid = true; } }); - }; + } return valid; } @@ -648,7 +648,7 @@ class Abide extends Plugin { if (checked >= minRequired) { valid = true; } - }; + } // Skip validation if more than 1 checkbox have to be checked AND if the form hasn't got submitted yet (otherwise it will already show an error during the first fill in) if (this.initialized !== true && minRequired > 1) { diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index e2f9116f0..962c531a9 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -91,7 +91,7 @@ class Accordion extends Plugin { if ($anchor && $link && $link.length) { if (!$link.parent('[data-accordion-item]').hasClass('is-active')) { this._openSingleTab($anchor); - }; + } } // Otherwise, close everything else { diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index 560fc2933..294f1ae85 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -73,7 +73,7 @@ class Dropdown extends Positionable { // Get the anchor ID or create one if (typeof this.$currentAnchor.attr('id') === 'undefined') { this.$currentAnchor.attr('id', GetYoDigits(6, 'dd-anchor')); - }; + } this.$element.attr('aria-labelledby', this.$currentAnchor.attr('id')); } @@ -153,12 +153,13 @@ class Dropdown extends Positionable { .on('click.zf.trigger', function(e) { _this._setCurrentAnchor(this); - if (_this.options.forceFollow === false) { + if ( // if forceFollow false, always prevent default action - e.preventDefault(); - } else if (hasTouch && _this.options.hover && _this.$element.hasClass('is-open') === false) { + (_this.options.forceFollow === false) || // if forceFollow true and hover option true, only prevent default action on 1st click // on 2nd click (dropown opened) the default action (e.g. follow a href) gets executed + (hasTouch && _this.options.hover && _this.$element.hasClass('is-open') === false) + ) { e.preventDefault(); } }); diff --git a/js/foundation.responsiveAccordionTabs.js b/js/foundation.responsiveAccordionTabs.js index 8d73237b6..e6477ff6e 100644 --- a/js/foundation.responsiveAccordionTabs.js +++ b/js/foundation.responsiveAccordionTabs.js @@ -55,7 +55,7 @@ class ResponsiveAccordionTabs extends Plugin{ this.className = 'ResponsiveAccordionTabs'; // ie9 back compat if (!this.$element.attr('id')) { this.$element.attr('id',GetYoDigits(6, 'responsiveaccordiontabs')); - }; + } this._init(); this._events(); @@ -178,7 +178,7 @@ class ResponsiveAccordionTabs extends Plugin{ if ($panels.length) fromString = 'tabs'; if (fromString === toSet) { return; - }; + } var tabsTitle = _this.allOptions.linkClass?_this.allOptions.linkClass:'tabs-title'; var tabsPanel = _this.allOptions.panelClass?_this.allOptions.panelClass:'tabs-panel'; @@ -192,7 +192,7 @@ class ResponsiveAccordionTabs extends Plugin{ $panels.children('a').removeAttr('role').removeAttr('aria-controls').removeAttr('aria-selected'); }else{ $panels = $liHeads.children('[data-tab-content]').removeClass('accordion-content'); - }; + } $panels.css({display:'',visibility:''}); $liHeads.css({display:'',visibility:''}); @@ -211,7 +211,7 @@ class ResponsiveAccordionTabs extends Plugin{ $placeholder.remove(); }else{ $tabsContent = $('
').insertAfter(_this.$element).attr('data-tabs-content',_this.$element.attr('id')); - }; + } $panels.each(function(key,value){ var tempValue = $(value).appendTo($tabsContent).addClass(tabsPanel); var hash = $liHeadsA.get(key).hash.slice(1); @@ -223,12 +223,12 @@ class ResponsiveAccordionTabs extends Plugin{ hash = id; $(value).attr('id',hash); $($liHeadsA.get(key)).attr('href',$($liHeadsA.get(key)).attr('href').replace('#','')+'#'+hash); - }; - }; + } + } var isActive = $($liHeads.get(key)).hasClass('is-active'); if (isActive) { tempValue.addClass('is-active'); - }; + } }); $liHeads.addClass(tabsTitle); }; diff --git a/js/foundation.util.box.js b/js/foundation.util.box.js index 11688c358..74ec89858 100644 --- a/js/foundation.util.box.js +++ b/js/foundation.util.box.js @@ -22,7 +22,7 @@ var Box = { */ function ImNotTouchingYou(element, parent, lrOnly, tbOnly, ignoreBottom) { return OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) === 0; -}; +} function OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) { var eleDims = GetDimensions(element), -- 2.47.2