From f9e6a37020c6347f8dbd749bde6b68c8f2e80510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Markovi=C4=87?= Date: Sat, 13 Jun 2026 10:27:44 +0200 Subject: [PATCH] =?UTF-8?q?fix(js):=20slajderi=20teme=20po=C5=A1tuju=20sa?= =?UTF-8?q?=C4=8Duvanu=20vrednost=200=20pri=20u=C4=8Ditavanju?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Init je koristio parseInt(x) || podrazumevano, gde je 0 falsy pa je padao na podrazumevanu vrednost — slajderi (blur, opacity, glassOpacity) su se pri ulasku na stranicu resetovali ako je sačuvana vrednost bila 0. Dodat helper broj() koji na podrazumevano pada samo kad vrednost nije broj. --- web/static/js/ntech.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/static/js/ntech.js b/web/static/js/ntech.js index 92ef82c..2e6b4c2 100644 --- a/web/static/js/ntech.js +++ b/web/static/js/ntech.js @@ -108,10 +108,16 @@ document.addEventListener('alpine:init', () => { glassOpacity: 10, init() { this.pozadina = this.$el.dataset.pozadina || '' - this.blur = parseInt(this.$el.dataset.blur) || 12 - this.opacity = parseInt(this.$el.dataset.opacity) || 50 - this.blurPozadine = parseInt(this.$el.dataset.blurPozadine) || 0 - this.glassOpacity = parseInt(this.$el.dataset.glassOpacity) || 10 + // ne koristimo „|| podrazumevano" jer je 0 validna vrednost a falsy — pala bi na podrazumevano + this.blur = this.broj(this.$el.dataset.blur, 12) + this.opacity = this.broj(this.$el.dataset.opacity, 50) + this.blurPozadine = this.broj(this.$el.dataset.blurPozadine, 0) + this.glassOpacity = this.broj(this.$el.dataset.glassOpacity, 10) + }, + // vraća ceo broj iz vrednosti; ako nije broj, vraća podrazumevano (0 ostaje 0) + broj(vrednost, podrazumevano) { + const n = parseInt(vrednost, 10) + return Number.isNaN(n) ? podrazumevano : n }, stilPozadine() { const bgCss = this.pozadina ? "background:url('" + this.pozadina + "') center/cover;" : 'background:#1a2033;'