From 5fcd73cd85d4c519af26fb25aadcb00bc6d830d4 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Tue, 15 Nov 2016 20:29:33 +0800 Subject: [PATCH] Loading: add loading service --- build/bin/build-entry.js | 7 +- examples/docs/en-US/loading.md | 29 ++- examples/docs/zh-CN/loading.md | 28 ++- examples/docs/zh-CN/message.md | 2 +- packages/loading/index.js | 8 +- packages/loading/src/directive.js | 26 +-- packages/loading/src/index.js | 86 +++++++ packages/loading/src/loading.vue | 22 ++ packages/loading/src/spinner.vue | 21 -- packages/theme-default/src/loading.css | 20 +- src/index.js | 6 +- test/unit/specs/loading.spec.js | 300 +++++++++++++++---------- 12 files changed, 375 insertions(+), 180 deletions(-) create mode 100644 packages/loading/src/index.js create mode 100644 packages/loading/src/loading.vue delete mode 100644 packages/loading/src/spinner.vue diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index ee77c0785..173b2f95a 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -19,8 +19,9 @@ const install = function(Vue, opts = {}) { {{install}} - Vue.use(Loading); + Vue.use(Loading.directive); + Vue.prototype.$loading = Loading.service; Vue.prototype.$msgbox = MessageBox; Vue.prototype.$alert = MessageBox.alert; Vue.prototype.$confirm = MessageBox.confirm; @@ -38,6 +39,8 @@ module.exports = { version: '{{version}}', locale: locale.use, install, + Loading: Loading.directive, + LoadingService: Loading.service, {{list}} }; `; @@ -65,7 +68,7 @@ ComponentNames.forEach(name => { })); } - listTemplate.push(` ${componentName}`); + if (componentName !== 'Loading') listTemplate.push(` ${componentName}`); }); var template = render(MAIN_TEMPLATE, { diff --git a/examples/docs/en-US/loading.md b/examples/docs/en-US/loading.md index 1b1dc13b4..0a3b819eb 100644 --- a/examples/docs/en-US/loading.md +++ b/examples/docs/en-US/loading.md @@ -40,7 +40,7 @@ Show animation while loading data. Displays animation in a container (such as a table) while loading data. -:::demo We provide a custom directive `v-loading`. You just need to bind a `boolean` value to it. By default, the loading mask will append to the element where the directive is used. Adding the `body` modifier makes the mask append to the body element. +:::demo Element provides two ways to invoke Loading: directive and service. For the custom directive `v-loading`, you just need to bind a `boolean` value to it. By default, the loading mask will append to the element where the directive is used. Adding the `body` modifier makes the mask append to the body element. ```html