svn: /web/doc-editor/trunk/js/ux/codemirror/js/ codemirror.js
[email protected] (Chan Ka Shing)
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
mrkschan Thu, 01 Apr 2010 03:08:38 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=297253
Log:
fix codemirror ignoring options lineNumberDelay and lineNumberTime for non-wrapping editor
Changed paths:
U web/doc-editor/trunk/js/ux/codemirror/js/codemirror.js
Modified: web/doc-editor/trunk/js/ux/codemirror/js/codemirror.js
===================================================================
--- web/doc-editor/trunk/js/ux/codemirror/js/codemirror.js 2010-04-01 02:57:58 UTC (rev 297252)
+++ web/doc-editor/trunk/js/ux/codemirror/js/codemirror.js 2010-04-01 03:08:38 UTC (rev 297253)
@@ -264,15 +264,41 @@
sizeInterval = setInterval(sizeBar, 500);
function nonWrapping() {
- var nextNum = 1;
- function update() {
- var target = 50 + Math.max(body.offsetHeight, frame.offsetHeight);
+ var nextNum = 1, pending, target, endTime;
+
+ //~ function update() {
+ //~ var target = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0));
+ //~ while (scroller.offsetHeight < target && (!scroller.firstChild || scroller.offsetHeight)) {
+ //~ scroller.appendChild(document.createElement("DIV"));
+ //~ scroller.lastChild.innerHTML = nextNum++;
+ //~ }
+ //~ doScroll();
+ //~ }
+
+ function work() {
while (scroller.offsetHeight < target) {
scroller.appendChild(document.createElement("DIV"));
scroller.lastChild.innerHTML = nextNum++;
+
+ if (new Date().getTime() > endTime) {
+ // sleep the task by options.lineNumberTime
+ pending = setTimeout(work, self.options.lineNumberDelay);
+ return;
+ }
}
+ }
+
+ function update() {
+ target = 50 + Math.max(body.offsetHeight, frame.offsetHeight);
+ endTime = new Date().getTime() + self.options.lineNumberTime;
+
+ if (pending) clearTimeout(pending);
+ pending = 0;
+
+ work();
doScroll();
}
+
var onScroll = win.addEventHandler(win, "scroll", update, true),
onResize = win.addEventHandler(win, "resize", update, true);
clear = function(){onScroll(); onResize();};