Sha256: fbd8395306133ae8e486dfc80a2194b25ac94bf0abe72e029e02c712e50b6707

Contents?: true

Size: 1.79 KB

Versions: 16

Compression:

Stored size: 1.79 KB

Contents

class IuguUI.Helpers
  @bindNavigatorToCollection: ( collection, navigator, context ) ->
    navigator.context = () ->
      info = collection.info()
      currentPage: info.currentPage
      firstPage: info.firstPage
      lastPage: info.lastPage

    gotoNextPage = () ->
      collection.gotoNext()

    gotoPreviousPage = () ->
      collection.gotoPrevious()

    gotoPage = () ->
      collection.gotoPage navigator.currentPage().val()

    navigator.collection = collection

    context.on navigator.identifier() + 'next', gotoNextPage, context
    context.on navigator.identifier() + 'previous', gotoPreviousPage, context
    context.on navigator.identifier() + 'change-page', gotoPage, context

    collection.on 'all', navigator.render, navigator
    collection.on 'changed-page:success', navigator.setFocus, navigator

  @bindPaginatorToCollection: ( collection, paginator, context ) ->
    paginator.context = () ->
      currentPage: collection.info().currentPage
      firstPage: collection.info().firstPage
      lastPage: collection.info().lastPage
      pageButtons: @pageButtonsToShow(paginator.options.numberOfPageButtons, collection.info().firstPage, collection.info().lastPage, collection.info().currentPage)
      enableAdditionalButtons: paginator.options.enableAdditionalButtons

    gotoNextPage = () ->
      collection.gotoNext()

    gotoPreviousPage = () ->
      collection.gotoPrevious()

    gotoPage = () ->
      collection.gotoPage paginator.currentPage

    paginator.collection = collection

    context.on paginator.identifier() + 'next', gotoNextPage, context
    context.on paginator.identifier() + 'previous', gotoPreviousPage, context
    context.on paginator.identifier() + 'change-page', gotoPage, context

    collection.on 'all', paginator.render, paginator

@IuguUI.Helpers = IuguUI.Helpers

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
iugu-ux-1.0.2 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-1.0.1 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-1.0.0 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.9 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.8 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.5 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.4 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.3 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.2 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.1 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.9.0 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.8.9 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.8.8 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.8.7 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.8.6 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee
iugu-ux-0.8.5 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee