2018-12-06 18:45:40 +00:00
|
|
|
<template>
|
2022-02-23 13:44:06 +00:00
|
|
|
<div :ref="containerRef" class="layout-topbar">
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="layout-topbar-inner">
|
|
|
|
<button type="button" class="p-link menu-button" @click="onMenuButtonClick" aria-haspopup aria-label="Menu">
|
|
|
|
<i class="pi pi-bars"></i>
|
|
|
|
</button>
|
2020-10-10 10:20:25 +00:00
|
|
|
|
2023-02-28 08:29:30 +00:00
|
|
|
<ul class="flex list-none m-0 p-0 ml-auto gap-2 align-items-center">
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="https://primefaces.github.io/primevue"
|
|
|
|
class="flex p-link border-1 w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary"
|
|
|
|
>
|
|
|
|
<i class="pi pi-github text-700"></i>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="https://discord.gg/gzKFYnpmCY" class="flex p-link border-1 w-2rem h-2rem surface-border border-round surface-card align-items-center justify-content-center transition-all transition-duration-300 hover:border-primary">
|
|
|
|
<i class="pi pi-discord text-700"></i>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button type="button" class="p-button flex border-1 w-2rem h-2rem p-0 align-items-center justify-content-center transition-all transition-duration-300" @click="onConfigButtonClick">
|
|
|
|
<i class="pi pi-cog"></i>
|
|
|
|
</button>
|
|
|
|
</li>
|
2021-11-15 07:55:18 +00:00
|
|
|
|
2023-02-28 08:29:30 +00:00
|
|
|
<li class="relative">
|
|
|
|
<button
|
|
|
|
v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'scalein', leaveToClass: 'hidden', leaveActiveClass: 'fadeout', hideOnOutsideClick: true }"
|
|
|
|
type="button"
|
|
|
|
class="p-link flex align-items-center surface-card h-2rem px-3 hover:surface-hover border-1 border-solid surface-border transition-all transition-duration-300 hover:border-primary"
|
|
|
|
>
|
|
|
|
<span class="text-900"> {{ versions[0].version }}</span>
|
|
|
|
<span class="ml-2 pi pi-angle-down text-600"></span>
|
|
|
|
</button>
|
2023-01-27 11:56:16 +00:00
|
|
|
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="p-3 surface-overlay hidden absolute right-0 top-auto border-round shadow-2 origin-top w-12rem">
|
|
|
|
<ul class="list-none m-0 p-0">
|
|
|
|
<li v-for="version in versions" :key="version.version" role="none">
|
|
|
|
<a :href="version.url" class="block p-2 border-round hover:surface-hover w-full">
|
|
|
|
<span class="font-bold text-900">{{ version.name }}</span>
|
|
|
|
<span class="ml-2 text-700">{{ version.version }}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2018-12-06 18:45:40 +00:00
|
|
|
</div>
|
2019-05-21 12:54:05 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-02-28 08:29:30 +00:00
|
|
|
import pkg from '@/package.json';
|
2022-02-23 19:52:21 +00:00
|
|
|
|
2019-05-21 12:54:05 +00:00
|
|
|
export default {
|
2023-02-28 08:29:30 +00:00
|
|
|
emits: ['menubutton-click', 'configbutton-click'],
|
2020-01-08 08:06:24 +00:00
|
|
|
outsideClickListener: null,
|
2019-05-21 12:54:05 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2023-02-28 08:29:30 +00:00
|
|
|
versions: [
|
|
|
|
{
|
|
|
|
name: 'v3',
|
|
|
|
version: pkg.version,
|
|
|
|
url: 'https://www.primevue.org'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'v2',
|
|
|
|
version: '2.10.1',
|
|
|
|
url: 'https://www.primefaces.org/primevue-v2'
|
|
|
|
}
|
|
|
|
]
|
2022-09-14 14:26:41 +00:00
|
|
|
};
|
2019-05-21 12:54:05 +00:00
|
|
|
},
|
2022-02-23 13:44:06 +00:00
|
|
|
scrollListener: null,
|
|
|
|
container: null,
|
2022-02-23 19:01:47 +00:00
|
|
|
mounted() {
|
2022-02-23 13:44:06 +00:00
|
|
|
this.bindScrollListener();
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
if (this.scrollListener) {
|
|
|
|
this.unbindScrollListener();
|
|
|
|
}
|
|
|
|
},
|
2019-05-21 12:54:05 +00:00
|
|
|
methods: {
|
2023-02-28 08:29:30 +00:00
|
|
|
onConfigButtonClick(event) {
|
|
|
|
this.$emit('configbutton-click', event);
|
2019-12-10 08:05:47 +00:00
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
onMenuButtonClick(event) {
|
|
|
|
this.$emit('menubutton-click', event);
|
2019-12-10 08:05:47 +00:00
|
|
|
},
|
2022-02-23 13:44:06 +00:00
|
|
|
bindScrollListener() {
|
|
|
|
if (!this.scrollListener) {
|
|
|
|
if (this.container) {
|
|
|
|
this.scrollListener = () => {
|
2022-09-14 14:26:41 +00:00
|
|
|
if (window.scrollY > 0) this.container.classList.add('layout-topbar-sticky');
|
|
|
|
else this.container.classList.remove('layout-topbar-sticky');
|
|
|
|
};
|
2022-02-23 13:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-08 19:24:21 +00:00
|
|
|
|
2022-02-23 13:44:06 +00:00
|
|
|
window.addEventListener('scroll', this.scrollListener);
|
|
|
|
},
|
|
|
|
unbindScrollListener() {
|
|
|
|
if (this.scrollListener) {
|
|
|
|
window.removeEventListener('scroll', this.scrollListener);
|
|
|
|
this.scrollListener = null;
|
|
|
|
}
|
|
|
|
},
|
2020-01-08 08:06:24 +00:00
|
|
|
bindOutsideClickListener() {
|
|
|
|
if (!this.outsideClickListener) {
|
|
|
|
this.outsideClickListener = (event) => {
|
2023-02-28 08:29:30 +00:00
|
|
|
if (this.isOutsideTopbarMenuClicked(event)) {
|
2020-06-18 09:17:14 +00:00
|
|
|
this.unbindOutsideClickListener();
|
2019-05-21 12:54:05 +00:00
|
|
|
}
|
|
|
|
};
|
2022-12-08 19:24:21 +00:00
|
|
|
|
2020-01-08 08:06:24 +00:00
|
|
|
document.addEventListener('click', this.outsideClickListener);
|
2019-05-21 12:54:05 +00:00
|
|
|
}
|
|
|
|
},
|
2020-01-08 08:06:24 +00:00
|
|
|
unbindOutsideClickListener() {
|
|
|
|
if (this.outsideClickListener) {
|
|
|
|
document.removeEventListener('click', this.outsideClickListener);
|
|
|
|
this.outsideClickListener = null;
|
2019-05-21 12:54:05 +00:00
|
|
|
}
|
|
|
|
},
|
2020-01-08 08:07:46 +00:00
|
|
|
isOutsideTopbarMenuClicked(event) {
|
2020-01-08 08:06:24 +00:00
|
|
|
return !(this.$refs.topbarMenu.isSameNode(event.target) || this.$refs.topbarMenu.contains(event.target));
|
2022-02-23 13:44:06 +00:00
|
|
|
},
|
|
|
|
containerRef(el) {
|
|
|
|
this.container = el;
|
2022-02-24 16:27:26 +00:00
|
|
|
}
|
2019-05-21 12:54:05 +00:00
|
|
|
}
|
2022-09-14 14:26:41 +00:00
|
|
|
};
|
2019-12-20 14:22:50 +00:00
|
|
|
</script>
|