@iamproperty/components 2.7.6 → 2.7.9

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.
@@ -11,7 +11,7 @@ function table(tableElement) {
11
11
  const sortedEvent = new Event('sorted');
12
12
  const filteredEvent = new Event('filtered');
13
13
  const reorderedEvent = new Event('reordered');
14
- const randID = 'tabe_'+Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
14
+ const randID = 'table_'+Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
15
15
  let draggedRow;
16
16
 
17
17
  tableElement.setAttribute('id',randID)
@@ -271,87 +271,6 @@ function table(tableElement) {
271
271
  tableElement.append(style);
272
272
  }
273
273
 
274
- const createPaginationForm = function(show,page,totalRows){
275
-
276
- const form = document.createElement("div");
277
- form.classList.add('table__pagination');
278
- form.classList.add('row');
279
- form.classList.add('pt-3');
280
- form.classList.add('pb-3');
281
-
282
- // Create the form and create a container div to hold the pagination buttons
283
- form.innerHTML = `<div class="col mw-fit-content mb-3">
284
- <div class="form-control__wrapper form-control-inline mb-0">
285
- <label for="${randID}_showing" class="form-label">Showing:</label>
286
- <input type="number" name="${randID}_showing" id="${randID}_showing" class="form-control form-control-sm showing-input-field" placeholder="" list="${randID}_pagination" value="${show}" min="1" max="${totalRows}" />
287
- </div>
288
- <datalist id="${randID}_pagination">
289
- <option value="5">5</option>
290
- ${totalRows > 10 ? `<option value="10">10</option>` : ''}
291
- ${totalRows > 20 ? `<option value="20">20</option>` : ''}
292
- <option value="${totalRows}">${totalRows}</option>
293
- </datalist>
294
- </div>
295
- <div class="col mw-fit-content me-auto d-flex align-items-center mb-3"><span class="label">per page</span></div>
296
- <div class="col mw-fit-content d-sm-flex justify-content-end align-items-center" id="${randID}_paginationBtns"></div>`;
297
-
298
- // Add after the actual table
299
- tableElement.append(form)
300
- }
301
-
302
- const createPaginationButttons = function(show,page,totalRows){
303
-
304
- const paginationButtonsWrapper = document.getElementById(randID+'_paginationBtns')
305
-
306
- if(paginationButtonsWrapper == null)
307
- return false;
308
-
309
- const numberPages = Math.ceil(totalRows / show)
310
-
311
- if(numberPages == 1){ // Remore the buttons or dont display any if we dont need them
312
- paginationButtonsWrapper.innerHTML = '';
313
- }
314
- else if(numberPages < 5){ // If less than 5 pages (which fits comfortably on mobile) we display buttons
315
-
316
- let strButtons = '';
317
-
318
- for (let i = 1; i <= numberPages; i++) {
319
-
320
- if(i == page)
321
- strButtons += `<li class="page-item active" aria-current="page"><span class="page-link">${i}</span></li>`;
322
- else
323
- strButtons += `<li class="page-item"><button class="page-link" data-page="${i}">${i}</button></li>`;
324
- }
325
-
326
- paginationButtonsWrapper.innerHTML = `<span class="pe-2 mb-3">Page: </span><ul class="pagination mb-3">
327
- ${page == 1 ? `<li class="page-item disabled"><span class="page-link">Previous</span></li>` : `<li class="page-item"><button class="page-link" data-page="${parseInt(page)-1}">Previous</button></li>`}
328
- ${strButtons}
329
- ${page == numberPages ? `<li class="page-item disabled"><span class="page-link">Next</span></li>` : `<li class="page-item"><button class="page-link" data-page="${parseInt(page)+1}">Next</button></li>`}
330
- </ul>`;
331
-
332
- }
333
- else { // If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
334
-
335
- let strOptions = '';
336
-
337
- for (let i = 1; i <= numberPages; i++) {
338
-
339
- if(i == page)
340
- strOptions += `<option value="${i}" selected>Page ${i}</option>`;
341
- else
342
- strOptions += `<option value="${i}">Page ${i}</option>`;
343
- }
344
-
345
- paginationButtonsWrapper.innerHTML = `
346
- <div class="form-control__wrapper page-number mb-2">
347
- <select class="form-select">
348
- ${strOptions}
349
- </select>
350
- </div>
351
- `;
352
- }
353
- }
354
-
355
274
  // On page load check if the table should be paginated
356
275
  if(tableElement.getAttribute('data-show')){
357
276
 
@@ -361,15 +280,15 @@ function table(tableElement) {
361
280
 
362
281
  if(show < totalRows){
363
282
  paginateRows(show,page);
364
- createPaginationForm(show,page,totalRows);
365
- createPaginationButttons(show,page,totalRows);
283
+ createPaginationForm(randID,tableElement,show,page,totalRows);
284
+ createPaginationButttons(randID,tableElement,show,page,totalRows);
366
285
 
367
286
  tableElement.addEventListener('change', function(e){
368
287
  for (var target = e.target; target && target != this; target = target.parentNode) {
369
288
  if (target.matches('.table__pagination input[type="number"]')) {
370
289
 
371
290
  paginateRows(target.value,page);
372
- createPaginationButttons(target.value,page,totalRows);
291
+ createPaginationButttons(randID,tableElement,target.value,page,totalRows);
373
292
  tableElement.setAttribute('data-show',target.value)
374
293
  }
375
294
  }
@@ -380,7 +299,7 @@ function table(tableElement) {
380
299
  if (target.matches('.page-item:not(.active):not(.disabled) .page-link')) {
381
300
 
382
301
  paginateRows(tableElement.getAttribute('data-show'),target.getAttribute('data-page'));
383
- createPaginationButttons(tableElement.getAttribute('data-show'),target.getAttribute('data-page'),totalRows);
302
+ createPaginationButttons(randID,tableElement,tableElement.getAttribute('data-show'),target.getAttribute('data-page'),totalRows);
384
303
  }
385
304
  }
386
305
  }, false);
@@ -390,7 +309,7 @@ function table(tableElement) {
390
309
  if (target.matches('.table__pagination select')) {
391
310
 
392
311
  paginateRows(tableElement.getAttribute('data-show'),target.value);
393
- createPaginationButttons(tableElement.getAttribute('data-show'),target.value,totalRows);
312
+ createPaginationButttons(randID,tableElement,tableElement.getAttribute('data-show'),target.value,totalRows);
394
313
  }
395
314
  }
396
315
  });
@@ -548,8 +467,8 @@ function table(tableElement) {
548
467
  if(show < totalRows){
549
468
 
550
469
  paginateRows(show,1);
551
- createPaginationForm(show,1,totalRows);
552
- createPaginationButttons(show,1,totalRows);
470
+ createPaginationForm(randID,tableElement,show,1,totalRows);
471
+ createPaginationButttons(randID,tableElement,show,1,totalRows);
553
472
  }
554
473
  }
555
474
 
@@ -582,4 +501,85 @@ function table(tableElement) {
582
501
  }, false);
583
502
  }
