@@ -377,28 +377,7 @@ function hideThemeButtonState() {
377377 if ( savedHash . length === 0 ) {
378378 return ;
379379 }
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 '#'
402381 }
403382 }
404383
@@ -465,25 +444,7 @@ function hideThemeButtonState() {
465444 }
466445
467446 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 ) ) ;
487448 }
488449
489450 function getHelpElement ( build ) {
@@ -678,10 +639,6 @@ function hideThemeButtonState() {
678639 var helpElem = getHelpElement ( false ) ;
679640 if ( hasClass ( ev . target , "help-button" ) ) {
680641 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" ) ;
685642 } else if ( ev . target . tagName === "SPAN" && hasClass ( ev . target . parentNode , "line-numbers" ) ) {
686643 handleSourceHighlight ( ev ) ;
687644 } else if ( helpElem && hasClass ( helpElem , "hidden" ) === false ) {
@@ -898,72 +855,34 @@ function hideThemeButtonState() {
898855 return "\u2212" ; // "\u2212" is "−" minus sign
899856 }
900857
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 ( ) {
916859 var innerToggle = document . getElementById ( toggleAllDocsId ) ;
917860 if ( ! innerToggle ) {
918861 return ;
919862 }
863+ var sectionIsCollapsed = false ;
920864 if ( hasClass ( innerToggle , "will-expand" ) ) {
921865 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+ }
927870 } ) ;
928871 innerToggle . title = "collapse all docs" ;
929- if ( fromAutoCollapse !== true ) {
930- onEachLazy ( document . getElementsByClassName ( "collapse-toggle" ) , function ( e ) {
931- collapseDocs ( e , "show" ) ;
932- } ) ;
933- }
934872 } else {
935873 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 ;
949880 }
950881 } ) ;
882+ sectionIsCollapsed = true ;
951883 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- }
966884 }
885+ innerToggle . children [ 0 ] . innerText = labelForToggleButton ( sectionIsCollapsed ) ;
967886 }
968887
969888 function collapseDocs ( toggle , mode ) {
@@ -1102,71 +1021,26 @@ function hideThemeButtonState() {
11021021 referenceNode . parentNode . insertBefore ( newNode , referenceNode . nextSibling ) ;
11031022 }
11041023
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-
11491024 ( function ( ) {
11501025 var toggles = document . getElementById ( toggleAllDocsId ) ;
11511026 if ( toggles ) {
11521027 toggles . onclick = toggleAllDocs ;
11531028 }
11541029
1155- var toggle = createSimpleToggle ( false ) ;
11561030 var hideMethodDocs = getSettingValue ( "auto-hide-method-docs" ) === "true" ;
11571031 var hideImplementors = getSettingValue ( "auto-collapse-implementors" ) !== "false" ;
11581032 var hideLargeItemContents = getSettingValue ( "auto-hide-large-items" ) !== "false" ;
11591033
11601034 var impl_list = document . getElementById ( "trait-implementations-list" ) ;
11611035 if ( impl_list !== null ) {
1162- onEachLazy ( impl_list . getElementsByClassName ( "collapse -toggle" ) , function ( e ) {
1036+ onEachLazy ( impl_list . getElementsByClassName ( "rustdoc -toggle" ) , function ( e ) {
11631037 collapseNonInherent ( e ) ;
11641038 } ) ;
11651039 }
11661040
11671041 var blanket_list = document . getElementById ( "blanket-implementations-list" ) ;
11681042 if ( blanket_list !== null ) {
1169- onEachLazy ( blanket_list . getElementsByClassName ( "collapse -toggle" ) , function ( e ) {
1043+ onEachLazy ( blanket_list . getElementsByClassName ( "rustdoc -toggle" ) , function ( e ) {
11701044 collapseNonInherent ( e ) ;
11711045 } ) ;
11721046 }
@@ -1205,66 +1079,6 @@ function hideThemeButtonState() {
12051079 }
12061080 }
12071081
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-
12681082 var pageId = getPageId ( ) ;
12691083 if ( pageId !== null ) {
12701084 expandSection ( pageId ) ;
0 commit comments