app: simplify embedded view
When embedded in a web page, hide the top banner
and add a new "Run" button in the top right.
Fixes golang/go#15163
Change-Id: I56887cd0e9f63588a92523836c77b00a45713cfb
Reviewed-on: https://go-review.googlesource.com/21643
Reviewed-by: Chris Broadfoot <cbro@golang.org>
diff --git a/app/goplay/edit.html b/app/goplay/edit.html
index e939e1a..6dc0909 100644
--- a/app/goplay/edit.html
+++ b/app/goplay/edit.html
@@ -12,7 +12,7 @@
playground({
'codeEl': '#code',
'outputEl': '#output',
- 'runEl': '#run',
+ 'runEl': '#run, #embedRun',
'fmtEl': '#fmt',
'fmtImportEl': '#imports',
{{if $.Share}}
@@ -81,6 +81,7 @@
</script>
</head>
<body itemscope itemtype="http://schema.org/CreativeWork">
+ <input type="button" value="Run" id="embedRun">
<div id="banner">
<div id="head" itemprop="name">The Go Playground</div>
<div id="controls">
diff --git a/app/static/playground-embed.js b/app/static/playground-embed.js
index c610c8e..c3870fd 100644
--- a/app/static/playground-embed.js
+++ b/app/static/playground-embed.js
@@ -4,26 +4,24 @@
// opts is an object with these keys
// codeEl - code editor element
-// shareEl - embed button element
// embedEl - embed checkbox element
// embedLabelEl - embed label element, containing embedEl
// embedHTMLEl - embed HTML text input element
function playgroundEmbed(opts) {
- if (opts.codeEl === null || opts.shareEl === null || opts.embedEl === null || opts.embedLabelEl === null || opts.embedHTMLEl === null) {
+ if (opts.codeEl === null || opts.embedEl === null || opts.embedLabelEl === null || opts.embedHTMLEl === null) {
return;
}
- code = $(opts.codeEl)
- embed = $(opts.embedEl);
- embedLabel = $(opts.embedLabelEl);
- share = $(opts.shareEl);
+ var code = $(opts.codeEl);
+ var embed = $(opts.embedEl);
+ var embedLabel = $(opts.embedLabelEl);
function inIFrame(){
return window.self !== window.top;
}
embedLabel.hide();
if (inIFrame()) {
- share.hide();
+ $("body").addClass("embedded");
return;
}
diff --git a/app/static/style.css b/app/static/style.css
index 571c945..f77a577 100644
--- a/app/static/style.css
+++ b/app/static/style.css
@@ -157,3 +157,20 @@
.exit {
color: lightgray;
}
+
+.embedded #banner {
+ display: none;
+}
+.embedded #wrap {
+ top: 0;
+}
+#embedRun {
+ display: none;
+}
+.embedded #embedRun {
+ display: block;
+ position: absolute;
+ z-index: 1;
+ top: 10px;
+ right: 10px;
+}