From e214dd08f6979d44c7cc4ca8f7838ac5364b32d9 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Thu, 20 Jun 2019 20:43:32 +0200 Subject: [PATCH] Update Toolbar.js Signed-off-by: Juraj Oravec --- readability/data/Toolbar.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/readability/data/Toolbar.js b/readability/data/Toolbar.js index c3965c7..f56810b 100644 --- a/readability/data/Toolbar.js +++ b/readability/data/Toolbar.js @@ -34,16 +34,16 @@ function addListeners(){ document.getElementById('style-button').addEventListener("click", toolbarService); var lightButton = document.getElementById('light-button'); - lightButton.addEventListener("click", function(){switchToLight(lightButton);}); + lightButton.addEventListener("click", function(){switchToLight();}); var sepiaButton = document.getElementById('sepia-button'); - sepiaButton.addEventListener("click", function(){switchToSepia(sepiaButton);}); + sepiaButton.addEventListener("click", function(){switchToSepia();}); var darkButton = document.getElementById('dark-button'); - darkButton.addEventListener("click", function(){switchToDark(darkButton);}); + darkButton.addEventListener("click", function(){switchToDark();}); var serifButton = document.getElementById('serif-button'); - serifButton.addEventListener("click", function(){switchToSerif(serifButton);}); + serifButton.addEventListener("click", function(){switchToSerif();}); var sansSerifButton = document.getElementById('sans-serif-button'); - sansSerifButton.addEventListener("click", function(){switchToSansSerif(sansSerifButton);}); + sansSerifButton.addEventListener("click", function(){switchToSansSerif();}); var fontSizePlusButton = document.getElementById('font-size-plus'); fontSizePlusButton.addEventListener("click", fontSizePlus); @@ -62,11 +62,10 @@ function toolbarService(){ element.classList.remove('open'); } else { element.classList.add('open'); - } } -function switchToLight(item){ +function switchToLight(){ document.body.classList.remove('sepia', 'dark'); document.body.classList.add('light'); @@ -74,10 +73,10 @@ function switchToLight(item){ for (var j = items.length - 1; j >= 0; j--) { items[j].classList.remove("selected"); } - item.classList.add('selected'); + document.getElementById('light-button').classList.add('selected'); } -function switchToSepia(item){ +function switchToSepia(){ document.body.classList.remove('light', 'dark'); document.body.classList.add('sepia'); @@ -85,10 +84,10 @@ function switchToSepia(item){ for (var j = items.length - 1; j >= 0; j--) { items[j].classList.remove("selected"); } - item.classList.add('selected'); + document.getElementById('sepia-button').classList.add('selected'); } -function switchToDark(item){ +function switchToDark(){ document.body.classList.remove('sepia', 'light'); document.body.classList.add('dark'); @@ -96,21 +95,21 @@ function switchToDark(item){ for (var j = items.length - 1; j >= 0; j--) { items[j].classList.remove("selected"); } - item.classList.add('selected'); + document.getElementById('dark-button').classList.add('selected'); } -function switchToSerif(item){ +function switchToSerif(){ document.body.classList.remove('sans-serif'); document.body.classList.add('serif'); document.getElementById('sans-serif-button').classList.remove('selected'); - item.classList.add('selected'); + document.getElementById('serif-button').classList.add('selected'); } -function switchToSansSerif(item){ +function switchToSansSerif(){ document.body.classList.remove('serif'); document.body.classList.add('sans-serif'); document.getElementById('serif-button').classList.remove('selected'); - item.classList.add('selected'); + document.getElementById('sans-serif-button').classList.add('selected'); } function fontSizePlus(){ @@ -143,4 +142,4 @@ function fontSizeMinus(){ return; } } -} \ No newline at end of file +}