5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"))
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod)
11
})(function(CodeMirror) {
14
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
15
if (cm.state.autoRefresh) {
16
stopListening(cm, cm.state.autoRefresh)
17
cm.state.autoRefresh = null
19
if (val && cm.display.wrapper.offsetHeight == 0)
20
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
23
function startListening(cm, state) {
25
if (cm.display.wrapper.offsetHeight) {
26
stopListening(cm, state)
27
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
30
state.timeout = setTimeout(check, state.delay)
33
state.timeout = setTimeout(check, state.delay)
34
state.hurry = function() {
35
clearTimeout(state.timeout)
36
state.timeout = setTimeout(check, 50)
38
CodeMirror.on(window, "mouseup", state.hurry)
39
CodeMirror.on(window, "keyup", state.hurry)
42
function stopListening(_cm, state) {
43
clearTimeout(state.timeout)
44
CodeMirror.off(window, "mouseup", state.hurry)
45
CodeMirror.off(window, "keyup", state.hurry)