mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 11:57:32 -06:00
add hideToolbar as url parameter
This commit is contained in:
+1
-3
@@ -277,8 +277,6 @@ function start() {
|
||||
|
||||
var root = $("#root");
|
||||
|
||||
var hideEditorToolbar = config.hideEditorToolbar;
|
||||
|
||||
var layout;
|
||||
var hub;
|
||||
try {
|
||||
@@ -384,7 +382,7 @@ function start() {
|
||||
$('#version-tree').prop('href', versionLink);
|
||||
}
|
||||
|
||||
if (options.embedded && hideEditorToolbar === "true") {
|
||||
if (options.hideEditorToolbars) {
|
||||
$('[name="editor-btn-toolbar"]').addClass("d-none");
|
||||
}
|
||||
|
||||
|
||||
+28
-4
@@ -224,14 +224,32 @@ function initShareButton(getLink, layout, noteNewState) {
|
||||
}
|
||||
}
|
||||
|
||||
function getEmbeddedUrl(config, root, readOnly) {
|
||||
function getEmbeddedUrl(config, root, readOnly, extraOptions) {
|
||||
var location = window.location.origin + root;
|
||||
var path = readOnly ? 'embed-ro#' : 'e#';
|
||||
var path = "";
|
||||
var parameters = "";
|
||||
|
||||
_.forEach(extraOptions, (value, key) => {
|
||||
if (parameters === "") {
|
||||
parameters = "?";
|
||||
} else {
|
||||
parameters += "&";
|
||||
}
|
||||
|
||||
parameters += key + "=" + value;
|
||||
});
|
||||
|
||||
if (readOnly) {
|
||||
path = 'embed-ro' + parameters + '#';
|
||||
} else {
|
||||
path = 'e' + parameters + '#';
|
||||
}
|
||||
|
||||
return location + path + url.serialiseState(config);
|
||||
}
|
||||
|
||||
function getEmbeddedHtml(config, root, isReadOnly) {
|
||||
return '<iframe width="800px" height="200px" src="' + getEmbeddedUrl(config, root, isReadOnly) + '"></iframe>';
|
||||
function getEmbeddedHtml(config, root, isReadOnly, extraOptions) {
|
||||
return '<iframe width="800px" height="200px" src="' + getEmbeddedUrl(config, root, isReadOnly, extraOptions) + '"></iframe>';
|
||||
}
|
||||
|
||||
function getShortLink(config, root, done) {
|
||||
@@ -276,6 +294,12 @@ function getLinks(config, currentBind, done) {
|
||||
case 'Embed (RO)':
|
||||
done(null, getEmbeddedHtml(config, root, readOnly), false);
|
||||
return;
|
||||
case 'Embed (hide Tb)':
|
||||
var options = {
|
||||
"hideEditorToolbars": true
|
||||
};
|
||||
done(null, getEmbeddedHtml(config, root, false, options), false);
|
||||
return;
|
||||
default:
|
||||
// Hmmm
|
||||
done('Unknown link type', null);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
| Embed
|
||||
button.dropdown-item.btn.btn-light.btn-sm(data-bind="Embed (RO)")
|
||||
| Embed (read only)
|
||||
button.dropdown-item.btn.btn-light.btn-sm(data-bind="Embed (hide Tb)")
|
||||
| Embed (hidden toolbars)
|
||||
input.form-control.input-sm.permalink(type="text" placeholder="Loading" readonly size="1024" style="font-size: 10px")
|
||||
.input-group-append
|
||||
button.input-group-btn.btn.btn-outline-secondary.btn-sm.clippy(type="button" data-clipboard-target=".popover .permalink" title="Copy to clipboard")
|
||||
|
||||
Reference in New Issue
Block a user