584
503
 
504
+ export const createPaginationForm = function(randID,tableElement,show,page,totalRows){
505
+
506
+ const form = document.createElement("div");
507
+ form.classList.add('table__pagination');
508
+ form.classList.add('row');
509
+ form.classList.add('pt-3');
510
+ form.classList.add('pb-3');
511
+
512
+ // Create the form and create a container div to hold the pagination buttons
513
+ form.innerHTML = `<div class="col mw-fit-content mb-3">
514
+ <div class="form-control__wrapper form-control-inline mb-0">
515
+ <label for="${randID}_showing" class="form-label">Showing:</label>
516
+ <input type="number" name="${randID}_showing" id="${randID}_showing" class="form-control form-control-sm showing-input-field" placeholder="" list="${randID}_pagination" value="${show}" min="1" max="${totalRows}" />
517
+ </div>
518
+ <datalist id="${randID}_pagination">
519
+ <option value="5">5</option>
520
+ ${totalRows > 10 ? `<option value="10">10</option>` : ''}
521
+ ${totalRows > 20 ? `<option value="20">20</option>` : ''}
522
+ <option value="${totalRows}">${totalRows}</option>
523
+ </datalist>
524
+ </div>
525
+ <div class="col mw-fit-content me-auto d-flex align-items-center mb-3"><span class="label">per page</span></div>
526
+ <div class="col mw-fit-content d-sm-flex justify-content-end align-items-center" id="${randID}_paginationBtns"></div>`;
527
+
528
+ // Add after the actual table
529
+ tableElement.append(form)
530
+ }
531
+
532
+ export const createPaginationButttons = function(randID,tableElement,show,page,totalRows){
533
+
534
+ const paginationButtonsWrapper = document.getElementById(randID+'_paginationBtns')
535
+
536
+ if(paginationButtonsWrapper == null)
537
+ return false;
538
+
539
+ const numberPages = Math.ceil(totalRows / show)
540
+
541
+ if(numberPages == 1){ // Remore the buttons or dont display any if we dont need them
542
+ paginationButtonsWrapper.innerHTML = '';
543
+ }
544
+ else if(numberPages < 5){ // If less than 5 pages (which fits comfortably on mobile) we display buttons
545
+
546
+ let strButtons = '';
547
+
548
+ for (let i = 1; i <= numberPages; i++) {
549
+
550
+ if(i == page)
551
+ strButtons += `<li class="page-item active" aria-current="page"><span class="page-link">${i}</span></li>`;
552
+ else
553
+ strButtons += `<li class="page-item"><button class="page-link" data-page="${i}">${i}</button></li>`;
554
+ }
555
+
556
+ paginationButtonsWrapper.innerHTML = `<span class="pe-2 mb-3">Page: </span><ul class="pagination mb-3">
557
+ ${page == 1 ? `<li class="page-item disabled"><span class="page-link">Previous</span></li>` : `<li class="page-item"><button class="page-link" data-page="${parseInt(page)-1}">Previous</button></li>`}
558
+ ${strButtons}
559
+ ${page == numberPages ? `<li class="page-item disabled"><span class="page-link">Next</span></li>` : `<li class="page-item"><button class="page-link" data-page="${parseInt(page)+1}">Next</button></li>`}
560
+ </ul>`;
561
+
562
+ }
563
+ else { // If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
564
+
565
+ let strOptions = '';
566
+
567
+ for (let i = 1; i <= numberPages; i++) {
568
+
569
+ if(i == page)
570
+ strOptions += `<option value="${i}" selected>Page ${i}</option>`;
571
+ else
572
+ strOptions += `<option value="${i}">Page ${i}</option>`;
573
+ }
574
+
575
+ paginationButtonsWrapper.innerHTML = `
576
+ <div class="form-control__wrapper page-number mb-2">
577
+ <select class="form-select">
578
+ ${strOptions}
579
+ </select>
580
+ </div>
581
+ `;
582
+ }
583
+ }
584
+
585
585
  export default table
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap v2.7.5
2
+ * Bootstrap v2.7.8
3
3
  * Copyright 2011-2022 [object Object]
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
@@ -26,12 +26,25 @@
26
26
 
