summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/_router.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-09 00:12:36 -0500
committerJules Laplace <jules@okfoc.us>2015-11-09 00:12:36 -0500
commit8524ed64401bd53dce1b5412fb732c9667a66ecc (patch)
treecfce88e504427fa0aa44de212fb0145f773450f1 /StoneIsland/www/js/lib/_router.js
parent069e15c10ed10b45673c2365f78fe8918753f19d (diff)
default view loading semantics
Diffstat (limited to 'StoneIsland/www/js/lib/_router.js')
-rw-r--r--StoneIsland/www/js/lib/_router.js73
1 files changed, 33 insertions, 40 deletions
diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js
index 8a117e39..344755e8 100644
--- a/StoneIsland/www/js/lib/_router.js
+++ b/StoneIsland/www/js/lib/_router.js
@@ -4,22 +4,36 @@ var SiteRouter = Router.extend({
routeByHash: true,
routes: {
- '/': 'intro',
- '/intro': 'intro',
- '/hub': 'hub',
- '/story': 'story',
- '/archive': 'archive',
+ '/': 'intro',
+ '/intro': 'intro',
+ '/hub': 'hub',
+ '/story': 'story',
+ '/archive': 'archive',
- '/store': 'store',
- '/store/:code': 'product',
+ '/store': 'collection',
+ '/store/:code': 'product',
- '/faq': 'faq',
- '/search': 'search',
+ '/account/login': 'login',
+ '/account/logout': 'logout',
+ '/account/signup': 'signup',
+ '/account/profile': 'profile',
+ '/account/billing': 'billing',
+ '/account/shipping': 'shipping',
- '/cart': 'cart',
+ '/faq': 'faq',
+ '/search': 'search',
+
+ '/cart': 'cart',
},
initialize: function(){
+ var fn
+ for (var route in this.routes) {
+ fn = this.routes[route]
+ if (! this.hasOwnProperty(fn)) {
+ this[fn] = this.default_view(fn)
+ }
+ }
},
go: function(url){
@@ -29,41 +43,20 @@ var SiteRouter = Router.extend({
window.location.href = "#/" + url
this.parseRoute(url)
},
+
+ default_view: function(name){
+ var fn = function(){
+ console.log(name)
+ app.view = app[name]
+ app[name].show()
+ }.bind(this)
+ return fn
+ },
- intro: function(){
- app.view = app.intro
- app.intro.show()
- },
-
- store: function(){
- app.view = app.store
- app.collection.show()
- },
-
product: function(code){
app.view = app.product
app.product.load(code)
app.product.show()
},
-
- hub: function(){
- app.view = app.hub
- app.hub.show()
- },
-
- story: function(){
- app.view = app.story
- app.story.show()
- },
-
- archive: function(){
- app.view = app.archive
- app.archive.show()
- },
-
- cart: function(){
- app.view = app.cart
- app.cart.show()
- },
})