diff options
Diffstat (limited to 'StoneIsland/www/js')
| -rw-r--r-- | StoneIsland/www/js/index.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartPayment.js | 56 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/_sdk.js | 2 |
3 files changed, 49 insertions, 11 deletions
diff --git a/StoneIsland/www/js/index.js b/StoneIsland/www/js/index.js index ed8d9e5a..546bd637 100644 --- a/StoneIsland/www/js/index.js +++ b/StoneIsland/www/js/index.js @@ -69,6 +69,8 @@ var app = (function(){ app.view = null app.router = new SiteRouter () app.account.connect( app.router.route.bind(app.router) ) + + $("body").removeClass("loading") } return app diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index 90fe4a76..62dfe32d 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -2,11 +2,18 @@ var CartPayment = FormView.extend({ el: "#cart_payment", + address_template: $("#cart_payment .address_template").html(), + cc_template: $("#cart_payment .cc_template").html(), + action: sdk.cart.set_credit_card, + address_list_mode: false, + cc_list_mode: false, + events: { "change [name=same_as_shipping]": "toggle_shipping", - "click .dropdown-wrapper": "toggle_dropdown", + "click .address_dropdown": "toggle_address", + "click .cc_dropdown": "toggle_cc", }, initialize: function(opt){ @@ -15,6 +22,7 @@ var CartPayment = FormView.extend({ this.$msg = this.$(".msg") this.$address_list = this.$(".address_list") this.$address_form = this.$(".address") + this.$cc_list = this.$(".cc_list") this.$cc_form = this.$(".cc") this.address = new AddressView ({ parent: this, checkPhone: false }) @@ -41,28 +49,56 @@ var CartPayment = FormView.extend({ this.deferScrollToTop() }, - toggle_dropdown: function(state){ + toggle_address: function(state){ if (! app.account.ccs.length) { state = false } - this.list_mode = typeof state == "boolean" ? state : ! this.list_mode - this.address.disabled = this.list_mode - this.$address_form.toggle(! this.list_mode) - this.$cc_form.toggle(! this.list_mode) - this.$address_list.toggle(this.list_mode) + this.address_list_mode = typeof state == "boolean" ? state : ! this.list_mode + this.address.disabled = this.address_list_mode + this.$address_form.toggle(! this.address_list_mode) + this.$address_list.toggle(this.address_list_mode) + }, + + toggle_cc: function(state){ + if (! app.account.ccs.length) { + state = false + } + this.cc_list_mode = typeof state == "boolean" ? state : ! this.cc_list_mode + this.cc.disabled = this.cc_list_mode + this.$cc_form.toggle(! this.cc_list_mode) + this.$cc_list.toggle(this.cc_list_mode) }, populate: function(){ app.account.ccs.forEach(function(cc){ + console.log(cc) + + var address_t = this.address_template.replace(/{{id}}/g, cc.Id) + .replace(/{{checked}}/g, cc.IsDefault ? "checked" : "") + .replace(/{{name}}/g, cc.Name + " " + cc.Surname) + .replace(/{{address}}/g, cc.Address.replace(/\n$/,"").replace("\n", "<br>")) + .replace(/{{city}}/g, cc.City) + .replace(/{{state}}/g, cc.Province) + .replace(/{{zip}}/g, cc.ZipCode) + + var cc_t = this.cc_template.replace(/{{id}}/g, cc.Id) + .replace(/{{checked}}/g, cc.IsDefault ? "checked" : "") + .replace(/{{last4}}/g, cc.Last4) + .replace(/{{type}}/g, cc.Type) + .replace(/{{exp}}/g, cc.ExpirationMonth + "/" + cc.ExpirationYear) + + this.$address_list.append(address_t) + this.$cc_list.append(cc_t) }) }, - save: function(){ - // use stored credit card - return + success: function(){ + app.router.go('cart/confirm') }, cancel: function(){ + app.router.go('cart/shipping') }, + })
\ No newline at end of file diff --git a/StoneIsland/www/js/sdk/_sdk.js b/StoneIsland/www/js/sdk/_sdk.js index 27773310..43f539a3 100644 --- a/StoneIsland/www/js/sdk/_sdk.js +++ b/StoneIsland/www/js/sdk/_sdk.js @@ -13,7 +13,7 @@ var sdk = (function(){ break default: case 'development': - endpoint = "http://api.yoox.biz/" + endpoint = "http://stone.sup.land:9090/" break case 'production': endpoint = "https://secure.api.yoox.biz/" |
