Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed Jan 5, 2012
0 parents commit 60b9c27
Show file tree
Hide file tree
Showing 702 changed files with 72,849 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
npm-debug.log
node_modules/**/out
node_modules/**/build
75 changes: 75 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Change *namespace* to your namespace!
// This contains the module definition factory function, application state,
// events, and the router.
this.namespace = {
// Assist with code organization, by breaking up logical components of code
// into modules.
module: function() {
// Internal module cache.
var modules = {};

// Create a new module reference scaffold or load an existing module.
return function(name) {
// If this module has already been created, return it.
if (modules[name]) {
return modules[name];
}

// Create a module and save it under this name
return modules[name] = { Views: {} };
};
}(),

// Keep active application instances namespaced under an app object.
app: _.extend({}, Backbone.Events)
};

// 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.
jQuery(function($) {

// Shorthand the application namespace
var app = namespace.app;

// All navigation that is relative should be passed through the navigate
// method, to be processed by the router.
$(document).delegate("a", "click", function(evt) {
// Get the anchor href and protcol
var href = $(this).attr("href");
var protocol = this.protocol + "//";

// Ensure the protocol is not part of URL, meaning its relative.
if (href.slice(protocol.length) !== protocol) {
// Stop the event bubbling to ensure the link will not cause a page
// refresh.
evt.preventDefault();

// Note by using Backbone.history.navigate, router events will not be
// triggered. If this is a problem, change this to navigate on your
// router.
app.router.navigate(href, true);
}
});

// Defining the application router, you can attach sub routers here, but
// typically if you're going to work with more than one router, you will
// use something like backbone.routemanager.
var Router = Backbone.Router.extend({
routes: {
"": "index"
},

index: function() {
//alert("Welcome to the homepage");
}
});

// Define your master router on the application namespace and trigger all
// navigation from this instance.
app.router = new Router();

// Trigger the initial route and enable HTML5 History API support
Backbone.history.start({ pushState: true });

});
34 changes: 34 additions & 0 deletions app/modules/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Use an IIFE...
// (http://benalman.com/news/2010/11/immediately-invoked-function-expression/)
// to assign your module reference to a local variable, in this case Example.
//
// Change line 16 'Example' to the name of your module, and change line 34 to
// the lowercase version of your module name. Then change the namespace
// for all the Models/Collections/Views/Routers to use your module name.
//
// For example: Renaming this to use the module name: Project
//
// Line 16: (function(Project) {
// Line 34: })(namespace.module("project"));
//
// Line 18: Project.Model = Backbone.Model.extend({
//
(function(Example) {

Example.Model = Backbone.Model.extend({
/* ... */
});

Example.Collection = Backbone.Collection.extend({
/* ... */
});

Example.Views.Detailed = Backbone.View.extend({
/* ... */
});

Example.Router = Backbone.Router.extend({
/* ... */
});

})(namespace.module("example"));
1 change: 1 addition & 0 deletions app/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
1 change: 1 addition & 0 deletions app/templates/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testing out the underscore template stuff...
Loading

0 comments on commit 60b9c27

Please sign in to comment.