From cdc14756aea3ab5d95819f1c3795f3b06bc0a165 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Mon, 29 Jan 2018 12:32:46 +0800 Subject: [PATCH] Notification: add closeAll --- examples/docs/en-US/message.md | 3 +-- examples/docs/en-US/notification.md | 2 +- examples/docs/es/message.md | 3 +-- examples/docs/es/notification.md | 2 +- examples/docs/zh-CN/message.md | 3 +-- examples/docs/zh-CN/notification.md | 2 +- packages/notification/src/main.js | 6 ++++++ 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/docs/en-US/message.md b/examples/docs/en-US/message.md index 5fb0acaa4..aee106f95 100644 --- a/examples/docs/en-US/message.md +++ b/examples/docs/en-US/message.md @@ -279,8 +279,7 @@ Import `Message`: import { Message } from 'element-ui'; ``` -In this case you should call `Message(options)`. We have also registered methods for different types, e.g. `Message.success(options)`. -You can call `Message.closeAll()` to manually close all the instances. +In this case you should call `Message(options)`. We have also registered methods for different types, e.g. `Message.success(options)`. You can call `Message.closeAll()` to manually close all the instances. ### Options | Attribute | Description | Type | Accepted Values | Default | diff --git a/examples/docs/en-US/notification.md b/examples/docs/en-US/notification.md index 2553bc9a3..dc8116197 100644 --- a/examples/docs/en-US/notification.md +++ b/examples/docs/en-US/notification.md @@ -397,7 +397,7 @@ Import `Notification`: import { Notification } from 'element-ui'; ``` -In this case you should call `Notification(options)`. We have also registered methods for different types, e.g. `Notification.success(options)`. +In this case you should call `Notification(options)`. We have also registered methods for different types, e.g. `Notification.success(options)`. You can call `Notification.closeAll()` to manually close all the instances. ### Options | Attribute | Description | Type | Accepted Values | Default | diff --git a/examples/docs/es/message.md b/examples/docs/es/message.md index cc389c160..20fbd9d9e 100644 --- a/examples/docs/es/message.md +++ b/examples/docs/es/message.md @@ -279,8 +279,7 @@ Import `Message`: import { Message } from 'element-ui'; ``` -En este caso deberia llamar al metodo `Message(options)`. Tambien se han registrado metodos para los diferentes tipos, e.g. `Message.success(options)`. -Puede llamar al metodo `Message.closeAll()` para cerrar manualmente todas las instancias. +En este caso deberia llamar al metodo `Message(options)`. Tambien se han registrado metodos para los diferentes tipos, e.g. `Message.success(options)`. Puede llamar al metodo `Message.closeAll()` para cerrar manualmente todas las instancias. ### Options | Atributo | Descripcion | Tipo | Valores permitidos | Por defecto | diff --git a/examples/docs/es/notification.md b/examples/docs/es/notification.md index 660fa334d..3efe1b47c 100644 --- a/examples/docs/es/notification.md +++ b/examples/docs/es/notification.md @@ -404,7 +404,7 @@ Importar `Notification`: import { Notification } from 'element-ui'; ``` -En este caso, debe llamar a `Notification(options)`. También se han registrado métodos para diferentes tipos, e.j. `Notification.success(options)`. +En este caso, debe llamar a `Notification(options)`. También se han registrado métodos para diferentes tipos, e.j. `Notification.success(options)`. Puede llamar al metodo `Notification.closeAll()` para cerrar manualmente todas las instancias. ### Opciones | Atributo | Descripción | Tipo | Valores aceptados | Por defecto | diff --git a/examples/docs/zh-CN/message.md b/examples/docs/zh-CN/message.md index ece43ea29..d2225814c 100644 --- a/examples/docs/zh-CN/message.md +++ b/examples/docs/zh-CN/message.md @@ -279,8 +279,7 @@ Element 为 Vue.prototype 添加了全局方法 $message。因此在 vue instanc import { Message } from 'element-ui'; ``` -此时调用方法为 `Message(options)`。我们也为每个 type 定义了各自的方法,如 `Message.success(options)`。 -并且可以调用 `Message.closeAll()` 手动关闭所有实例。 +此时调用方法为 `Message(options)`。我们也为每个 type 定义了各自的方法,如 `Message.success(options)`。并且可以调用 `Message.closeAll()` 手动关闭所有实例。 ### Options | 参数 | 说明 | 类型 | 可选值 | 默认值 | diff --git a/examples/docs/zh-CN/notification.md b/examples/docs/zh-CN/notification.md index e063db525..9876f785a 100644 --- a/examples/docs/zh-CN/notification.md +++ b/examples/docs/zh-CN/notification.md @@ -398,7 +398,7 @@ Element 为 `Vue.prototype` 添加了全局方法 `$notify`。因此在 vue inst import { Notification } from 'element-ui'; ``` -此时调用方法为 `Notification(options)`。我们也为每个 type 定义了各自的方法,如 `Notification.success(options)`。 +此时调用方法为 `Notification(options)`。我们也为每个 type 定义了各自的方法,如 `Notification.success(options)`。并且可以调用 `Notification.closeAll()` 手动关闭所有实例。 ### Options | 参数 | 说明 | 类型 | 可选值 | 默认值 | diff --git a/packages/notification/src/main.js b/packages/notification/src/main.js index 995bd41e3..3e9a23ec4 100644 --- a/packages/notification/src/main.js +++ b/packages/notification/src/main.js @@ -84,4 +84,10 @@ Notification.close = function(id, userOnClose) { } }; +Notification.closeAll = function() { + for (let i = instances.length - 1; i >= 0; i--) { + instances[i].close(); + } +}; + export default Notification;