mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-04 05:48:11 +00:00
poprawki do popupów
This commit is contained in:
+24
@@ -48,6 +48,7 @@ import StorageManager from './managers/storageManager';
|
|||||||
import PopUp from './components/PopUp/PopUp.vue';
|
import PopUp from './components/PopUp/PopUp.vue';
|
||||||
import { useApiStore } from './store/apiStore';
|
import { useApiStore } from './store/apiStore';
|
||||||
import { Status } from './typings/common';
|
import { Status } from './typings/common';
|
||||||
|
import { usePopupStore } from './store/popupStore';
|
||||||
|
|
||||||
const STORAGE_VERSION_KEY = 'app_version';
|
const STORAGE_VERSION_KEY = 'app_version';
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ export default defineComponent({
|
|||||||
VERSION: version,
|
VERSION: version,
|
||||||
store: useMainStore(),
|
store: useMainStore(),
|
||||||
apiStore: useApiStore(),
|
apiStore: useApiStore(),
|
||||||
|
popupStore: usePopupStore(),
|
||||||
|
|
||||||
currentLang: 'pl',
|
currentLang: 'pl',
|
||||||
releaseURL: '',
|
releaseURL: '',
|
||||||
@@ -81,6 +83,28 @@ export default defineComponent({
|
|||||||
this.apiStore.fetchActiveData();
|
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(
|
watch(
|
||||||
() => this.store.blockScroll,
|
() => this.store.blockScroll,
|
||||||
(value) => {
|
(value) => {
|
||||||
|
|||||||
@@ -24,14 +24,11 @@
|
|||||||
{{ stockName.split(':')[1] }}
|
{{ stockName.split(':')[1] }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<span
|
<span>
|
||||||
@mouseenter="
|
|
||||||
popupStore.onPopUpShow($event, 'VehiclePreviewPopUp', stockName.split(':')[0])
|
|
||||||
"
|
|
||||||
@mousemove="popupStore.onPopUpMove"
|
|
||||||
@mouseleave="popupStore.onPopUpHide"
|
|
||||||
>
|
|
||||||
<img
|
<img
|
||||||
|
:data-mouseover="stockName"
|
||||||
|
data-popup-key="VehiclePreviewPopUp"
|
||||||
|
:data-popup-content="stockName.split(':')[0]"
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}${
|
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}${
|
||||||
/^EN/.test(stockName) ? 'rb' : ''
|
/^EN/.test(stockName) ? 'rb' : ''
|
||||||
}.png`"
|
}.png`"
|
||||||
@@ -42,6 +39,9 @@
|
|||||||
|
|
||||||
<!-- /// Manualne dodawanie miniaturek członów dla kibelków /// -->
|
<!-- /// Manualne dodawanie miniaturek członów dla kibelków /// -->
|
||||||
<img
|
<img
|
||||||
|
:data-mouseover="stockName"
|
||||||
|
data-popup-key="VehiclePreviewPopUp"
|
||||||
|
:data-popup-content="stockName.split(':')[0]"
|
||||||
v-if="/^(EN|2EN)/.test(stockName)"
|
v-if="/^(EN|2EN)/.test(stockName)"
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
|
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
|
||||||
@error="
|
@error="
|
||||||
@@ -50,7 +50,9 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="train-thumbnail"
|
:data-mouseover="stockName"
|
||||||
|
data-popup-key="VehiclePreviewPopUp"
|
||||||
|
:data-popup-content="stockName.split(':')[0]"
|
||||||
v-if="/^EN71/.test(stockName)"
|
v-if="/^EN71/.test(stockName)"
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
|
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
|
||||||
@error="
|
@error="
|
||||||
@@ -59,7 +61,9 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="train-thumbnail"
|
:data-mouseover="stockName"
|
||||||
|
data-popup-key="VehiclePreviewPopUp"
|
||||||
|
:data-popup-content="stockName.split(':')[0]"
|
||||||
v-if="/^(EN|2EN)/.test(stockName)"
|
v-if="/^(EN|2EN)/.test(stockName)"
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}ra.png`"
|
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}ra.png`"
|
||||||
@error="
|
@error="
|
||||||
@@ -76,7 +80,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import { useApiStore } from '../../store/apiStore';
|
import { useApiStore } from '../../store/apiStore';
|
||||||
import { usePopupStore } from '../../store/popupStore';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
@@ -92,8 +95,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
apiStore: useApiStore(),
|
apiStore: useApiStore()
|
||||||
popupStore: usePopupStore()
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="item-general">
|
<div class="item-general">
|
||||||
<span
|
<span class="general-train">
|
||||||
class="general-train"
|
|
||||||
tabindex="0"
|
|
||||||
@click.stop="showTimetable(timetable, $event.currentTarget)"
|
|
||||||
@keydown.enter="showTimetable(timetable, $event.currentTarget)"
|
|
||||||
>
|
|
||||||
<span class="text--grayed">#{{ timetable.id }}</span>
|
<span class="text--grayed">#{{ timetable.id }}</span>
|
||||||
|
|
||||||
<span class="badges" v-if="timetable.skr || timetable.twr">
|
<span class="badges" v-if="timetable.skr || timetable.twr">
|
||||||
@@ -39,6 +34,17 @@
|
|||||||
<strong v-else>
|
<strong v-else>
|
||||||
{{ timetable.driverName }}
|
{{ timetable.driverName }}
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
|
<span v-if="timetable.terminated == false">
|
||||||
|
•
|
||||||
|
<button
|
||||||
|
class="btn--image btn-timetable"
|
||||||
|
@click.stop="showTimetable(timetable, $event.currentTarget)"
|
||||||
|
>
|
||||||
|
<img src="/images/icon-train.svg" alt="" />
|
||||||
|
RJ ONLINE
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="general-time">
|
<span class="general-time">
|
||||||
@@ -148,6 +154,11 @@ export default defineComponent({
|
|||||||
gap: 0.25em;
|
gap: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-timetable {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
@include smallScreen {
|
@include smallScreen {
|
||||||
.item-general {
|
.item-general {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -120,15 +120,8 @@
|
|||||||
<b
|
<b
|
||||||
v-if="apiStore.donatorsData.includes(station.onlineInfo.dispatcherName)"
|
v-if="apiStore.donatorsData.includes(station.onlineInfo.dispatcherName)"
|
||||||
@click.stop="openDonationModal"
|
@click.stop="openDonationModal"
|
||||||
@mouseenter="
|
data-popup-key="DonatorPopUp"
|
||||||
popupStore.onPopUpShow(
|
:data-popup-content="$t('donations.dispatcher-message')"
|
||||||
$event,
|
|
||||||
'DonatorPopUp',
|
|
||||||
$t('donations.dispatcher-message')
|
|
||||||
)
|
|
||||||
"
|
|
||||||
@mousemove="popupStore.onPopUpMove"
|
|
||||||
@mouseleave="popupStore.onPopUpHide"
|
|
||||||
>
|
>
|
||||||
<img src="/images/icon-diamond.svg" alt="" />
|
<img src="/images/icon-diamond.svg" alt="" />
|
||||||
{{ station.onlineInfo.dispatcherName }}
|
{{ station.onlineInfo.dispatcherName }}
|
||||||
@@ -380,6 +373,7 @@ export default defineComponent({
|
|||||||
openDonationModal(e: Event) {
|
openDonationModal(e: Event) {
|
||||||
this.$emit('toggleDonationModal', true);
|
this.$emit('toggleDonationModal', true);
|
||||||
this.mainStore.modalLastClickedTarget = e.target;
|
this.mainStore.modalLastClickedTarget = e.target;
|
||||||
|
this.popupStore.currentPopupComponent = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
openForumSite(e: Event, url: string | undefined) {
|
openForumSite(e: Event, url: string | undefined) {
|
||||||
|
|||||||
@@ -36,21 +36,22 @@
|
|||||||
<div class="train-driver">
|
<div class="train-driver">
|
||||||
<b
|
<b
|
||||||
v-if="apiStore.donatorsData.includes(train.driverName)"
|
v-if="apiStore.donatorsData.includes(train.driverName)"
|
||||||
@mouseenter="
|
data-popup-key="DonatorPopUp"
|
||||||
popupStore.onPopUpShow($event, 'DonatorPopUp', $t('donations.driver-message'))
|
:data-popup-content="$t('donations.driver-message')"
|
||||||
"
|
|
||||||
@mousemove="popupStore.onPopUpMove"
|
|
||||||
@mouseleave="popupStore.onPopUpHide"
|
|
||||||
>
|
>
|
||||||
{{ train.driverName }}
|
{{ train.driverName }}
|
||||||
<img src="/images/icon-diamond.svg" alt="donator diamond icon" />
|
<img src="/images/icon-diamond.svg" alt="donator diamond icon" />
|
||||||
</b>
|
</b>
|
||||||
|
|
||||||
<span v-else>{{ train.driverName }}</span>
|
<span v-else>{{ train.driverName }}</span>
|
||||||
•
|
|
||||||
<button class="btn--image btn--text btn-journal" v-if="extended">
|
<span v-if="extended">
|
||||||
<img src="/images/icon-train.svg" alt="" />
|
•
|
||||||
DZIENNIK
|
<button class="btn--image btn--text btn-timetable" @click="navigateToJournal">
|
||||||
</button>
|
<img src="/images/icon-train.svg" alt="" />
|
||||||
|
DZIENNIK
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -58,17 +59,10 @@
|
|||||||
<strong>{{ train.timetableData.route.replace('|', ' - ') }}</strong>
|
<strong>{{ train.timetableData.route.replace('|', ' - ') }}</strong>
|
||||||
<span
|
<span
|
||||||
v-if="getSceneriesWithComments(train.timetableData).length > 0"
|
v-if="getSceneriesWithComments(train.timetableData).length > 0"
|
||||||
@mouseenter="
|
data-popup-key="TrainCommentsPopUp"
|
||||||
popupStore.onPopUpShow(
|
:data-popup-content="`${$t('trains.timetable-comments')} (${getSceneriesWithComments(
|
||||||
$event,
|
train.timetableData
|
||||||
'TrainCommentsPopUp',
|
)})`"
|
||||||
`${$t('trains.timetable-comments')} (${getSceneriesWithComments(
|
|
||||||
train.timetableData
|
|
||||||
)})`
|
|
||||||
)
|
|
||||||
"
|
|
||||||
@mousemove="popupStore.onPopUpMove"
|
|
||||||
@mouseleave="popupStore.onPopUpHide"
|
|
||||||
>
|
>
|
||||||
<img class="image-warning" src="/images/icon-warning.svg" />
|
<img class="image-warning" src="/images/icon-warning.svg" />
|
||||||
</span>
|
</span>
|
||||||
@@ -143,9 +137,10 @@ import { useMainStore } from '../../store/mainStore';
|
|||||||
import { useApiStore } from '../../store/apiStore';
|
import { useApiStore } from '../../store/apiStore';
|
||||||
import StockList from '../Global/StockList.vue';
|
import StockList from '../Global/StockList.vue';
|
||||||
import { usePopupStore } from '../../store/popupStore';
|
import { usePopupStore } from '../../store/popupStore';
|
||||||
|
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [trainInfoMixin, styleMixin],
|
mixins: [trainInfoMixin, styleMixin, modalTrainMixin],
|
||||||
components: { ProgressBar, StockList },
|
components: { ProgressBar, StockList },
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@@ -164,6 +159,19 @@ export default defineComponent({
|
|||||||
apiStore: useApiStore(),
|
apiStore: useApiStore(),
|
||||||
popupStore: usePopupStore()
|
popupStore: usePopupStore()
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
navigateToJournal() {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/journal/timetables',
|
||||||
|
query: {
|
||||||
|
'search-driver': this.train.driverName
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.closeModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -205,7 +213,7 @@ export default defineComponent({
|
|||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-journal {
|
.btn-timetable {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { useMainStore } from '../store/mainStore';
|
import { useMainStore } from '../store/mainStore';
|
||||||
|
import { usePopupStore } from '../store/popupStore';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
store: useMainStore()
|
store: useMainStore(),
|
||||||
|
popupStore: usePopupStore()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
closeModal() {
|
closeModal() {
|
||||||
this.store.chosenModalTrainId = undefined;
|
this.store.chosenModalTrainId = undefined;
|
||||||
|
this.popupStore.currentPopupComponent = null;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
(this.store.modalLastClickedTarget as any)?.focus();
|
(this.store.modalLastClickedTarget as any)?.focus();
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
|
|
||||||
|
export const popupKeys = ['DonatorPopUp', 'TrainCommentsPopUp', 'VehiclePreviewPopUp'] as const;
|
||||||
|
export type PopUp = (typeof popupKeys)[number];
|
||||||
|
|
||||||
|
const isPopUp = (v: any): v is PopUp => popupKeys.includes(v);
|
||||||
|
|
||||||
export const usePopupStore = defineStore('popupStore', {
|
export const usePopupStore = defineStore('popupStore', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
popupPosition: { x: 0, y: 0 },
|
popupPosition: { x: 0, y: 0 },
|
||||||
currentPopupComponent: null as
|
currentPopupComponent: null as PopUp | null,
|
||||||
| null
|
|
||||||
| 'DonatorPopUp'
|
|
||||||
| 'TrainCommentsPopUp'
|
|
||||||
| 'VehiclePreviewPopUp',
|
|
||||||
currentPopupContent: '',
|
currentPopupContent: '',
|
||||||
donatorPopupVisible: false
|
donatorPopupVisible: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onPopUpShow(e: MouseEvent, componentKey: typeof this.currentPopupComponent, value?: string) {
|
onPopUpShow(e: MouseEvent, componentKey: string, value?: string) {
|
||||||
|
if (!isPopUp(componentKey)) return;
|
||||||
|
|
||||||
this.popupPosition.x = e.pageX;
|
this.popupPosition.x = e.pageX;
|
||||||
this.popupPosition.y = e.pageY;
|
this.popupPosition.y = e.pageY;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
$animDuration: 150ms;
|
$animDuration: 95ms;
|
||||||
$animType: ease-in-out;
|
$animType: ease-in-out;
|
||||||
|
|
||||||
// List animation
|
// List animation
|
||||||
@@ -72,7 +72,6 @@ $animType: ease-in-out;
|
|||||||
|
|
||||||
&-enter-from,
|
&-enter-from,
|
||||||
&-leave-to {
|
&-leave-to {
|
||||||
transform: translateY(-25%);
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ a.a-button {
|
|||||||
padding: 0.35em 0.75em;
|
padding: 0.35em 0.75em;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 1.5em;
|
width: 1.35em;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user