mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
popupy
This commit is contained in:
+27
-31
@@ -34,11 +34,12 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, watch } from 'vue';
|
||||
import { defineComponent } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { version } from '.././package.json';
|
||||
|
||||
import { useMainStore } from './store/mainStore';
|
||||
import popupMixin from './mixins/popupMixin';
|
||||
|
||||
import Clock from './components/App/Clock.vue';
|
||||
import StatusIndicator from './components/App/StatusIndicator.vue';
|
||||
@@ -48,7 +49,6 @@ import StorageManager from './managers/storageManager';
|
||||
import PopUp from './components/PopUp/PopUp.vue';
|
||||
import { useApiStore } from './store/apiStore';
|
||||
import { Status } from './typings/common';
|
||||
import { usePopupStore } from './store/popupStore';
|
||||
|
||||
const STORAGE_VERSION_KEY = 'app_version';
|
||||
|
||||
@@ -61,11 +61,12 @@ export default defineComponent({
|
||||
PopUp
|
||||
},
|
||||
|
||||
mixins: [popupMixin],
|
||||
|
||||
data: () => ({
|
||||
VERSION: version,
|
||||
store: useMainStore(),
|
||||
apiStore: useApiStore(),
|
||||
popupStore: usePopupStore(),
|
||||
|
||||
currentLang: 'pl',
|
||||
releaseURL: '',
|
||||
@@ -83,33 +84,7 @@ export default defineComponent({
|
||||
this.apiStore.fetchActiveData();
|
||||
});
|
||||
|
||||
// popup handling
|
||||
window.addEventListener('mousemove', (e: MouseEvent) => {
|
||||
const targetEl = e
|
||||
.composedPath()
|
||||
.find((p) => p instanceof HTMLElement && p.getAttribute('data-popup-key'));
|
||||
|
||||
if (!targetEl || !(targetEl instanceof HTMLElement)) {
|
||||
if (this.popupStore.currentPopupComponent != null) this.popupStore.onPopUpHide();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const popupComponentKey = targetEl.getAttribute('data-popup-key');
|
||||
const popupContent = targetEl.getAttribute('data-popup-content');
|
||||
|
||||
if (popupComponentKey && popupContent)
|
||||
this.popupStore.onPopUpShow(e, popupComponentKey, popupContent);
|
||||
else if (this.popupStore.currentPopupComponent != null) this.popupStore.onPopUpHide();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => this.store.blockScroll,
|
||||
(value) => {
|
||||
if (value) document.body.classList.add('no-scroll');
|
||||
else document.body.classList.remove('no-scroll');
|
||||
}
|
||||
);
|
||||
window.addEventListener('mousemove', (e: MouseEvent) => this.handlePopUpEvents(e));
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -162,6 +137,27 @@ export default defineComponent({
|
||||
this.apiStore.connectToAPI();
|
||||
},
|
||||
|
||||
handlePopUpEvents(e: MouseEvent) {
|
||||
const targetEl = e
|
||||
.composedPath()
|
||||
.find((p) => p instanceof HTMLElement && p.getAttribute('data-popup-key'));
|
||||
|
||||
if (!targetEl || !(targetEl instanceof HTMLElement)) {
|
||||
if (this.store.popUpData.key != null) this.hidePopUp();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const popupComponentKey = targetEl.getAttribute('data-popup-key');
|
||||
const popupContent = targetEl.getAttribute('data-popup-content');
|
||||
|
||||
if (popupComponentKey && popupContent) this.showPopUp(e, popupComponentKey, popupContent);
|
||||
else if (this.store.popUpData.key != null) this.hidePopUp();
|
||||
|
||||
this.store.mousePos.x = e.pageX;
|
||||
this.store.mousePos.y = e.pageY;
|
||||
},
|
||||
|
||||
changeLang(lang: string) {
|
||||
this.$i18n.locale = lang;
|
||||
this.currentLang = lang;
|
||||
@@ -241,7 +237,7 @@ export default defineComponent({
|
||||
grid-template-columns: 100%;
|
||||
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app_main {
|
||||
|
||||
Reference in New Issue
Block a user