blob: b8c85056a951afe2654ba5578a6c1251a1bca19e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>A Code Editor</title>
<script src="jquery-1.2.1.js"></script>
<script src="testcode.js"></script>
<script src="ace2.js"></script>
<script>
$(document).ready(function() {
var editor = new Ace2Editor();
editor.init("editorcontainer", getTestCode(), editorReady);
editor.setOnKeyPress(function (evt) {
if (evt.ctrlKey && evt.which == "s".charCodeAt(0)) {
alert("You tried to save.");
return false;
}
return true;
});
function editorReady() {
resizeEditor();
$(window).bind("resize", resizeEditor);
setTimeout(function() {editor.focus();}, 0);
}
function resizeEditor() {
$("#editorcontainer").get(0).style.height = "100%";
editor.getFrame().style.height = ((document.documentElement.clientHeight)-1)+"px";
editor.adjustSize();
}
});
</script>
<style>
html { overflow: hidden } /* for Win IE 6 */
body { margin:0; padding:0; border:0; overflow: hidden; }
#editorcontainer { height: 1000px; /* changed programmatically */ }
#editorcontainer iframe { width: 100%; height: 100%; border:0; padding:0; margin:0; }
</style>
</head>
<body>
<div id="editorcontainer"><!-- --></div>
</body>
</html>
|