27
27
  return null;
28
28
  };
29
+ /**
30
+ * Add global events.
31
+ * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
32
+ */
33
+
34
+ var addGlobalEvents = body => {
35
+ window.addEventListener('hashchange', function () {
36
+ var hash = location.hash.replace('#', '');
37
+ var label = document.querySelector("label[for=\"".concat(hash, "\"]"));
38
+ var detail = document.querySelector("details[id=\"".concat(hash, "\"]:not([open])"));
39
+ if (label) label.click();else if (detail) detail.setAttribute('open', 'open');
40
+ }, false);
41
+ return null;
42
+ };
29
43
  /**
30
44
  * Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
31
45
  * @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
32
46
  */
33
47
 
34
-
35
48
  var checkElements = element => {
36
49
  // Tables
37
50
  Array.from(element.querySelectorAll('table')).forEach((table, index) => {
@@ -44,7 +57,6 @@
44
57
  * @param {HTMLElement} table Dom table element
45
58
  */
46
59
 
47
-
48
60
  var tableWrap = table => {
49
61
  if (!table.parentNode.classList.contains('table__wrapper')) {
50
62
  var tableHTML = table.outerHTML;
@@ -56,7 +68,6 @@
56
68
  * @param {HTMLElement} table Dom table element
57
69
  */
58
70
 
59
-
60
71
  var tableStacked = table => {
61
72
  var colHeadings = Array.from(table.querySelectorAll('thead th'));
62
73
  var colRows = Array.from(table.querySelectorAll('tbody tr'));
@@ -74,14 +85,12 @@
74
85
  });
75
86
  });
76
87
  };
77
-
78
88
  var isNumeric = function isNumeric(str) {
79
89
  if (typeof str != "string") return false; // we only process strings!
80
90
 
81
91
  return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
82
92
  !isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail
83
93
  };
84
-
85
94
  var zeroPad = (num, places) => String(num).padStart(places, '0');
86
95
 
87
96
  var navbar = element => {
@@ -110,7 +119,7 @@
110
119
  var sortedEvent = new Event('sorted');
111
120
  var filteredEvent = new Event('filtered');
112
121
  var reorderedEvent = new Event('reordered');
113
- var randID = 'tabe_' + Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
122
+ var randID = 'table_' + Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
114
123
 
115
124
  var draggedRow;
116
125
  tableElement.setAttribute('id', randID); // #region Sortable
@@ -296,47 +305,6 @@
296
305
  var stopShowing = show * page;
297
306
  style.innerHTML = "\n #".concat(randID, " tbody tr {\n display: none;\n }\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, "),\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, ") ~ tr{\n display: block;\n }\n @media screen and (min-width: 36em) {\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, "),\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, ") ~ tr{\n display: table-row;\n }\n }\n #").concat(randID, " tbody tr:nth-child(").concat(stopShowing, ") ~ tr{\n display: none;\n }\n ");
