mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 02:40:11 +01:00
[mod] simple theme, JS: introduce window.searxng.theme namespace
In window.searxng.theme the theme data can be passed through to JS implementations. Initial the window.searxng.theme namespace starts with a value for `img_load_error`:: // image that is displayed if load of <img src='...'> failed img_load_error: 'img/img_load_error.svg' The searx/static/themes/__common__/js/image_layout.js is patched to uses the value, if the theme defines a value for img_load_error in this namespace. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
eff0884498
commit
7dc9cc91a8
@ -149,7 +149,7 @@
|
|||||||
|
|
||||||
function img_load_error(event) {
|
function img_load_error(event) {
|
||||||
// console.log("ERROR can't load: " + event.originalTarget.src);
|
// console.log("ERROR can't load: " + event.originalTarget.src);
|
||||||
event.originalTarget.src = window.searxng.static_path + 'img/img_load_error.svg';
|
event.originalTarget.src = w.searxng.static_path + w.searxng.theme.img_load_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function throttleAlign() {
|
function throttleAlign() {
|
||||||
@ -175,9 +175,11 @@
|
|||||||
img.addEventListener('load', throttleAlign);
|
img.addEventListener('load', throttleAlign);
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror
|
||||||
img.addEventListener('error', throttleAlign);
|
img.addEventListener('error', throttleAlign);
|
||||||
|
if (w.searxng.theme.img_load_error) {
|
||||||
img.addEventListener('error', img_load_error, {once: true});
|
img.addEventListener('error', img_load_error, {once: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
w.searxng.ImageLayout = ImageLayout;
|
w.searxng.ImageLayout = ImageLayout;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
hotkeys: script.getAttribute('data-hotkeys') === 'true',
|
||||||
static_path: script.getAttribute('data-static-path'),
|
static_path: script.getAttribute('data-static-path'),
|
||||||
translations: JSON.parse(script.getAttribute('data-translations')),
|
translations: JSON.parse(script.getAttribute('data-translations')),
|
||||||
|
theme : {
|
||||||
|
// image that is displayed if load of <img src='...'> failed
|
||||||
|
img_load_error: 'img/img_load_error.svg'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// update the css
|
// update the css
|
||||||
|
Loading…
Reference in New Issue
Block a user