directory adjust: delete entry index.js

This commit is contained in:
陈嘉涵
2017-08-22 17:52:16 +08:00
parent 707b48aa61
commit c494292e3f
88 changed files with 587 additions and 713 deletions

View File

@@ -14,8 +14,8 @@
</template>
<script>
import Button from '../../button';
import Popup from '../../mixins/popup';
import Button from '../button';
import Popup from '../mixins/popup';
export default {
name: 'van-dialog',

View File

@@ -1,3 +1,97 @@
import Dialog from './src/dialog.js';
import Vue from 'vue';
import Dialog from './dialog';
export default Dialog;
const DialogConstructor = Vue.extend(Dialog);
let currentDialog;
let instance;
let dialogQueue = [];
const defaultCallback = action => {
/* istanbul ignore else */
if (currentDialog) {
if (currentDialog.resolve && action === 'confirm') {
currentDialog.resolve(action);
} else if (currentDialog.reject && action === 'cancel') {
currentDialog.reject(action);
}
}
};
const initInstance = () => {
instance = new DialogConstructor({
el: document.createElement('div')
});
instance.$on('input', value => {
instance.value = value;
})
instance.callback = defaultCallback;
};
const showNextDialog = () => {
if (!instance) {
initInstance();
}
/* istanbul ignore else */
if (!instance.value && dialogQueue.length > 0) {
currentDialog = dialogQueue.shift();
const { options } = currentDialog;
for (const prop in options) {
/* istanbul ignore else */
if (options.hasOwnProperty(prop)) {
instance[prop] = options[prop];
}
}
instance.callback = options.callback || defaultCallback;
instance.value = true;
document.body.appendChild(instance.$el);
}
};
const DialogBox = options => {
return new Promise((resolve, reject) => { // eslint-disable-line
dialogQueue.push({
options: { ...options },
callback: options.callback,
resolve: resolve,
reject: reject
});
showNextDialog();
});
};
DialogBox.alert = function(options) {
return DialogBox({
type: 'alert',
title: '',
message: '',
closeOnClickOverlay: false,
showCancelButton: false,
...options
});
};
DialogBox.confirm = function(options) {
return DialogBox({
type: 'confirm',
title: '',
message: '',
closeOnClickOverlay: true,
showCancelButton: true,
...options
});
};
DialogBox.close = function() {
instance.value = false;
dialogQueue = [];
currentDialog = null;
};
export default DialogBox;

View File

@@ -1,97 +0,0 @@
import Vue from 'vue';
import Dialog from './dialog.vue';
const DialogConstructor = Vue.extend(Dialog);
let currentDialog;
let instance;
let dialogQueue = [];
const defaultCallback = action => {
/* istanbul ignore else */
if (currentDialog) {
if (currentDialog.resolve && action === 'confirm') {
currentDialog.resolve(action);
} else if (currentDialog.reject && action === 'cancel') {
currentDialog.reject(action);
}
}
};
const initInstance = () => {
instance = new DialogConstructor({
el: document.createElement('div')
});
instance.$on('input', value => {
instance.value = value;
})
instance.callback = defaultCallback;
};
const showNextDialog = () => {
if (!instance) {
initInstance();
}
/* istanbul ignore else */
if (!instance.value && dialogQueue.length > 0) {
currentDialog = dialogQueue.shift();
const { options } = currentDialog;
for (const prop in options) {
/* istanbul ignore else */
if (options.hasOwnProperty(prop)) {
instance[prop] = options[prop];
}
}
instance.callback = options.callback || defaultCallback;
instance.value = true;
document.body.appendChild(instance.$el);
}
};
var DialogBox = options => {
return new Promise((resolve, reject) => { // eslint-disable-line
dialogQueue.push({
options: { ...options },
callback: options.callback,
resolve: resolve,
reject: reject
});
showNextDialog();
});
};
DialogBox.alert = function(options) {
return DialogBox({
type: 'alert',
title: '',
message: '',
closeOnClickOverlay: false,
showCancelButton: false,
...options
});
};
DialogBox.confirm = function(options) {
return DialogBox({
type: 'confirm',
title: '',
message: '',
closeOnClickOverlay: true,
showCancelButton: true,
...options
});
};
DialogBox.close = function() {
instance.value = false;
dialogQueue = [];
currentDialog = null;
};
export default DialogBox;