11// Only import what we need:
22// https://getbootstrap.com/docs/5.1/customize/optimize/
33
4- // import "bootstrap/js/dist/alert";
4+ import "bootstrap/js/dist/alert" ;
55import "bootstrap/js/dist/button" ;
66// import "bootstrap/js/dist/carousel";
77import "bootstrap/js/dist/collapse" ;
88import "bootstrap/js/dist/dropdown" ;
9- // import "bootstrap/js/dist/modal";
9+ import "bootstrap/js/dist/modal" ;
1010// import "bootstrap/js/dist/offcanvas";
1111// import "bootstrap/js/dist/popover";
1212// import "bootstrap/js/dist/scrollspy";
1313import "bootstrap/js/dist/tab" ;
1414// import "bootstrap/js/dist/toast";
15- // import "bootstrap/js/dist/tooltip";
15+ import "bootstrap/js/dist/tooltip" ;
1616
1717import jquery from "jquery"
1818
@@ -29,6 +29,7 @@ function csrfSafeMethod(method) {
2929 // these HTTP methods do not require CSRF protection
3030 return ( / ^ ( G E T | H E A D | O P T I O N S | T R A C E ) $ / . test ( method ) ) ;
3131}
32+
3233jQuery . ajaxSetup ( {
3334 crossDomain : false , // obviates need for sameOrigin test
3435 beforeSend : function ( xhr , settings ) {
@@ -38,59 +39,63 @@ jQuery.ajaxSetup({
3839 }
3940} ) ;
4041
41- function dropdown_hover ( ) {
42- var navbar = $ ( this )
43- . closest ( ".navbar" ) ;
44- if ( navbar . length === 0 || navbar . find ( ".navbar-toggler" )
45- . is ( ":hidden" ) ) {
46- $ ( this )
47- . children ( ".dropdown-toggle" )
48- . dropdown ( "toggle" ) ;
49- }
50- }
51-
52- if ( ! ( "ontouchstart" in document . documentElement ) ) {
53- $ ( "ul.nav li.dropdown, ul.nav li.dropend" )
54- . on ( "mouseenter mouseleave" , dropdown_hover ) ;
55- }
42+ $ ( document )
43+ . ready ( function ( ) {
5644
57- // load data for the menu
58- $ . ajax ( {
59- url : $ ( document . body )
60- . data ( "group-menu-data-url" ) ,
61- type : "GET" ,
62- dataType : "json" ,
63- success : function ( data ) {
64- for ( var parentId in data ) {
65- var attachTo = $ ( ".group-menu.group-parent-" + parentId ) ;
66- if ( attachTo . length == 0 ) {
67- console . log ( "Could not find parent " + parentId ) ;
68- continue ;
45+ function dropdown_hover ( ) {
46+ var navbar = $ ( this )
47+ . closest ( ".navbar" ) ;
48+ if ( navbar . length === 0 || navbar . find ( ".navbar-toggler" )
49+ . is ( ":hidden" ) ) {
50+ $ ( this )
51+ . children ( ".dropdown-toggle" )
52+ . dropdown ( "toggle" ) ;
6953 }
70- attachTo . find ( ".dropdown-menu" )
71- . remove ( ) ;
72- var menu = [ '<ul class="dropdown-menu ms-n1">' ] ;
73- var groups = data [ parentId ] ;
74- var gtype = "" ;
75- for ( var i = 0 ; i < groups . length ; ++ i ) {
76- var g = groups [ i ] ;
77- if ( g . type != gtype ) {
78- if ( i > 0 )
79- menu . push ( '<li class="dropdown-divider"></li>' ) ;
80- menu . push ( '<li class="dropdown-header">' + g . type + 's</li>' ) ;
81- gtype = g . type ;
54+ }
55+
56+ // load data for the menu
57+ $ . ajax ( {
58+ url : $ ( document . body )
59+ . data ( "group-menu-data-url" ) ,
60+ type : "GET" ,
61+ dataType : "json" ,
62+ success : function ( data ) {
63+ for ( var parentId in data ) {
64+ var attachTo = $ ( ".group-menu.group-parent-" + parentId ) ;
65+ if ( attachTo . length == 0 ) {
66+ console . log ( "Could not find parent " + parentId ) ;
67+ continue ;
68+ }
69+ attachTo . find ( ".dropdown-menu" )
70+ . remove ( ) ;
71+ var menu = [ '<ul class="dropdown-menu ms-n1">' ] ;
72+ var groups = data [ parentId ] ;
73+ var gtype = "" ;
74+ for ( var i = 0 ; i < groups . length ; ++ i ) {
75+ var g = groups [ i ] ;
76+ if ( g . type != gtype ) {
77+ if ( i > 0 )
78+ menu . push ( '<li class="dropdown-divider"></li>' ) ;
79+ menu . push ( '<li class="dropdown-header">' + g . type + "s</li>" ) ;
80+ gtype = g . type ;
81+ }
82+ menu . push ( '<li><a class="dropdown-item" href="' + g . url + '">' +
83+ g . acronym + " — " + g . name + "</a></li>" ) ;
84+ }
85+ menu . push ( "</ul>" ) ;
86+ for ( i = 0 ; i < attachTo . length ; i ++ ) {
87+ attachTo . closest ( ".dropdown-menu" ) ;
88+ }
89+ attachTo . append ( menu . join ( "" ) ) ;
8290 }
83- menu . push ( '<li><a class="dropdown-item" href="' + g . url + '">' +
84- g . acronym + ' — ' + g . name + '</a></li>' ) ;
85- }
86- menu . push ( "</ul>" ) ;
87- for ( var i = 0 ; i < attachTo . length ; i ++ ) {
88- attachTo . closest ( ".dropdown-menu" ) ;
8991 }
90- attachTo . append ( menu . join ( "" ) ) ;
92+ } ) ;
93+
94+ if ( ! ( "ontouchstart" in document . documentElement ) ) {
95+ $ ( "ul.nav li.dropdown, ul.nav li.dropend" )
96+ . on ( "mouseenter mouseleave" , dropdown_hover ) ;
9197 }
92- }
93- } ) ;
98+ } ) ;
9499
95100// This used to be in doc-search.js; consolidate all JS in one file.
96101$ ( document )
@@ -172,15 +177,15 @@ $(document)
172177 updateAdvanced ( ) ;
173178 }
174179
175- $ ( ' .review-wish-add-remove-doc.ajax, .track-untrack-doc' )
180+ $ ( " .review-wish-add-remove-doc.ajax, .track-untrack-doc" )
176181 . on ( "click" , function ( e ) {
177182 e . preventDefault ( ) ;
178183 var trigger = $ ( this ) ;
179184 $ . ajax ( {
180- url : trigger . attr ( ' href' ) ,
181- type : ' POST' ,
185+ url : trigger . attr ( " href" ) ,
186+ type : " POST" ,
182187 cache : false ,
183- dataType : ' json' ,
188+ dataType : " json" ,
184189 success : function ( response ) {
185190 if ( response . success ) {
186191 trigger . parent ( )
@@ -189,12 +194,11 @@ $(document)
189194 trigger . attr ( "hidden" , true ) ;
190195
191196 var target_unhide = null ;
192- if ( trigger . hasClass ( ' review-wish-add-remove-doc' ) ) {
193- target_unhide = ' .review-wish-add-remove-doc' ;
194- } else if ( trigger . hasClass ( ' track-untrack-doc' ) ) {
195- target_unhide = ' .track-untrack-doc' ;
197+ if ( trigger . hasClass ( " review-wish-add-remove-doc" ) ) {
198+ target_unhide = " .review-wish-add-remove-doc" ;
199+ } else if ( trigger . hasClass ( " track-untrack-doc" ) ) {
200+ target_unhide = " .track-untrack-doc" ;
196201 }
197- if ( target_unhide ) { }
198202 trigger . parent ( )
199203 . find ( target_unhide )
200204 . not ( trigger )
@@ -203,5 +207,4 @@ $(document)
203207 }
204208 } ) ;
205209 } ) ;
206-
207210 } ) ;
0 commit comments