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.concat.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'js/record.concat.js') diff --git a/js/record.concat.js b/js/record.concat.js index f4d06f4..fe35688 100644 --- a/js/record.concat.js +++ b/js/record.concat.js @@ -944,6 +944,7 @@ function GifEncoder(){ el.innerHTML = UI_TEMPLATE document.body.appendChild(el) bind() + activate() } function bind(){ curtain = $("curtain") @@ -962,8 +963,25 @@ function GifEncoder(){ 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 @@ -973,6 +991,7 @@ function GifEncoder(){ } } function box_start(e){ + if (! listening) return e.stopPropagation() x = e.pageX y = e.pageY @@ -1024,6 +1043,7 @@ function GifEncoder(){ 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