298
307
  tableElement.append(style);
299
- };
300
-
301
- var createPaginationForm = function createPaginationForm(show, page, totalRows) {
302
- var form = document.createElement("div");
303
- form.classList.add('table__pagination');
304
- form.classList.add('row');
305
- form.classList.add('pt-3');
306
- form.classList.add('pb-3'); // Create the form and create a container div to hold the pagination buttons
307
-
308
- form.innerHTML = "<div class=\"col mw-fit-content mb-3\">\n <div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_showing\" class=\"form-label\">Showing:</label>\n <input type=\"number\" name=\"").concat(randID, "_showing\" id=\"").concat(randID, "_showing\" class=\"form-control form-control-sm showing-input-field\" placeholder=\"\" list=\"").concat(randID, "_pagination\" value=\"").concat(show, "\" min=\"1\" max=\"").concat(totalRows, "\" />\n </div>\n <datalist id=\"").concat(randID, "_pagination\">\n <option value=\"5\">5</option>\n ").concat(totalRows > 10 ? "<option value=\"10\">10</option>" : '', "\n ").concat(totalRows > 20 ? "<option value=\"20\">20</option>" : '', "\n <option value=\"").concat(totalRows, "\">").concat(totalRows, "</option>\n </datalist>\n</div>\n<div class=\"col mw-fit-content me-auto d-flex align-items-center mb-3\"><span class=\"label\">per page</span></div>\n<div class=\"col mw-fit-content d-sm-flex justify-content-end align-items-center\" id=\"").concat(randID, "_paginationBtns\"></div>"); // Add after the actual table
309
-
310
- tableElement.append(form);
311
- };
312
-
313
- var createPaginationButttons = function createPaginationButttons(show, page, totalRows) {
314
- var paginationButtonsWrapper = document.getElementById(randID + '_paginationBtns');
315
- if (paginationButtonsWrapper == null) return false;
316
- var numberPages = Math.ceil(totalRows / show);
317
-
318
- if (numberPages == 1) {
319
- // Remore the buttons or dont display any if we dont need them
320
- paginationButtonsWrapper.innerHTML = '';
321
- } else if (numberPages < 5) {
322
- // If less than 5 pages (which fits comfortably on mobile) we display buttons
323
- var strButtons = '';
324
-
325
- for (var i = 1; i <= numberPages; i++) {
326
- if (i == page) strButtons += "<li class=\"page-item active\" aria-current=\"page\"><span class=\"page-link\">".concat(i, "</span></li>");else strButtons += "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(i, "\">").concat(i, "</button></li>");
327
- }
328
-
329
- paginationButtonsWrapper.innerHTML = "<span class=\"pe-2 mb-3\">Page: </span><ul class=\"pagination mb-3\">\n ".concat(page == 1 ? "<li class=\"page-item disabled\"><span class=\"page-link\">Previous</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) - 1, "\">Previous</button></li>"), "\n ").concat(strButtons, "\n ").concat(page == numberPages ? "<li class=\"page-item disabled\"><span class=\"page-link\">Next</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) + 1, "\">Next</button></li>"), "\n </ul>");
330
- } else {
331
- // If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
332
- var strOptions = '';
333
-
334
- for (var _i = 1; _i <= numberPages; _i++) {
335
- if (_i == page) strOptions += "<option value=\"".concat(_i, "\" selected>Page ").concat(_i, "</option>");else strOptions += "<option value=\"".concat(_i, "\">Page ").concat(_i, "</option>");
336
- }
337
-
338
- paginationButtonsWrapper.innerHTML = "\n<div class=\"form-control__wrapper page-number mb-2\">\n<select class=\"form-select\">\n ".concat(strOptions, "\n</select>\n</div>\n ");
339
- }
340
308
  }; // On page load check if the table should be paginated
