diff --git a/src/App.vue b/src/App.vue index 69d85ca..2b80633 100644 --- a/src/App.vue +++ b/src/App.vue @@ -48,6 +48,7 @@ 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'; @@ -64,6 +65,7 @@ export default defineComponent({ VERSION: version, store: useMainStore(), apiStore: useApiStore(), + popupStore: usePopupStore(), currentLang: 'pl', releaseURL: '', @@ -81,6 +83,28 @@ export default defineComponent({ this.apiStore.fetchActiveData(); }); + // popup handling + window.addEventListener('mousemove', (e: MouseEvent) => { + e.stopPropagation(); + + 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) => { diff --git a/src/components/Global/StockList.vue b/src/components/Global/StockList.vue index 6fc56f1..7c50a7b 100644 --- a/src/components/Global/StockList.vue +++ b/src/components/Global/StockList.vue @@ -24,14 +24,11 @@ {{ stockName.split(':')[1] }}

- + import { PropType, defineComponent } from 'vue'; import { useApiStore } from '../../store/apiStore'; -import { usePopupStore } from '../../store/popupStore'; export default defineComponent({ props: { @@ -92,8 +95,7 @@ export default defineComponent({ data() { return { - apiStore: useApiStore(), - popupStore: usePopupStore() + apiStore: useApiStore() }; }, diff --git a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue index b469d2c..885fd2a 100644 --- a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue +++ b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue @@ -1,11 +1,6 @@