1
1
// ignore-tidy-filelength
2
- /* global addClass, getNakedUrl, getVar, nonnull, getSettingValue */
2
+ /* global addClass, getNakedUrl, getVar, getSettingValue, hasClass, nonnull */
3
3
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
4
4
5
5
"use strict" ;
@@ -4804,6 +4804,15 @@ function printTab(nb) {
4804
4804
if ( nb === iter ) {
4805
4805
addClass ( elem , "selected" ) ;
4806
4806
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
+ } ) ;
4807
4816
} else {
4808
4817
removeClass ( elem , "selected" ) ;
4809
4818
}
@@ -4904,11 +4913,6 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
4904
4913
let output = document . createElement ( "ul" ) ;
4905
4914
output . className = "search-results " + extraClass ;
4906
4915
4907
- const throbber = document . createElement ( "div" ) ;
4908
- throbber . className = "search-throbber" ;
4909
- throbber . innerHTML = "Loading..." ;
4910
- output . appendChild ( throbber ) ;
4911
-
4912
4916
let count = 0 ;
4913
4917
4914
4918
/** @type {Promise<string|null>[] } */
@@ -5015,7 +5019,7 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
5015
5019
}
5016
5020
5017
5021
link . appendChild ( description ) ;
5018
- output . insertBefore ( link , throbber ) ;
5022
+ output . appendChild ( link ) ;
5019
5023
5020
5024
results . next ( ) . then ( async nextResult => {
5021
5025
if ( nextResult . value ) {
@@ -5026,7 +5030,6 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
5026
5030
// running this callback
5027
5031
yieldToBrowser ( ) . then ( ( ) => {
5028
5032
finishedCallback ( count , output ) ;
5029
- throbber . remove ( ) ;
5030
5033
} ) ;
5031
5034
}
5032
5035
} ) ;
@@ -5164,6 +5167,7 @@ function makeTab(tabNb, text, results, query, isTypeSearch, goToFirst) {
5164
5167
count < 100 ? `\u{2007}(${ count } )\u{2007}` : `\u{2007}(${ count } )` ;
5165
5168
tabCount . innerHTML = fmtNbElems ;
5166
5169
tabCount . className = "count" ;
5170
+ printTab ( window . searchState . currentTab ) ;
5167
5171
} , isTypeSearch ) ,
5168
5172
] ;
5169
5173
}
@@ -5227,9 +5231,7 @@ async function showResults(docSearch, results, goToFirst, filterCrates) {
5227
5231
tabsElem . appendChild ( tab ) ;
5228
5232
const isCurrentTab = window . searchState . currentTab === tabNb ;
5229
5233
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" ;
5233
5235
placeholder . innerHTML = "Loading..." ;
5234
5236
output . then ( output => {
5235
5237
if ( placeholder . parentElement ) {
@@ -5487,11 +5489,6 @@ if (ROOT_PATH === null) {
5487
5489
const database = await Stringdex . loadDatabase ( hooks ) ;
5488
5490
if ( typeof window !== "undefined" ) {
5489
5491
docSearch = new DocSearch ( ROOT_PATH , database ) ;
5490
- onEachLazy ( document . querySelectorAll (
5491
- ".search-form.loading" ,
5492
- ) , form => {
5493
- removeClass ( form , "loading" ) ;
5494
- } ) ;
5495
5492
registerSearchEvents ( ) ;
5496
5493
// If there's a search term in the URL, execute the search now.
5497
5494
if ( window . searchState . getQueryStringParams ( ) . search !== undefined ) {
0 commit comments