diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-09-06 10:35:19 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-09-06 11:04:39 +1000 |
| commit | 9151874f406c5caf723d8cd6c09f1a9029b4d038 (patch) | |
| tree | 8d0fa6429de066fee18885a2b75edd14a2405e04 /src/librustdoc/html/static | |
| parent | 5dfb7a6ec1c1b7827a1f019b276c4d959cf2d71e (diff) | |
| download | rust-9151874f406c5caf723d8cd6c09f1a9029b4d038.tar.gz rust-9151874f406c5caf723d8cd6c09f1a9029b4d038.zip | |
Use more jQuery to avoid displaying Expand Description more often.
Sometimes (e.g. on Rust CI) the "expand description" text of the collapse toggle was displayed by default, when a page is first loaded (even though the description is expanded), because some Content-Security-Policy settings disable inline CSS. Setting it the style with the `.css` method allows the output to be used in more places.
Diffstat (limited to 'src/librustdoc/html/static')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 7b5d1b7be2f..1ea86e84c83 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -118,7 +118,7 @@ * A function to compute the Levenshtein distance between two strings * Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported * Full License can be found at http://creativecommons.org/licenses/by-sa/3.0/legalcode - * This code is an unmodified version of the code written by Marco de Wit + * This code is an unmodified version of the code written by Marco de Wit * and was found at http://stackoverflow.com/a/18514751/745719 */ var levenshtein = (function() { @@ -224,7 +224,7 @@ }); } } else if ( - (lev_distance = levenshtein(searchWords[j], val)) <= + (lev_distance = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) { if (typeFilter < 0 || typeFilter === searchIndex[j].ty) { results.push({ @@ -350,16 +350,16 @@ function validateResult(name, path, keys, parent) { for (var i=0; i < keys.length; ++i) { // each check is for validation so we negate the conditions and invalidate - if (!( + if (!( // check for an exact name match name.toLowerCase().indexOf(keys[i]) > -1 || // then an exact path match path.toLowerCase().indexOf(keys[i]) > -1 || // next if there is a parent, check for exact parent match - (parent !== undefined && + (parent !== undefined && parent.name.toLowerCase().indexOf(keys[i]) > -1) || // lastly check to see if the name was a levenshtein match - levenshtein(name.toLowerCase(), keys[i]) <= + levenshtein(name.toLowerCase(), keys[i]) <= MAX_LEV_DISTANCE)) { return false; } @@ -765,20 +765,21 @@ }); $(function() { - var toggle = "<a href='javascript:void(0)'" - + "class='collapse-toggle'>[<span class='inner'>-</span>]</a>"; + var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'}) + .html("[<span class='inner'>-</span>]"); $(".method").each(function() { if ($(this).next().is(".docblock")) { - $(this).children().first().after(toggle); + $(this).children().first().after(toggle[0]); } }); - var mainToggle = $(toggle); - mainToggle.append("<span class='toggle-label' style='display:none'>" - + " Expand description</span></a>") - var wrapper = $("<div class='toggle-wrapper'>"); - wrapper.append(mainToggle); + var mainToggle = + $(toggle).append( + $('<span/>', {'class': 'toggle-label'}) + .css('display', 'none') + .html(' Expand description')); + var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle); $("#main > .docblock").before(wrapper); }); |
