Browse Source

Use classList.toggle wherever possible

Aarni Koskela 2 years ago
parent
commit
34a6ad80d5
2 changed files with 4 additions and 12 deletions
  1. 3 7
      javascript/hires_fix.js
  2. 1 5
      javascript/imageviewer.js

+ 3 - 7
javascript/hires_fix.js

@@ -1,13 +1,9 @@
 
 
-function setInactive(elem, inactive){
-    if(inactive){
-        elem.classList.add('inactive')
-    } else{
-        elem.classList.remove('inactive')
+function onCalcResolutionHires(enable, width, height, hr_scale, hr_resize_x, hr_resize_y){
+    function setInactive(elem, inactive){
+        elem.classList.toggle('inactive', !!inactive)
     }
     }
-}
 
 
-function onCalcResolutionHires(enable, width, height, hr_scale, hr_resize_x, hr_resize_y){
     hrUpscaleBy = gradioApp().getElementById('txt2img_hr_scale')
     hrUpscaleBy = gradioApp().getElementById('txt2img_hr_scale')
     hrResizeX = gradioApp().getElementById('txt2img_hr_resize_x')
     hrResizeX = gradioApp().getElementById('txt2img_hr_resize_x')
     hrResizeY = gradioApp().getElementById('txt2img_hr_resize_y')
     hrResizeY = gradioApp().getElementById('txt2img_hr_resize_y')

+ 1 - 5
javascript/imageviewer.js

@@ -144,11 +144,7 @@ function setupImageForLightbox(e) {
 }
 }
 
 
 function modalZoomSet(modalImage, enable) {
 function modalZoomSet(modalImage, enable) {
-    if (enable) {
-        modalImage.classList.add('modalImageFullscreen');
-    } else {
-        modalImage.classList.remove('modalImageFullscreen');
-    }
+    if(modalImage) modalImage.classList.toggle('modalImageFullscreen', !!enable);
 }
 }
 
 
 function modalZoomToggle(event) {
 function modalZoomToggle(event) {