OSDN Git Service

merge graph.js into projects.js
authorNihad Abbasov <narkoz.2008@gmail.com>
Tue, 16 Oct 2012 11:57:13 +0000 (04:57 -0700)
committerNihad Abbasov <narkoz.2008@gmail.com>
Fri, 19 Oct 2012 10:41:10 +0000 (03:41 -0700)
app/assets/javascripts/graph.js.coffee [deleted file]
app/assets/javascripts/projects.js.coffee
app/views/projects/graph.html.haml

diff --git a/app/assets/javascripts/graph.js.coffee b/app/assets/javascripts/graph.js.coffee
deleted file mode 100644 (file)
index 5fe8ae3..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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
index 008fa8e..3059723 100644 (file)
@@ -22,3 +22,10 @@ $ ->
   # Ref switcher
   $('.project-refs-select').on 'change', ->
     $(@).parents('form').submit()
+
+class @GraphNav
+  @init: ->
+    $('.graph svg').css 'position', 'relative'
+    $('body').bind 'keyup', (e) ->
+      $('.graph svg').animate(left: '+=400') if e.keyCode is 37 # left
+      $('.graph svg').animate(left: '-=400') if e.keyCode is 39 # right
index 76ada99..07f038d 100644 (file)
@@ -10,5 +10,5 @@
   initGraph();
   $(function(){
     branchGraph($("#holder")[0]);
-    initGraphNav();
+    GraphNav.init();
   });