diff options
author | Wu Cheng-Han | 2016-01-17 14:28:04 -0600 |
---|---|---|
committer | Wu Cheng-Han | 2016-01-17 14:28:04 -0600 |
commit | eaa8ccaccb1091820d0a8d1223996a6dd057347d (patch) | |
tree | 6b4aaa3b3d1a2fed68147510142663222533775a /public/vendor/codemirror/addon/display | |
parent | ce65e58096d57ace02723d11a125673f9d48c293 (diff) |
Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor
Diffstat (limited to 'public/vendor/codemirror/addon/display')
-rw-r--r-- | public/vendor/codemirror/addon/display/autorefresh.js | 47 | ||||
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/display/fullscreen.css | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/display/fullscreen.js | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/display/panel.js | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/display/placeholder.js | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | public/vendor/codemirror/addon/display/rulers.js | 0 |
6 files changed, 51 insertions, 2 deletions
diff --git a/public/vendor/codemirror/addon/display/autorefresh.js b/public/vendor/codemirror/addon/display/autorefresh.js new file mode 100644 index 00000000..1e0e8504 --- /dev/null +++ b/public/vendor/codemirror/addon/display/autorefresh.js @@ -0,0 +1,47 @@ +// 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) + } +}); diff --git a/public/vendor/codemirror/addon/display/fullscreen.css b/public/vendor/codemirror/addon/display/fullscreen.css index 437acd89..e258ad66 100755..100644 --- a/public/vendor/codemirror/addon/display/fullscreen.css +++ b/public/vendor/codemirror/addon/display/fullscreen.css @@ -2,5 +2,5 @@ position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: auto; - z-index: 9; + z-index: 2000; } diff --git a/public/vendor/codemirror/addon/display/fullscreen.js b/public/vendor/codemirror/addon/display/fullscreen.js index cd3673b9..cd3673b9 100755..100644 --- a/public/vendor/codemirror/addon/display/fullscreen.js +++ b/public/vendor/codemirror/addon/display/fullscreen.js diff --git a/public/vendor/codemirror/addon/display/panel.js b/public/vendor/codemirror/addon/display/panel.js index ba29484d..ba29484d 100755..100644 --- a/public/vendor/codemirror/addon/display/panel.js +++ b/public/vendor/codemirror/addon/display/panel.js diff --git a/public/vendor/codemirror/addon/display/placeholder.js b/public/vendor/codemirror/addon/display/placeholder.js index bb0c3931..babddfb1 100755..100644 --- a/public/vendor/codemirror/addon/display/placeholder.js +++ b/public/vendor/codemirror/addon/display/placeholder.js @@ -37,7 +37,9 @@ var elt = cm.state.placeholder = document.createElement("pre"); elt.style.cssText = "height: 0; overflow: visible"; elt.className = "CodeMirror-placeholder"; - elt.appendChild(document.createTextNode(cm.getOption("placeholder"))); + var placeHolder = cm.getOption("placeholder") + if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder) + elt.appendChild(placeHolder) cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild); } diff --git a/public/vendor/codemirror/addon/display/rulers.js b/public/vendor/codemirror/addon/display/rulers.js index 01f65667..01f65667 100755..100644 --- a/public/vendor/codemirror/addon/display/rulers.js +++ b/public/vendor/codemirror/addon/display/rulers.js |