2020-02-06 12:10:29 +00:00
|
|
|
<script>
|
|
|
|
import { mapActions, mapState } from 'vuex';
|
|
|
|
import Popover from './popover.vue';
|
2020-04-09 06:09:30 +00:00
|
|
|
import eventHub from '../../notes/event_hub';
|
2020-02-06 12:10:29 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Popover,
|
|
|
|
},
|
|
|
|
computed: {
|
2020-04-24 18:09:46 +00:00
|
|
|
...mapState([
|
|
|
|
'currentDefinition',
|
|
|
|
'currentDefinitionPosition',
|
|
|
|
'currentBlobPath',
|
|
|
|
'definitionPathPrefix',
|
|
|
|
]),
|
2020-02-06 12:10:29 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2020-04-09 06:09:30 +00:00
|
|
|
this.body = document.body;
|
|
|
|
|
|
|
|
eventHub.$on('showBlobInteractionZones', this.showBlobInteractionZones);
|
2020-02-06 12:10:29 +00:00
|
|
|
|
|
|
|
this.addGlobalEventListeners();
|
|
|
|
this.fetchData();
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2020-04-09 06:09:30 +00:00
|
|
|
eventHub.$off('showBlobInteractionZones', this.showBlobInteractionZones);
|
2020-02-06 12:10:29 +00:00
|
|
|
this.removeGlobalEventListeners();
|
|
|
|
},
|
|
|
|
methods: {
|
2020-04-09 06:09:30 +00:00
|
|
|
...mapActions(['fetchData', 'showDefinition', 'showBlobInteractionZones']),
|
2020-02-06 12:10:29 +00:00
|
|
|
addGlobalEventListeners() {
|
2020-04-09 06:09:30 +00:00
|
|
|
if (this.body) {
|
|
|
|
this.body.addEventListener('click', this.showDefinition);
|
2020-02-06 12:10:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
removeGlobalEventListeners() {
|
2020-04-09 06:09:30 +00:00
|
|
|
if (this.body) {
|
|
|
|
this.body.removeEventListener('click', this.showDefinition);
|
2020-02-06 12:10:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<popover
|
|
|
|
v-if="currentDefinition"
|
|
|
|
:position="currentDefinitionPosition"
|
|
|
|
:data="currentDefinition"
|
2020-03-24 18:07:55 +00:00
|
|
|
:definition-path-prefix="definitionPathPrefix"
|
2020-04-24 18:09:46 +00:00
|
|
|
:blob-path="currentBlobPath"
|
2020-02-06 12:10:29 +00:00
|
|
|
/>
|
|
|
|
</template>
|