11// ignore-tidy-filelength
2- /* global addClass, getNakedUrl, getVar, nonnull, getSettingValue */
2+ /* global addClass, getNakedUrl, getVar, getSettingValue, hasClass, nonnull */
33/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
44
55"use strict" ;
@@ -4804,6 +4804,15 @@ function printTab(nb) {
48044804 if ( nb === iter ) {
48054805 addClass ( elem , "selected" ) ;
48064806 foundCurrentTab = true ;
4807+ onEachLazy ( document . querySelectorAll (
4808+ ".search-form" ,
4809+ ) , form => {
4810+ if ( hasClass ( elem . firstElementChild , "loading" ) ) {
4811+ addClass ( form , "loading" ) ;
4812+ } else {
4813+ removeClass ( form , "loading" ) ;
4814+ }
4815+ } ) ;
48074816 } else {
48084817 removeClass ( elem , "selected" ) ;
48094818 }
@@ -4904,11 +4913,6 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
49044913 let output = document . createElement ( "ul" ) ;
49054914 output . className = "search-results " + extraClass ;
49064915
4907- const throbber = document . createElement ( "div" ) ;
4908- throbber . className = "search-throbber" ;
4909- throbber . innerHTML = "Loading..." ;
4910- output . appendChild ( throbber ) ;
4911-
49124916 let count = 0 ;
49134917
49144918 /** @type {Promise<string|null>[] } */
@@ -5015,7 +5019,7 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
50155019 }
50165020
50175021 link . appendChild ( description ) ;
5018- output . insertBefore ( link , throbber ) ;
5022+ output . appendChild ( link ) ;
50195023
50205024 results . next ( ) . then ( async nextResult => {
50215025 if ( nextResult . value ) {
@@ -5026,7 +5030,6 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
50265030 // running this callback
50275031 yieldToBrowser ( ) . then ( ( ) => {
50285032 finishedCallback ( count , output ) ;
5029- throbber . remove ( ) ;
50305033 } ) ;
50315034 }
50325035 } ) ;
@@ -5164,6 +5167,7 @@ function makeTab(tabNb, text, results, query, isTypeSearch, goToFirst) {
51645167 count < 100 ? `\u{2007}(${ count } )\u{2007}` : `\u{2007}(${ count } )` ;
51655168 tabCount . innerHTML = fmtNbElems ;
51665169 tabCount . className = "count" ;
5170+ printTab ( window . searchState . currentTab ) ;
51675171 } , isTypeSearch ) ,
51685172 ] ;
51695173}
@@ -5227,9 +5231,7 @@ async function showResults(docSearch, results, goToFirst, filterCrates) {
52275231 tabsElem . appendChild ( tab ) ;
52285232 const isCurrentTab = window . searchState . currentTab === tabNb ;
52295233 const placeholder = document . createElement ( "div" ) ;
5230- placeholder . className = isCurrentTab ?
5231- "search-throbber search-results active" :
5232- "search-throbber search-results" ;
5234+ placeholder . className = isCurrentTab ? "search-results active" : "search-results" ;
52335235 placeholder . innerHTML = "Loading..." ;
52345236 output . then ( output => {
52355237 if ( placeholder . parentElement ) {
@@ -5487,11 +5489,6 @@ if (ROOT_PATH === null) {
54875489const database = await Stringdex . loadDatabase ( hooks ) ;
54885490if ( typeof window !== "undefined" ) {
54895491 docSearch = new DocSearch ( ROOT_PATH , database ) ;
5490- onEachLazy ( document . querySelectorAll (
5491- ".search-form.loading" ,
5492- ) , form => {
5493- removeClass ( form , "loading" ) ;
5494- } ) ;
54955492 registerSearchEvents ( ) ;
54965493 // If there's a search term in the URL, execute the search now.
54975494 if ( window . searchState . getQueryStringParams ( ) . search !== undefined ) {
0 commit comments