godoc/static: prevent menu "bouncing" when showing Play button

The code as written would use JavaScript to show the "Play" button in
the menu when the Playground is enabled, making the button appear
after the page first renders, causing a visible "bounce" in the menu.
This change checks the condition (whether this is not the front page, or
"wide") in the template code, instead of with JavaScript after the page
has loaded.

Change-Id: Iccf0a344116372f3207158793be8c7734e67a4ae
Reviewed-on: https://go-review.googlesource.com/c/140798
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Andrew Gerrand 2018-10-10 18:01:02 +11:00
parent 38981630ec
commit 0e57ebad1d
4 changed files with 4 additions and 6 deletions

View File

@ -57,7 +57,7 @@ window.trackEvent = function(category, action, opt_label, opt_value, opt_noninte
{{if not .GoogleCN}}
<a href="/blog/">Blog</a>
{{end}}
{{if .Playground}}
{{if (and .Playground .Title)}}
<a id="playgroundButton" href="http://play.golang.org/" title="Show Go Playground">Play</a>
{{end}}
<span class="search-box"><input type="search" id="search" name="q" placeholder="Search" aria-label="Search" required><button type="submit"><span><!-- magnifying glass: --><svg width="24" height="24" viewBox="0 0 24 24"><title>submit search</title><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg></span></button></span>

View File

@ -149,7 +149,6 @@ function setupDropdownPlayground() {
button.removeClass('active');
div.hide();
});
button.show();
$('#menu').css('min-width', '+=60');
}

File diff suppressed because one or more lines are too long

View File

@ -624,7 +624,6 @@ div.play .buttons a {
}
/* drop-down playground */
#playgroundButton,
div#playground {
/* start hidden; revealed by javascript */
display: none;