forked from tbranyen/backbone-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 60b9c27
Showing
702 changed files
with
72,849 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
npm-debug.log | ||
node_modules/**/out | ||
node_modules/**/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing out the underscore template stuff... |
Oops, something went wrong.