Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Para usar con turbolinks. En los cambios de página muestra mensajes de carga tipo carrousel.
class App.LoadingManager
'Sigo cargando...'
'Y sigo cargando...'
'Parece que se está extendiendo bastante la espera, ¿no?'
'Mmmm...capaz que algo se rompió'
'Lo dejo a tu criterio el seguir esperando...'
interval: 8000
# -----------------
index: 0
constructor: () ->
$(document).off('page:before-change').on 'page:before-change', =>
$(document).on 'page:change', =>
onBeforePageChanged: () ->
@index = 0
displayLoadingMessage: () ->
App.flash_snackbar_render [@currentMessage()]
setTimer: ->
@timer = setTimeout (=>
), @interval
currentMessage: ->
msg = MESSAGES[@index]
@index++ unless @index == MESSAGES.length-1
# You must create an instance on page-change
$(document).on "page:change", ->
new App.LoadingManager()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.