|
1979 | 1979 | if (collapse) {
|
1980 | 1980 | toggleAllDocs(pageId, true);
|
1981 | 1981 | }
|
1982 |
| - if (getCurrentValue('rustdoc-trait-implementations') !== "false") { |
1983 |
| - onEach(document.getElementsByClassName("collapse-toggle"), function(e) { |
| 1982 | + var collapser = function(e) { |
1984 | 1983 | // inherent impl ids are like 'impl' or impl-<number>'.
|
1985 | 1984 | // they will never be hidden by default.
|
1986 |
| - var n = e.parentNode; |
| 1985 | + var n = e.parentElement; |
1987 | 1986 | if (n.id.match(/^impl(?:-\d+)?$/) === null) {
|
1988 | 1987 | // Automatically minimize all non-inherent impls
|
1989 | 1988 | if (collapse || hasClass(n, 'impl')) {
|
1990 | 1989 | collapseDocs(e, "hide", pageId);
|
1991 | 1990 | }
|
1992 | 1991 | }
|
1993 |
| - }); |
| 1992 | + }; |
| 1993 | + if (getCurrentValue('rustdoc-trait-implementations') !== "false") { |
| 1994 | + onEach(document.getElementById('implementations-list') |
| 1995 | + .getElementsByClassName("collapse-toggle"), collapser); |
| 1996 | + } |
| 1997 | + if (getCurrentValue('rustdoc-method-docs') !== "false") { |
| 1998 | + var implItems = document.getElementsByClassName('impl-items'); |
| 1999 | + |
| 2000 | + if (implItems && implItems.length > 0) { |
| 2001 | + onEach(implItems, function(elem) { |
| 2002 | + onEach(elem.getElementsByClassName("collapse-toggle"), collapser); |
| 2003 | + }); |
| 2004 | + } |
1994 | 2005 | }
|
1995 | 2006 | }
|
1996 | 2007 |
|
|
2041 | 2052 | onEach(document.getElementsByClassName('associatedconstant'), func);
|
2042 | 2053 | onEach(document.getElementsByClassName('impl'), func);
|
2043 | 2054 |
|
2044 |
| - function createToggle(otherMessage, fontSize, extraClass) { |
| 2055 | + function createToggle(otherMessage, fontSize, extraClass, show) { |
2045 | 2056 | var span = document.createElement('span');
|
2046 | 2057 | span.className = 'toggle-label';
|
2047 |
| - span.style.display = 'none'; |
| 2058 | + if (show) { |
| 2059 | + span.style.display = 'none'; |
| 2060 | + } |
2048 | 2061 | if (!otherMessage) {
|
2049 | 2062 | span.innerHTML = ' Expand description';
|
2050 | 2063 | } else {
|
|
2060 | 2073 |
|
2061 | 2074 | var wrapper = document.createElement('div');
|
2062 | 2075 | wrapper.className = 'toggle-wrapper';
|
| 2076 | + if (!show) { |
| 2077 | + addClass(wrapper, 'collapsed'); |
| 2078 | + var inner = mainToggle.getElementsByClassName('inner'); |
| 2079 | + if (inner && inner.length > 0) { |
| 2080 | + inner[0].innerHTML = '+'; |
| 2081 | + } |
| 2082 | + } |
2063 | 2083 | if (extraClass) {
|
2064 |
| - wrapper.className += ' ' + extraClass; |
| 2084 | + addClass(wrapper, extraClass); |
2065 | 2085 | }
|
2066 | 2086 | wrapper.appendChild(mainToggle);
|
2067 | 2087 | return wrapper;
|
|
2093 | 2113 | var otherMessage;
|
2094 | 2114 | var fontSize;
|
2095 | 2115 | var extraClass;
|
| 2116 | + var show = true; |
2096 | 2117 |
|
2097 | 2118 | if (hasClass(e, "type-decl")) {
|
2098 | 2119 | fontSize = "20px";
|
2099 | 2120 | otherMessage = ' Show declaration';
|
| 2121 | + show = getCurrentValue('rustdoc-item-declarations') === "false"; |
| 2122 | + if (!show) { |
| 2123 | + extraClass = 'collapsed'; |
| 2124 | + } |
2100 | 2125 | } else if (hasClass(e, "non-exhaustive")) {
|
2101 | 2126 | otherMessage = ' This ';
|
2102 | 2127 | if (hasClass(e, "non-exhaustive-struct")) {
|
|
2111 | 2136 | extraClass = "marg-left";
|
2112 | 2137 | }
|
2113 | 2138 |
|
2114 |
| - e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass), e); |
2115 |
| - if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") { |
| 2139 | + e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass, show), e); |
| 2140 | + if (otherMessage && show) { |
2116 | 2141 | collapseDocs(e.previousSibling.childNodes[0], "toggle");
|
2117 | 2142 | }
|
2118 | 2143 | }
|
|
0 commit comments