Skip to content

Commit

Permalink
Upgrade to CodeMirror 4.6
Browse files Browse the repository at this point in the history
Everything works, except for autocomplete.  More cleanup and testing needed.
  • Loading branch information
mramato committed Oct 15, 2014
1 parent 8abc4e3 commit 5c2653d
Show file tree
Hide file tree
Showing 480 changed files with 69,928 additions and 18,161 deletions.
11 changes: 7 additions & 4 deletions Apps/Sandcastle/CesiumSandcastle.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ a.linkButton:focus, a.linkButton:hover {
background-color: #9ED3FF !important;
}

.CodeMirror pre.errorMarker {
.gutter {
}

.errorMarker {
color: #222;
font-weight: bold;
background: #F42;
Expand All @@ -202,7 +205,7 @@ a.linkButton:focus, a.linkButton:hover {
background: rgba(200, 50, 0, 0.2);
}

.CodeMirror pre.hintMarker {
.hintMarker {
color: #222;
font-weight: bold;
background: #FE2;
Expand All @@ -213,7 +216,7 @@ a.linkButton:focus, a.linkButton:hover {
background: rgba(200, 200, 0, 0.2);
}

.CodeMirror pre.highlightMarker {
.highlightMarker {
color: #222;
font-weight: bold;
background: #2E2;
Expand All @@ -224,7 +227,7 @@ a.linkButton:focus, a.linkButton:hover {
background: rgba(0, 200, 0, 0.2);
}

.CodeMirror pre.searchMarker {
.searchMarker {
color: #222;
font-weight: bold;
background: #CEF;
Expand Down
62 changes: 36 additions & 26 deletions Apps/Sandcastle/CesiumSandcastle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ require({
}, {
name : 'Source',
location : '.'
}, {
name : 'CodeMirror',
location : '../ThirdParty/codemirror-4.6'
}]
}, [
'dijit/layout/ContentPane',
Expand All @@ -33,6 +36,13 @@ require({
'dojo/query',
'Sandcastle/LinkButton',
'Source/Cesium',
'CodeMirror/lib/codemirror',
'CodeMirror/addon/hint/show-hint',
'CodeMirror/addon/hint/javascript-hint',
'CodeMirror/mode/javascript/javascript',
'CodeMirror/mode/css/css',
'CodeMirror/mode/xml/xml',
'CodeMirror/mode/htmlmixed/htmlmixed',
'dijit/form/Button',
'dijit/form/DropDownButton',
'dijit/form/ToggleButton',
Expand Down Expand Up @@ -64,7 +74,8 @@ require({
parser,
query,
LinkButton,
Cesium) {
Cesium,
CodeMirror) {
"use strict";

//In order for CodeMirror auto-complete to work, Cesium needs to be defined as a global.
Expand Down Expand Up @@ -247,14 +258,12 @@ require({
docTimer = window.setTimeout(showDocPopup, 500);
}

var abbrDiv = document.createElement('div');
var abbrEle = document.createElement('abbr');
abbrEle.textContent = '%N%';
abbrDiv.appendChild(abbrEle);

function makeLineLabel(msg) {
abbrEle.title = msg;
return abbrDiv.innerHTML;
function makeLineLabel(msg, className) {
var element = document.createElement('abbr');
element.textContent = '!';
element.className = className;
element.title = msg;
return element;
}

function closeGalleryTooltip() {
Expand Down Expand Up @@ -307,21 +316,21 @@ require({
closeGalleryTooltip();
while (errorLines.length > 0) {
line = errorLines.pop();
jsEditor.setLineClass(line, null);
jsEditor.clearMarker(line);
jsEditor.removeLineClass(line, 'text');
jsEditor.clearGutter(line);
}
while (highlightLines.length > 0) {
line = highlightLines.pop();
jsEditor.setLineClass(line, null);
jsEditor.clearMarker(line);
jsEditor.removeLineClass(line, 'text');
jsEditor.clearGutter(line);
}
var code = jsEditor.getValue();
if (searchTerm !== '') {
var codeLines = code.split('\n');
for (i = 0, len = codeLines.length; i < len; ++i) {
if (searchRegExp.test(codeLines[i])) {
line = jsEditor.setMarker(i, makeLineLabel('Search: ' + searchTerm), 'searchMarker');
jsEditor.setLineClass(line, 'searchLine');
line = jsEditor.setGutterMarker(i, 'gutter', makeLineLabel('Search: ' + searchTerm, 'searchMarker'));
jsEditor.addLineClass(line, 'text', 'searchLine');
errorLines.push(line);
}
}
Expand All @@ -333,8 +342,8 @@ require({
for (i = 0, len = hints.length; i < len; ++i) {
var hint = hints[i];
if (hint !== null && defined(hint.reason) && hint.line > 0) {
line = jsEditor.setMarker(scriptLineToEditorLine(hint.line), makeLineLabel(hint.reason), 'hintMarker');
jsEditor.setLineClass(line, 'hintLine');
line = jsEditor.setGutterMarker(scriptLineToEditorLine(hint.line), 'gutter', makeLineLabel(hint.reason, 'hintMarker'));
jsEditor.addLineClass(line, 'text', 'hintLine');
errorLines.push(line);
}
}
Expand Down Expand Up @@ -383,13 +392,13 @@ require({
var line;
while (highlightLines.length > 0) {
line = highlightLines.pop();
jsEditor.setLineClass(line, null);
jsEditor.clearMarker(line);
jsEditor.removeLineClass(line, 'text');
jsEditor.clearGutter(line);
}
if (lineNum > 0) {
lineNum = scriptLineToEditorLine(lineNum);
line = jsEditor.setMarker(lineNum, makeLineLabel('highlighted by demo'), 'highlightMarker');
jsEditor.setLineClass(line, 'highlightLine');
line = jsEditor.setGutterMarker(lineNum, 'gutter', makeLineLabel('highlighted by demo', 'highlightMarker'));
jsEditor.addLineClass(line, 'text', 'highlightLine');
highlightLines.push(line);
scrollToLine(lineNum);
}
Expand Down Expand Up @@ -445,6 +454,7 @@ require({

jsEditor = CodeMirror.fromTextArea(document.getElementById('code'), {
mode : 'javascript',
gutters: ['gutter'],
lineNumbers : true,
matchBrackets : true,
indentUnit : 4,
Expand Down Expand Up @@ -645,7 +655,7 @@ require({
});

var parser = new DOMParser();
var doc = parser.parseFromString(demo.code, "text/html");
var doc = parser.parseFromString(demo.code, 'text/html');

var script = doc.querySelector('script[id="cesium_sandcastle_script"]');
if (!script) {
Expand Down Expand Up @@ -707,7 +717,7 @@ require({
// into the iframe, causing the demo to run there.
applyBucket();
if (docError) {
appendConsole('consoleError', "Documentation not available. Please run the 'generateDocumentation' build script to generate Cesium documentation.", true);
appendConsole('consoleError', 'Documentation not available. Please run the "generateDocumentation" build script to generate Cesium documentation.', true);
showGallery();
}
if (galleryError) {
Expand All @@ -729,8 +739,8 @@ require({
} else {
lineNumber = scriptLineToEditorLine(lineNumber);
errorMsg += (lineNumber + 1) + ')';
line = jsEditor.setMarker(lineNumber, makeLineLabel(e.data.error), 'errorMarker');
jsEditor.setLineClass(line, 'errorLine');
line = jsEditor.setGutterMarker(lineNumber, 'gutter', makeLineLabel(e.data.error, 'errorMarker'));
jsEditor.addLineClass(line, 'text', 'errorLine');
errorLines.push(line);
scrollToLine(lineNumber);
}
Expand Down Expand Up @@ -909,7 +919,7 @@ require({
demo.code = value;

var parser = new DOMParser();
var doc = parser.parseFromString(value, "text/html");
var doc = parser.parseFromString(value, 'text/html');

var bucket = doc.body.getAttribute('data-sandcastle-bucket');
demo.bucket = bucket ? bucket : 'bucket-requirejs.html';
Expand Down
11 changes: 2 additions & 9 deletions Apps/Sandcastle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Cesium Sandcastle</title>
<link rel="stylesheet" href="../../ThirdParty/CodeMirror-2.24/lib/codemirror.css">
<link rel="stylesheet" href="../../ThirdParty/codemirror-4.6/lib/codemirror.css">
<link rel="stylesheet" href="CesiumSandcastle.css">
<script>
if (window.location.protocol === 'file:') {
Expand All @@ -15,21 +15,14 @@
}
</script>
<script src="../../ThirdParty/jshint-2.1.10/jshint.js"></script>
<script src="../../ThirdParty/CodeMirror-2.24/lib/codemirror.js"></script>
<script src="../../ThirdParty/CodeMirror-2.24/mode/javascript/javascript.js"></script>
<script src="../../ThirdParty/CodeMirror-2.24/mode/css/css.js"></script>
<script src="../../ThirdParty/CodeMirror-2.24/mode/xml/xml.js"></script>
<script src="../../ThirdParty/CodeMirror-2.24/mode/htmlmixed/htmlmixed.js"></script>

<script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../ThirdParty/dojo-release-1.9.3/dojo/dojo.js"></script>

<script src="jsHintOptions.js"></script>
<script src="gallery/gallery-index.js"></script>
<script src="CesiumSandcastle.js"></script>
<!-- The next three lines are for autocomplete -->
<script src="../../ThirdParty/CodeMirror-2.24/lib/util/simple-hint.js"></script>
<link rel="stylesheet" href="../../ThirdParty/CodeMirror-2.24/lib/util/simple-hint.css">
<script src="ThirdParty/Cesium-hint.js"></script>
<link rel="stylesheet" href="../../ThirdParty/codemirror-4.6/addon/hint/show-hint.css">
<!-- End of autocomplete -->
<meta property="og:title" content="Cesium Sandcastle" />
<meta property="og:description" content="The Cesium Sandcastle provides an interactive environment for testing Cesium code." />
Expand Down
23 changes: 0 additions & 23 deletions ThirdParty/CodeMirror-2.24/LICENSE

This file was deleted.

6 changes: 0 additions & 6 deletions ThirdParty/CodeMirror-2.24/README.md

This file was deleted.

50 changes: 0 additions & 50 deletions ThirdParty/CodeMirror-2.24/demo/changemode.html

This file was deleted.

74 changes: 0 additions & 74 deletions ThirdParty/CodeMirror-2.24/demo/closetag.html

This file was deleted.

Loading

0 comments on commit 5c2653d

Please sign in to comment.