diff options
Diffstat (limited to 'StoneIsland/www/js/lib/account/AccountView.js')
| -rw-r--r-- | StoneIsland/www/js/lib/account/AccountView.js | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js index c72a2a40..c6f68e88 100644 --- a/StoneIsland/www/js/lib/account/AccountView.js +++ b/StoneIsland/www/js/lib/account/AccountView.js @@ -1,15 +1,18 @@ var AccountView = View.extend({ initialize: function(){ - auth.init(this.ready.bind(this)) }, - ready: function(){ + connect: function(cb){ + auth.init(this.ready.bind(this, cb)) + }, + + ready: function(cb){ if (auth.logged_in()) { - this.logged_in() + this.logged_in(cb) } else { - this.logged_out() + this.logged_out(cb) } }, @@ -19,27 +22,41 @@ var AccountView = View.extend({ console.log("no addresses") return } - data.AddressBook.forEach(function(address){ - if (addressBookItem.isDefault) { + // console.log(data.AddressBook) + data.AddressBook.addressBookItem.forEach(function(item){ + if (item.isDefault) { // populate app.shipping.address } - else if (addressBookItem.isBillingDefault) { + else if (item.isBillingDefault) { // populate app.billing.address } }) }, - logged_in: function(){ + logged_in: function(cb){ sdk.address.list({ success: this.populateAddresses.bind(this) }) $("#nav .login").hide() $("#nav .account, #nav .logout").show() + if (app.last_view && app.last_view != app.login && app.last_view != app.signin && app.last_view != app.logout) { + app.view && app.view.hide && app.view.hide() + app.view = app.last_view + app.view.show() + } + else { + cb && cb() + } + if (auth.deferred_product) { + auth.add_deferred_product_to_cart() + } }, - logged_out: function(){ + logged_out: function(cb){ $("#nav .login").show() $("#nav .account, #nav .logout").hide() + $("#nav").removeClass("account") + cb && cb() }, }) |
