aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/CoursewareCompanionOverlay.vue
blob: 9cce904e758657fe1487259b39846f3d361f27a4 (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
47
48
49
<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 { mapActions, mapGetters } from 'vuex';

export default {
    name: 'courseware-companion-overlay',
    computed: {
        ...mapGetters({
            showCompanion: 'showCompanionOverlay',
            msgCompanion: 'msgCompanionOverlay',
            styleCompanion: 'styleCompanionOverlay',
            showToolbar: 'showToolbar',
        }),
    },
    methods: {
        ...mapActions({
            coursewareShowCompanionOverlay: 'coursewareShowCompanionOverlay'
        }),
        hideCompanion() {
            this.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>