This commit is contained in:
Fabian Jakobs 2011-10-12 17:08:40 +02:00
commit 6d4df6c520
43 changed files with 313 additions and 184 deletions

View file

@ -3404,7 +3404,7 @@ var Keys = (function() {
};
// A reverse map of FUNCTION_KEYS
for (i in ret.FUNCTION_KEYS) {
for (var i in ret.FUNCTION_KEYS) {
var name = ret.FUNCTION_KEYS[i].toUpperCase();
ret[name] = parseInt(i, 10);
}
@ -5017,7 +5017,7 @@ exports.Plugin.prototype = {
startup: function(data, reason) {
reason = reason || exports.REASONS.APP_STARTUP;
var pr = new Promise();
if (this.status != this.REGISTERED) {
if (this.status < this.REGISTERED) {
pr.resolve(this);
return pr;
}
@ -6194,7 +6194,7 @@ exports.preventDefault = function(e) {
};
exports.getDocumentX = function(e) {
if (e.clientX) {
if (e.clientX) {
return e.clientX + dom.getPageScrollLeft();
} else {
return e.pageX;
@ -6217,7 +6217,7 @@ exports.getButton = function(e) {
return 0;
else if (e.type == "contextmenu")
return 2;
// DOM Event
if (e.preventDefault) {
return e.button;
@ -6238,7 +6238,7 @@ if (document.documentElement.setCapture) {
var called = false;
function onReleaseCapture(e) {
eventHandler(e);
if (!called) {
called = true;
releaseCaptureHandler();
@ -6283,7 +6283,7 @@ exports.addMouseWheelListener = function(el, callback) {
var max = 0;
var listener = function(e) {
if (e.wheelDelta !== undefined) {
// some versions of Safari (e.g. 5.0.5) report insanely high
// scroll values. These browsers require a higher factor
if (Math.abs(e.wheelDeltaY) > max)
@ -6293,7 +6293,7 @@ exports.addMouseWheelListener = function(el, callback) {
factor = 400;
else
factor = 8;
if (e.wheelDeltaX !== undefined) {
e.wheelX = -e.wheelDeltaX / factor;
e.wheelY = -e.wheelDeltaY / factor;
@ -6340,7 +6340,7 @@ exports.addMultiMouseDownListener = function(el, button, count, timeout, callbac
clicks = 0;
callback(e);
}
if (isButton)
return exports.preventDefault(e);
};
@ -6384,7 +6384,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
// If there is no hashID and the keyCode is not a function key, then
// we don't call the callback as we don't handle a command key here
// (it's a normal key/character input).
if (hashId == 0 && !(keyCode in keys.FUNCTION_KEYS)) {
if (!(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
return false;
}
return callback(e, hashId, keyCode);
@ -6453,6 +6453,7 @@ exports.addCommandKeyListener = function(el, callback) {
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai AT sucan AT gmail ODT com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -6563,18 +6564,36 @@ exports.setCssClass = function(node, className, include) {
}
};
exports.importCssString = function(cssText, doc){
doc = doc || document;
function hasCssString(id, doc) {
var index = 0, sheets;
doc = doc || document
if ((sheets = doc.styleSheets)) {
while (index < sheets.length)
if (sheets[index++].title === id) return true;
} else if ((sheets = doc.getElementsByTagName("style"))) {
while (index < sheets.length)
if (sheets[index++].id === id) return true;
}
return false;
}
exports.hasCssString = hasCssString;
exports.importCssString = function importCssString(cssText, id, doc) {
doc = doc || document;
// If style is already imported return immediately.
if (id && hasCssString(id, doc)) return null;
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet();
sheet.cssText = cssText;
}
else {
if (id) sheet.title = id;
} else {
var style = doc.createElementNS ?
doc.createElementNS(XHTML_NS, "style") :
doc.createElement("style");
if (id) style.id = id;
style.appendChild(doc.createTextNode(cssText));
var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
@ -6582,6 +6601,19 @@ exports.importCssString = function(cssText, doc){
}
};
exports.importCssStylsheet = function(uri, doc) {
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet(uri);
} else {
var link = exports.createElement('link');
link.rel = 'stylesheet';
link.href = uri;
var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
head.appendChild(link);
}
};
exports.getInnerWidth = function(element) {
return (parseInt(exports.computedStyle(element, "paddingLeft"))
+ parseInt(exports.computedStyle(element, "paddingRight")) + element.clientWidth);
@ -6624,7 +6656,7 @@ else
return element.currentStyle
};
exports.scrollbarWidth = function() {
exports.scrollbarWidth = function(document) {
var inner = exports.createElement("p");
inner.style.width = "100%";
@ -6674,6 +6706,7 @@ exports.setInnerHtml = function(el, innerHtml) {
};
exports.setInnerText = function(el, innerText) {
var document = el.ownerDocument;
if (document.body && "textContent" in document.body)
el.textContent = innerText;
else
@ -6682,6 +6715,7 @@ exports.setInnerText = function(el, innerText) {
};
exports.getInnerText = function(el) {
var document = el.ownerDocument;
if (document.body && "textContent" in document.body)
return el.textContent;
else
@ -14560,11 +14594,11 @@ var RenderLoop = require("ace/renderloop").RenderLoop;
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var editorCss = require("text!ace/css/editor.css");
// import CSS once
dom.importCssString(editorCss);
var VirtualRenderer = function(container, theme) {
this.container = container;
// Imports CSS once per DOM document ('ace_editor' serves as an identifier).
dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
dom.addCssClass(this.container, "ace_editor");
this.setTheme(theme);
@ -14642,7 +14676,10 @@ var VirtualRenderer = function(container, theme) {
height : 1
};
this.$loop = new RenderLoop(this.$renderChanges.bind(this));
this.$loop = new RenderLoop(
this.$renderChanges.bind(this),
this.container.ownerDocument.defaultView
);
this.$loop.schedule(this.CHANGE_FULL);
this.setPadding(4);
@ -15307,6 +15344,12 @@ var VirtualRenderer = function(container, theme) {
}
function afterLoad(theme) {
dom.importCssString(
theme.cssText,
theme.cssClass,
_self.container.ownerDocument
);
if (_self.$theme)
dom.removeCssClass(_self.container, _self.$theme);
@ -15734,6 +15777,7 @@ exports.Marker = Marker;
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
* Mihai Sucan <mihai.sucan@gmail.com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -15832,8 +15876,8 @@ var Text = function(parentEl) {
// Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n);
if (document.body) {
document.body.appendChild(measureNode);
if (this.element.ownerDocument.body) {
this.element.ownerDocument.body.appendChild(measureNode);
} else {
var container = this.element.parentNode;
while (!dom.hasCssClass(container, "ace_editor"))
@ -15968,7 +16012,7 @@ var Text = function(parentEl) {
};
this.$renderLinesFragment = function(config, firstRow, lastRow) {
var fragment = document.createDocumentFragment(),
var fragment = this.element.ownerDocument.createDocumentFragment(),
row = firstRow,
fold = this.session.getNextFold(row),
foldStart = fold ?fold.start.row :Infinity;
@ -16442,6 +16486,7 @@ exports.Cursor = Cursor;
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -16478,7 +16523,7 @@ var ScrollBar = function(parent) {
// of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed
this.width = dom.scrollbarWidth();
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.element.style.width = (this.width || 15) + 5 + "px";
event.addListener(this.element, "scroll", this.onScroll.bind(this));
@ -16533,6 +16578,7 @@ exports.ScrollBar = ScrollBar;
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -16552,10 +16598,11 @@ define('ace/renderloop', ['require', 'exports', 'module' , 'pilot/event'], funct
var event = require("pilot/event");
var RenderLoop = function(onRender) {
var RenderLoop = function(onRender, window) {
this.onRender = onRender;
this.pending = false;
this.changes = 0;
this.setTimeoutZero = this.setTimeoutZero.bind(window);
};
(function() {
@ -16583,31 +16630,31 @@ var RenderLoop = function(onRender) {
window.msRequestAnimationFrame;
if (this.setTimeoutZero) {
this.setTimeoutZero = this.setTimeoutZero.bind(window)
this.setTimeoutZero = this.setTimeoutZero;
} else if (window.postMessage) {
this.messageName = "zero-timeout-message";
this.setTimeoutZero = (function(messageName, attached, listener) {
return function setTimeoutZero(callback) {
// Set up listener if not listening already.
if (!attached) {
event.addListener(this, "message", function(e) {
if (listener && e.data == messageName) {
event.stopPropagation(e);
listener();
}
});
attached = true;
}
this.setTimeoutZero = function(callback) {
if (!this.attached) {
var _self = this;
event.addListener(window, "message", function(e) {
if (_self.callback && e.data == _self.messageName) {
event.stopPropagation(e);
_self.callback();
}
});
this.attached = true;
}
this.callback = callback;
window.postMessage(this.messageName, "*");
}
listener = callback;
this.postMessage(messageName, "*");
};
})("zero-timeout-message", false, null);
} else {
this.setTimeoutZero = function(callback) {
setTimeout(callback, 0);
this.setTimeout(callback, 0);
}
}
@ -16652,11 +16699,11 @@ exports.RenderLoop = RenderLoop;
*
* ***** END LICENSE BLOCK ***** */
define('ace/theme/textmate', ['require', 'exports', 'module' , 'pilot/dom'], function(require, exports, module) {
define('ace/theme/textmate', ['require', 'exports', 'module' ], function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-tm .ace_editor {\
exports.cssClass = "ace-tm";
exports.cssText = ".ace-tm .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@ -16823,10 +16870,6 @@ define('ace/theme/textmate', ['require', 'exports', 'module' , 'pilot/dom'], fun
color: rgb(255, 0, 0)\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tm";
});
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****

File diff suppressed because one or more lines are too long