set menuEntry href based on link form -> no href on menus without full url, hash links on menus dont trigger routing anymore; news widget check if carousel exists on mounted nextTick;

This commit is contained in:
Johann Hoffmann
2025-02-12 11:56:12 +01:00
parent bcb88c0cb7
commit 8525c82305
3 changed files with 24 additions and 10 deletions
+12 -3
View File
@@ -98,11 +98,12 @@ const app = Vue.createApp({
const target = event.target.closest('a');
if (target && this.isInternalRoute(target.href)) {
const url = new URL(target.href)
const path = new URL(target.href).pathname
const path = url.pathname
const base = this.$router.options.history.base
const route = path.replace(base, '') || '/'
// let click event propagate normally if we dont route internally
const res = this.$router.resolve(route)
if(!res?.matched?.length) return
@@ -112,10 +113,13 @@ const app = Vue.createApp({
if(this.isMobile) { // toggle the menu
const navMain = document.getElementById('nav-main');
// fix unwanted toggle from off to on for some links on mobile
if(navMain.classList.contains('show')) document.getElementById('nav-main-btn').click();
if(navMain.classList.contains('show')){
document.getElementById('nav-main-btn').click();
}
}
this.$router.push(route);
}
}
},
@@ -127,6 +131,11 @@ const app = Vue.createApp({
},
});
router.beforeEach((to,from) => {
console.log('to', to)
console.log('from', from)
})
// kind of a bandaid for bad css on some pages to avoid horizontal scroll
setScrollbarWidth();
app.use(router);
+5 -2
View File
@@ -74,7 +74,7 @@ export default {
return '';
let xmlDoc = (new DOMParser()).parseFromString(this.entry.content,"text/xml");
let url = xmlDoc.getElementsByTagName('url')[0];
if (!url)
return '';
// TODO(chris): replace get params
@@ -101,6 +101,9 @@ export default {
}
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/content/' + this.entry.content_id;
},
hasFullLink() {
return this.link.startsWith(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router)
},
target() {
if (this.entry.template_kurzbz == 'redirect') {
if (!this.entry.content)
@@ -201,7 +204,7 @@ export default {
<template v-if="hasChilds">
<div class="btn-group w-100">
<a :target="target"
:href="(entry.menu_open)?link:null"
:href="(entry.menu_open && hasFullLink)?link:null"
@click="toggleCollapse"
:class="{
'btn btn-default rounded-0 text-start': true,
+7 -5
View File
@@ -139,11 +139,13 @@ export default {
}
}).observe(this.$refs.container);
}
Vue.nextTick(()=>{
this.carouselInstance = new bootstrap.Carousel(this.$refs.carousel, {
wrap: false, // keep this off even though it actually wraps
interval: false
});
Vue.nextTick(()=> {
if(this.$refs.carousel) { // carousel ref might not exist in every widget width/height
this.carouselInstance = new bootstrap.Carousel(this.$refs.carousel, {
wrap: false, // keep this off even though it actually wraps
interval: false
});
}
})
},