avalynx-modal 1.0.0 → 1.0.1

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
@@ -42,8 +42,8 @@ Replace `path/to/avalynx-modal.js` and `path/to/avalynx-modal.css` with the actu
42
42
  AvalynxModal is also available via [jsDelivr](https://www.jsdelivr.com/). You can include it in your project like this:
43
43
 
44
44
  ```html
45
- <link href="https://cdn.jsdelivr.net/npm/avalynx-modal@1.0.0/dist/css/avalynx-modal.css" rel="stylesheet">
46
- <script src="https://cdn.jsdelivr.net/npm/avalynx-modal@1.0.0/dist/js/avalynx-modal.js"></script>
45
+ <link href="https://cdn.jsdelivr.net/npm/avalynx-modal@1.0.1/dist/css/avalynx-modal.css" rel="stylesheet">
46
+ <script src="https://cdn.jsdelivr.net/npm/avalynx-modal@1.0.1/dist/js/avalynx-modal.js"></script>
47
47
  ```
48
48
 
49
49
  Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxModal displays correctly.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * AvalynxModal is a simple modal system for web applications with fullscreen support. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 1.0.0
6
+ * @version 1.0.1
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-modal/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * AvalynxModal is a simple modal system for web applications with fullscreen support. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 1.0.0
6
+ * @version 1.0.1
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-modal/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -36,6 +36,9 @@ import * as bootstrap from 'bootstrap';
36
36
  export class AvalynxModal {
37
37
  constructor(id, options = {}, language = {}) {
38
38
  this.id = id;
39
+ if (options === null || typeof options !== 'object') {
40
+ options = {};
41
+ }
39
42
  this.options = {
40
43
  modalFullscreen: false,
41
44
  title: '',
@@ -55,6 +58,9 @@ export class AvalynxModal {
55
58
  onModalClosed: null,
56
59
  ...options
57
60
  };
61
+ if (language === null || typeof language !== 'object') {
62
+ language = {};
63
+ }
58
64
  this.language = {
59
65
  ...language
60
66
  };
@@ -134,7 +140,9 @@ export class AvalynxModal {
134
140
  async fetchData(url, isHtml) {
135
141
  if (this.options.loader === null) {
136
142
  const overlay = document.getElementById(`${this.id}-overlay`);
137
- overlay.style.display = 'flex';
143
+ if (overlay) {
144
+ overlay.style.display = 'flex';
145
+ }
138
146
  } else {
139
147
  this.options.loader.load = true;
140
148
  }
@@ -196,7 +204,7 @@ export class AvalynxModal {
196
204
 
197
205
  setTitle(content, isHtml = this.options.titleIsHtml) {
198
206
  const modalTitleElement = this.modal.querySelector('.modal-title');
199
- if (this.options.titleIsHtml) {
207
+ if (isHtml) {
200
208
  modalTitleElement.innerHTML = content;
201
209
  } else {
202
210
  modalTitleElement.innerText = content;
@@ -205,7 +213,7 @@ export class AvalynxModal {
205
213
 
206
214
  setBody(content, isHtml = this.options.bodyIsHtml) {
207
215
  const modalBodyElement = this.modal.querySelector('.modal-body');
208
- if (this.options.bodyIsHtml) {
216
+ if (isHtml) {
209
217
  modalBodyElement.innerHTML = content;
210
218
  } else {
211
219
  modalBodyElement.innerText = content;
@@ -265,3 +273,7 @@ export class AvalynxModal {
265
273
  }
266
274
  }
267
275
  }
276
+
277
+ if (typeof module !== 'undefined' && module.exports) {
278
+ module.exports = AvalynxModal
279
+ }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * AvalynxModal is a simple modal system for web applications with fullscreen support. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 1.0.0
6
+ * @version 1.0.1
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-modal/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -34,6 +34,9 @@
34
34
  class AvalynxModal {
35
35
  constructor(id, options = {}, language = {}) {
36
36
  this.id = id;
37
+ if (options === null || typeof options !== 'object') {
38
+ options = {};
39
+ }
37
40
  this.options = {
38
41
  modalFullscreen: false,
39
42
  title: '',
@@ -53,6 +56,9 @@ class AvalynxModal {
53
56
  onModalClosed: null,
54
57
  ...options
55
58
  };
59
+ if (language === null || typeof language !== 'object') {
60
+ language = {};
61
+ }
56
62
  this.language = {
57
63
  ...language
58
64
  };
@@ -132,7 +138,9 @@ class AvalynxModal {
132
138
  async fetchData(url, isHtml) {
133
139
  if (this.options.loader === null) {
134
140
  const overlay = document.getElementById(`${this.id}-overlay`);
135
- overlay.style.display = 'flex';
141
+ if (overlay) {
142
+ overlay.style.display = 'flex';
143
+ }
136
144
  } else {
137
145
  this.options.loader.load = true;
138
146
  }
@@ -194,7 +202,7 @@ class AvalynxModal {
194
202
 
195
203
  setTitle(content, isHtml = this.options.titleIsHtml) {
196
204
  const modalTitleElement = this.modal.querySelector('.modal-title');
197
- if (this.options.titleIsHtml) {
205
+ if (isHtml) {
198
206
  modalTitleElement.innerHTML = content;
199
207
  } else {
200
208
  modalTitleElement.innerText = content;
@@ -203,7 +211,7 @@ class AvalynxModal {
203
211
 
204
212
  setBody(content, isHtml = this.options.bodyIsHtml) {
205
213
  const modalBodyElement = this.modal.querySelector('.modal-body');
206
- if (this.options.bodyIsHtml) {
214
+ if (isHtml) {
207
215
  modalBodyElement.innerHTML = content;
208
216
  } else {
209
217
  modalBodyElement.innerText = content;
@@ -263,3 +271,7 @@ class AvalynxModal {
263
271
  }
264
272
  }
265
273
  }
274
+
275
+ if (typeof module !== 'undefined' && module.exports) {
276
+ module.exports = AvalynxModal
277
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "avalynx-modal",
3
3
  "title": "AvalynxModal",
4
4
  "description": "AvalynxModal is a simple modal system for web applications with fullscreen support. Based on Bootstrap >=5.3 without any framework dependencies.",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "license": "MIT",
7
7
  "main": "dist/js/avalynx-modal.js",
8
8
  "module": "dist/js/avalynx-modal.esm.js",