diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-24 20:57:41 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-24 20:57:41 -0500 |
| commit | 612561818f907f0f9988247c82ec158ba4494986 (patch) | |
| tree | 8bbc773dad7a6364cbdb8aed2ef4cab04854f49a /StoneIsland/platforms/ios/www/js/lib/_router.js | |
| parent | d548a7d02ce6349ca9a820b6824e4374b759812b (diff) | |
build
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/_router.js')
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/lib/_router.js | 106 |
1 files changed, 69 insertions, 37 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js index 08b8b819..b70d9be8 100644 --- a/StoneIsland/platforms/ios/www/js/lib/_router.js +++ b/StoneIsland/platforms/ios/www/js/lib/_router.js @@ -4,20 +4,48 @@ var SiteRouter = Router.extend({ routeByHash: true, routes: { - '/': 'intro', - '/intro': 'intro', - '/store': 'store', - '/hub': 'hub', - '/story': 'story', - '/archive': 'archive', + '/': 'intro', + '/intro': 'intro', + '/hub': 'hub', + '/story': 'story', + '/archive': 'archive', - '/faq': 'faq', - '/search': 'search', + '/store': 'collection', + '/store/closed': 'closed', + '/store/:code': 'product', - '/cart': 'cart', + '/account/login': 'login', + '/account/logout': 'logout', + '/account/signup': 'signup', + '/account/profile': 'profile', + '/account/payment': 'payment', + '/account/shipping': 'shipping', + '/account/orders': 'orders', + '/account/settings': 'settings', + + '/page/terms': 'terms', + '/page/privacy': 'privacy', + '/page/returns': 'returns', + '/page/care': 'care', + + '/search': 'search', + + '/cart': 'cart.summary', + '/cart/summary': 'cart.summary', + '/cart/payment': 'cart.payment', + '/cart/shipping': 'cart.shipping', + '/cart/confirm': 'cart.confirm', + '/cart/thanks': 'cart.thanks', }, initialize: function(){ + var fn + for (var route in this.routes) { + fn = this.routes[route] + if (! this[fn]) { + this[fn] = this.default_view(fn) + } + } }, go: function(url){ @@ -27,35 +55,39 @@ var SiteRouter = Router.extend({ window.location.href = "#/" + url this.parseRoute(url) }, + + default_view: function(name){ + var fn = function(){ + console.log(name) + if (app.view != app.login && app.view != app.signin) { + app.last_view = app.view + } + if (app.view && app.view.hide) { + app.view.hide() + } + if (name.match(/\./)) { + var n = name.split(".") + console.log(name, n) + app.view = app[n[0]][n[1]] + } + else { + app.view = app[name] + } + app.header.set_back( !! app.view.back ) + app.view.show() + }.bind(this) + return fn + }, - intro: function(){ - app.view = app.intro - app.intro.show() - }, - - store: function(){ - app.view = app.store - app.collection.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() + product: function(code){ + if (app.view && app.view.hide) { + app.view.hide() + } + app.view = app.product + app.header.set_back( true ) + app.product.load(code) + app.product.show() }, }) + |
