@@ -377,28 +377,7 @@ function hideThemeButtonState() {
377
377
if ( savedHash . length === 0 ) {
378
378
return ;
379
379
}
380
- elem = document . getElementById ( savedHash . slice ( 1 ) ) ; // we remove the '#'
381
- if ( ! elem || ! isHidden ( elem ) ) {
382
- return ;
383
- }
384
- var parent = elem . parentNode ;
385
- if ( parent && hasClass ( parent , "impl-items" ) ) {
386
- // In case this is a trait implementation item, we first need to toggle
387
- // the "Show hidden undocumented items".
388
- onEachLazy ( parent . getElementsByClassName ( "collapsed" ) , function ( e ) {
389
- if ( e . parentNode === parent ) {
390
- // Only click on the toggle we're looking for.
391
- e . click ( ) ;
392
- return true ;
393
- }
394
- } ) ;
395
- if ( isHidden ( elem ) ) {
396
- // The whole parent is collapsed. We need to click on its toggle as well!
397
- if ( hasClass ( parent . lastElementChild , "collapse-toggle" ) ) {
398
- parent . lastElementChild . click ( ) ;
399
- }
400
- }
401
- }
380
+ expandSection ( savedHash . slice ( 1 ) ) ; // we remove the '#'
402
381
}
403
382
}
404
383
@@ -465,25 +444,7 @@ function hideThemeButtonState() {
465
444
}
466
445
467
446
function expandSection ( id ) {
468
- var elem = document . getElementById ( id ) ;
469
- if ( elem && isHidden ( elem ) ) {
470
- var h3 = elem . parentNode . previousElementSibling ;
471
- if ( h3 && h3 . tagName !== "H3" ) {
472
- h3 = h3 . previousElementSibling ; // skip div.docblock
473
- }
474
-
475
- if ( h3 ) {
476
- var collapses = h3 . getElementsByClassName ( "collapse-toggle" ) ;
477
- if ( collapses . length > 0 ) {
478
- // The element is not visible, we need to make it appear!
479
- collapseDocs ( collapses [ 0 ] , "show" ) ;
480
- }
481
- // Open all ancestor <details> to make this element visible.
482
- openParentDetails ( h3 . parentNode ) ;
483
- } else {
484
- openParentDetails ( elem . parentNode ) ;
485
- }
486
- }
447
+ openParentDetails ( document . getElementById ( id ) ) ;
487
448
}
488
449
489
450
function getHelpElement ( build ) {
@@ -678,10 +639,6 @@ function hideThemeButtonState() {
678
639
var helpElem = getHelpElement ( false ) ;
679
640
if ( hasClass ( ev . target , "help-button" ) ) {
680
641
displayHelp ( true , ev ) ;
681
- } else if ( hasClass ( ev . target , "collapse-toggle" ) ) {
682
- collapseDocs ( ev . target , "toggle" ) ;
683
- } else if ( hasClass ( ev . target . parentNode , "collapse-toggle" ) ) {
684
- collapseDocs ( ev . target . parentNode , "toggle" ) ;
685
642
} else if ( ev . target . tagName === "SPAN" && hasClass ( ev . target . parentNode , "line-numbers" ) ) {
686
643
handleSourceHighlight ( ev ) ;
687
644
} else if ( helpElem && hasClass ( helpElem , "hidden" ) === false ) {
@@ -898,72 +855,34 @@ function hideThemeButtonState() {
898
855
return "\u2212" ; // "\u2212" is "−" minus sign
899
856
}
900
857
901
- function onEveryMatchingChild ( elem , className , func ) {
902
- if ( elem && className && func ) {
903
- var length = elem . childNodes . length ;
904
- var nodes = elem . childNodes ;
905
- for ( var i = 0 ; i < length ; ++ i ) {
906
- if ( hasClass ( nodes [ i ] , className ) ) {
907
- func ( nodes [ i ] ) ;
908
- } else {
909
- onEveryMatchingChild ( nodes [ i ] , className , func ) ;
910
- }
911
- }
912
- }
913
- }
914
-
915
- function toggleAllDocs ( fromAutoCollapse ) {
858
+ function toggleAllDocs ( ) {
916
859
var innerToggle = document . getElementById ( toggleAllDocsId ) ;
917
860
if ( ! innerToggle ) {
918
861
return ;
919
862
}
863
+ var sectionIsCollapsed = false ;
920
864
if ( hasClass ( innerToggle , "will-expand" ) ) {
921
865
removeClass ( innerToggle , "will-expand" ) ;
922
- onEachLazy ( document . getElementsByTagName ( "details" ) , function ( e ) {
923
- e . open = true ;
924
- } ) ;
925
- onEveryMatchingChild ( innerToggle , "inner" , function ( e ) {
926
- e . innerHTML = labelForToggleButton ( false ) ;
866
+ onEachLazy ( document . getElementsByClassName ( "rustdoc-toggle" ) , function ( e ) {
867
+ if ( ! hasClass ( e , "type-contents-toggle" ) ) {
868
+ e . open = true ;
869
+ }
927
870
} ) ;
928
871
innerToggle . title = "collapse all docs" ;
929
- if ( fromAutoCollapse !== true ) {
930
- onEachLazy ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
931
- collapseDocs ( e , "show" ) ;
932
- } ) ;
933
- }
934
872
} else {
935
873
addClass ( innerToggle , "will-expand" ) ;
936
- onEachLazy ( document . getElementsByTagName ( "details" ) , function ( e ) {
937
- e . open = false ;
938
- } ) ;
939
- onEveryMatchingChild ( innerToggle , "inner" , function ( e ) {
940
- var parent = e . parentNode ;
941
- var superParent = null ;
942
-
943
- if ( parent ) {
944
- superParent = parent . parentNode ;
945
- }
946
- if ( ! parent || ! superParent || superParent . id !== "main" ||
947
- hasClass ( parent , "impl" ) === false ) {
948
- e . innerHTML = labelForToggleButton ( true ) ;
874
+ onEachLazy ( document . getElementsByClassName ( "rustdoc-toggle" ) , function ( e ) {
875
+ if ( e . parentNode . id !== "main" ||
876
+ ( ! hasClass ( e , "implementors-toggle" ) &&
877
+ ! hasClass ( e , "type-contents-toggle" ) ) )
878
+ {
879
+ e . open = false ;
949
880
}
950
881
} ) ;
882
+ sectionIsCollapsed = true ;
951
883
innerToggle . title = "expand all docs" ;
952
- if ( fromAutoCollapse !== true ) {
953
- onEachLazy ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
954
- var parent = e . parentNode ;
955
- var superParent = null ;
956
-
957
- if ( parent ) {
958
- superParent = parent . parentNode ;
959
- }
960
- if ( ! parent || ! superParent || superParent . id !== "main" ||
961
- hasClass ( parent , "impl" ) === false ) {
962
- collapseDocs ( e , "hide" ) ;
963
- }
964
- } ) ;
965
- }
966
884
}
885
+ innerToggle . children [ 0 ] . innerText = labelForToggleButton ( sectionIsCollapsed ) ;
967
886
}
968
887
969
888
function collapseDocs ( toggle , mode ) {
@@ -1102,71 +1021,26 @@ function hideThemeButtonState() {
1102
1021
referenceNode . parentNode . insertBefore ( newNode , referenceNode . nextSibling ) ;
1103
1022
}
1104
1023
1105
- function createSimpleToggle ( sectionIsCollapsed ) {
1106
- var toggle = document . createElement ( "a" ) ;
1107
- toggle . href = "javascript:void(0)" ;
1108
- toggle . className = "collapse-toggle" ;
1109
- toggle . innerHTML = "[<span class=\"inner\">" + labelForToggleButton ( sectionIsCollapsed ) +
1110
- "</span>]" ;
1111
- return toggle ;
1112
- }
1113
-
1114
- function createToggle ( toggle , otherMessage , fontSize , extraClass , show ) {
1115
- var span = document . createElement ( "span" ) ;
1116
- span . className = "toggle-label" ;
1117
- if ( show ) {
1118
- span . style . display = "none" ;
1119
- }
1120
- if ( ! otherMessage ) {
1121
- span . innerHTML = " Expand description" ;
1122
- } else {
1123
- span . innerHTML = otherMessage ;
1124
- }
1125
-
1126
- if ( fontSize ) {
1127
- span . style . fontSize = fontSize ;
1128
- }
1129
-
1130
- var mainToggle = toggle . cloneNode ( true ) ;
1131
- mainToggle . appendChild ( span ) ;
1132
-
1133
- var wrapper = document . createElement ( "div" ) ;
1134
- wrapper . className = "toggle-wrapper" ;
1135
- if ( ! show ) {
1136
- addClass ( wrapper , "collapsed" ) ;
1137
- var inner = mainToggle . getElementsByClassName ( "inner" ) ;
1138
- if ( inner && inner . length > 0 ) {
1139
- inner [ 0 ] . innerHTML = "+" ;
1140
- }
1141
- }
1142
- if ( extraClass ) {
1143
- addClass ( wrapper , extraClass ) ;
1144
- }
1145
- wrapper . appendChild ( mainToggle ) ;
1146
- return wrapper ;
1147
- }
1148
-
1149
1024
( function ( ) {
1150
1025
var toggles = document . getElementById ( toggleAllDocsId ) ;
1151
1026
if ( toggles ) {
1152
1027
toggles . onclick = toggleAllDocs ;
1153
1028
}
1154
1029
1155
- var toggle = createSimpleToggle ( false ) ;
1156
1030
var hideMethodDocs = getSettingValue ( "auto-hide-method-docs" ) === "true" ;
1157
1031
var hideImplementors = getSettingValue ( "auto-collapse-implementors" ) !== "false" ;
1158
1032
var hideLargeItemContents = getSettingValue ( "auto-hide-large-items" ) !== "false" ;
1159
1033
1160
1034
var impl_list = document . getElementById ( "trait-implementations-list" ) ;
1161
1035
if ( impl_list !== null ) {
1162
- onEachLazy ( impl_list . getElementsByClassName ( "collapse -toggle" ) , function ( e ) {
1036
+ onEachLazy ( impl_list . getElementsByClassName ( "rustdoc -toggle" ) , function ( e ) {
1163
1037
collapseNonInherent ( e ) ;
1164
1038
} ) ;
1165
1039
}
1166
1040
1167
1041
var blanket_list = document . getElementById ( "blanket-implementations-list" ) ;
1168
1042
if ( blanket_list !== null ) {
1169
- onEachLazy ( blanket_list . getElementsByClassName ( "collapse -toggle" ) , function ( e ) {
1043
+ onEachLazy ( blanket_list . getElementsByClassName ( "rustdoc -toggle" ) , function ( e ) {
1170
1044
collapseNonInherent ( e ) ;
1171
1045
} ) ;
1172
1046
}
@@ -1205,66 +1079,6 @@ function hideThemeButtonState() {
1205
1079
}
1206
1080
}
1207
1081
1208
- function buildToggleWrapper ( e ) {
1209
- if ( hasClass ( e , "autohide" ) ) {
1210
- var wrap = e . previousElementSibling ;
1211
- if ( wrap && hasClass ( wrap , "toggle-wrapper" ) ) {
1212
- var inner_toggle = wrap . childNodes [ 0 ] ;
1213
- var extra = e . childNodes [ 0 ] . tagName === "H3" ;
1214
-
1215
- e . style . display = "none" ;
1216
- addClass ( wrap , "collapsed" ) ;
1217
- onEachLazy ( inner_toggle . getElementsByClassName ( "inner" ) , function ( e ) {
1218
- e . innerHTML = labelForToggleButton ( true ) ;
1219
- } ) ;
1220
- onEachLazy ( inner_toggle . getElementsByClassName ( "toggle-label" ) , function ( e ) {
1221
- e . style . display = "inline-block" ;
1222
- if ( extra === true ) {
1223
- e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
1224
- }
1225
- } ) ;
1226
- }
1227
- }
1228
- if ( e . parentNode . id === "main" ) {
1229
- var otherMessage = "" ;
1230
- var fontSize ;
1231
- var extraClass ;
1232
-
1233
- if ( hasClass ( e , "type-decl" ) ) {
1234
- // We do something special for these
1235
- return ;
1236
- } else if ( hasClass ( e , "non-exhaustive" ) ) {
1237
- otherMessage = " This " ;
1238
- if ( hasClass ( e , "non-exhaustive-struct" ) ) {
1239
- otherMessage += "struct" ;
1240
- } else if ( hasClass ( e , "non-exhaustive-enum" ) ) {
1241
- otherMessage += "enum" ;
1242
- } else if ( hasClass ( e , "non-exhaustive-variant" ) ) {
1243
- otherMessage += "enum variant" ;
1244
- } else if ( hasClass ( e , "non-exhaustive-type" ) ) {
1245
- otherMessage += "type" ;
1246
- }
1247
- otherMessage += " is marked as non-exhaustive" ;
1248
- } else if ( hasClass ( e . childNodes [ 0 ] , "impl-items" ) ) {
1249
- extraClass = "marg-left" ;
1250
- }
1251
-
1252
- e . parentNode . insertBefore (
1253
- createToggle (
1254
- toggle ,
1255
- otherMessage ,
1256
- fontSize ,
1257
- extraClass ,
1258
- true ) ,
1259
- e ) ;
1260
- if ( hasClass ( e , "non-exhaustive" ) === true ) {
1261
- collapseDocs ( e . previousSibling . childNodes [ 0 ] , "toggle" ) ;
1262
- }
1263
- }
1264
- }
1265
-
1266
- onEachLazy ( document . getElementsByClassName ( "docblock" ) , buildToggleWrapper ) ;
1267
-
1268
1082
var pageId = getPageId ( ) ;
1269
1083
if ( pageId !== null ) {
1270
1084
expandSection ( pageId ) ;
0 commit comments