aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/CoursewareCompanionOverlay.vue
blob: 5c4fc97c8f9a13e9ec072478d19bc981d40bc46e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<template>
    <div
        class="cw-companion-overlay"
        :class="[showCompanion ? 'cw-companion-overlay-in' : '', showCompanion ? '' : 'cw-companion-overlay-out', styleCompanion]"
    >
        <div class="cw-companion-overlay-content" v-html="msgCompanion"></div>
        <button class="cw-compantion-overlay-close" @click="hideCompanion"></button>
    </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
    name: 'courseware-companion-overlay',
    computed: {
        ...mapGetters({
            showCompanion: 'showCompanionOverlay',
            msgCompanion: 'msgCompanionOverlay',
            styleCompanion: 'styleCompanionOverlay',
            showToolbar: 'showToolbar',
        }),
    },
    methods: {
        hideCompanion() {
            this.$store.dispatch('coursewareShowCompanionOverlay', false);
        },
    },
    watch: {
        showCompanion(newValue, oldValue) {
            let view = this;
            if (newValue === true && oldValue === false) {
                setTimeout(() => {
                    view.hideCompanion();
                }, 4000);
            }
        },
        showToolbar(newValue, oldValue) {
            // hide companion when toolbar is closed 
            if (oldValue === true && newValue === false) {
                this.hideCompanion();
            }
        }
    },
};
</script>