Show notice when using experimental features

This commit is contained in:
Tim Schaub
2019-09-26 20:06:28 +02:00
parent 6a5f6e4363
commit 443213e175
3 changed files with 22 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ docs: >
makes it so the map view uses geographic coordinates (even if the view projection is
not geographic).
tags: "geographic"
experimental: true
---
<div id="map" class="map"></div>
<select id="mode">

View File

@@ -99,6 +99,12 @@
This example uses OpenLayers v<span>{{ olVersion }}</span>. The <a id="latest-link" href="#" class="alert-link">latest</a> is v<span id="latest-version"></span>.
</div>
<div id="experimental" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
<button id="experimental-dismiss" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
This example uses features that are not part of the stable API and subject to change between releases. Consult the <a href="https://openlayers.org/en/latest/apidoc/">API documentation</a>
to see what is supported in the latest release.
</div>
<div class="row-fluid">
<a class="codepen-button pull-right"><i class="fa fa-codepen"></i> Edit</a>
<div class="span12">
@@ -183,6 +189,15 @@
document.cookie = cookieText;
}
}
var experimentalNotice = document.getElementById('experimental');
if (window.experimental) {
experimentalNotice.style.display = 'block';
document.getElementById('experimental-dismiss').onclick = function() {
experimentalNotice.style.display = 'none';
}
}
});
</script>
</html>

View File

@@ -200,6 +200,12 @@ ExampleBuilder.prototype.render = async function(dir, chunk) {
tag: `<script src="${this.common}.js"></script><script src="${jsName}"></script>`,
source: jsSource
};
if (data.experimental) {
const prelude = '<script>window.experimental = true;</script>';
data.js.tag = prelude + data.js.tag;
}
data.pkgJson = JSON.stringify({
name: name,
dependencies: getDependencies(jsSource),