From 83703e75dc8298b5047c0fb40b53a69044f14d2c Mon Sep 17 00:00:00 2001 From: LKLG Date: Fri, 31 Jan 2014 10:13:12 +0100 Subject: [PATCH] hide mouse after 5 sec of inactivity Add some code to hide the mouse cursor after 5 seconds of inactivity --- .../project/assets/javascripts/application.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/templates/project/assets/javascripts/application.coffee b/templates/project/assets/javascripts/application.coffee index a1cbf3fc..93fa2c47 100644 --- a/templates/project/assets/javascripts/application.coffee +++ b/templates/project/assets/javascripts/application.coffee @@ -11,6 +11,18 @@ Dashing.on 'ready', -> Dashing.widget_margins ||= [5, 5] Dashing.widget_base_dimensions ||= [300, 360] Dashing.numColumns ||= 4 + # hide mouse after 5 sec of inactivity + timeout = null + $(document).on "mousemove", -> + if timeout isnt null + $("body").css cursor: "" + $(".gs_w").css cursor: "" + clearTimeout timeout + timeout = setTimeout(-> + timeout = null + $("body").css cursor: "none" + $(".gs_w").css cursor: "none" + , 5000) contentWidth = (Dashing.widget_base_dimensions[0] + Dashing.widget_margins[0] * 2) * Dashing.numColumns