88#
99*/
1010
11+ function setupTooltips ( ) {
12+ // Enables all tooltips
13+ const tooltipTriggerList = document . querySelectorAll ( '[data-bs-toggle="tooltip"]' ) ;
14+ const tooltips = Array . from ( tooltipTriggerList ) . map ( element => {
15+ return new bootstrap . Tooltip ( element , {
16+ container : 'body'
17+ } ) ;
18+ } ) ;
19+ }
20+
21+ function setupPopovers ( ) {
22+ // Enables all popovers
23+ const popoverTriggerList = document . querySelectorAll ( '[data-bs-toggle="popover"]' ) ;
24+ const popovers = Array . from ( popoverTriggerList ) . map ( element => {
25+ return new bootstrap . Popover ( element , {
26+ container : 'body' ,
27+ html : true
28+ } ) ;
29+ } ) ;
30+ }
31+
32+ function setupSelectionCheckboxes ( ) {
33+ const selectAllCheckbox = document . getElementById ( "checkbox-select-all" ) ;
34+ const rowCheckboxes = document . querySelectorAll ( "table#object-list-table tbody input[type='checkbox']" ) ;
35+ let lastChecked ; // Store the last checked checkbox
36+
37+ if ( ! rowCheckboxes ) return ;
38+
39+ // Select-all checkboxes
40+ if ( selectAllCheckbox ) {
41+ selectAllCheckbox . addEventListener ( "click" , function ( ) {
42+ rowCheckboxes . forEach ( function ( checkbox ) {
43+ checkbox . checked = selectAllCheckbox . checked ;
44+ } ) ;
45+ } ) ;
46+ }
47+
48+ // Add a click event listener to each row checkbox to handle individual selections
49+ rowCheckboxes . forEach ( ( checkbox ) => {
50+ checkbox . addEventListener ( "click" , function ( event ) {
51+ if ( event . shiftKey && lastChecked ) {
52+ // Determine the index of the clicked checkbox
53+ const currentCheckboxIndex = Array . from ( rowCheckboxes ) . indexOf ( checkbox ) ;
54+ const lastCheckedIndex = Array . from ( rowCheckboxes ) . indexOf ( lastChecked ) ;
55+
56+ // Determine the range of checkboxes to check/uncheck
57+ const startIndex = Math . min ( currentCheckboxIndex , lastCheckedIndex ) ;
58+ const endIndex = Math . max ( currentCheckboxIndex , lastCheckedIndex ) ;
59+
60+ // Toggle the checkboxes within the range
61+ for ( let i = startIndex ; i <= endIndex ; i ++ ) {
62+ rowCheckboxes [ i ] . checked = checkbox . checked ;
63+ }
64+ }
65+
66+ // Update the last checked checkbox
67+ lastChecked = checkbox ;
68+
69+ // Check if all row checkboxes are checked and update the "Select All" checkbox accordingly
70+ if ( selectAllCheckbox ) {
71+ selectAllCheckbox . checked = Array . from ( rowCheckboxes ) . every ( ( cb ) => cb . checked ) ;
72+ }
73+
74+ } ) ;
75+ } ) ;
76+ }
77+
78+ function setupBackToTop ( ) {
79+ // Get the back-to-top button element
80+ const backToTopButton = document . getElementById ( 'back-to-top' ) ;
81+
82+ // Add a scroll event listener
83+ window . addEventListener ( 'scroll' , function ( ) {
84+ if ( window . scrollY >= 250 ) { // Page is scrolled more than 250px
85+ backToTopButton . style . display = 'block' ;
86+ } else {
87+ backToTopButton . style . display = 'none' ;
88+ }
89+ } ) ;
90+
91+ // Add a click event listener to scroll back to the top
92+ backToTopButton . addEventListener ( 'click' , function ( ) {
93+ window . scrollTo ( 0 , 0 ) ;
94+ } ) ;
95+ }
96+
1197document . addEventListener ( 'DOMContentLoaded' , ( ) => {
1298 NEXB = { } ;
1399 NEXB . client_data = JSON . parse ( document . getElementById ( "client_data" ) . textContent ) ;
@@ -37,23 +123,6 @@ document.addEventListener('DOMContentLoaded', () => {
37123 document . body . appendChild ( overlay ) ;
38124 }
39125
40- // Enables all tooltips
41- const tooltipTriggerList = document . querySelectorAll ( '[data-bs-toggle="tooltip"]' ) ;
42- const tooltips = Array . from ( tooltipTriggerList ) . map ( element => {
43- return new bootstrap . Tooltip ( element , {
44- container : 'body'
45- } ) ;
46- } ) ;
47-
48- // Enables all popovers
49- const popoverTriggerList = document . querySelectorAll ( '[data-bs-toggle="popover"]' ) ;
50- const popovers = Array . from ( popoverTriggerList ) . map ( element => {
51- return new bootstrap . Popover ( element , {
52- container : 'body' ,
53- html : true
54- } ) ;
55- } ) ;
56-
57126 // Search selection in the header
58127 $ ( '#search-selector-list a' ) . click ( function ( event ) {
59128 event . preventDefault ( ) ;
@@ -62,21 +131,9 @@ document.addEventListener('DOMContentLoaded', () => {
62131 $ ( '#search-input' ) . focus ( ) ;
63132 } ) ;
64133
65- // Get the back-to-top button element
66- const backToTopButton = document . getElementById ( 'back-to-top' ) ;
67-
68- // Add a scroll event listener
69- window . addEventListener ( 'scroll' , function ( ) {
70- if ( window . scrollY >= 250 ) { // Page is scrolled more than 250px
71- backToTopButton . style . display = 'block' ;
72- } else {
73- backToTopButton . style . display = 'none' ;
74- }
75- } ) ;
76-
77- // Add a click event listener to scroll back to the top
78- backToTopButton . addEventListener ( 'click' , function ( ) {
79- window . scrollTo ( 0 , 0 ) ;
80- } ) ;
134+ setupTooltips ( ) ;
135+ setupPopovers ( ) ;
136+ setupSelectionCheckboxes ( ) ;
137+ setupBackToTop ( ) ;
81138
82139} ) ;
0 commit comments