-
-
Save jesperronn/8b26690daaf17c21123d to your computer and use it in GitHub Desktop.
Simple loading spinner for long requests with turbolinks and bootstrap modal. This fork: HTML for Bootstrap 3.3.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PageSpinner = | |
spin: (ms=500)-> | |
@spinner = setTimeout( (=> @add_spinner()), ms) | |
$(document).on 'page:change', => | |
@remove_spinner() | |
spinner_html: ' | |
<div class="modal hide fade" id="page-spinner" role="dialog"> | |
<div class="modal-dialog modal-sm" role="document"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
<h4 class="modal-title card-title">Please Wait...</h4> | |
</div> | |
<div class="modal-body card-body"> | |
<i class="icon-spinner icon-spin icon-2x"></i> | |
 Loading... | |
</div> | |
</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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment