Skip to content

Commit

Permalink
_content: fix go.dev/play share not to reload page
Browse files Browse the repository at this point in the history
Mainly the JS invocation was set up wrong.

Also add the display box for the share URL back,
and style the share URL box and the Go release box
the same as the example selector box.

Also hide the example box when sharing.
This used to happen somewhat accidentally
on play.golang.org. Make it intentional.

Fixes golang/go#49766.

Change-Id: Ib297feff123f6fdabebe24cf868a54874c5afc83
Reviewed-on: https://go-review.googlesource.com/c/website/+/368014
Trust: Russ Cox <[email protected]>
Run-TryBot: Russ Cox <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Jamal Carvalho <[email protected]>
  • Loading branch information
passionSeven committed Nov 30, 2021
1 parent 396281f commit 49a53ce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions _content/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3832,7 +3832,7 @@ a.error {
gap: 0.5rem;
justify-content: flex-end;
}
.Playground-selectExample {
.Playground-selectExample, .Playground-selectGoVersion, .Playground-shareURL {
background-color: white;
border-radius: 3px;
border: 0.0625rem solid #979797;
Expand All @@ -3857,7 +3857,7 @@ a.error {
.Playground-controls {
flex-wrap: nowrap;
}
.Playground-selectExample {
.Playground-selectExample, .Playground-selectGoVersion, .Playground-shareURL {
margin: 0 0.4375rem 0 0;
width: auto;
}
Expand Down
3 changes: 3 additions & 0 deletions _content/js/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ function PlaygroundOutput(el) {
.focus()
.select();

if (opts.toysEl !== null) {
$(opts.toysEl).hide();
}
if (rewriteHistory) {
var historyData = { code: sharingData };
window.history.pushState(historyData, '', path);
Expand Down
2 changes: 1 addition & 1 deletion _content/js/playsite.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ window.addEventListener('DOMContentLoaded', () => {
"runEl": ".js-playgroundRunEl",
"fmtEl": ".js-playgroundFmtEl",
"shareEl": ".js-playgroundShareEl",
"shareRedirect": "/play/p/",
"shareURLEl": ".js-playgroundShareURLEl",
"toysEl": ".js-playgroundToysEl",
"versionEl": ".js-playgroundVersionEl",
'enableHistory': true,
Expand Down
1 change: 1 addition & 0 deletions _content/play.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<button id="share" class="Button js-playgroundShareEl" title="Share this code">Share</button>
{{- end}}
</div>
<input type="text" class="Playground-shareURL js-playgroundShareURLEl" title="Sharing URL" style="display: none;"></input>
<select class="Playground-selectExample js-playgroundToysEl" aria-label="Code examples">
<option value="hello.go">Hello, World!</option>
<option value="life.go">Conway's Game of Life</option>
Expand Down

0 comments on commit 49a53ce

Please sign in to comment.