diff options
| author | Rene Ae <aehtyb@gmail.com> | 2015-12-04 20:32:44 -0600 |
|---|---|---|
| committer | Rene Ae <aehtyb@gmail.com> | 2015-12-04 20:32:44 -0600 |
| commit | 10efb0f7b426426057fed757fe3c851a249358dd (patch) | |
| tree | b80e285251d30fbca36220c932ef180c29c55dcf /StoneIsland/platforms/android/assets/www/js/lib/_router.js | |
| parent | 015b58ff6845b5cb79b13fec109a37b4c10c7813 (diff) | |
android build
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/_router.js')
| -rwxr-xr-x | StoneIsland/platforms/android/assets/www/js/lib/_router.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/_router.js b/StoneIsland/platforms/android/assets/www/js/lib/_router.js new file mode 100755 index 00000000..b1fa1c97 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/_router.js @@ -0,0 +1,105 @@ +var SiteRouter = Router.extend({ + + el: 'body', + routeByHash: true, + + routes: { + '/': 'intro', + '/intro': 'intro', + '/hub': 'hub', + '/story': 'story', + '/archive': 'archive', + + '/store': 'collection', + '/store/closed': 'closed', + '/store/:code': 'product', + + '/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', + '/cart/error': 'cart.error', + }, + + initialize: function(){ + var fn + for (var route in this.routes) { + fn = this.routes[route] + if (! this[fn]) { + this[fn] = this.default_view(fn) + } + } + }, + + initial_route: null, + launch: function(){ + if (this.initial_route) { + this.parseRoute( this.initial_route ) + } + else { + this.route() + } + this.initial_route = null + }, + + go: function(url){ + if (app.view && app.view.hide) { + app.view.hide() + } + 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 + }, + + 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() + }, + +}) + |
