restore ie8 compatibility
This commit is contained in:
parent
6c235fee7d
commit
051128c16f
5 changed files with 34 additions and 12 deletions
|
|
@ -161,7 +161,12 @@ function highlight() {
|
||||||
var highlighter = ace.require("ace/ext/static_highlight")
|
var highlighter = ace.require("ace/ext/static_highlight")
|
||||||
var dom = ace.require("ace/lib/dom")
|
var dom = ace.require("ace/lib/dom")
|
||||||
function qsa(sel) {
|
function qsa(sel) {
|
||||||
return [].slice.call(document.querySelectorAll(sel));
|
var items = document.querySelectorAll(sel);
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
result.push(items[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsa("code[class]").forEach(function(el) {
|
qsa("code[class]").forEach(function(el) {
|
||||||
|
|
|
||||||
11
index.html
11
index.html
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
<script src="./build/src-min/ace.js"></script>
|
<script src="./build/src-min/ace.js"></script>
|
||||||
<script src="./build/src-min/ext-static_highlight.js"></script>
|
<script src="./build/src-min/ext-static_highlight.js"></script>
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="./build/src-min/ext-old_ie.js"></script>
|
||||||
|
<![endif]-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a href="http://github.com/ajaxorg/ace">
|
<a href="http://github.com/ajaxorg/ace">
|
||||||
|
|
@ -65,7 +68,7 @@
|
||||||
and is the successor of the Mozilla Skywriter (Bespin) project.
|
and is the successor of the Mozilla Skywriter (Bespin) project.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="ace_editor_demo" style="opacity:0">/**
|
<pre id="ace_editor_demo" style="opacity:0">/**
|
||||||
* In fact, you're looking at ACE right now. Go ahead and play with it!
|
* In fact, you're looking at ACE right now. Go ahead and play with it!
|
||||||
*
|
*
|
||||||
* We are currently showing off the JavaScript mode. ACE has support for 45
|
* We are currently showing off the JavaScript mode. ACE has support for 45
|
||||||
|
|
@ -80,7 +83,7 @@ function add(x, y) {
|
||||||
|
|
||||||
var addResult = add(3, 2);
|
var addResult = add(3, 2);
|
||||||
console.log(addResult);
|
console.log(addResult);
|
||||||
</div>
|
</pre>
|
||||||
<p id="embed_link"><a href="#nav=embedding">Learn how to embed this in your own site</a></p>
|
<p id="embed_link"><a href="#nav=embedding">Learn how to embed this in your own site</a></p>
|
||||||
<p class="highlight_note">Looking for a more full-featured demo? Check out the
|
<p class="highlight_note">Looking for a more full-featured demo? Check out the
|
||||||
<a href="build/kitchen-sink.html" target="_blank">kitchen sink</a>.
|
<a href="build/kitchen-sink.html" target="_blank">kitchen sink</a>.
|
||||||
|
|
@ -140,7 +143,7 @@ console.log(addResult);
|
||||||
<h1>Embedding Ace in Your Site</h1>
|
<h1>Embedding Ace in Your Site</h1>
|
||||||
<p>Ace can be easily embedded into a web page. Get prebuilt version of ace from
|
<p>Ace can be easily embedded into a web page. Get prebuilt version of ace from
|
||||||
<a href="https://github.com/ajaxorg/ace-builds/">ace-builds</a> repository and use the code below:</p>
|
<a href="https://github.com/ajaxorg/ace-builds/">ace-builds</a> repository and use the code below:</p>
|
||||||
<div id="embedded_ace_code" style="opacity:0"><!DOCTYPE html>
|
<pre id="embedded_ace_code" style="opacity:0"><!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>ACE in Action</title>
|
<title>ACE in Action</title>
|
||||||
|
|
@ -168,7 +171,7 @@ console.log(addResult);
|
||||||
editor.getSession().setMode("ace/mode/javascript");
|
editor.getSession().setMode("ace/mode/javascript");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html></div>
|
</html></pre>
|
||||||
<p>Now check out the <a href="#nav=howto">How-To Guide</a> for instructions on
|
<p>Now check out the <a href="#nav=howto">How-To Guide</a> for instructions on
|
||||||
common operations, such as setting a different language mode or
|
common operations, such as setting a different language mode or
|
||||||
getting the contents from the editor.
|
getting the contents from the editor.
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,12 @@ patch(
|
||||||
}"
|
}"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
patch(
|
||||||
|
require("ace/mode/text").Mode.prototype, "getTokenizer",
|
||||||
|
/Tokenizer/,
|
||||||
|
"TokenizerModule.Tokenizer"
|
||||||
|
);
|
||||||
|
|
||||||
useragent.isOldIE = true;
|
useragent.isOldIE = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
require("ace/lib/fixoldbrowsers");
|
||||||
|
|
||||||
var themeData = [
|
var themeData = [
|
||||||
["Chrome" ],
|
["Chrome" ],
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
||||||
|
|
||||||
if (!CHAR_COUNT)
|
if (!CHAR_COUNT)
|
||||||
this.$testFractionalRect();
|
this.$testFractionalRect();
|
||||||
this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT);
|
this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
|
||||||
|
|
||||||
this.$characterSize = {width: 0, height: 0};
|
this.$characterSize = {width: 0, height: 0};
|
||||||
this.checkForSizeChanges();
|
this.checkForSizeChanges();
|
||||||
|
|
@ -121,11 +121,18 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$measureSizes = function() {
|
this.$measureSizes = function() {
|
||||||
var rect = this.$measureNode.getBoundingClientRect();
|
if (CHAR_COUNT === 1) {
|
||||||
var size = {
|
var rect = this.$measureNode.getBoundingClientRect();
|
||||||
height: rect.height,
|
var size = {
|
||||||
width: rect.width / CHAR_COUNT
|
height: rect.height,
|
||||||
};
|
width: rect.width
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
var size = {
|
||||||
|
height: this.$measureNode.clientHeight,
|
||||||
|
width: this.$measureNode.clientWidth / CHAR_COUNT
|
||||||
|
};
|
||||||
|
}
|
||||||
// Size and width can be null if the editor is not visible or
|
// Size and width can be null if the editor is not visible or
|
||||||
// detached from the document
|
// detached from the document
|
||||||
if (size.width === 0 || size.height === 0)
|
if (size.width === 0 || size.height === 0)
|
||||||
|
|
@ -134,7 +141,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$measureCharWidth = function(ch) {
|
this.$measureCharWidth = function(ch) {
|
||||||
this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT);
|
this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
|
||||||
var rect = this.$main.getBoundingClientRect();
|
var rect = this.$main.getBoundingClientRect();
|
||||||
return rect.width / CHAR_COUNT;
|
return rect.width / CHAR_COUNT;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue