From 348f3e71eafe07f22b2b6efe1d37bfcc47fe5d65 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:37:57 +0200 Subject: [PATCH] improve pip classList add/remove with no intermediary variable --- .../directives/components/umbrangeslider.directive.js | 11 ++--------- .../src/installer/steps/user.controller.js | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbrangeslider.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbrangeslider.directive.js index 9d9c6a3421..405641a9ab 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbrangeslider.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbrangeslider.directive.js @@ -322,20 +322,13 @@ For extra details about options and events take a look here: https://refreshless }); } function setUpActivePipsHandling() { - let activePip = [null, null]; sliderInstance.noUiSlider.on('update', function (values,handle) { - if(activePip[handle]){ - activePip[handle].classList.remove("noUi-value-active"); - } sliderInstance.querySelectorAll('.noUi-value').forEach(pip => { + pip.classList.remove("noUi-value-active"); if (Number(values[handle]) === Number(pip.getAttribute('data-value'))) { - activePip[handle] = pip; + pip.classList.add("noUi-value-active"); } }); - - if (activePip[handle]) { - activePip[handle].classList.add("noUi-value-active"); - } }); } function addPipClickHandler(){ diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js b/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js index a8bb36d3d5..4726a53aaf 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js @@ -54,20 +54,13 @@ angular.module("umbraco.install").controller("Umbraco.Install.UserController", f const pips = consentSlider.querySelectorAll('.noUi-value'); - let activePip = [null, null]; consentSlider.noUiSlider.on('update', function (values,handle) { - if(activePip[handle]){ - activePip[handle].classList.remove("noUi-value-active"); - } consentSlider.querySelectorAll('.noUi-value').forEach(pip => { + pip.classList.remove("noUi-value-active"); if (Number(values[handle]) === Number(pip.getAttribute('data-value'))) { - activePip[handle] = pip; + pip.classList.add("noUi-value-active"); } }); - - if (activePip[handle]) { - activePip[handle].classList.add("noUi-value-active"); - } }); $(consentSlider).on('$destroy', function () {