2018-02-13 02:15:12 -06:00
|
|
|
<template>
|
|
|
|
<div class="mk-dialog">
|
|
|
|
<div class="bg" ref="bg" @click="onBgClick"></div>
|
|
|
|
<div class="main" ref="main">
|
2018-02-22 10:27:02 -06:00
|
|
|
<header v-html="title" :class="$style.header"></header>
|
2018-02-13 02:15:12 -06:00
|
|
|
<div class="body" v-html="text"></div>
|
|
|
|
<div class="buttons">
|
2018-02-20 11:53:34 -06:00
|
|
|
<button v-for="button in buttons" @click="click(button)">{{ button.text }}</button>
|
2018-02-13 02:15:12 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import * as anime from 'animejs';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-03-02 03:46:08 -06:00
|
|
|
props: {
|
2018-02-13 02:15:12 -06:00
|
|
|
title: {
|
2018-03-02 03:46:08 -06:00
|
|
|
type: String,
|
|
|
|
required: false
|
2018-02-13 02:15:12 -06:00
|
|
|
},
|
|
|
|
text: {
|
2018-03-02 03:46:08 -06:00
|
|
|
type: String,
|
|
|
|
required: true
|
2018-02-13 02:15:12 -06:00
|
|
|
},
|
|
|
|
buttons: {
|
2018-03-02 03:46:08 -06:00
|
|
|
type: Array,
|
|
|
|
default: () => {
|
|
|
|
return [{
|
|
|
|
text: 'OK'
|
|
|
|
}];
|
|
|
|
}
|
2018-02-13 02:15:12 -06:00
|
|
|
},
|
2018-02-17 21:35:18 -06:00
|
|
|
modal: {
|
2018-02-13 02:15:12 -06:00
|
|
|
type: Boolean,
|
2018-02-17 21:35:18 -06:00
|
|
|
default: false
|
2018-02-13 02:15:12 -06:00
|
|
|
}
|
2018-03-02 03:46:08 -06:00
|
|
|
},
|
2018-02-13 02:15:12 -06:00
|
|
|
mounted() {
|
2018-02-17 21:37:18 -06:00
|
|
|
this.$nextTick(() => {
|
|
|
|
(this.$refs.bg as any).style.pointerEvents = 'auto';
|
|
|
|
anime({
|
|
|
|
targets: this.$refs.bg,
|
|
|
|
opacity: 1,
|
|
|
|
duration: 100,
|
|
|
|
easing: 'linear'
|
|
|
|
});
|
2018-02-13 02:15:12 -06:00
|
|
|
|
2018-02-17 21:37:18 -06:00
|
|
|
anime({
|
|
|
|
targets: this.$refs.main,
|
|
|
|
opacity: 1,
|
|
|
|
scale: [1.2, 1],
|
|
|
|
duration: 300,
|
|
|
|
easing: [0, 0.5, 0.5, 1]
|
|
|
|
});
|
2018-02-13 02:15:12 -06:00
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click(button) {
|
2018-02-17 21:35:18 -06:00
|
|
|
this.$emit('clicked', button.id);
|
2018-02-13 02:15:12 -06:00
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
close() {
|
|
|
|
(this.$refs.bg as any).style.pointerEvents = 'none';
|
|
|
|
anime({
|
|
|
|
targets: this.$refs.bg,
|
|
|
|
opacity: 0,
|
|
|
|
duration: 300,
|
|
|
|
easing: 'linear'
|
|
|
|
});
|
|
|
|
|
|
|
|
(this.$refs.main as any).style.pointerEvents = 'none';
|
|
|
|
anime({
|
|
|
|
targets: this.$refs.main,
|
|
|
|
opacity: 0,
|
|
|
|
scale: 0.8,
|
|
|
|
duration: 300,
|
|
|
|
easing: [ 0.5, -0.5, 1, 0.5 ],
|
2018-09-15 07:53:04 -05:00
|
|
|
complete: () => this.destroyDom()
|
2018-02-13 02:15:12 -06:00
|
|
|
});
|
|
|
|
},
|
|
|
|
onBgClick() {
|
2018-02-17 21:35:18 -06:00
|
|
|
if (!this.modal) {
|
2018-02-13 02:15:12 -06:00
|
|
|
this.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-03-02 22:47:55 -06:00
|
|
|
@import '~const.styl'
|
|
|
|
|
2018-02-13 02:15:12 -06:00
|
|
|
.mk-dialog
|
|
|
|
> .bg
|
|
|
|
display block
|
|
|
|
position fixed
|
|
|
|
z-index 8192
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
width 100%
|
|
|
|
height 100%
|
2018-04-28 18:51:17 -05:00
|
|
|
background rgba(#000, 0.7)
|
2018-02-13 02:15:12 -06:00
|
|
|
opacity 0
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
> .main
|
|
|
|
display block
|
|
|
|
position fixed
|
|
|
|
z-index 8192
|
|
|
|
top 20%
|
|
|
|
left 0
|
|
|
|
right 0
|
|
|
|
margin 0 auto 0 auto
|
|
|
|
padding 32px 42px
|
|
|
|
width 480px
|
|
|
|
background #fff
|
|
|
|
opacity 0
|
|
|
|
|
|
|
|
> .body
|
|
|
|
margin 1em 0
|
|
|
|
color #888
|
|
|
|
|
|
|
|
> .buttons
|
|
|
|
> button
|
|
|
|
display inline-block
|
|
|
|
float right
|
|
|
|
margin 0
|
|
|
|
padding 10px 10px
|
|
|
|
font-size 1.1em
|
|
|
|
font-weight normal
|
|
|
|
text-decoration none
|
|
|
|
color #888
|
|
|
|
background transparent
|
|
|
|
outline none
|
|
|
|
border none
|
|
|
|
border-radius 0
|
|
|
|
cursor pointer
|
|
|
|
transition color 0.1s ease
|
|
|
|
|
|
|
|
i
|
|
|
|
margin 0 0.375em
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
color $theme-color
|
|
|
|
|
|
|
|
&:active
|
|
|
|
color darken($theme-color, 10%)
|
|
|
|
transition color 0s ease
|
|
|
|
|
|
|
|
</style>
|
2018-02-22 10:27:02 -06:00
|
|
|
|
|
|
|
<style lang="stylus" module>
|
2018-03-02 22:47:55 -06:00
|
|
|
@import '~const.styl'
|
|
|
|
|
2018-02-22 10:27:02 -06:00
|
|
|
.header
|
|
|
|
margin 1em 0
|
|
|
|
color $theme-color
|
|
|
|
// color #43A4EC
|
|
|
|
font-weight bold
|
|
|
|
|
|
|
|
&:empty
|
|
|
|
display none
|
|
|
|
|
|
|
|
> i
|
|
|
|
margin-right 0.5em
|
|
|
|
|
|
|
|
</style>
|