Sha256: 003992026f27cbf2ba7428af00392244b7c987b01067229b3cffeca8365727c0

Contents?: true

Size: 1.51 KB

Versions: 80

Compression:

Stored size: 1.51 KB

Contents

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    mod(require("../../lib/codemirror"))
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod)
  else // Plain browser env
    mod(CodeMirror)
})(function(CodeMirror) {
  "use strict"

  CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
    if (cm.state.autoRefresh) {
      stopListening(cm, cm.state.autoRefresh)
      cm.state.autoRefresh = null
    }
    if (val && cm.display.wrapper.offsetHeight == 0)
      startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
  })

  function startListening(cm, state) {
    function check() {
      if (cm.display.wrapper.offsetHeight) {
        stopListening(cm, state)
        if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
          cm.refresh()
      } else {
        state.timeout = setTimeout(check, state.delay)
      }
    }
    state.timeout = setTimeout(check, state.delay)
    state.hurry = function() {
      clearTimeout(state.timeout)
      state.timeout = setTimeout(check, 50)
    }
    CodeMirror.on(window, "mouseup", state.hurry)
    CodeMirror.on(window, "keyup", state.hurry)
  }

  function stopListening(_cm, state) {
    clearTimeout(state.timeout)
    CodeMirror.off(window, "mouseup", state.hurry)
    CodeMirror.off(window, "keyup", state.hurry)
  }
});

Version data entries

80 entries across 54 versions & 7 rubygems

Version Path
locomotivecms-4.2.0.alpha2 vendor/assets/javascripts/locomotive/codemirror/addons/display/autorefresh.js
locomotivecms-4.2.0.alpha1 vendor/assets/javascripts/locomotive/codemirror/addons/display/autorefresh.js
scrivito_codemirror_editor-1.1.0 vendor/assets/javascripts/codemirror/addons/display/autorefresh.js
keppler-2.1.22 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.22 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.21 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.21 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.20 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.20 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.19 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.19 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.18 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.18 testing-with-2.1.18/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.18 testing-with-2.1.18/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.18 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.17 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.17 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
stisla-rails-0.0.2 vendor/assets/modules/codemirror/addon/display/autorefresh.js
keppler-2.1.16 installer/core/app/assets/javascripts/admin/codemirror/addon/display/autorefresh.js
keppler-2.1.16 installer/core/app/assets/stylesheets/admin/codemirror/addon/display/autorefresh.js