restore ie8 compatibility

This commit is contained in:
nightwing 2014-03-11 18:30:20 +04:00
commit 051128c16f
5 changed files with 34 additions and 12 deletions

View file

@ -161,7 +161,12 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
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) {

View file

@ -11,6 +11,9 @@
<script src="./build/src-min/ace.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>
<body>
<a href="http://github.com/ajaxorg/ace">
@ -65,7 +68,7 @@
and is the successor of the Mozilla Skywriter (Bespin) project.
</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!
*
* 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);
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 class="highlight_note">Looking for a more full-featured demo? Check out the
<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>
<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>
<div id="embedded_ace_code" style="opacity:0">&lt;!DOCTYPE html>
<pre id="embedded_ace_code" style="opacity:0">&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
&lt;title>ACE in Action&lt;/title>
@ -168,7 +171,7 @@ console.log(addResult);
editor.getSession().setMode("ace/mode/javascript");
&lt;/script>
&lt;/body>
&lt;/html></div>
&lt;/html></pre>
<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
getting the contents from the editor.

View file

@ -103,6 +103,12 @@ patch(
}"
);
patch(
require("ace/mode/text").Mode.prototype, "getTokenizer",
/Tokenizer/,
"TokenizerModule.Tokenizer"
);
useragent.isOldIE = true;
});

View file

@ -41,6 +41,7 @@
define(function(require, exports, module) {
"use strict";
require("ace/lib/fixoldbrowsers");
var themeData = [
["Chrome" ],

View file

@ -54,7 +54,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
if (!CHAR_COUNT)
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.checkForSizeChanges();
@ -121,11 +121,18 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
};
this.$measureSizes = function() {
var rect = this.$measureNode.getBoundingClientRect();
var size = {
height: rect.height,
width: rect.width / CHAR_COUNT
};
if (CHAR_COUNT === 1) {
var rect = this.$measureNode.getBoundingClientRect();
var size = {
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
// detached from the document
if (size.width === 0 || size.height === 0)
@ -134,7 +141,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
};
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();
return rect.width / CHAR_COUNT;
};