update the master branch to the latest
This commit is contained in:
parent
67d534df27
commit
23a0ba9831
611 changed files with 122648 additions and 0 deletions
33
src/components/spin/index.js
Normal file
33
src/components/spin/index.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import Spin from './spin.js';
|
||||
|
||||
let spinInstance;
|
||||
|
||||
function getSpinInstance (render = undefined) {
|
||||
spinInstance = spinInstance || Spin.newInstance({
|
||||
render: render
|
||||
});
|
||||
|
||||
return spinInstance;
|
||||
}
|
||||
|
||||
function loading (options) {
|
||||
const render = ('render' in options) ? options.render : undefined;
|
||||
let instance = getSpinInstance(render);
|
||||
|
||||
instance.show(options);
|
||||
}
|
||||
|
||||
Spin.show = function (props = {}) {
|
||||
return loading(props);
|
||||
};
|
||||
Spin.hide = function () {
|
||||
if (!spinInstance) return false;
|
||||
|
||||
const instance = getSpinInstance();
|
||||
|
||||
instance.remove(() => {
|
||||
spinInstance = null;
|
||||
});
|
||||
};
|
||||
|
||||
export default Spin;
|
70
src/components/spin/spin.js
Normal file
70
src/components/spin/spin.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
import Vue from 'vue';
|
||||
import Spin from './spin.vue';
|
||||
|
||||
import { transferIndex, transferIncrease } from '../../utils/transfer-queue';
|
||||
|
||||
function handleGetIndex() {
|
||||
transferIncrease();
|
||||
return transferIndex;
|
||||
}
|
||||
|
||||
let tIndex = handleGetIndex();
|
||||
|
||||
Spin.newInstance = properties => {
|
||||
const _props = properties || {};
|
||||
|
||||
const Instance = new Vue({
|
||||
data: Object.assign({}, _props, {
|
||||
|
||||
}),
|
||||
render (h) {
|
||||
let vnode = '';
|
||||
if (this.render) {
|
||||
vnode = h(Spin, {
|
||||
props: {
|
||||
fix: true,
|
||||
fullscreen: true
|
||||
}
|
||||
}, [this.render(h)]);
|
||||
} else {
|
||||
vnode = h(Spin, {
|
||||
props: {
|
||||
size: 'large',
|
||||
fix: true,
|
||||
fullscreen: true
|
||||
}
|
||||
});
|
||||
}
|
||||
return h('div', {
|
||||
'class': 'ivu-spin-fullscreen ivu-spin-fullscreen-wrapper',
|
||||
'style': {
|
||||
'z-index': 2010 + tIndex
|
||||
}
|
||||
}, [vnode]);
|
||||
}
|
||||
});
|
||||
|
||||
const component = Instance.$mount();
|
||||
document.body.appendChild(component.$el);
|
||||
const spin = Instance.$children[0];
|
||||
|
||||
return {
|
||||
show () {
|
||||
spin.visible = true;
|
||||
tIndex = handleGetIndex();
|
||||
},
|
||||
remove (cb) {
|
||||
spin.visible = false;
|
||||
setTimeout(function() {
|
||||
spin.$parent.$destroy();
|
||||
if (document.getElementsByClassName('ivu-spin-fullscreen')[0] !== undefined) {
|
||||
document.body.removeChild(document.getElementsByClassName('ivu-spin-fullscreen')[0]);
|
||||
}
|
||||
cb();
|
||||
}, 500);
|
||||
},
|
||||
component: spin
|
||||
};
|
||||
};
|
||||
|
||||
export default Spin;
|
87
src/components/spin/spin.vue
Normal file
87
src/components/spin/spin.vue
Normal file
|
@ -0,0 +1,87 @@
|
|||
<template>
|
||||
<transition name="fade">
|
||||
<div :class="classes" v-if="fullscreenVisible">
|
||||
<div :class="mainClasses">
|
||||
<span :class="dotClasses"></span>
|
||||
<div :class="textClasses"><slot></slot></div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
import ScrollbarMixins from '../modal/mixins-scrollbar';
|
||||
|
||||
const prefixCls = 'ivu-spin';
|
||||
|
||||
export default {
|
||||
name: 'Spin',
|
||||
mixins: [ ScrollbarMixins ],
|
||||
props: {
|
||||
size: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['small', 'large', 'default']);
|
||||
},
|
||||
default () {
|
||||
return !this.$IVIEW || this.$IVIEW.size === '' ? 'default' : this.$IVIEW.size;
|
||||
}
|
||||
},
|
||||
fix: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
fullscreen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
showText: false,
|
||||
// used for $Spin
|
||||
visible: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
{
|
||||
[`${prefixCls}-${this.size}`]: !!this.size,
|
||||
[`${prefixCls}-fix`]: this.fix,
|
||||
[`${prefixCls}-show-text`]: this.showText,
|
||||
[`${prefixCls}-fullscreen`]: this.fullscreen
|
||||
}
|
||||
];
|
||||
},
|
||||
mainClasses () {
|
||||
return `${prefixCls}-main`;
|
||||
},
|
||||
dotClasses () {
|
||||
return `${prefixCls}-dot`;
|
||||
},
|
||||
textClasses () {
|
||||
return `${prefixCls}-text`;
|
||||
},
|
||||
fullscreenVisible () {
|
||||
if (this.fullscreen) {
|
||||
return this.visible;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible (val) {
|
||||
if (val) {
|
||||
this.addScrollEffect();
|
||||
} else {
|
||||
this.removeScrollEffect();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.showText = this.$slots.default !== undefined;
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue