Permalink
Browse files

Converted CodeMirror + htmlmixed mode to be loadable as modules.

They're not *really* modules, but jslint should help ensure that nothing
is accessing the CodeMirror global that doesn't specifically cite it as
a dependency via require().
  • Loading branch information...
1 parent 4b3fff6 commit 3bd76ec04b014b490b5b2de1918e62f928b0be15 @toolness committed May 19, 2012
View
@@ -160,11 +160,6 @@
<script src="js/jquery.tipsy.js"></script>
<script src="js/underscore.min.js"></script>
<script src="js/backbone.min.js"></script>
- <script src="codemirror2/lib/codemirror.js"></script>
- <script src="codemirror2/mode/xml/xml.js"></script>
- <script src="codemirror2/mode/javascript/javascript.js"></script>
- <script src="codemirror2/mode/css/css.js"></script>
- <script src="codemirror2/mode/htmlmixed/htmlmixed.js"></script>
<script src="slowparse/spec/errors.jquery.js"></script>
<script data-main="js/main" src="js/require.min.js"></script>
</body>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,11 @@
+// This is just a convenience "wrapper" for the CodeMirror library
+// which makes it more usable with RequireJS.
+define([
+ "order!../../codemirror2/lib/codemirror.js",
+ "order!../../codemirror2/mode/xml/xml.js",
+ "order!../../codemirror2/mode/javascript/javascript.js",
+ "order!../../codemirror2/mode/css/css.js",
+ "order!../../codemirror2/mode/htmlmixed/htmlmixed.js"
+], function() {
+ return CodeMirror;
+});
@@ -2,7 +2,7 @@
// A subclass of CodeMirror which adds a few methods that make it easier
// to work with character indexes rather than {line, ch} objects.
-define(function() {
+define(["./codemirror"], function(CodeMirror) {
return function IndexableCodeMirror(place, givenOptions) {
var codeMirror = CodeMirror(place, givenOptions);
View
@@ -44,10 +44,17 @@ <h2 id="qunit-userAgent"></h2>
<script src="qunit.js"></script>
<script>QUnit.config.autostart = false;</script>
- <script src="../codemirror2/lib/codemirror.js"></script>
<script src="../js/jquery.min.js"></script>
<script src="../js/underscore.min.js"></script>
<script src="../js/backbone.min.js"></script>
<script data-main="test-main" src="../js/require.min.js"></script>
+ <script>
+ require.config({
+ baseUrl: "../js",
+ paths: {
+ "test": "../test"
+ }
+ });
+ </script>
</body>
</html>
View
@@ -1,4 +1,4 @@
-require(["../js/help", "../slowparse/slowparse"], function(Help, Slowparse) {
+require(["help", "../slowparse/slowparse"], function(Help, Slowparse) {
module("Help");
function helpAt(index, searchString, html) {
@@ -1,6 +1,6 @@
"use strict";
-require(["../js/ui/indexable-codemirror"], function(IndexableCodeMirror) {
+require(["ui/indexable-codemirror"], function(IndexableCodeMirror) {
module("IndexableCodeMirror");
function icmTest(name, cb) {
@@ -1,6 +1,6 @@
"use strict";
-require(["../js/ui/live-preview"], function(LivePreview) {
+require(["ui/live-preview"], function(LivePreview) {
module("LivePreview");
function lpTest(name, cb) {
View
@@ -1,10 +1,10 @@
require([
- "./test-help",
- "./test-indexable-codemirror",
- "./test-parsing-codemirror",
- "./test-mark-tracker",
- "./test-live-preview",
- "./test-publisher"
+ "test/test-help",
+ "test/test-indexable-codemirror",
+ "test/test-parsing-codemirror",
+ "test/test-mark-tracker",
+ "test/test-live-preview",
+ "test/test-publisher"
], function() {
if (QUnit.config.blocking)
QUnit.config.autostart = true;
@@ -1,6 +1,9 @@
"use strict";
-require(["../js/ui/mark-tracker"], function(MarkTracker) {
+require([
+ "ui/mark-tracker",
+ "ui/codemirror"
+], function(MarkTracker, CodeMirror) {
module("MarkTracker");
function mtTest(name, cb) {
@@ -1,6 +1,6 @@
"use strict";
-require(["../js/ui/parsing-codemirror"], function(ParsingCodeMirror) {
+require(["ui/parsing-codemirror"], function(ParsingCodeMirror) {
module("ParsingCodeMirror");
function pcmTest(name, cb) {
View
@@ -1,4 +1,4 @@
-require(["../js/publisher"], function(Publisher) {
+require(["publisher"], function(Publisher) {
module("Publisher");
fixDoctypeHeadBodyMunging = Publisher._fixDoctypeHeadBodyMunging;

0 comments on commit 3bd76ec

Please sign in to comment.