From 08d9421dd9c291def896c78f703fec933d1c540f Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Thu, 6 Sep 2012 04:32:31 -0700 Subject: [PATCH] rewrite graph.js in coffeescript --- app/assets/javascripts/graph.js | 10 ---------- app/assets/javascripts/graph.js.coffee | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 app/assets/javascripts/graph.js create mode 100644 app/assets/javascripts/graph.js.coffee diff --git a/app/assets/javascripts/graph.js b/app/assets/javascripts/graph.js deleted file mode 100644 index 434cf70a..00000000 --- a/app/assets/javascripts/graph.js +++ /dev/null @@ -1,10 +0,0 @@ -function initGraphNav() { - $(".graph svg").css("position", "relative"); - $("body").bind("keyup", function(e) { - if(e.keyCode == 37) { // left - $(".graph svg").animate({ left: "+=400" }); - } else if(e.keyCode == 39) { // right - $(".graph svg").animate({ left: "-=400" }); - } - }); -} diff --git a/app/assets/javascripts/graph.js.coffee b/app/assets/javascripts/graph.js.coffee new file mode 100644 index 00000000..5fe8ae3f --- /dev/null +++ b/app/assets/javascripts/graph.js.coffee @@ -0,0 +1,10 @@ +initGraphNav = -> + $('.graph svg').css 'position', 'relative' + + $('body').bind 'keyup', (e) -> + if e.keyCode is 37 # left + $('.graph svg').animate left: '+=400' + else if e.keyCode is 39 # right + $('.graph svg').animate left: '-=400' + +window.initGraphNav = initGraphNav