Sha256: 2a06f719d2ee9797e3ed695e6c3e066d3fbf2d340a48a25fc75233791248884e

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

window.app.BaseResources = Backbone.Paginator.requestPager.extend

  paginator_ui:
    firstPage: 1
    currentPage: 1
    perPage: 30

  server_api:
    'limit': ->
      return @perPage

    'start': ->
      return (@currentPage - 1) * @perPage

    'api_token': ->
      return api_token

  configureFilter: ( param, value ) ->
    @server_api[param] = value
    @trigger 'configured-filter', param

  removeFilter: (param) ->
    delete @server_api[param]
    @trigger "removed-filter:#{param}"

  removeFiltersEndingWith: (param) ->
    self = @
    _.each @server_api, (value, key) ->
      _regex = new RegExp( "#{param}$")
      self.removeFilter(key) if key.match(_regex)

  parse: (response) ->
    @totalRecords = response.totalItems
    @facets = response.facets
    @totalPages = Math.ceil(@totalRecords / @perPage)
    return response.items

  buildChangedPageEventOptions: ->
    that = @
    success: ( ( collection, response ) ->
      that.trigger 'changed-page:success'
    )
    error: ( ( collection, response ) ->
      that.trigger 'changed-page:error'
    )

  gotoFirst: ->
    @goTo @information.firstPage, @buildChangedPageEventOptions()

  gotoLast: ->
    @goTo @information.lastPage, @buildChangedPageEventOptions()

  gotoPage: ( page ) ->
    @goTo page, @buildChangedPageEventOptions()

  gotoNext: ->
    if @information.currentPage < @information.lastPage
      @requestNextPage @buildChangedPageEventOptions()

  gotoPrevious: ->
    if @information.currentPage > 1
      @requestPreviousPage @buildChangedPageEventOptions()

  disablePagination: () ->
    # 64 Bit Integer Size
    @perPage = 9223372036854775807

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iugu-ux-0.9.5 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.9.4 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.9.3 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.9.2 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.9.1 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.9.0 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.8.9 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.8.8 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee
iugu-ux-0.8.7 vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee