added showrooms pages, made page-title color

This commit is contained in:
2019-07-24 17:20:44 +02:00
parent 77154f04a3
commit f2d8c15c25
18 changed files with 1668 additions and 258 deletions

View File

@@ -55,9 +55,40 @@ import 'theme/assets/styles/main.scss'
}
function initVRouter(){
// we need this to update the title while using history nav
// we need this to update the title and body classes while using history nav
router.beforeEach((to, from, next) => {
// console.log('router beforeEach to ', to);
// commit new title to store
store.commit('Common/setPagetitle', to.name != 'home' ? to.name : null)
// remove all path related body classes
let body_classes = document.querySelector('body').classList;
let classes_to_rm = [];
for (var i = 0; i < body_classes.length; i++) {
if(body_classes[i].startsWith('path-')){
classes_to_rm.push(body_classes[i]);
}
}
document.querySelector('body').classList.remove(...classes_to_rm);
// add new path classes to body
let classes = [];
if(to.path == '/'){
classes.push('path-home');
}else{
let path_parts = to.path.replace(/^\//, '').split('/');
for (var i = 0; i < path_parts.length; i++) {
if(i == 0){
var c = "path-" + path_parts[i];
}else if (path_parts[i] !== ''){
var c = classes[i-1] +'-'+ path_parts[i];
}
classes.push(c)
}
}
document.querySelector('body').classList.add(...classes);
// trigger router
next();
})
}
@@ -157,7 +188,7 @@ import 'theme/assets/styles/main.scss'
onclick(event){
// console.log("Clicked on header menu link", event);
let href = event.target.getAttribute('href');
let title = event.target.innerText;
// let title = event.target.innerText;
// console.log("Clicked on header menu link : href", href);
this.$router.push(href)
// replaced by router.beforeEach