Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit f502740

Browse files
author
Steven Morrison
committed
SM: Upgraded src files added.
1 parent f85e93d commit f502740

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ <h3 class="category-name">{{ cat.name }}</h3>
4242
</ul>
4343

4444
<!-- Modal component -->
45-
<zaffri-modal v-if="modalVisible" v-bind:data="zaffriModal" v-on:hide_modal_emit="hideModal"></zaffri-modal>
45+
<zaffri-modal v-bind:data="modalConfig"></zaffri-modal>
4646
</section>
4747

48-
<!-- Modal markup -->
49-
<div id="zaffri-modal-template" class="zaffri-modal-template">
50-
<div class="zaffri-modal">
48+
<!-- Modal Component markup -->
49+
<template id="zaffri-modal-template" class="zaffri-modal-template">
50+
<div v-if="data.visible" class="zaffri-modal">
5151

5252
<div class="zaffri-modal-body">
5353
<header><h3>{{ data.title }}</h3></header>
@@ -59,18 +59,18 @@ <h3 class="category-name">{{ cat.name }}</h3>
5959
<div class="zaffri-modal-button-area">
6060

6161
<div v-if="data.type == 'confirm'">
62-
<button v-on:click="hideModal(true)">{{ data.confirmText }}</button>
63-
<button v-on:click="hideModal(false)">{{ data.cancelText }}</button>
62+
<button @click="closeModal(true)">{{ data.confirmText }}</button>
63+
<button @click="closeModal(false)">{{ data.cancelText }}</button>
6464
</div>
6565

6666
<div v-else>
67-
<button v-on:click="hideModal">{{ data.confirmText }}</button>
67+
<button @click="closeModal">{{ data.confirmText }}</button>
6868
</div>
6969
</div>
7070
</div>
7171

7272
</div>
73-
</div>
73+
</template>
7474

7575
<script src="js/vue.dev.js"></script>
7676
<script src="js/modal.js"></script>

js/modal.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* --------------------------------------------------------
22
VueJS - Modal Component
3-
Version: 0.0.1
3+
Version: 0.0.3
44
Author: Steven Morrison
55
Website: www.zaffri.com
66
GitHub: github.com/Zaffri
@@ -10,8 +10,16 @@ var ZaffriModal = Vue.component('zaffri-modal', {
1010
template: "#zaffri-modal-template",
1111
props: ['data'],
1212
methods: {
13-
hideModal: function(action = null) {
14-
this.$emit('hide_modal_emit', action);
13+
closeModal: function(action = null) {
14+
var callbackData = {};
15+
16+
if(this.data.callbackData != undefined) callbackData = this.data.callbackData;
17+
if(this.data.confirmCallback != undefined) this.confirmCallback(action, callbackData);
18+
19+
this.data.visible = false;
20+
},
21+
confirmCallback: function(action, callbackData) {
22+
this.data.confirmCallback(action, callbackData);
1523
}
1624
}
1725
});

0 commit comments

Comments
 (0)