Skip to content

Commit 5c3e989

Browse files
committed
add confirm.vue and fix some base write
1 parent cce4b96 commit 5c3e989

File tree

8 files changed

+301
-97
lines changed

8 files changed

+301
-97
lines changed

build/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function genConfig(opts) {
6666
dest: opts.dest,
6767
format: opts.format,
6868
banner,
69-
moduleName: 'vuejsModal',
69+
moduleName: 'VuejsModal',
7070
plugins: [
7171
flow(),
7272
node(),

dist/vuejs-modal.common.js

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vuejs-modal v0.0.1
2+
* vuejs-modal v0.0.2
33
* (c) 2017 shaodahong
44
* @license MIT
55
*/
@@ -20,6 +20,11 @@ var Modal = {
2020
id: 'modal',
2121
modals: null,
2222
style: {
23+
position: 'fixed',
24+
top: 0,
25+
left: 0,
26+
right: 0,
27+
bottom: 0,
2328
zIndex: 1000
2429
}
2530
}, options);
@@ -28,7 +33,7 @@ var Modal = {
2833
this.zIndex = defaultOptions.style.zIndex;
2934

3035
// if no modals
31-
if (!defaultOptions.modals) {
36+
if (this.isEmpty(defaultOptions.modals)) {
3237
throw new Error('vuejs-modal plugin have a modals params');
3338
}
3439

@@ -49,27 +54,32 @@ var Modal = {
4954
*/
5055
modals[v] = function (options) {
5156
return new Promise(function (resolve, reject) {
52-
new Vue({
53-
render: function render(h) {
54-
return h(defaultOptions.modals[v], {
55-
props: options,
56-
style: Object.assign(defaultOptions.style, {
57-
zIndex: this$1.zIndex
58-
}),
59-
on: {
60-
$ok: function $ok(info) {
61-
resolve(info);
62-
},
63-
$close: function $close(info) {
64-
reject(info);
57+
try {
58+
new Vue({
59+
render: function render(h) {
60+
return h(defaultOptions.modals[v], {
61+
props: options,
62+
style: Object.assign(defaultOptions.style, {
63+
zIndex: this$1.zIndex
64+
}),
65+
on: {
66+
$ok: function $ok($el, info) {
67+
$el.remove();
68+
resolve(info);
69+
},
70+
$cancel: function $cancel($el, info) {
71+
$el.remove();
72+
reject(info);
73+
}
6574
}
66-
}
67-
});
68-
}
69-
}).$mount('#' + defaultOptions.id);
70-
71-
this$1.zIndex += 5;
72-
this$1.init(defaultOptions.id);
75+
});
76+
}
77+
}).$mount('#' + defaultOptions.id);
78+
this$1.zIndex += 5;
79+
this$1.init(defaultOptions.id);
80+
} catch (error) {
81+
console.error('vuejs-modal', error);
82+
}
7383
});
7484
};
7585
});
@@ -84,7 +94,16 @@ var Modal = {
8494
div.setAttribute('id', name || 'modal');
8595
document.getElementsByTagName('body')[0].appendChild(div);
8696
},
87-
zIndex: 1000
97+
zIndex: 1000,
98+
isEmpty: function isEmpty(object) {
99+
if (object === null || object === undefined) {
100+
return true;
101+
}
102+
for (var i in object) {
103+
return false;
104+
}
105+
return true;
106+
}
88107

89108
// if vue in window
90109
};if (typeof window !== 'undefined' && window.Vue) {

dist/vuejs-modal.esm.js

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vuejs-modal v0.0.1
2+
* vuejs-modal v0.0.2
33
* (c) 2017 shaodahong
44
* @license MIT
55
*/
@@ -18,6 +18,11 @@ var Modal = {
1818
id: 'modal',
1919
modals: null,
2020
style: {
21+
position: 'fixed',
22+
top: 0,
23+
left: 0,
24+
right: 0,
25+
bottom: 0,
2126
zIndex: 1000
2227
}
2328
}, options);
@@ -26,7 +31,7 @@ var Modal = {
2631
this.zIndex = defaultOptions.style.zIndex;
2732

2833
// if no modals
29-
if (!defaultOptions.modals) {
34+
if (this.isEmpty(defaultOptions.modals)) {
3035
throw new Error('vuejs-modal plugin have a modals params');
3136
}
3237

@@ -47,27 +52,32 @@ var Modal = {
4752
*/
4853
modals[v] = function (options) {
4954
return new Promise(function (resolve, reject) {
50-
new Vue({
51-
render: function render(h) {
52-
return h(defaultOptions.modals[v], {
53-
props: options,
54-
style: Object.assign(defaultOptions.style, {
55-
zIndex: this$1.zIndex
56-
}),
57-
on: {
58-
$ok: function $ok(info) {
59-
resolve(info);
60-
},
61-
$close: function $close(info) {
62-
reject(info);
55+
try {
56+
new Vue({
57+
render: function render(h) {
58+
return h(defaultOptions.modals[v], {
59+
props: options,
60+
style: Object.assign(defaultOptions.style, {
61+
zIndex: this$1.zIndex
62+
}),
63+
on: {
64+
$ok: function $ok($el, info) {
65+
$el.remove();
66+
resolve(info);
67+
},
68+
$cancel: function $cancel($el, info) {
69+
$el.remove();
70+
reject(info);
71+
}
6372
}
64-
}
65-
});
66-
}
67-
}).$mount('#' + defaultOptions.id);
68-
69-
this$1.zIndex += 5;
70-
this$1.init(defaultOptions.id);
73+
});
74+
}
75+
}).$mount('#' + defaultOptions.id);
76+
this$1.zIndex += 5;
77+
this$1.init(defaultOptions.id);
78+
} catch (error) {
79+
console.error('vuejs-modal', error);
80+
}
7181
});
7282
};
7383
});
@@ -82,7 +92,16 @@ var Modal = {
8292
div.setAttribute('id', name || 'modal');
8393
document.getElementsByTagName('body')[0].appendChild(div);
8494
},
85-
zIndex: 1000
95+
zIndex: 1000,
96+
isEmpty: function isEmpty(object) {
97+
if (object === null || object === undefined) {
98+
return true;
99+
}
100+
for (var i in object) {
101+
return false;
102+
}
103+
return true;
104+
}
86105

87106
// if vue in window
88107
};if (typeof window !== 'undefined' && window.Vue) {

dist/vuejs-modal.js

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* vuejs-modal v0.0.1
2+
* vuejs-modal v0.0.2
33
* (c) 2017 shaodahong
44
* @license MIT
55
*/
66
(function (global, factory) {
77
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
88
typeof define === 'function' && define.amd ? define(factory) :
9-
(global.vuejsModal = factory());
9+
(global.VuejsModal = factory());
1010
}(this, (function () { 'use strict';
1111

1212
var Modal = {
@@ -24,6 +24,11 @@ var Modal = {
2424
id: 'modal',
2525
modals: null,
2626
style: {
27+
position: 'fixed',
28+
top: 0,
29+
left: 0,
30+
right: 0,
31+
bottom: 0,
2732
zIndex: 1000
2833
}
2934
}, options);
@@ -32,7 +37,7 @@ var Modal = {
3237
this.zIndex = defaultOptions.style.zIndex;
3338

3439
// if no modals
35-
if (!defaultOptions.modals) {
40+
if (this.isEmpty(defaultOptions.modals)) {
3641
throw new Error('vuejs-modal plugin have a modals params');
3742
}
3843

@@ -53,27 +58,32 @@ var Modal = {
5358
*/
5459
modals[v] = function (options) {
5560
return new Promise(function (resolve, reject) {
56-
new Vue({
57-
render: function render(h) {
58-
return h(defaultOptions.modals[v], {
59-
props: options,
60-
style: Object.assign(defaultOptions.style, {
61-
zIndex: this$1.zIndex
62-
}),
63-
on: {
64-
$ok: function $ok(info) {
65-
resolve(info);
66-
},
67-
$close: function $close(info) {
68-
reject(info);
61+
try {
62+
new Vue({
63+
render: function render(h) {
64+
return h(defaultOptions.modals[v], {
65+
props: options,
66+
style: Object.assign(defaultOptions.style, {
67+
zIndex: this$1.zIndex
68+
}),
69+
on: {
70+
$ok: function $ok($el, info) {
71+
$el.remove();
72+
resolve(info);
73+
},
74+
$cancel: function $cancel($el, info) {
75+
$el.remove();
76+
reject(info);
77+
}
6978
}
70-
}
71-
});
72-
}
73-
}).$mount('#' + defaultOptions.id);
74-
75-
this$1.zIndex += 5;
76-
this$1.init(defaultOptions.id);
79+
});
80+
}
81+
}).$mount('#' + defaultOptions.id);
82+
this$1.zIndex += 5;
83+
this$1.init(defaultOptions.id);
84+
} catch (error) {
85+
console.error('vuejs-modal', error);
86+
}
7787
});
7888
};
7989
});
@@ -88,7 +98,16 @@ var Modal = {
8898
div.setAttribute('id', name || 'modal');
8999
document.getElementsByTagName('body')[0].appendChild(div);
90100
},
91-
zIndex: 1000
101+
zIndex: 1000,
102+
isEmpty: function isEmpty(object) {
103+
if (object === null || object === undefined) {
104+
return true;
105+
}
106+
for (var i in object) {
107+
return false;
108+
}
109+
return true;
110+
}
92111

93112
// if vue in window
94113
};if (typeof window !== 'undefined' && window.Vue) {

dist/vuejs-modal.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)