Permalink
Browse files

adding in tutorial and todomvc fixes

  • Loading branch information...
tbranyen committed Jun 2, 2012
1 parent 63d0876 commit a7b67b001e4fd869d1d08a369ee38d60adbfda55
@@ -1,2 +1,2 @@
-@import "style.css";
+@import "h5bp.css";
@import "todo.css";
View
@@ -60,6 +60,7 @@ module.exports = function(grunt) {
// only want to load one stylesheet in index.html.
mincss: {
"dist/release/index.css": [
+ "assets/css/h5bp.css",
"assets/css/style.css",
"assets/css/todo.css"
]
View
@@ -0,0 +1,17 @@
+exports.description = "Backbone Boilerplate Tutorial";
+exports.notes = "Generates the tutorial files.";
+
+exports.template = function(grunt, init, done) {
+
+ // Files to copy (and process).
+ var files = init.filesToCopy({});
+
+ // Actually copy (and process). files.
+ init.copyAndProcess(files, {}, {
+ noProcess: [ "assets/**", "test/**", "favicon.ico" ]
+ });
+
+ // All done!
+ done();
+
+};
View
@@ -1,49 +1,33 @@
require([
- "namespace",
+ "app",
// Libs
"jquery",
- "use!backbone",
+ "backbone",
// Modules
"modules/example"
],
-function(namespace, $, Backbone, Example) {
+function(app, $, Backbone, Example) {
// Defining the application router, you can attach sub routers here.
var Router = Backbone.Router.extend({
routes: {
- "": "index",
- ":hash": "index"
+ "": "index"
},
- index: function(hash) {
- var route = this;
+ index: function() {
var tutorial = new Example.Views.Tutorial();
// Attach the tutorial to the DOM
- tutorial.render(function(el) {
- $("#main").html(el);
+ tutorial.$el.appendTo("#main");
- // Fix for hashes in pushState and hash fragment
- if (hash && !route._alreadyTriggered) {
- // Reset to home, pushState support automatically converts hashes
- Backbone.history.navigate("", false);
-
- // Trigger the default browser behavior
- location.hash = hash;
-
- // Set an internal flag to stop recursive looping
- route._alreadyTriggered = true;
- }
- });
+ // Render the tutorial.
+ tutorial.render();
}
});
- // Shorthand the application namespace
- var app = namespace.app;
-
// Treat the jQuery ready function as the entry point to the application.
// Inside this function, kick-off all initialization, everything up to this
// point should be definitions.
@@ -1,40 +1,29 @@
define([
- "namespace",
+ "app",
// Libs
- "use!backbone"
+ "backbone"
// Modules
// Plugins
],
-function(namespace, Backbone) {
+function(app, Backbone) {
// Create a new module
var Example = namespace.module();
- // Example extendings
- Example.Model = Backbone.Model.extend({ /* ... */ });
- Example.Collection = Backbone.Collection.extend({ /* ... */ });
- Example.Router = Backbone.Router.extend({ /* ... */ });
-
// This will fetch the tutorial template and render it.
Example.Views.Tutorial = Backbone.View.extend({
- template: "app/templates/example.html",
+ template: "app/templates/example",
render: function(done) {
- var view = this;
-
- // Fetch the template, render it to the View element and call done.
- namespace.fetchTemplate(this.template, function(tmpl) {
- view.el.innerHTML = tmpl();
+ // Fetch the template.
+ var tmpl = app.fetchTemplate(this.template);
- // If a done function is passed, call it with the element
- if (_.isFunction(done)) {
- done(view.el);
- }
- });
+ // Set the template contents.
+ this.$el.html(tmpl());
}
});
@@ -1 +1,2 @@
+@import "h5bp.css";
@import "style.css";
Oops, something went wrong.

0 comments on commit a7b67b0

Please sign in to comment.