Skip to content

Commit 6f23481

Browse files
committed
fix screensaver event icon missing
1 parent eb8eece commit 6f23481

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

assets/js/screensaver.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@
9292
const g = parseInt(fullHex.substring(2, 4), 16) || 0;
9393
const b = parseInt(fullHex.substring(4, 6), 16) || 0;
9494
const screensaverBackdrop = `rgba(${r}, ${g}, ${b}, ${safeAlpha})`;
95-
const eventText = [config.event.textLeft, config.event.textRight].filter(Boolean).join(' ').trim();
95+
const buildEventText = () => {
96+
const left = config.event.textLeft || '';
97+
const right = config.event.textRight || '';
98+
const symbolClass = config.event.symbol || '';
99+
const symbol = symbolClass ? `<i class="fa ${symbolClass}" aria-hidden="true"></i>` : '';
100+
return [left, symbol, right].filter(Boolean).join(' ').trim();
101+
};
102+
103+
const eventText = buildEventText();
96104
const showEvent = screensaverMode === 'gallery';
97105
const hasScreensaver = !!screensaverText;
98106
const hasEvent = showEvent && !!eventText;
@@ -108,47 +116,64 @@
108116
textBottom.hide().text('');
109117
};
110118

111-
const setSlot = (text) => {
119+
const applyContent = ($el, content, isHtml = false) => {
120+
if (isHtml) {
121+
$el.html(content);
122+
} else {
123+
$el.text(content);
124+
}
125+
};
126+
127+
const setSlot = (content, isHtml = false) => {
112128
resetSlots();
113129
[textTop, textCenter, textBottom].forEach(($el) => {
114130
$el.css('background', screensaverBackdrop);
115131
});
116132
if (showCenter) {
117-
textCenter.text(text).show();
133+
applyContent(textCenter, content, isHtml);
134+
textCenter.show();
118135
return;
119136
}
120137
if (showTop) {
121-
textTop.text(text).show();
138+
applyContent(textTop, content, isHtml);
139+
textTop.show();
122140
}
123141
if (showBottom) {
124-
textBottom.text(text).show();
142+
applyContent(textBottom, content, isHtml);
143+
textBottom.show();
125144
}
126145
};
127146

128147
if (hasScreensaver && hasEvent) {
129148
if (screensaverFlip) {
130149
setSlot(screensaverText);
131150
if (showTop && showBottom) {
132-
textBottom.text(eventText).show();
151+
applyContent(textBottom, eventText, true);
152+
textBottom.show();
133153
} else if (showCenter || showTop) {
134-
textBottom.text(eventText).show();
154+
applyContent(textBottom, eventText, true);
155+
textBottom.show();
135156
} else {
136-
textTop.text(eventText).show();
157+
applyContent(textTop, eventText, true);
158+
textTop.show();
137159
}
138160
} else {
139-
setSlot(eventText);
161+
setSlot(eventText, true);
140162
if (showTop && showBottom) {
141-
textBottom.text(screensaverText).show();
163+
applyContent(textBottom, screensaverText);
164+
textBottom.show();
142165
} else if (showCenter || showTop) {
143-
textBottom.text(screensaverText).show();
166+
applyContent(textBottom, screensaverText);
167+
textBottom.show();
144168
} else {
145-
textTop.text(screensaverText).show();
169+
applyContent(textTop, screensaverText);
170+
textTop.show();
146171
}
147172
}
148173
} else {
149174
const singleText = hasScreensaver ? screensaverText : hasEvent ? eventText : '';
150175
if (singleText) {
151-
setSlot(singleText);
176+
setSlot(singleText, hasEvent);
152177
} else {
153178
resetSlots();
154179
}

0 commit comments

Comments
 (0)