dom-update.js 493 B

1234567891011121314151617
  1. const runWhenDOMLoaded = cb => {
  2. if (document.readyState != 'loading') {
  3. cb()
  4. } else if (document.addEventListener) {
  5. document.addEventListener('DOMContentLoaded', cb)
  6. } else {
  7. document.attachEvent('onreadystatechange', function() {
  8. if (document.readyState == 'complete') cb()
  9. })
  10. }
  11. }
  12. // Helper function to init things quickly
  13. initFunction = function(myfunc) {
  14. runWhenDOMLoaded(myfunc);
  15. document.addEventListener('turbolinks:load', myfunc);
  16. };