 # GRAPHEDIT CLASS DEFINITION
 # =========================
 class GraphEdit
-	constructor: ( element, options ) ->
+  constructor: ( element, options ) ->
     $el = $(element)
-    
-	# config
+
+    me = @
+
+    # config
     @width = 960
     @height = 500
     @colors = d3.scale.category10()

# ===================================

$ ->
	$('body').on 'click.graphEdit.data-api', '[data-pluginNameAction^=Action]', ( e ) ->
		$(e.target).graphEdit()

      .append "g"

    # init nodes
    @node_data = ({id:a, reflexive:false} for a in [1..4])
    @link_data = [{"source":1, "target":3, "value":4}, {"source":1, "target":3, "value":4}]
    @force = d3.layout.force()
      #.nodes @node_data
      #.links @link_data
      .size [@width, @height]
      .linkDistance 150
      .charge -500
      .on 'tick', @tick
      .start()

    @nodes = @svg.selectAll ".node"
    @links = @svg.selectAll ".link"

    #@setNodes(@node_data)
    #@setLinks([{"source":1, "target":3, "value":4}, {"source":1, "target":3, "value":4}])
    @restart()



  _constructor: GraphEdit

  method : =>
    alert "I am a method"
    0

  #animation
  tick : =>
    @nodes.attr "cx", (d) -> d.x
    @nodes.attr "cy", (d) -> d.y

