frayerjj-frontend 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +41 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frayerjj-frontend",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "My base frontend for various projects",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -1,50 +1,51 @@
1
1
  import * as bootstrap from 'bootstrap';
2
2
 
3
- function build(vars) {
4
- let html =
5
- '<div id="' + vars.id + '" class="modal" tabindex="-1">' +
6
- '<div class="modal-dialog ' + (vars.class ?? '') + '">' +
7
- '<div class="modal-content">' +
8
- '<div class="modal-header">' +
9
- '<h5 class="modal-title">' + vars.title + '</h5>' +
10
- '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>' +
3
+ export const modal = {
4
+ build: vars => {
5
+ let html =
6
+ '<div id="' + vars.id + '" class="modal" tabindex="-1">' +
7
+ '<div class="modal-dialog ' + (vars.class ?? '') + '">' +
8
+ '<div class="modal-content">' +
9
+ '<div class="modal-header">' +
10
+ '<h5 class="modal-title">' + vars.title + '</h5>' +
11
+ '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>' +
12
+ '</div>' +
13
+ '<div class="modal-body">' +
14
+ '<div class="col">' + (vars.body ?? '');
15
+ if (vars.inputs) Object.values(vars.inputs).forEach(i => {
16
+ if (i.type) html += modal.buildInputLine(i);
17
+ else html += modal.buildLine(i);
18
+ });
19
+ html +=
20
+ '</div>' +
11
21
  '</div>' +
12
- '<div class="modal-body">' +
13
- '<div class="col">' + (vars.body ?? '');
14
- if (vars.inputs) Object.values(vars.inputs).forEach(i => {
15
- if (i.type) html += modal.buildInputLine(i);
16
- else html += modal.buildLine(i);
17
- });
18
- html +=
22
+ '<div class="modal-footer">';
23
+ if (vars.buttons) Object.values(vars.buttons).forEach(b => {
24
+ html += '<button type="button" class="btn btn-outline-secondary me-1 ' + (b.class ?? '') + '" data-bs-dismiss="modal">' + b.text + '</button>';
25
+ });
26
+ html +=
19
27
  '</div>' +
20
28
  '</div>' +
21
- '<div class="modal-footer">';
22
- if (vars.buttons) Object.values(vars.buttons).forEach(b => {
23
- html += '<button type="button" class="btn btn-outline-secondary me-1 ' + (b.class ?? '') + '" data-bs-dismiss="modal">' + b.text + '</button>';
24
- });
25
- html +=
26
- '</div>' +
27
29
  '</div>' +
28
- '</div>' +
29
- '</div>';
30
- return html;
31
- }
32
-
33
- export function modalAlert(msg, title = "Alert", button = "OK") {
34
- document.querySelector('body').insertAdjacentHTML('beforeend', build({
35
- id: 'alert-modal',
36
- title: title,
37
- body: '<p>' + msg + '</p>',
38
- buttons: [ { text: button } ]
39
- }));
40
- let alertModal = document.getElementById('alert-modal');
41
- alertModal.addEventListener('hidden.bs.modal', ev => {
42
- ev.target.remove();
43
- });
44
- let bsAlertModal = new bootstrap.Modal(alertModal);
45
- bsAlertModal.show();
46
- }
30
+ '</div>';
31
+ return html;
32
+ },
47
33
 
34
+ alert: (msg, title = "Alert", button = "OK") => {
35
+ document.querySelector('body').insertAdjacentHTML('beforeend', modal.build({
36
+ id: 'alert-modal',
37
+ title: title,
38
+ body: '<p>' + msg + '</p>',
39
+ buttons: [ { text: button } ]
40
+ }));
41
+ let alertModal = document.getElementById('alert-modal');
42
+ alertModal.addEventListener('hidden.bs.modal', ev => {
43
+ ev.target.remove();
44
+ });
45
+ let bsAlertModal = new bootstrap.Modal(alertModal);
46
+ bsAlertModal.show();
47
+ }
48
+ };
48
49
 
49
50
  /*import modal from "./modal.js";
50
51
  import { ajax, getIntVar, pageInit } from "./helpers.js";