Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 3bd76ec04b014b490b5b2de1918e62f928b0be15 1 parent 4b3fff6
@toolness authored
View
5 index.html
@@ -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
8 js/order.js
@@ -0,0 +1,8 @@
+/*
+ RequireJS order 1.0.5 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ Available via the MIT or new BSD license.
+ see: http://github.com/jrburke/requirejs for details
+*/
+(function(){function k(a){var b=a.currentTarget||a.srcElement,c;if(a.type==="load"||l.test(b.readyState)){a=b.getAttribute("data-requiremodule");j[a]=!0;for(a=0;c=g[a];a++)if(j[c.name])c.req([c.name],c.onLoad);else break;a>0&&g.splice(0,a);setTimeout(function(){b.parentNode.removeChild(b)},15)}}function m(a){var b,c;a.setAttribute("data-orderloaded","loaded");for(a=0;c=h[a];a++)if((b=i[c])&&b.getAttribute("data-orderloaded")==="loaded")delete i[c],require.addScriptToDom(b);else break;a>0&&h.splice(0,
+a)}var f=typeof document!=="undefined"&&typeof window!=="undefined"&&document.createElement("script"),n=f&&(f.async||window.opera&&Object.prototype.toString.call(window.opera)==="[object Opera]"||"MozAppearance"in document.documentElement.style),o=f&&f.readyState==="uninitialized",l=/^(complete|loaded)$/,g=[],j={},i={},h=[],f=null;define({version:"1.0.5",load:function(a,b,c,e){var d;b.nameToUrl?(d=b.nameToUrl(a,null),require.s.skipAsync[d]=!0,n||e.isBuild?b([a],c):o?(e=require.s.contexts._,!e.urlFetched[d]&&
+!e.loaded[a]&&(e.urlFetched[d]=!0,require.resourcesReady(!1),e.scriptCount+=1,d=require.attach(d,e,a,null,null,m),i[a]=d,h.push(a)),b([a],c)):b.specified(a)?b([a],c):(g.push({name:a,req:b,onLoad:c}),require.attach(d,null,a,k,"script/cache"))):b([a],c)}})})();
View
11 js/ui/codemirror.js
@@ -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;
+});
View
2  js/ui/indexable-codemirror.js
@@ -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
9 test/index.html
@@ -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
2  test/test-help.js
@@ -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) {
View
2  test/test-indexable-codemirror.js
@@ -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) {
View
2  test/test-live-preview.js
@@ -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
12 test/test-main.js
@@ -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;
View
5 test/test-mark-tracker.js
@@ -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) {
View
2  test/test-parsing-codemirror.js
@@ -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
2  test/test-publisher.js
@@ -1,4 +1,4 @@
-require(["../js/publisher"], function(Publisher) {
+require(["publisher"], function(Publisher) {
module("Publisher");
fixDoctypeHeadBodyMunging = Publisher._fixDoctypeHeadBodyMunging;
Please sign in to comment.
Something went wrong with that request. Please try again.