341
309
 
342
310
 
@@ -347,13 +315,13 @@
347
315
 
348
316
  if (show < totalRows) {
349
317
  paginateRows(show, page);
350
- createPaginationForm(show, page, totalRows);
351
- createPaginationButttons(show, page, totalRows);
318
+ createPaginationForm(randID, tableElement, show, page, totalRows);
319
+ createPaginationButttons(randID, tableElement, show, page, totalRows);
352
320
  tableElement.addEventListener('change', function (e) {
353
321
  for (var target = e.target; target && target != this; target = target.parentNode) {
354
322
  if (target.matches('.table__pagination input[type="number"]')) {
355
323
  paginateRows(target.value, page);
356
- createPaginationButttons(target.value, page, totalRows);
324
+ createPaginationButttons(randID, tableElement, target.value, page, totalRows);
357
325
  tableElement.setAttribute('data-show', target.value);
358
326
  }
359
327
  }
@@ -362,7 +330,7 @@
362
330
  for (var target = e.target; target && target != this; target = target.parentNode) {
363
331
  if (target.matches('.page-item:not(.active):not(.disabled) .page-link')) {
364
332
  paginateRows(tableElement.getAttribute('data-show'), target.getAttribute('data-page'));
365
- createPaginationButttons(tableElement.getAttribute('data-show'), target.getAttribute('data-page'), totalRows);
333
+ createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.getAttribute('data-page'), totalRows);
366
334
  }
367
335
  }
368
336
  }, false);
@@ -370,7 +338,7 @@
370
338
  for (var target = e.target; target && target != this; target = target.parentNode) {
371
339
  if (target.matches('.table__pagination select')) {
372
340
  paginateRows(tableElement.getAttribute('data-show'), target.value);
373
- createPaginationButttons(tableElement.getAttribute('data-show'), target.value, totalRows);
341
+ createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.value, totalRows);
374
342
  }
375
343
  }
376
344
  });
@@ -496,8 +464,8 @@
496
464
 
497
465
  if (_show < _totalRows) {
498
466
  paginateRows(_show, 1);
499
- createPaginationForm(_show, 1, _totalRows);
500
- createPaginationButttons(_show, 1, _totalRows);
467
+ createPaginationForm(randID, tableElement, _show, 1, _totalRows);
468
+ createPaginationButttons(randID, tableElement, _show, 1, _totalRows);
501
469
  }
502
470
  }
503
471
 
@@ -521,6 +489,46 @@
521
489
  }, false);
522
490
  }
523
491
 
