avalynx-alert 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,6 +17,7 @@ Here's a simple example of how to use AvalynxAlert in your project:
17
17
 
18
18
  * [Overview](https://avalynx-alert.jbs-newmedia.de/examples/index.html)
19
19
  * [Random Alerts](https://avalynx-alert.jbs-newmedia.de/examples/random-alerts.html)
20
+ * [Callback on close](https://avalynx-alert.jbs-newmedia.de/examples/callback-onclose.html)
20
21
 
21
22
  ## Installation
22
23
 
@@ -48,6 +49,8 @@ AvalynxAlert is also available via [jsDelivr](https://www.jsdelivr.com/). You ca
48
49
  <script src="https://cdn.jsdelivr.net/npm/avalynx-alert/dist/avalynx-alert.js"></script>
49
50
  ```
50
51
 
52
+ Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxAlert displays correctly.
53
+
51
54
  ## Installation via NPM
52
55
 
53
56
  AvalynxAlert is also available as a npm package. You can add it to your project with the following command:
@@ -63,7 +66,7 @@ import { AvalynxAlert } from 'avalynx-alert';
63
66
  import 'avalynx-alert/dist/css/avalynx-alert.min.css';
64
67
  ```
65
68
 
66
- Make sure to also include Bootstrap's CSS in your project to ensure AvalynxAlert displays correctly.
69
+ Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxAlert displays correctly.
67
70
 
68
71
  ## Installation via Symfony AssetMapper
69
72
 
@@ -78,7 +81,7 @@ import { AvalynxAlert } from 'avalynx-alert';
78
81
  import 'avalynx-alert/dist/css/avalynx-alert.min.css';
79
82
  ```
80
83
 
81
- Make sure to also include Bootstrap's CSS in your project to ensure AvalynxAlert displays correctly.
84
+ Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxAlert displays correctly.
82
85
 
83
86
  ## Usage
84
87
 
@@ -106,6 +109,7 @@ AvalynxAlert allows the following options for customization:
106
109
  - `closeable`: Whether the alert can be closed by the user (default: true).
107
110
  - `autoClose`: Whether the alert will close automatically after the duration (default: true).
108
111
  - `width`: The width of the alert (default: `400px`).
112
+ - `onClose`: A callback function to be called when the alert is closed.
109
113
 
110
114
  ## Contributing
111
115
 
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.4
6
+ * @version 0.0.5
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.4
6
+ * @version 0.0.5
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -29,6 +29,8 @@ export class AvalynxAlert {
29
29
  this.closeable = options.closeable || true;
30
30
  this.autoClose = options.autoClose || true;
31
31
  this.width = options.width || '400px';
32
+ this.onClose = options.onClose || null;
33
+
32
34
  if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
33
35
  this.type = 'info';
34
36
  }
@@ -123,7 +125,12 @@ export class AvalynxAlert {
123
125
 
124
126
  setTimeout(() => {
125
127
  alert.classList.remove('show');
126
- setTimeout(() => alert.remove(), 150);
128
+ setTimeout(() => {
129
+ alert.remove();
130
+ if (typeof this.onClose === 'function') {
131
+ this.onClose();
132
+ }
133
+ }, 150);
127
134
  }, this.duration);
128
135
  }
129
136
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.4
6
+ * @version 0.0.5
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -18,6 +18,7 @@
18
18
  * @param {boolean} options.closeable - Whether the alert can be closed by the user. Default is true.
19
19
  * @param {boolean} options.autoClose - Whether the alert will close automatically after the duration. Default is true.
20
20
  * @param {string} options.width - The width of the alert. Default is '400px'.
21
+ * @param {function} options.onClose - A callback function to be called when the alert is closed.
21
22
  */
22
23
 
23
24
  class AvalynxAlert {
@@ -29,6 +30,8 @@ class AvalynxAlert {
29
30
  this.closeable = options.closeable || true;
30
31
  this.autoClose = options.autoClose || true;
31
32
  this.width = options.width || '400px';
33
+ this.onClose = options.onClose || null;
34
+
32
35
  if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
33
36
  this.type = 'info';
34
37
  }
@@ -123,7 +126,12 @@ class AvalynxAlert {
123
126
 
124
127
  setTimeout(() => {
125
128
  alert.classList.remove('show');
126
- setTimeout(() => alert.remove(), 150);
129
+ setTimeout(() => {
130
+ alert.remove();
131
+ if (typeof this.onClose === 'function') {
132
+ this.onClose();
133
+ }
134
+ }, 150);
127
135
  }, this.duration);
128
136
  }
129
137
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "avalynx-alert",
3
3
  "title": "AvalynxAlert",
4
4
  "description": "AvalynxAlert is a simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.",
5
- "version": "0.0.4",
5
+ "version": "0.0.5",
6
6
  "license": "MIT",
7
7
  "main": "dist/js/avalynx-alert.js",
8
8
  "module": "dist/js/avalynx-alert.esm.js",