Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactor backbone structure and get back to mockup view

  • Loading branch information...
commit 209705923c8c78130850fad0b7c4366f0a7234df 1 parent 52152dc
@minism authored
View
4 static/app/app.js
@@ -2,7 +2,9 @@
function init()
{
// Load application view
- $('#app-container').html(new app.views.ApplicationView().render().$el);
+ var appView = new app.views.ApplicationView({
+ el: '#app-container',
+ }).render();
}
// All js files inject into app namespace
View
14 static/app/loader.js
@@ -1,14 +0,0 @@
-/* Cached template loader */
-
-var template_cache = {}
-
-function loadTemplate()
-{
- return "Template!"
-}
-
-
-// Namespace
-app.loader = {
- loadTemplate: loadTemplate
-}
View
39 static/app/views.js
@@ -1,26 +1,29 @@
var ApplicationView = Backbone.View.extend({
+ initialize: function() {
+ // Setup global window events
+ $(window).resize(this.fixLayout);
+ },
+
render: function() {
- this.$el.html("Hello!");
- return this;
- }
-})
+ // Load template
+ this.$el.html($('#Application-template').html());
+ this.fixLayout();
- // Setup resize callback
- // $(window).resize(fix_size);
+ // Load editor
+ this.editor = ace.edit("editor");
+ this.editor.setShowPrintMargin(false);
+ this.editor.renderer.setShowGutter(false);
+
+ return this;
+ },
- // // Load editor
- // var editor = ace.edit("editor");
- // editor.setShowPrintMargin(false);
- // editor.renderer.setShowGutter(false);
- // fix_size();
+ fixLayout: function() {
+ var height = window.innerHeight - $('#menu').height();
+ this.$('.fullscreen').css('height', height);
+ this.$('#editor').css('height', height);
+ },
-// Callback on window resize to fix layout
-// function fix_size()
-// {
-// var height = window.innerHeight - $('#menu').height();
-// $('.fullscreen').css('height', height);
-// $('#editor').css('height', height);
-// }
+});
// Namespace
View
4 templates/napkin/main.html
@@ -30,9 +30,11 @@
<script src="{{STATIC_URL}}app/views.js"></script>
<script src="{{STATIC_URL}}app/models.js"></script>
<script src="{{STATIC_URL}}app/collections.js"></script>
-<script src="{{STATIC_URL}}app/loader.js"></script>
<script src="{{STATIC_URL}}app/utils.js"></script>
+<!-- Load templates -->
+{% include "napkin/templates/application.html" %}
+
<script>
$(function() {
// Document loaded, initialize backbone app
View
10 static/app/templates/app.html → templates/napkin/templates/application.html
@@ -1,3 +1,5 @@
+<script type="text/template" id="Application-template">
+
<div class="fullscreen pane-container">
<div id="pane1" class="pane pane-scroll">
@@ -9,7 +11,7 @@
<li class="divider"></li>
<li>
- <a href="#"><i class="icon-tag" style="red">Tag</a>
+ <a href="#"><i class="icon-tag" style="red"></i>Tag</a>
</li>
<li class="divider"></li>
@@ -25,7 +27,7 @@
<a href="#"><i class="icon-file"></i>Document</a>
</li>
</ul>
- </div>
+ </div>
</div>
<!-- Statically positioned elements -->
@@ -50,4 +52,6 @@
<div id="status" class="pull-right">
Status
</div>
-</div>
+</div>
+
+</script>
Please sign in to comment.
Something went wrong with that request. Please try again.