@iamproperty/components 2.7.6 → 2.7.7
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/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/modules/chart.js +217 -0
- package/assets/js/modules/helpers.js +18 -14
- package/assets/js/modules/table.js +89 -89
- package/assets/js/scripts.bundle.js +49 -55
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/sass/foundations/icons.scss +3 -2
- package/assets/svg/icons.svg +483 -0
- package/dist/components.common.js +57 -56
- package/dist/components.common.js.map +1 -1
- package/dist/components.umd.js +57 -56
- package/dist/components.umd.js.map +1 -1
- package/dist/components.umd.min.js +1 -1
- package/dist/components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Chart/Chart.vue +8 -165
|
@@ -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 = '
|
|
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.
|
|
2
|
+
* Bootstrap v2.7.6
|
|
3
3
|
* Copyright 2011-2022 [object Object]
|
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
|
|
35
34
|
var checkElements = element => {
|
|
36
35
|
// Tables
|
|
37
36
|
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
@@ -44,7 +43,6 @@
|
|
|
44
43
|
* @param {HTMLElement} table Dom table element
|
|
45
44
|
*/
|
|
46
45
|
|
|
47
|
-
|
|
48
46
|
var tableWrap = table => {
|
|
49
47
|
if (!table.parentNode.classList.contains('table__wrapper')) {
|
|
50
48
|
var tableHTML = table.outerHTML;
|
|
@@ -56,7 +54,6 @@
|
|
|
56
54
|
* @param {HTMLElement} table Dom table element
|
|
57
55
|
*/
|
|
58
56
|
|
|
59
|
-
|
|
60
57
|
var tableStacked = table => {
|
|
61
58
|
var colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
62
59
|
var colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
@@ -74,14 +71,12 @@
|
|
|
74
71
|
});
|
|
75
72
|
});
|
|
76
73
|
};
|
|
77
|
-
|
|
78
74
|
var isNumeric = function isNumeric(str) {
|
|
79
75
|
if (typeof str != "string") return false; // we only process strings!
|
|
80
76
|
|
|
81
77
|
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
82
78
|
!isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail
|
|
83
79
|
};
|
|
84
|
-
|
|
85
80
|
var zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
86
81
|
|
|
87
82
|
var navbar = element => {
|
|
@@ -110,7 +105,7 @@
|
|
|
110
105
|
var sortedEvent = new Event('sorted');
|
|
111
106
|
var filteredEvent = new Event('filtered');
|
|
112
107
|
var reorderedEvent = new Event('reordered');
|
|
113
|
-
var randID = '
|
|
108
|
+
var randID = 'table_' + Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
|
|
114
109
|
|
|
115
110
|
var draggedRow;
|
|
116
111
|
tableElement.setAttribute('id', randID); // #region Sortable
|
|
@@ -296,47 +291,6 @@
|
|
|
296
291
|
var stopShowing = show * page;
|
|
297
292
|
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
293
|
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
294
|
}; // On page load check if the table should be paginated
|
|
341
295
|
|
|
342
296
|
|
|
@@ -347,13 +301,13 @@
|
|
|
347
301
|
|
|
348
302
|
if (show < totalRows) {
|
|
349
303
|
paginateRows(show, page);
|
|
350
|
-
createPaginationForm(show, page, totalRows);
|
|
351
|
-
createPaginationButttons(show, page, totalRows);
|
|
304
|
+
createPaginationForm(randID, tableElement, show, page, totalRows);
|
|
305
|
+
createPaginationButttons(randID, tableElement, show, page, totalRows);
|
|
352
306
|
tableElement.addEventListener('change', function (e) {
|
|
353
307
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
354
308
|
if (target.matches('.table__pagination input[type="number"]')) {
|
|
355
309
|
paginateRows(target.value, page);
|
|
356
|
-
createPaginationButttons(target.value, page, totalRows);
|
|
310
|
+
createPaginationButttons(randID, tableElement, target.value, page, totalRows);
|
|
357
311
|
tableElement.setAttribute('data-show', target.value);
|
|
358
312
|
}
|
|
359
313
|
}
|
|
@@ -362,7 +316,7 @@
|
|
|
362
316
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
363
317
|
if (target.matches('.page-item:not(.active):not(.disabled) .page-link')) {
|
|
364
318
|
paginateRows(tableElement.getAttribute('data-show'), target.getAttribute('data-page'));
|
|
365
|
-
createPaginationButttons(tableElement.getAttribute('data-show'), target.getAttribute('data-page'), totalRows);
|
|
319
|
+
createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.getAttribute('data-page'), totalRows);
|
|
366
320
|
}
|
|
367
321
|
}
|
|
368
322
|
}, false);
|
|
@@ -370,7 +324,7 @@
|
|
|
370
324
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
371
325
|
if (target.matches('.table__pagination select')) {
|
|
372
326
|
paginateRows(tableElement.getAttribute('data-show'), target.value);
|
|
373
|
-
createPaginationButttons(tableElement.getAttribute('data-show'), target.value, totalRows);
|
|
327
|
+
createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.value, totalRows);
|
|
374
328
|
}
|
|
375
329
|
}
|
|
376
330
|
});
|
|
@@ -496,8 +450,8 @@
|
|
|
496
450
|
|
|
497
451
|
if (_show < _totalRows) {
|
|
498
452
|
paginateRows(_show, 1);
|
|
499
|
-
createPaginationForm(_show, 1, _totalRows);
|
|
500
|
-
createPaginationButttons(_show, 1, _totalRows);
|
|
453
|
+
createPaginationForm(randID, tableElement, _show, 1, _totalRows);
|
|
454
|
+
createPaginationButttons(randID, tableElement, _show, 1, _totalRows);
|
|
501
455
|
}
|
|
502
456
|
}
|
|
503
457
|
|
|
@@ -521,6 +475,46 @@
|
|
|
521
475
|
}, false);
|
|
522
476
|
}
|
|
523
477
|
|
|
478
|
+
var createPaginationForm = function createPaginationForm(randID, tableElement, show, page, totalRows) {
|
|
479
|
+
var form = document.createElement("div");
|
|
480
|
+
form.classList.add('table__pagination');
|
|
481
|
+
form.classList.add('row');
|
|
482
|
+
form.classList.add('pt-3');
|
|
483
|
+
form.classList.add('pb-3'); // Create the form and create a container div to hold the pagination buttons
|
|
484
|
+
|
|
485
|
+
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
|
|
486
|
+
|
|
487
|
+
tableElement.append(form);
|
|
488
|
+
};
|
|
489
|
+
var createPaginationButttons = function createPaginationButttons(randID, tableElement, show, page, totalRows) {
|
|
490
|
+
var paginationButtonsWrapper = document.getElementById(randID + '_paginationBtns');
|
|
491
|
+
if (paginationButtonsWrapper == null) return false;
|
|
492
|
+
var numberPages = Math.ceil(totalRows / show);
|
|
493
|
+
|
|
494
|
+
if (numberPages == 1) {
|
|
495
|
+
// Remore the buttons or dont display any if we dont need them
|
|
496
|
+
paginationButtonsWrapper.innerHTML = '';
|
|
497
|
+
} else if (numberPages < 5) {
|
|
498
|
+
// If less than 5 pages (which fits comfortably on mobile) we display buttons
|
|
499
|
+
var strButtons = '';
|
|
500
|
+
|
|
501
|
+
for (var i = 1; i <= numberPages; i++) {
|
|
502
|
+
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>");
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
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>");
|
|
506
|
+
} else {
|
|
507
|
+
// If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
|
|
508
|
+
var strOptions = '';
|
|
509
|
+
|
|
510
|
+
for (var _i = 1; _i <= numberPages; _i++) {
|
|
511
|
+
if (_i == page) strOptions += "<option value=\"".concat(_i, "\" selected>Page ").concat(_i, "</option>");else strOptions += "<option value=\"".concat(_i, "\">Page ").concat(_i, "</option>");
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
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 ");
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
524
518
|
function accordion(accordionElement) {
|
|
525
519
|
// Fetch all the details element.
|
|
526
520
|
if (!accordionElement.classList.contains('accordion--keep-open')) {
|