-
-
Save cisaacstern/0094946216ce1b68b15258fbb18fc16d to your computer and use it in GitHub Desktop.
file.html for background blur on modal open
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
Renders Bokeh models into a basic .html file. | |
:param title: value for ``<title>`` tags | |
:type title: str | |
:param plot_resources: typically the output of RESOURCES | |
:type plot_resources: str | |
:param plot_script: typically the output of PLOT_SCRIPT | |
:type plot_script: str | |
Users can customize the file output by providing their own Jinja2 template | |
that accepts these same parameters. | |
#} | |
{% from macros import embed %} | |
<!DOCTYPE html> | |
<html lang="en"> | |
{% block head %} | |
<head> | |
{% block inner_head %} | |
<meta charset="utf-8"> | |
<title>{% block title %}{{ title | e if title else "Bokeh Plot" }}{% endblock %}</title> | |
{% block preamble %}{% endblock %} | |
{% block resources %} | |
{% block css_resources %} | |
{{ bokeh_css | indent(8) if bokeh_css }} | |
{% endblock %} | |
{% block js_resources %} | |
{{ bokeh_js | indent(8) if bokeh_js }} | |
{% endblock %} | |
{% endblock %} | |
{% block postamble %}{% endblock %} | |
{% endblock %} | |
</head> | |
{% endblock %} | |
{% block body %} | |
<body> | |
{% block inner_body %} | |
{% block contents %} | |
{% for doc in docs %} | |
{{ embed(doc) if doc.elementid }} | |
{% for root in doc.roots %} | |
{% block root scoped %} | |
{{ embed(root) | indent(10) }} | |
{% endblock %} | |
{% endfor %} | |
{% endfor %} | |
{% endblock %} | |
{{ plot_script | indent(8) }} | |
{% endblock %} | |
</body> | |
{% endblock %} | |
</html> | |
<script type='text/javascript'> | |
function addBlur(){ | |
closeNav() | |
document.getElementById("responsive-grid").className = "blurred"; | |
document.getElementById("header").className = "blurred"; | |
// reset the close listener | |
var close = document.getElementById("pn-closeModal"); | |
close.addEventListener('click', unBlur); | |
} | |
function unBlur(){ | |
openNav() | |
document.getElementById("responsive-grid").className = ""; | |
document.getElementById("header").className = ""; | |
// reset the open listener | |
var open = document.getElementById("sidebar").getElementsByTagName("button"); | |
open[0].addEventListener('click', addBlur); | |
} | |
function delay() { | |
setTimeout(function() { | |
var open = document.getElementById("sidebar").getElementsByTagName("button"); | |
var close = document.getElementById("pn-closeModal"); | |
open[0].addEventListener('click', addBlur); | |
close.addEventListener('click', unBlur); | |
}, 200); | |
} | |
if (document.readyState == 'complete') { | |
delay(); | |
} else { | |
document.onreadystatechange = function () { | |
if (document.readyState === "complete") { | |
delay(); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment