aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dom_utils.coffee')
-rw-r--r--lib/dom_utils.coffee7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index ba5e279f..762c6418 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -178,5 +178,12 @@ DomUtils =
event.preventDefault()
@suppressPropagation(event)
+ # Calls func either now (if the DOM has already loaded), or when the DOM is loaded.
+ runWhenDOMLoaded: (func) ->
+ if document.readyState == "loading"
+ window.addEventListener "DOMContentLoaded", func
+ else
+ func()
+
root = exports ? window
root.DomUtils = DomUtils