diff options
| author | Will Crichton <wcrichto@cs.stanford.edu> | 2021-10-07 09:46:18 -0700 |
|---|---|---|
| committer | Will Crichton <wcrichto@cs.stanford.edu> | 2021-10-07 09:46:23 -0700 |
| commit | bb383edb69e2aaa718dc94147275053005d112e3 (patch) | |
| tree | 1020f3b981ef933b301e5b932ea3bc051d9f1a48 /src/librustdoc/html/static/js | |
| parent | 5584c795975e9cc07884b479c7cb7aef2f47c231 (diff) | |
| download | rust-bb383edb69e2aaa718dc94147275053005d112e3.tar.gz rust-bb383edb69e2aaa718dc94147275053005d112e3.zip | |
Move some expansion logic into generation-time, fix section header links, remove ID from line numbers, fix horizontal scrolling on non-expanded elements
Diffstat (limited to 'src/librustdoc/html/static/js')
| -rw-r--r-- | src/librustdoc/html/static/js/scrape-examples.js | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/librustdoc/html/static/js/scrape-examples.js b/src/librustdoc/html/static/js/scrape-examples.js index 191ce37d653..307843f2426 100644 --- a/src/librustdoc/html/static/js/scrape-examples.js +++ b/src/librustdoc/html/static/js/scrape-examples.js @@ -15,7 +15,8 @@ function updateScrapedExample(example) { var locs = JSON.parse(example.attributes.getNamedItem("data-locs").textContent); - var offset = parseInt(example.attributes.getNamedItem("data-offset").textContent); + var first_line_no = example.querySelector('.line-numbers > span:first-child'); + var offset = parseInt(first_line_no.innerHTML) - 1; var locIndex = 0; var highlights = example.querySelectorAll('.highlight'); @@ -68,11 +69,8 @@ example.querySelector('.next').remove(); } - var codeEl = example.querySelector('.rust'); - var codeOverflows = codeEl.scrollHeight > codeEl.clientHeight; var expandButton = example.querySelector('.expand'); - if (codeOverflows) { - // If file is larger than default height, give option to expand the viewer + if (expandButton) { expandButton.addEventListener('click', function () { if (hasClass(example, "expanded")) { removeClass(example, "expanded"); @@ -81,10 +79,6 @@ addClass(example, "expanded"); } }); - } else { - // Otherwise remove expansion buttons - addClass(example, 'expanded'); - expandButton.remove(); } // Start with the first example in view |
