-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdialog-alert.vue
53 lines (51 loc) · 1.49 KB
/
dialog-alert.vue
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
<style lang="css">
</style>
<template lang="html">
<div> <!-- initial wrapper required by Vue2 -->
<!-- Embedded blackayer on main element, where wrapper is the real content -->
<div class="vac dialog-vac dialog-alert" v-bind:class="{ active: active }" v-bind:style="{ zIndex: zIndex }">
<div class="wrapper">
<h1>{{title}}</h1>
<p>{{message}}</p>
<div class="buttons">
<button class="ok" v-on:click="ok">{{buttonOk}}</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
active: Boolean,
zIndex: Number,
title: String,
message: String,
buttonOk: {
type: String,
default: "Ok",
},
callback: {
type: Function,
default() {
console.log("No callback specified. Default executed.");
}
},
},
methods: {
ok() {
this.active = false;
this.zIndex = -1;
if(this.callback) this.callback();
}
},
created() {
var self = this;
window.addEventListener("click", function(e) {
if(new RegExp("dialog-vac").test(e.target.className)) {
self.ok();
}
});
}
}
</script>