Sha256: 65ed5528f62d01ef44a029ebe950402dc876887e410b89fb8aac907a0e131dd5
Contents?: true
Size: 1.33 KB
Versions: 38
Compression:
Stored size: 1.33 KB
Contents
wait = -> $.ajax url: window.location.pathname + '/wait' dataType: 'json' timeout: 29 * 1000 success: -> $.get window.location.pathname + '.js', (html)-> $('#book').html html initMathJax() initNavOffset() wait() error: (jqXHR, textStatus)-> if textStatus == 'timeout' # polling end, reconnect immediately wait() else # server down, try reconnecting again after timeout setTimeout wait, 5000 initMathJax = -> $('#mathJaxJS').remove() delete MathJax chapter_number = $('.chapter').attr('data-number') script = document.createElement( 'script' ) script.id = 'mathJaxJS' script.type = 'text/javascript' script.src = '<%= @mathjax_src %>' script.innerHTML = """ <%= @mathjax_config %> """ $('head').append script delay = 1000 initNavOffset = -> loading = true finish = _.debounce -> loading = false , delay offset = 20 navHeight = $('#bookMenu').height() + offset $(window).scroll -> if loading offset = $(window.location.hash).offset().top - navHeight $(window).scrollTop offset finish() $(window).bind 'hashchange', (e)-> e.preventDefault() offset = $(window.location.hash).offset().top - navHeight $(window).scrollTop offset $ -> initMathJax() initNavOffset() wait()
Version data entries
38 entries across 38 versions & 1 rubygems