From 10e4555669b554c74db9fc84e19aad4fe0caec24 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Wed, 1 Jan 2014 14:29:19 -0500 Subject: show/hide with esc --- js/record.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'js/record.js') diff --git a/js/record.js b/js/record.js index 06c8ba9..fab2669 100644 --- a/js/record.js +++ b/js/record.js @@ -36,6 +36,7 @@ el.innerHTML = UI_TEMPLATE document.body.appendChild(el) bind() + activate() } function bind(){ curtain = $("curtain") @@ -54,8 +55,25 @@ h_el.addEventListener("change", box_position, false) x_el.addEventListener("change", box_position, false) y_el.addEventListener("change", box_position, false) + window.addEventListener("keydown", keydown, false) + } + var listening = false + function activate(){ + listening = true outline.style.display = "none" controls.style.display = "block" + curtain.style.display = "block" + } + function deactivate(){ + listening = false + outline.style.display = "none" + controls.style.display = "none" + curtain.style.display = "none" + } + function keydown(e){ + if (e.keyCode == 27) { // esc + ! activated ? activate : deactivate + } } function defer(callback){ var timeout = null @@ -65,6 +83,7 @@ } } function box_start(e){ + if (! listening) return e.stopPropagation() x = e.pageX y = e.pageY @@ -116,6 +135,7 @@ function unclickable(id){ $(id).style.pointerEvents = "none" } function px(n){ return (~~n) + "px" } function record(e){ + if (! listening) return e.stopPropagation() count = _int("framecount") delay = _float("framedelay") * 1000 -- cgit v1.2.3-70-g09d2