Sha256: 9bee8e1079d8fe50b27ede6321622d668345b648503e02764adc3054acd4cbaa

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

class @Table

  constructor: (element, checkboxable) ->
    @element      = $(element)
    @actions      = @element.find('th.actions > a')
    @checkboxable = checkboxable
    @element.on('click', @checkboxes(), @update)

  checkboxes: () -> @element.find("input:checkbox")

  update: () =>
    if @getChecked().length then @enableActions() else @disableActions()

  notify: (data) =>
    new Flash(data['message'], data['status'])
    @checkboxable.updateSelectAll()

  enableActions: () =>
    @actions.removeClass('disabled').addClass('btn-info')

  disableActions: () =>
    @actions.addClass('disabled').removeClass('btn-info')

  stopEvent: (event) ->
    event.stopPropagation()
    event.preventDefault()

  getChecked: () => @element.find("input:checkbox:checked")
  getId:      (c) => $(c).data('id')
  getIds:     () => $.map(@getChecked(), (c) => @getId(c))

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/assets/javascripts/georgia/components/tables.js.coffee