Skip to content

Commit e2b17d4

Browse files
committed
v-confirm accepts any option available with optional argument.
1 parent 40eec67 commit e2b17d4

File tree

8 files changed

+39
-15
lines changed

8 files changed

+39
-15
lines changed

dist/vuejs-dialog.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuejs-dialog.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
<meta charset="UTF-8">
55
<title>VueJs Plugin usage example</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<link href="css/app.main.css?f66896d58ecf078c390f" rel="stylesheet"></head>
7+
<link href="css/app.main.css?de9020f60bd560de3b6a" rel="stylesheet"></head>
88
<body>
99

1010
<div id="app"></div>
1111

12-
<a href="https://github.com/godofbrowser/vuejs-dialog" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
1312
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
1413
<script type="text/javascript" src="js/vuejs-dialog.min.js"></script>
1514
<script>
@@ -22,5 +21,5 @@
2221
ga('send', 'pageview');
2322

2423
</script>
25-
<script type="text/javascript" src="js/app.main.js?f66896d58ecf078c390f"></script></body>
24+
<script type="text/javascript" src="js/app.main.js?de9020f60bd560de3b6a"></script></body>
2625
</html>

docs/js/app.main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/vuejs-dialog.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/components/app.vue

+16
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,31 @@
8383
</section>
8484

8585
<notifications position="bottom left"></notifications>
86+
87+
<a href="https://github.com/godofbrowser/vuejs-dialog"
88+
v-confirm:soft="{html: true, message: exitMessage, cancelText: `Stay on Page`, okText: `Source Code`}">
89+
<img style="position: absolute; top: 0; right: 0; border: 0;"
90+
src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67"
91+
alt="Fork me on GitHub"
92+
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png">
93+
</a>
8694
</div>
8795
</template>
8896

8997
<script>
9098
import trans from '../js/translations'
9199
100+
const exitMessage = `
101+
<p style="text-align: center; margin: 0;">
102+
<span style="font-weight: bold; font-size: large; color: lime">Thank You!</span>
103+
<br/>
104+
I hope you find it useful
105+
</p>`
106+
92107
export default {
93108
data(){
94109
return {
110+
exitMessage,
95111
forms: {
96112
demo1: {
97113
name: null

src/docs/index.html

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
<div id="app"></div>
1111

12-
<a href="https://github.com/godofbrowser/vuejs-dialog" target="_blank">
13-
<img style="position: absolute; top: 0; right: 0; border: 0;"
14-
src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67"
15-
alt="Fork me on GitHub"
16-
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png">
17-
</a>
1812
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
1913
<script type="text/javascript" src="js/vuejs-dialog.min.js"></script>
2014
<script>

src/plugin/js/directives.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Directives
22

33
import {noop, clickNode} from './utilities'
4+
import {CONFIRM_TYPES} from './constants'
45

56

67
let Directives = function (Vue) {
@@ -26,6 +27,19 @@ Directives.prototype.defineConfirm = function () {
2627
return typeof binding.value === 'string' ? binding.value : null
2728
}
2829

30+
const getOptions = function(binding) {
31+
let options = typeof binding.value === 'object' ? binding.value : {}
32+
33+
delete options['ok']
34+
delete options['cancel']
35+
36+
if(binding.arg && CONFIRM_TYPES.hasOwnProperty(binding.arg.toUpperCase())){
37+
options.type = CONFIRM_TYPES[binding.arg.toUpperCase()]
38+
}
39+
40+
return options
41+
}
42+
2943
const getCatchCallback = function(binding) {
3044
if (binding.value && binding.value.cancel) {
3145
return binding.value.cancel
@@ -52,12 +66,13 @@ Directives.prototype.defineConfirm = function () {
5266
event.preventDefault()
5367
event.stopImmediatePropagation()
5468

69+
let options = getOptions(binding)
5570
let confirmMessage = getConfirmMessage(binding)
5671
let thenCallback = getThenCallback(binding, el)
5772
let catchCallback = getCatchCallback(binding)
5873

5974
_this.Vue.dialog
60-
.confirm(confirmMessage)
75+
.confirm(confirmMessage, options)
6176
.then(thenCallback)
6277
.catch(catchCallback)
6378
}
@@ -83,7 +98,7 @@ Directives.prototype.defineConfirm = function () {
8398
}
8499

85100
Directives.prototype.defineAlert = function () {
86-
//
101+
// Still Considering it uses case.
87102
}
88103

89104
export default Directives

0 commit comments

Comments
 (0)