-# TODO:
-# 
-# handlers
 window.SvgNodes = {}
 
 class SvgNodes.Map
+  
+  this._eventNameToHandlerName = (en) ->
+    en.replace ':', '_'
   constructor: (parent = null, params = {} )->
     @w = params.w
     @h = params.h
     @svg = Snap(parent) || Snap(@w, @h)
+    @domElement = @svg.node
     @bbox = {
       x: @svg.node.getBoundingClientRect().x
       y: @svg.node.getBoundingClientRect().y

  attr: (hash)->
    @svg.attr(hash)

class SvgNodes.Label extends SvgNodes.Responsible
  constructor: (@map, @x, @y, @text, @style)->
    @_clickHandlers = []
    @_dragHandlers =  []
    @svg = @map.svg.text(@x, @y, @text)
  attr: (hash)->
    @svg.attr(hash)

class SvgNodes.Edge extends SvgNodes.Responsible
  constructor: (@map, @src, @dest)->
    @_clickHandlers = []
    @_dragHandlers =  []


    @nodes = []
    @edges = []
    @selection = []

    @handlers =
      "selection:change": []
      "selection:empty": []
      "click:map": []
      "click:node": []
      "drag:map:start": []
      "drag:map:move": []
      "drag:map:end": []
      "drag:node:start": []
      "drag:node:move": []
      "drag:node:end": []
      "zoom": []

    @options = params.options ||
      nodes:
        fill: 'white',
        stroke: 'black',
        strokeWidth: 1.5,
        fillOpacity: 1,
        draggable: true
      edges:
        stroke: 'black',
        strokeWidth: 1
    @interactive = true
    @transformations =
      zoom: 1
      x:    0
      y:    0
      dx:   0
      dy:   0

    this._setDefaultHandlers()
    this.enableInteractivity()

  addNode: (node)->
    n = new SvgNodes.Node(
