Sha256: 49429fbb3763939771a49d7e64a84520f41820fedc799143938d2d705289e13f

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

class IuguUI.Helpers
  @formatISO8601Date: ( date ) ->
    dt = date.split('-')
    return "" if dt.length < 3
    "#{dt[2]}/#{dt[1]}/#{dt[0]}"

  @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

1 entries across 1 versions & 1 rubygems

Version Path
iugu-ux-1.0.3 vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee