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
50
51
52
53
54
55
56
57
58
59
60
61
|
<template>
<div class="cw-collapsible" :class="{ 'cw-collapsible-open': isOpen }">
<a href="#" :aria-expanded="isOpen" @click.prevent="isOpen = !isOpen">
<header :class="{ 'cw-collapsible-open': isOpen }" class="cw-collapsible-title">
<studip-icon v-if="icon" :shape="icon" />
<slot name="title" :is-open="isOpen">{{ title }}</slot>
</header>
</a>
<div v-if="isOpen" class="cw-collapsible-content" :class="{ 'cw-collapsible-content-open': isOpen }">
<slot></slot>
</div>
</div>
</template>
<script>
import StudipIcon from '../../StudipIcon.vue';
export default {
name: 'courseware-collapsible-box',
components: {
StudipIcon,
},
props: {
title: String,
icon: {
type: String,
default: '',
},
open: {
type: Boolean,
default: false,
},
},
data() {
return {
isOpen: this.open,
};
},
mounted(){
this.updateCollapsible();
},
updated() {
this.updateCollapsible();
},
methods: {
updateCollapsible() {
if (this.isOpen) {
STUDIP.eventBus.emit('courseware:update-collapsible', { 'uid': this._.uid });
this.$emit('open', true);
} else {
this.$emit('open', false);
}
}
},
watch: {
open(state) {
this.isOpen = state;
}
}
};
</script>
|