primevue-mirror/src/App.vue

123 lines
4.2 KiB
Vue
Raw Normal View History

<template>
2020-04-13 16:02:51 +00:00
<div class="layout-wrapper" :class="[{'layout-news-active':newsActive}]">
<a class="layout-news" href="https://www.primefaces.org/store" target="_blank" tabindex="-1" v-if="newsActive">
<div class="layout-news-container">
<img class="layouts-news-text-image" alt="easter" src="./assets/images/topbar-easter-2020-text.png">
<img class="layouts-news-mockup-image" alt="easter" src="./assets/images/topbar-easter-2020-ultima.png">
<a href="#" class="layout-news-close" @click="hideNews">
<i class="pi pi-times"></i>
</a>
</div>
</a>
<app-topbar @menubutton-click="onMenuButtonClick" @change-theme="changeTheme" :theme="theme" />
<app-menu :active="sidebarActive" />
<app-configurator @change-theme="changeTheme" :theme="theme" />
2018-12-26 09:36:00 +00:00
<div :class="['layout-mask', {'layout-mask-active': sidebarActive}]" @click="onMaskClick"></div>
2018-12-06 18:26:49 +00:00
<div class="layout-content">
<router-view/>
<app-footer />
2018-12-06 18:26:49 +00:00
</div>
2019-02-08 10:55:52 +00:00
<Toast />
2019-02-08 13:16:00 +00:00
<Toast position="topleft" group="tl" />
<Toast position="bottomleft" group="bl" />
<Toast position="bottomright" group="br" />
</div>
</template>
2018-12-06 18:26:49 +00:00
<script>
import AppTopBar from '@/AppTopBar.vue';
import AppMenu from '@/AppMenu.vue';
import AppFooter from '@/AppFooter.vue';
2019-12-20 13:49:40 +00:00
import AppConfigurator from '@/AppConfigurator.vue';
2020-05-13 12:25:03 +00:00
import EventBus from '@/EventBus';
2018-12-06 18:26:49 +00:00
export default {
2018-12-26 09:36:00 +00:00
data() {
return {
2020-04-13 16:02:51 +00:00
sidebarActive: false,
newsActive: false,
theme: 'saga-blue'
2018-12-26 09:36:00 +00:00
}
},
2020-05-13 14:54:04 +00:00
mounted() {
if (this.isOutdatedIE()) {
this.$toast.add({severity: 'warn', summary: 'Limited Functionality', detail: 'Although PrimeVue supports IE11, ThemeSwitcher in this application cannot be not fully supported by your browser. Please use a modern browser for the best experience of the showcase.'});
}
},
watch: {
2020-02-27 07:47:33 +00:00
$route: {
immediate: true,
handler(to) {
this.sidebarActive = false;
this.$toast.removeAllGroups();
}
}
},
2018-12-26 09:36:00 +00:00
methods: {
onMenuButtonClick() {
this.sidebarActive = !this.sidebarActive;
},
2019-02-08 14:14:35 +00:00
onMaskClick() {
2018-12-26 09:36:00 +00:00
this.sidebarActive = false;
2020-04-13 16:02:51 +00:00
},
hideNews() {
this.newsActive = false;
},
changeTheme(event) {
let themeElement = document.getElementById('theme-link');
themeElement.setAttribute('href', themeElement.getAttribute('href').replace(this.theme, event.theme));
this.theme = event.theme;
this.activeMenuIndex = null;
2020-05-13 12:25:03 +00:00
EventBus.$emit('change-theme', event);
if (event.dark)
document.body.setAttribute('data-darktheme', 'true');
else
document.body.removeAttribute('data-darktheme')
2020-05-13 12:53:01 +00:00
},
addClass(element, className) {
if (!this.hasClass(element, className)) {
if (element.classList)
element.classList.add(className);
else
element.className += ' ' + className;
}
},
removeClass(element, className) {
if (element.classList)
element.classList.remove(className);
else
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
},
hasClass(element, className) {
if (element.classList)
return element.classList.contains(className);
else
return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
2020-05-13 14:54:04 +00:00
},
isOutdatedIE() {
let ua = window.navigator.userAgent;
if (ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0) {
return true;
}
2020-05-13 15:04:28 +00:00
2020-05-13 14:54:04 +00:00
return false;
2018-12-26 09:36:00 +00:00
}
},
components: {
'app-topbar': AppTopBar,
'app-menu': AppMenu,
2019-12-20 13:49:40 +00:00
'app-footer': AppFooter,
'app-configurator': AppConfigurator
2018-12-26 09:36:00 +00:00
},
}
2018-12-06 18:26:49 +00:00
</script>
<style lang="scss">
2020-05-12 08:31:09 +00:00
@import './assets/styles/app/app.scss';
</style>