Allovue

<thead>

  <tr>

    <th></th><th></th><th></th><th></th>

  </tr>

</thead>

<table>

  <tr>

    <td></td><td></td><td></td><td></td>

  </tr>

  <tr>

    <td></td><td></td><td></td><td></td>

  </tr>

<table>

<table id="ember1392" class="ember-view"><script id="metamorph-1-start" type="text/x-placeholder"></script><script id="metamorph-0-start" type="text/x-placeholder"></script><thead><tr><script id="metamorph-5-start" type="text/x-placeholder"></script><script id="metamorph-2-start" type="text/x-placeholder"></script><th><script id="metamorph-6-start" type="text/x-placeholder"></script>Arbitraray<script id="metamorph-6-end" type="text/x-placeholder"></script></th><script id="metamorph-2-end" type="text/x-placeholder"></script><script id="metamorph-3-start" type="text/x-placeholder"></script><th><script id="metamorph-7-start" type="text/x-placeholder"></script>Table<script id="metamorph-7-end" type="text/x-placeholder"></script></th><script id="metamorph-3-end" type="text/x-placeholder"></script><script id="metamorph-4-start" type="text/x-placeholder"></script><th><script id="metamorph-8-start" type="text/x-placeholder"></script>Column<script id="metamorph-8-end" type="text/x-placeholder"></script></th><script id="metamorph-4-end" type="text/x-placeholder"></script><script id="metamorph-5-end" type="text/x-placeholder"></script></tr><script id="metamorph-0-end" type="text/x-placeholder"></script></thead><script id="metamorph-1-end" type="text/x-placeholder"></script> </table>

# Offsets

  lowerOffset: Em.computed 'currentPage', 'totalPages', ->
    currentPage = @get('currentPage')
    totalPages = @get('totalPages')
    if currentPage < 6
      currentPage
    else if (totalPages - currentPage) < 10
      11 - (totalPages - currentPage)
    else
      6

  upperOffset: Em.computed 'currentPage', 'totalPages', ->
    currentPage = @get('currentPage')
    totalPages = @get('totalPages')
    if currentPage <= 5
      10 - currentPage
    else if (totalPages - currentPage) > 5
      5
    else
      totalPages - currentPage

# Page Range

  pageRange: Em.computed 'currentPage', 'totalPages', 'lowerOffset', 'upperOffset', ->
    count = 1
    pageArray = []
    while count <= parseInt(@get('totalPages'))
      pageArray.push count
      count += 1
    if @maxPageLinksToDisplay < @get('totalPages')
      pageArray.slice(@get('currentPage') - @get('lowerOffset'),
                      @get('currentPage') + @get('upperOffset'))
    else
      pageArray
// Transition user to highest page number with visible data

  afterModel: (model, transition) ->
    @_super(model, transition)
    totalPages = model.get('meta.total_pages')
    if 0 < totalPages < model.get('query.page')
      transition.abort()
      this.transitionTo( {queryParams: {page: totalPages} } )

miliseconds

illustrated-guide-to-ember

By brigittewarner

illustrated-guide-to-ember

  • 732
Loading comments...

More from brigittewarner