summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-29 12:38:30 -0500
committerJules Laplace <jules@okfoc.us>2015-11-29 12:38:30 -0500
commit532ed5f1a16fad3c2dfc7980c163083f21a60fbc (patch)
treee977cc9f3d73b19fc1d8862bb7fb77bc70e24a16 /StoneIsland/www/js
parent72ba42fce0c81601ec8ea5e544f35de1fdbf708d (diff)
cart billing/confirm html
Diffstat (limited to 'StoneIsland/www/js')
-rw-r--r--StoneIsland/www/js/lib/account/AccountView.js9
-rw-r--r--StoneIsland/www/js/lib/cart/CartPayment.js29
-rw-r--r--StoneIsland/www/js/lib/cart/CartShipping.js9
3 files changed, 45 insertions, 2 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js
index f76541be..116d5ba1 100644
--- a/StoneIsland/www/js/lib/account/AccountView.js
+++ b/StoneIsland/www/js/lib/account/AccountView.js
@@ -18,6 +18,9 @@ var AccountView = View.extend({
addresses: [],
addressLookup: {},
+ ccs: [],
+ ccLookup: {},
+
listAddresses: function(cb){
sdk.address.list({
success: function(data){
@@ -64,10 +67,16 @@ var AccountView = View.extend({
populateCreditCards: function(data, cb){
console.log(data)
+ this.ccs = data.CreditCards
+ this.ccLookup = {}
if (! data.CreditCards || ! data.CreditCards.length) {
}
else {
+ data.CreditCards.forEach(function(cc){
+ this.ccLookup[cc.Id] = cc
+ }.bind(this))
app.payment.populate( data.CreditCards[0] )
+ app.cart.payment.populate()
}
cb && cb()
},
diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js
index 8412f35d..90fe4a76 100644
--- a/StoneIsland/www/js/lib/cart/CartPayment.js
+++ b/StoneIsland/www/js/lib/cart/CartPayment.js
@@ -2,16 +2,26 @@ var CartPayment = FormView.extend({
el: "#cart_payment",
+ action: sdk.cart.set_credit_card,
+
events: {
+ "change [name=same_as_shipping]": "toggle_shipping",
+ "click .dropdown-wrapper": "toggle_dropdown",
},
initialize: function(opt){
this.parent = opt.parent
this.$form = this.$("form")
this.$msg = this.$(".msg")
+ this.$address_list = this.$(".address_list")
+ this.$address_form = this.$(".address")
+ this.$cc_form = this.$(".cc")
+
this.address = new AddressView ({ parent: this, checkPhone: false })
this.cc = new CreditCardView ({ parent: this })
this.scroller = new IScroll('#cart_payment', app.iscroll_options)
+ this.address.disabled = true
+ this.cc.disabled = true
},
// sdk.cart.set_credit_card
@@ -27,12 +37,29 @@ var CartPayment = FormView.extend({
app.footer.show("CONFIRM &gt;", "CANCEL")
window.location.hash = "#/cart/payment"
+ this.populate()
this.deferScrollToTop()
+ },
+
+ toggle_dropdown: 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)
+ },
- sdk.cart.set_payment_type({ data: payment_id })
+ populate: function(){
+ app.account.ccs.forEach(function(cc){
+ })
},
save: function(){
+ // use stored credit card
+ return
},
cancel: function(){
diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js
index d1e1a97e..e52eec4c 100644
--- a/StoneIsland/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/www/js/lib/cart/CartShipping.js
@@ -15,6 +15,7 @@ var CartShipping = FormView.extend({
initialize: function(opt){
this.parent = opt.parent
this.$form = this.$("form")
+ this.$dropdown_wrapper = this.$(".dropdown-wrapper")
this.$address_list = this.$(".address_list")
this.$address_form = this.$(".address")
this.$msg = this.$(".msg")
@@ -37,7 +38,8 @@ var CartShipping = FormView.extend({
this.$(".save_as_default").show()
this.$address_list.empty()
if (! app.account.addresses.length) {
- this.toggle_dropdown(true)
+ this.toggle_dropdown(false)
+ return
}
app.account.addresses.forEach(function(address){
var t = this.template.replace(/{{id}}/g, address.Id)
@@ -52,7 +54,11 @@ var CartShipping = FormView.extend({
},
toggle_dropdown: function(state){
+ if (! app.account.addresses.length) {
+ state = false
+ }
this.list_mode = typeof state == "boolean" ? state : ! this.list_mode
+ this.$dropdown_wrapper.toggle( ! app.account.addresses.length )
this.address.disabled = this.list_mode
this.$address_form.toggle(! this.list_mode)
this.$address_list.toggle(this.list_mode)
@@ -70,6 +76,7 @@ var CartShipping = FormView.extend({
finalize: function(data){
var shipping_info = {}, address_data, address_id
var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val()
+
sdk.shipping.set_delivery_type({
id: this.shipping_types[shipping_type],
success: function(data){ console.log("set shipping type", data) },