#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require graph_starter/underscore
#= require semantic-ui/api
#= require semantic-ui/rating
#= require semantic-ui/search
#= require semantic-ui/transition
#= require semantic-ui/dropdown

spinner_timeout_id = null

ready = ->
  $('#loading-spinner').hide()
  if spinner_timeout_id?
    window.clearTimeout(spinner_timeout_id)
    spinner_timeout_id = null

  $("img").error ->
    console.log 'imgError!!!!'

    img = $(@)

    img.attr('src', <%= asset_path("missing.png").to_json %>)
    img.css('padding', '40px')
    img.insertBefore("")
    img.unbind('error')

  $('.message > .close').on 'click', ->
    $(@).closest('.message').transition('fade')

$(document).ready ready
$(document).on 'page:load', ready

$(document).on 'page:fetch', (e) ->
  spinner_timeout_id = window.setTimeout ->
    $('#loading-spinner').css 'display', 'inline-block'
  , 300


#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require graph_starter/underscore
#= require semantic-ui/api
#= require semantic-ui/rating
#= require semantic-ui/search
#= require semantic-ui/transition
#= require semantic-ui/dropdown

spinner_timeout_id = null

ready = ->
  $('#loading-spinner').hide()
  if spinner_timeout_id?
    window.clearTimeout(spinner_timeout_id)
    spinner_timeout_id = null

  $("img").error ->
    console.log 'imgError!!!!'

    img = $(@)

    img.attr('src', <%= asset_path("missing.png").to_json %>)
    img.css('padding', '40px')
    img.insertBefore("")
    img.unbind('error')

  $('.message > .close').on 'click', ->
    $(@).closest('.message').transition('fade')


  # Make sure page is in the right place when an anchor is clicked
  # See: https://github.com/twbs/bootstrap/issues/1768
  shiftWindow = -> scrollBy(0, -50)
  shiftWindow() if location.hash
  window.addEventListener('hashchange', shiftWindow)

$(document).ready ready
$(document).on 'page:load', ready

$(document).on 'page:fetch', (e) ->
  spinner_timeout_id = window.setTimeout ->
    $('#loading-spinner').css 'display', 'inline-block'
  , 300


Make sure page is in the right place when an anchor is clicked
Make sure page is in the right place when an anchor is clicked
