Эх сурвалжийг харах

Notification: add closeAll

Leopoldthecoder 7 жил өмнө
parent
commit
cdc14756ae

+ 1 - 2
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  |

+ 1 - 1
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  |

+ 1 - 2
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 |

+ 1 - 1
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 |

+ 1 - 2
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
 | 参数      | 说明          | 类型      | 可选值                           | 默认值  |

+ 1 - 1
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
 | 参数      | 说明          | 类型      | 可选值                           | 默认值  |

+ 6 - 0
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;