Sha256: b39bb08624814741b38f6aac4f1967fcb1a1fcdac67e0ae444cde3a83fc272dc

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

class IuguUI.Table extends IuguUI.Dataset
  layout: "iugu-ui-table"

  defaults:
    itemLayout: "iugu-ui-table-row"
    itemTagName: "tr"
    itemClassName: "table-row"

  events:
    'click a.sort-button' : 'sortByColumn'

  context: ->
    sortableBy: @options.sortableBy
    fields: @options.fields
    sortBy: @sortBy

  initialize: ->
    super
    @sortBy = {}

  sortByColumn: (e) ->
    btn = $(e.target)
    name = btn.context.id

    if btn.data('direction') == "ASC"
      btn.data('direction', "")
      delete @sortBy[name]
    else if btn.data('direction') == "DESC"
      btn.data('direction', "ASC")
      @sortBy[name] = "asc"
    else
      btn.data('direction', "DESC")
      @sortBy[name] = "desc"

    @collection.removeFilter 'sortBy'
    @collection.configureFilter 'sortBy', @sortBy
    @collection.fetch()

@IuguUI.Table = IuguUI.Table

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iugu-ux-0.8.6 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-table.js.coffee
iugu-ux-0.8.5 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-table.js.coffee