Sha256: f02f61c6579c8b1a3276093c8697eafaf411cd8866b1f52080d9acde7d4669d8

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

class Tao.Dialog.Element extends TaoComponent

  @tag 'tao-dialog'

  @attribute 'active', type: 'boolean', observe: true

  @attribute 'modal', 'withCloseButton', 'autoDestroy', type: 'boolean'

  @attribute 'triggerSelector', 'triggerTraversal', 'size'

  _connected: ->
    @triggerEl = if @triggerTraversal && @triggerSelector
      @jq[@triggerTraversal]?(@triggerSelector)
    else if @triggerSelector
      $ @triggerSelector

    @_bind()
    @_activeChanged() if @active

  _disconnected: ->
    @triggerEl?.off ".tao-slide-box-#{@taoId}"
    @off()

  _bind: ->
    @on 'click', (e) =>
      @active = false if e.target == @

    @on 'click', '.tao-dialog-wrapper > .link-close', =>
      @active = false

    if @triggerEl && @triggerEl.length > 0
      @triggerEl.on "click.tao-slide-box-#{@taoId}", (e) =>
        @active = true

  _beforeActiveChanged: (active) ->
    if active
      @jq.find('.tao-dialog-content').css
        maxHeight: $(window).height() - 40
      @jq.show()
      @_reflow()
    else
      @one 'transitionend', =>
        if @autoDestroy
          @jq.remove()
        else
          @jq.hide()
    null

  _activeChanged: ->
    if @active
      $('body').addClass('dialog-active')
      @trigger 'show'
    else
      $('body').removeClass('dialog-active')
      @trigger 'hide'

  setContent: (content) ->
    @jq.find('.tao-dialog-content').empty()
      .append content

TaoComponent.register Tao.Dialog.Element

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tao_ui-0.2.2 lib/assets/javascripts/tao/ui/dialog/element.coffee
tao_ui-0.2.1 lib/assets/javascripts/tao/ui/dialog/element.coffee
tao_ui-0.2.0 lib/assets/javascripts/tao/ui/dialog/element.coffee