Skip to content
Browse files

load entire app through require.js

  • Loading branch information...
1 parent 6a24675 commit 8bfbeb862e2e9fbe52c138fce689bee846351538 @JustinTulloss committed
Showing with 23 additions and 21 deletions.
  1. +9 −20 static/js/application.js
  2. +13 −0 static/js/bootstrap.js
  3. +1 −1 templates/layout.html
View
29 static/js/application.js
@@ -1,5 +1,5 @@
-(function($, _) {
+define(function() {
// This is an instance of File class that can be written
var current_file;
var current_dir;
@@ -187,24 +187,6 @@
});
}
- var setup = function() {
- window.ace = ace;
- hookup_controls();
- focus_editor();
- start_converting();
- load_readme();
- }
-
- $(function() {
- require.config({
- baseUrl: "/static/js/lib",
- });
- require(['ace/ace', '/static/js/lib/markdown.js'], function(ace) {
- window.ace = ace;
- setup();
- });
- });
-
function doNothing() {}
function errorWrapper(callback) {
@@ -452,4 +434,11 @@
}
}
});
-})(jQuery, _);
+
+ return function() {
+ hookup_controls();
+ focus_editor();
+ start_converting();
+ load_readme();
+ };
+});
View
13 static/js/bootstrap.js
@@ -0,0 +1,13 @@
+require.config({
+ baseUrl: "/static/js",
+ paths: {
+ ace: 'lib/ace'
+ }
+});
+
+$(function() {
+ require(['application', 'ace/ace', '/static/js/lib/markdown.js'], function(app, ace) {
+ window.ace = ace;
+ app();
+ });
+});
View
2 templates/layout.html
@@ -7,6 +7,6 @@
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js"></script>
<script type="text/javascript" src="/static/js/lib/require.js"></script>
- <script type="text/javascript" src="/static/js/application.js"></script>
+ <script type="text/javascript" src="/static/js/bootstrap.js"></script>
{% block body %}{% endblock %}
</div>

0 comments on commit 8bfbeb8

Please sign in to comment.
Something went wrong with that request. Please try again.