Merge pull request #836 from ajaxorg/ie8

fixes for Ie8
This commit is contained in:
Lennart Kats 2012-08-02 02:48:15 -07:00
commit 2956f1b61f
8 changed files with 83 additions and 20 deletions

View file

@ -729,7 +729,7 @@ function Folding() {
} else { } else {
if (addSubfolds) if (addSubfolds)
this.foldAll(row + 1, this.getLength()); this.foldAll(row + 1, this.getLength());
e.target.className += " invalid" (e.target || e.srcElement).className += " invalid"
} }
}; };

View file

@ -166,7 +166,24 @@ var TextInput = function(parentNode, host) {
}; };
event.addCommandKeyListener(text, host.onCommandKey.bind(host)); event.addCommandKeyListener(text, host.onCommandKey.bind(host));
event.addListener(text, "input", useragent.isIE ? onPropertyChange : onTextInput); event.addListener(text, "input", onTextInput);
if (useragent.isOldIE) {
var keytable = { 13:1, 27:1 };
event.addListener(text, "keyup", function (e) {
if (inCompostion && (!text.value || keytable[e.keyCode]))
setTimeout(onCompositionEnd, 0);
if ((text.value.charCodeAt(0)|0) < 129) {
return;
}
inCompostion ? onCompositionUpdate() : onCompositionStart();
});
event.addListener(text, "propertychange", function() {
if (text.value != PLACEHOLDER)
setTimeout(sendText, 0);
});
}
event.addListener(text, "paste", function(e) { event.addListener(text, "paste", function(e) {
// Mark that the next input text comes from past. // Mark that the next input text comes from past.
@ -268,11 +285,14 @@ var TextInput = function(parentNode, host) {
tempStyle = text.style.cssText; tempStyle = text.style.cssText;
text.style.cssText = text.style.cssText =
"position:fixed; z-index:100000;" + //"background:rgba(250, 0, 0, 0.3); opacity:1;" + "position:fixed; z-index:100000;" +
(useragent.isIE ? "background:rgba(0, 0, 0, 0.03); opacity:0.1;" : "") + //"background:rgba(250, 0, 0, 0.3); opacity:1;" +
"left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;"; "left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;";
if (host.selection.isEmpty()) if (host.selection.isEmpty())
text.value = ""; text.value = "";
else
reset(true);
if (e.type != "mousedown") if (e.type != "mousedown")
return; return;
@ -281,7 +301,7 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = null; host.renderer.$keepTextAreaAtCursor = null;
// on windows context menu is opened after mouseup // on windows context menu is opened after mouseup
if (useragent.isGecko && useragent.isWin) if (useragent.isWin && (useragent.isGecko || useragent.isIE))
event.capture(host.container, function(e) { event.capture(host.container, function(e) {
text.style.left = e.clientX - 2 + "px"; text.style.left = e.clientX - 2 + "px";
text.style.top = e.clientY - 2 + "px"; text.style.top = e.clientY - 2 + "px";

View file

@ -174,12 +174,32 @@ var Gutter = function(parentEl) {
dom.removeCssClass(this.element, "ace_folding-enabled"); dom.removeCssClass(this.element, "ace_folding-enabled");
this.$showFoldWidgets = show; this.$showFoldWidgets = show;
this.$padding = null;
}; };
this.getShowFoldWidgets = function() { this.getShowFoldWidgets = function() {
return this.$showFoldWidgets; return this.$showFoldWidgets;
}; };
this.$computePadding = function() {
if (!this.element.firstChild)
return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild);
this.$padding = {}
this.$padding.left = parseInt(style.paddingLeft) + 1;
this.$padding.right = parseInt(style.paddingRight);
return this.$padding;
};
this.getRegion = function(point) {
var padding = this.$padding || this.$computePadding();
var rect = this.element.getBoundingClientRect();
if (point.x < padding.left + rect.left)
return "markers";
if (this.$showFoldWidgets && point.x > rect.right - padding.right)
return "foldWidgets";
};
}).call(Gutter.prototype); }).call(Gutter.prototype);
exports.Gutter = Gutter; exports.Gutter = Gutter;

View file

@ -193,7 +193,7 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
4: "quadclick" 4: "quadclick"
}; };
var listener = function(e) { exports.addListener(el, "mousedown", function(e) {
if (exports.getButton(e) != 0) { if (exports.getButton(e) != 0) {
clicks = 0; clicks = 0;
} else { } else {
@ -219,10 +219,18 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
clicks = 0; clicks = 0;
else if (clicks > 1) else if (clicks > 1)
return eventHandler[callbackName](eventNames[clicks], e); return eventHandler[callbackName](eventNames[clicks], e);
}; });
exports.addListener(el, "mousedown", listener); if (useragent.isOldIE) {
useragent.isOldIE && exports.addListener(el, "dblclick", listener); exports.addListener(el, "dblclick", function(e) {
clicks = 2;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
eventHandler[callbackName]("mousedown", e);
eventHandler[callbackName](eventNames[clicks], e);
});
}
}; };
function normalizeCommandKeys(callback, e, keyCode) { function normalizeCommandKeys(callback, e, keyCode) {
@ -292,7 +300,7 @@ exports.addCommandKeyListener = function(el, callback) {
} }
}; };
if (window.postMessage) { if (window.postMessage && !useragent.isOldIE) {
var postMessageId = 1; var postMessageId = 1;
exports.nextTick = function(callback, win) { exports.nextTick = function(callback, win) {
win = win || window; win = win || window;

View file

@ -8,6 +8,8 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var useragent = require("ace/lib/useragent");
exports.get = function (url, callback) { exports.get = function (url, callback) {
var xhr = exports.createXhr(); var xhr = exports.createXhr();
xhr.open('GET', url, true); xhr.open('GET', url, true);
@ -56,7 +58,12 @@ exports.loadScript = function(path, callback) {
s.src = path; s.src = path;
head.appendChild(s); head.appendChild(s);
s.onload = callback; if (useragent.isOldIE)
s.onreadystatechange = function () {
this.readyState == 'loaded' && callback();
};
else
s.onload = callback;
}; };
}); });

View file

@ -44,15 +44,11 @@ function GutterHandler(mouseHandler) {
var editor = mouseHandler.editor; var editor = mouseHandler.editor;
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) { mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
var target = e.domEvent.target;
if (target.className.indexOf("ace_gutter-cell") == -1)
return;
if (!editor.isFocused()) if (!editor.isFocused())
return; return;
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
var padding = parseInt(dom.computedStyle(target).paddingLeft); if (gutterRegion)
if (e.x < padding + target.getBoundingClientRect().left + 1)
return; return;
var row = e.getDocumentPosition().row; var row = e.getDocumentPosition().row;

View file

@ -58,9 +58,12 @@ function FoldHandler(editor) {
}); });
editor.on("gutterclick", function(e) { editor.on("gutterclick", function(e) {
if (e.domEvent.target.className.indexOf("ace_fold-widget") != -1) { var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
if (gutterRegion == "foldWidgets") {
var row = e.getDocumentPosition().row; var row = e.getDocumentPosition().row;
editor.session.onFoldWidgetClick(row, e.domEvent); if (editor.session.foldWidgets[row])
editor.session.onFoldWidgetClick(row, e);
e.stop(); e.stop();
} }
}); });

View file

@ -41,6 +41,7 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var event = require("../lib/event"); var event = require("../lib/event");
var useragent = require("../lib/useragent");
var DefaultHandlers = require("./default_handlers").DefaultHandlers; var DefaultHandlers = require("./default_handlers").DefaultHandlers;
var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler; var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
var MouseEvent = require("./mouse_event").MouseEvent; var MouseEvent = require("./mouse_event").MouseEvent;
@ -149,6 +150,14 @@ var MouseHandler = function(editor) {
self[self.state] && self[self.state](); self[self.state] && self[self.state]();
} }
if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
setTimeout(function() {
onCaptureInterval();
onCaptureEnd(ev.domEvent);
});
return;
}
event.capture(this.editor.container, onMouseMove, onCaptureEnd); event.capture(this.editor.container, onMouseMove, onCaptureEnd);
var timerId = setInterval(onCaptureInterval, 20); var timerId = setInterval(onCaptureInterval, 20);
}; };