     return
 
   close: (event) ->
-    @attrs.onClose?()
-    @get('modalManager').close()
+    @hide().then(() =>
+      @attrs.onClose?()
+      @get('modalManager').close()
+      return
+    )
     return
 
   actions: {


  didInsertElement: ->
    @._super()
    @setupBinders()
    if @get('isVisible')
      @becameVisible()
    return

  becameVisible: ->
    Em.$('body').addClass('modal-open')
    @appendBackdrop() if @get('backdrop')
    return

  becameHidden: ->
    Em.$('body').removeClass('modal-open')
    @_backdrop.remove() if @_backdrop
    return

  appendBackdrop: ->
    parentElement = @$().parent()
    @_backdrop = Em.$(@modalBackdrop).appendTo(parentElement)
    return

  hide: ->
    @set('isVis', false)
    current = this
    @$().one('webkitTransitionEnd', (e) ->
      current.set('isVisible', false)
      return
    )
    return false

  keyPressed: (event) ->
#Handle ESC

      return
  }

#Invoked automatically by ember when the view is destroyed, giving us a chance to perform cleanups
  willDestroyElement: () ->
    @_super(arguments...)
    @becameHidden()
    return

  removeHandlers: ->
#Remove key press
    jQuery(window.document).unbind('keyup', @_keyUpHandler)
    @_keyUpHandler = null
    return

  setupBinders: ->
#Key press
    if @_keyUpHandler
      return
    handler = (event) =>
      @keyPressed(event)
      return
