49 lines
2.7 KiB
JavaScript
49 lines
2.7 KiB
JavaScript
// Enable styling body background while using vue hotreload
|
|
// Tags with side effect (<script> and <style>) are ignored in client component templates.
|
|
|
|
const backgrounds = new Map();
|
|
//backgrounds.set('default', "linear-gradient(#738ef2, white)");
|
|
//backgrounds.set('default', "linear-gradient(rgba(115, 142, 242, 0.9), white)");
|
|
backgrounds.set('default', "white");
|
|
backgrounds.set('/', "url(/static/radiocampus/backgrounds/photo-04-20.jpg) no-repeat center center fixed");
|
|
backgrounds.set('/pages/a-propos/', "white");
|
|
backgrounds.set('/emissions/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/emissions/c/musicale/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/emissions/c/communautaire/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/emissions/c/magazine/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/emissions/c/creation/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/emissions/c/agenda-culturel/', "url(/static/radiocampus/backgrounds/08.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/grille/', "url(/static/radiocampus/backgrounds/photo-04-19.jpg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/c/musicale/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/c/communautaire/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/c/magazine/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/c/creation/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
backgrounds.set('/podcasts/c/agenda-culturel/', "url(/static/radiocampus/backgrounds/09.jpeg) no-repeat center center fixed");
|
|
|
|
|
|
class BackgroundLoad {
|
|
constructor () {
|
|
let url = new URL(document.location);
|
|
this.path = url.pathname;
|
|
this.update();
|
|
document.addEventListener("pageLoaded", this.handlePageLoad.bind(this), false);
|
|
}
|
|
|
|
handlePageLoad (e) {
|
|
this.path = e.detail;
|
|
this.update();
|
|
}
|
|
|
|
update () {
|
|
let background = backgrounds.get(this.path) || backgrounds.get("default");
|
|
// let target = document.getElementsByClassName("page")[0];
|
|
let target = document.body;
|
|
target.style.background = background;
|
|
target.style.backgroundSize = "cover";
|
|
}
|
|
}
|
|
window.onload = function() {
|
|
let backgroundLoad = new BackgroundLoad();
|
|
}
|