Fixed non-disappearing tooltip

This commit is contained in:
squidfunk 2017-06-06 21:51:25 +02:00 committed by Martin Donath
parent e5761ccfb1
commit ba0b46e9b0
5 changed files with 11 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -149,7 +149,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application-e3caa82af6.js"></script>
<script src="{{ base_url }}/assets/javascripts/application-b30566c560.js"></script>
{% set languages = lang.t("search.languages").split(",") %}
{% if languages | length and languages[0] != "" %}
{% set path = base_url + "/assets/javascripts/lunr" %}

View File

@ -89,7 +89,6 @@ function initialize(config) { // eslint-disable-line func-style
const copy = new Clipboard(".md-clipboard")
/* Success handler */
let timer = null
copy.on("success", action => {
const message = action.trigger.querySelector(".md-clipboard__message")
if (!(message instanceof HTMLElement))
@ -97,17 +96,18 @@ function initialize(config) { // eslint-disable-line func-style
/* Clear selection and reset debounce logic */
action.clearSelection()
if (timer)
clearTimeout(timer)
if (message.dataset.mdTimer)
clearTimeout(parseInt(message.dataset.mdTimer, 10))
/* Set message indicating success and show it */
message.classList.add("md-clipboard__message--active")
message.innerHTML = "Copied to clipboard"
/* Hide message after two seconds */
timer = setTimeout(() => {
message.dataset.mdTimer = setTimeout(() => {
message.classList.remove("md-clipboard__message--active")
}, 2000)
message.dataset.mdTimer = ""
}, 2000).toString()
})
}