lib/assets/javascripts/tao/ui/shared/slide_box/element/base.coffee in tao_ui-0.2.2 vs lib/assets/javascripts/tao/ui/shared/slide_box/element/base.coffee in tao_ui-0.2.3

- old
+ new

@@ -43,28 +43,29 @@ @active = true _beforeActiveChanged: (active) -> if active @jq.show() - @_reflow() + @reflow() else - @one 'transitionend', => - if @autoDestroy - @jq.remove() - else - @jq.hide() + if @jq.is(':visible') + @one 'transitionend', => + if @autoDestroy + @remove() + else + @jq.hide() null _activeChanged: -> @_unbindAutoHideEvent() if @autoHide if @active @_bindAutoHideEvent() if @autoHide $('body').addClass('slide-box-active') - @trigger 'show' + @trigger 'tao:show' else $('body').removeClass('slide-box-active') - @trigger 'hide' + @trigger 'tao:hide' _autoHideEvent: '' _unbindAutoHideEvent: -> $(document).off "#{@_autoHideEvent}.tao-slide-box-#{@taoId}" @@ -72,5 +73,17 @@ _bindAutoHideEvent: -> $(document).on "#{@_autoHideEvent}.tao-slide-box-#{@taoId}", (e) => return if e.target == @ || $.contains(@, e.target) || @triggerEl?.is(e.target) @active = false @_unbindAutoHideEvent() + + remove: -> + @trigger 'tao:beforeRemove' + @jq.remove() + @trigger 'tao:remove' + + beforeCache: -> + if @autoDestroy + @remove() + else + @jq.hide() + active = false