Sha256: b2c04c480d1ff27d62699dadbfed5c927ff623efb9e266758c773f53aa7ee739

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

# http://stackoverflow.com/a/15310394/1045752
@PageSpinner =
  spin: (ms=250)->
    @spinner = setTimeout( (=> @add_spinner()), ms)
    $(document).on 'page:change', =>
      @remove_spinner()
  spinner_html: '
    <div class="modal hide fade" id="page-spinner">
      <div class="modal-head card-title"> <%= I18n.t :loading %></div>
      <div class="modal-body card-body">
        <i class="icon-spinner icon-spin icon-2x"></i>
        &emsp;<%= I18n.t :loading %>
      </div>
    </div>
  '
  spinner: null
  add_spinner: ->
    $('body').append(@spinner_html)
    $('body div#page-spinner').modal()
  remove_spinner: ->
    clearTimeout(@spinner)
    $('div#page-spinner').modal('hide')
    $('div#page-spinner').on 'hidden', ->
      $(this).remove()

$(document).on 'page:fetch', ->
  PageSpinner.spin()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basepack-0.0.2 app/assets/javascripts/basepack/loading_spinner.coffee.erb