     if @getOptions().animate then @setClass 'out' else @hide()
 
     @addListeners()
-    KD.singletons.windowController.on "ScrollHappened", @bound "hide"
-
-    @once "viewAppended", =>
-      o = @getOptions()
-
-      if o.view?
-        @setView o.view
+    KD.singletons.windowController.on 'ScrollHappened', @bound "hide"
+
+    @once 'viewAppended', =>
+
+      {view, title, html} = @getOptions()
+
+      if view?
+        @setView view
       else
         @setClass 'just-text'
-        @setTitle o.title, o
+        @setTitle title, html
 
       @parentView.emit 'TooltipReady'
 


    @utils.wait 500, => @unsetClass 'animate-movement'

  setTitle:(title,o={})->
    unless o.html is no
      @wrapper.updatePartial title
    else
      @wrapper.updatePartial Encoder.htmlEncode title

  directionMap = (placement, gravity)->
    if placement in ["top", "bottom"]


  hide: (event)->
    return unless @visible
    {permanent} = @getOptions()
    super
    @getDomElement().remove()
    KD.singletons.windowController.removeLayer this  unless permanent
    @visible = no

  update: (o = @getOptions(), view) ->

    unless view
      o.selector or= null
      o.title    or= ""
      @setTitle o.title, o.html
      @display()
    else
      @setView view

    @visible = yes

  addListeners:->
    {events, sticky, permanent} = @getOptions()

    _show = @bound 'show'
    _hide = @bound 'hide'

    @parentView.bindEvent name for name in events
    @parentView.on 'mouseenter', _show
    @parentView.on 'mouseleave', _hide  unless sticky

    @on 'ReceivedClickElsewhere', _hide  unless permanent

    @once 'KDObjectWillBeDestroyed', =>
      @parentView.off 'mouseenter',  _show
      @parentView.off 'mouseleave',  _hide  unless sticky

  setView: (childView) ->
    return unless childView
