Sha256: de4ae8ed06ca52db60870842f52c3d05577dfeec25037287ef530a827c2ec3f5

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

window.toggleLoading = (isLoading=true) ->
  $('#loading').toggle(isLoading)
  $.rails.enableFormElements($('#search_form')) unless isLoading

$ ->
  $(document).on 'click', '.pjax, .pagination a, .pjax_links a', (e) ->
    if e.which > 1 || e.metaKey || e.ctrlKey
      return
    else if $.support.pjax
      e.preventDefault()
      container = $(this).data('pjax-container')
      unless container
        table = $(this).closest('table.index_table:not(#list)')
        if table[0]
          container = "##{table.attr('id')}"
        else
          container = '[data-pjax-container]'

      main_pjax_wrap = container == '[data-pjax-container]'
      $.pjax
        container: container
        url: $(this).data('href') || $(this).attr('href')
        timeout: 50000
        push: main_pjax_wrap
        scrollTo: main_pjax_wrap
    else if $(this).data('href')
      e.preventDefault()
      window.location = $(this).data('href')

  unless fv.test
    $(document).on 'submit', '.pjax-form', (e) ->
      $el = $(this)
      if $.support.pjax
        e.preventDefault()
        $.pjax
          type: $el.attr('method')
          container: $el.data('pjax-container') || '[data-pjax-container]'
          url: this.action + (if (this.action.indexOf('?') != -1) then '&' else '?') + $el.serialize()
          timeout: 50000

  $(document)
    .on 'pjax:start', ->
      toggleLoading(true)
    .on 'pjax:end', ->
      toggleLoading(false)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ab_admin-0.11.0 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.10.0 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.9.0 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.8.3 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.8.2 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.8.1 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.8.0 app/assets/javascripts/ab_admin/core/pjax.js.coffee
ab_admin-0.7.0 app/assets/javascripts/ab_admin/core/pjax.js.coffee