492
+ var createPaginationForm = function createPaginationForm(randID, tableElement, show, page, totalRows) {
493
+ var form = document.createElement("div");
494
+ form.classList.add('table__pagination');
495
+ form.classList.add('row');
496
+ form.classList.add('pt-3');
497
+ form.classList.add('pb-3'); // Create the form and create a container div to hold the pagination buttons
498
+
499
+ form.innerHTML = "<div class=\"col mw-fit-content mb-3\">\n<div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_showing\" class=\"form-label\">Showing:</label>\n <input type=\"number\" name=\"").concat(randID, "_showing\" id=\"").concat(randID, "_showing\" class=\"form-control form-control-sm showing-input-field\" placeholder=\"\" list=\"").concat(randID, "_pagination\" value=\"").concat(show, "\" min=\"1\" max=\"").concat(totalRows, "\" />\n</div>\n<datalist id=\"").concat(randID, "_pagination\">\n<option value=\"5\">5</option>\n").concat(totalRows > 10 ? "<option value=\"10\">10</option>" : '', "\n").concat(totalRows > 20 ? "<option value=\"20\">20</option>" : '', "\n<option value=\"").concat(totalRows, "\">").concat(totalRows, "</option>\n</datalist>\n</div>\n<div class=\"col mw-fit-content me-auto d-flex align-items-center mb-3\"><span class=\"label\">per page</span></div>\n<div class=\"col mw-fit-content d-sm-flex justify-content-end align-items-center\" id=\"").concat(randID, "_paginationBtns\"></div>"); // Add after the actual table
500
+
501
+ tableElement.append(form);
502
+ };
503
+ var createPaginationButttons = function createPaginationButttons(randID, tableElement, show, page, totalRows) {
504
+ var paginationButtonsWrapper = document.getElementById(randID + '_paginationBtns');
505
+ if (paginationButtonsWrapper == null) return false;
506
+ var numberPages = Math.ceil(totalRows / show);
507
+
508
+ if (numberPages == 1) {
509
+ // Remore the buttons or dont display any if we dont need them
510
+ paginationButtonsWrapper.innerHTML = '';
511
+ } else if (numberPages < 5) {
512
+ // If less than 5 pages (which fits comfortably on mobile) we display buttons
513
+ var strButtons = '';
514
+
515
+ for (var i = 1; i <= numberPages; i++) {
516
+ if (i == page) strButtons += "<li class=\"page-item active\" aria-current=\"page\"><span class=\"page-link\">".concat(i, "</span></li>");else strButtons += "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(i, "\">").concat(i, "</button></li>");
517
+ }
518
+
519
+ paginationButtonsWrapper.innerHTML = "<span class=\"pe-2 mb-3\">Page: </span><ul class=\"pagination mb-3\">\n ".concat(page == 1 ? "<li class=\"page-item disabled\"><span class=\"page-link\">Previous</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) - 1, "\">Previous</button></li>"), "\n ").concat(strButtons, "\n ").concat(page == numberPages ? "<li class=\"page-item disabled\"><span class=\"page-link\">Next</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) + 1, "\">Next</button></li>"), "\n </ul>");
520
+ } else {
521
+ // If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
522
+ var strOptions = '';
523
+
524
+ for (var _i = 1; _i <= numberPages; _i++) {
525
+ if (_i == page) strOptions += "<option value=\"".concat(_i, "\" selected>Page ").concat(_i, "</option>");else strOptions += "<option value=\"".concat(_i, "\">Page ").concat(_i, "</option>");
526
+ }
527
+
528
+ paginationButtonsWrapper.innerHTML = "\n<div class=\"form-control__wrapper page-number mb-2\">\n<select class=\"form-select\">\n".concat(strOptions, "\n</select>\n</div>\n ");
529
+ }
530
+ };
531
+
524
532
  function accordion(accordionElement) {
525
533
  // Fetch all the details element.
526
534
  if (!accordionElement.classList.contains('accordion--keep-open')) {
@@ -914,6 +922,7 @@
914
922
 
915
923
  document.addEventListener("DOMContentLoaded", function () {
916
924
  addBodyClasses(document.body);
925
+ addGlobalEvents();
917
926
  checkElements(document.body);
918
927
  console.log('test.js'); // ANav
919
928
 
@@ -948,6 +957,11 @@
948
957
  Array.from(document.querySelectorAll('.youtube-embed')).forEach((arrayElement, index) => {
949
958
  new youtubeVideo(arrayElement);
950
959
  });
960
+ window.addEventListener('hashchange', function () {
961
+ var hash = location.hash.replace('#', '');
962
+ var label = document.querySelector("label[for=\"".concat(hash, "\"]"));
963
+ if (label) label.click();
964
+ }, false);
951
965
  });
952
966
 
953
967
  }));