diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-12-02 21:00:30 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-12-02 21:00:30 -0500 |
| commit | 393dc6eaf8d5a119c9cf71f1f5dac44abf70db59 (patch) | |
| tree | 84d2856b9b7c97731970347a9357722f63679b4e /StoneIsland/platforms/ios/www/js | |
| parent | d6910087feae6cd30141a615f2de753c37af14b8 (diff) | |
build..
Diffstat (limited to 'StoneIsland/platforms/ios/www/js')
16 files changed, 403 insertions, 69 deletions
diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js index e6bdf49f..573ce720 100644 --- a/StoneIsland/platforms/ios/www/js/index.js +++ b/StoneIsland/platforms/ios/www/js/index.js @@ -2,11 +2,12 @@ var app = (function(){ var app = {} app.init = function(){ + + sdk.init({ env: "test" }) + app.bind() app.build() - - sdk.init({ env: "test" }) - + app.iscroll_options = { mouseWheel: true, scrollbars: true, @@ -69,7 +70,12 @@ var app = (function(){ app.view = null app.router = new SiteRouter () - app.account.connect( app.router.launch.bind(app.router) ) + if (sdk.env == "test") { + app.router.launch() + } + else { + app.account.connect( app.router.launch.bind(app.router) ) + } $("body").removeClass("loading") } diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js index 23daf4c7..b1fa1c97 100644 --- a/StoneIsland/platforms/ios/www/js/lib/_router.js +++ b/StoneIsland/platforms/ios/www/js/lib/_router.js @@ -36,6 +36,7 @@ var SiteRouter = Router.extend({ '/cart/shipping': 'cart.shipping', '/cart/confirm': 'cart.confirm', '/cart/thanks': 'cart.thanks', + '/cart/error': 'cart.error', }, initialize: function(){ diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js index 22b310de..bba959bd 100644 --- a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js +++ b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js @@ -4,7 +4,8 @@ var SignupView = FormView.extend({ action: sdk.account.signup, last_data: null, - + +/* test_data: { "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com", "Password": "TestPassword", @@ -16,7 +17,8 @@ var SignupView = FormView.extend({ "DataProfiling": true, "DataProfiling2": true, }, - +*/ + events: { "click .privacy-msg": "privacy_link", "submit form": "save", @@ -47,6 +49,7 @@ var SignupView = FormView.extend({ "Surname": "Please enter your last name.", "Email": "Please enter a valid email address.", "ConfirmEmail": "Please enter a valid email address.", + "BirthDay": "Please enter your birthday.", "Password": "Please enter your password.", "Password2": "Please enter your password again.", "DataProfiling": "You must agree to data profiling.", @@ -97,7 +100,13 @@ var SignupView = FormView.extend({ }, error: function(data){ - console.log('error', data) + try { + data = JSON.parse(data.responseText) + app.signup.show_errors([[ 'Name', data['Error']['Description'] ]]) + } + catch (e) { + app.signup.show_errors([[ 'Name', "There was an unknown error." ]]) + } }, cancel: function(){ diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js index f0a796bf..c156aed0 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js @@ -6,6 +6,12 @@ var ArchiveView = ScrollableView.extend({ events: { "click .item": "pick", + "mousedown .row": "mousedown", + "touchstart .row": "touchstart", + "mousemove .row": "mousemove", + "touchmove .row": "touchmove", + "mouseup .row": "mouseup", + "touchend .row": "touchend", }, initialize: function(){ @@ -20,9 +26,11 @@ var ArchiveView = ScrollableView.extend({ app.header.set_back(false) }, - pick: function(){ + pick: function(e){ this.$el.removeClass("menu") - app.header.set_back(true) + app.header.set_back(true) + var index = $(e.currentTarget).data("index") + this.populateDecade(index) }, show: function(){ @@ -41,11 +49,6 @@ var ArchiveView = ScrollableView.extend({ // id title images[ uri label code caption ] this.data.forEach(function(row, index){ - var t = this.row_template.replace(/{{image}}/, row.images[0].uri) - .replace(/{{label}}/, row.images[0].label) - .replace(/{{code}}/, row.images[0].code) - .replace(/{{caption}}/, row.images[0].caption) - this.$content.append(t) var t = this.menu_template.replace(/{{title}}/, row.title) var $t = $(t) @@ -56,6 +59,68 @@ var ArchiveView = ScrollableView.extend({ this.back() this.deferScrollToTop() + + this.populateDecade(0, 3) + }, + + populateDecade: function(index, count){ + this.$content.empty() + + var loader = new Loader() + + var row = this.data[index] + + row.images.forEach(function(cell, i){ + if (i > count) return + var $t = $("<div>") + $t.addClass("row").addClass("loading") + var t = this.row_template.replace(/{{image}}/, cell.uri) + .replace(/{{label}}/, cell.label) + .replace(/{{code}}/, cell.code) + .replace(/{{caption}}/, cell.caption) + $t.html(t) + this.$content.append($t) + + loader.preloadImage(cell.uri, function(){ + $t.removeClass('loading') + }.bind(this)) + }.bind(this)) + }, + +// ['transformProp'] = "translateZ(0) translateX(-50%) translateY(-50%) "; +// .image, .text + + touchstart: function(e){ + this.$row = e.currentTarget + this.mousedown(e.touches[0]) + }, + touchmove: function(e){ + this.mousemove(e.touches[0]) + }, + touchend: function(e){ + this.mouseup() + }, + mouse: { x: 0, y: 0 }, + $row: null, + + mousedown: function(e){ + this.$row = this.$row || e.currentTarget + this.mouse.x = e.pageX + this.mouse.y = e.pageY + }, + mousemove: function(e){ + var dx = ( this.mouse.x - e.pageX ) / window.innerWidth + var dy = ( this.mouse.y - e.pageY ) / window.innerWidth + this.$row.style['transformProp'] = [ + "translateZ(0)", + "translateX(-50%)", + "translateY(-50%)", + "rotateY(" + dx + "deg)", + ].join(" ") + }, + mouseup: function(e){ + this.mouse.x = this.mouse.y = 0 + this.$row = null }, })
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js index 3ea35418..ddfff9e6 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js @@ -10,7 +10,7 @@ var BlogView = View.extend({ fetch: function(){ $.ajax({ method: "GET", - url: "http://stone.sup.land/db.json", + url: sdk.env == 'test' ? '/db.json' : "http://stone.sup.land/db.json", success: this.success.bind(this), cache: true, }) @@ -21,11 +21,10 @@ var BlogView = View.extend({ if (this.loaded) return this.loaded = true - this.data = data + this.data = data = typeof data == "string" ? JSON.parse(data) : data + + app.archive.populate(data.archive) - this.loader.preloadImage(data.archive[0].images[0].uri, function(img){ - app.archive.populate(data.archive) - }) this.loader.preloadImage(data.hub[0].image[0].uri, function(img){ app.hub.populate(data.hub) }) @@ -54,7 +53,7 @@ var BlogView = View.extend({ app.gallery_id = data.store[0].CollectionId - app.collection.fetch() + // app.collection.fetch() }, })
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js index a6ae958e..49c05ff6 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js @@ -4,15 +4,17 @@ var HubView = ScrollableView.extend({ template: $("#hub .template").html(), events: { + "click .share": "content-share", "click .store": "store_link", "click .gallery-left": "gallery_left", "click .gallery-right": "gallery_right", + "click .play": "play_video", }, initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#hub', app.iscroll_optionsx) + this.scroller = new IScroll('#hub', app.iscroll_options) }, show: function(){ @@ -21,14 +23,16 @@ var HubView = ScrollableView.extend({ document.body.className = "hub" }, + galleries: {}, populate: function(data){ this.data = data this.$loader.hide() this.$content.empty() + this.galleries = {} // id date subtitle body link store image[uri caption] this.data.forEach(function(row){ // console.log(row) - var t = this.template.replace(/{{id}}/, row.id) + var t = this.template.replace(/{{id}}/g, row.id) .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) .replace(/{{title}}/, row.title) .replace(/{{subtitle}}/, row.subtitle) @@ -49,7 +53,7 @@ var HubView = ScrollableView.extend({ el.className = "item" $gallery.append(el) }) - new Flickity( ".gallery-" + row.id, { + this.galleries[row.id] = new Flickity( ".gallery-" + row.id, { selector: '.item', cellAlign: 'center', autoPlay: false, @@ -68,6 +72,7 @@ var HubView = ScrollableView.extend({ el.style.backgroundImage = "url(" + row.image[0].uri + ")" el.className = "item" $(".gallery-" + row.id).append(el) + $(".gallery-" + row.id).data("row", row) // video, append play button if (row.link.match(/youtube|youtu.be|vimeo/)) { @@ -75,8 +80,8 @@ var HubView = ScrollableView.extend({ play.className = "play" $(".gallery-" + row.id).append(play) } - $t.find("gallery-left").remove() - $t.find("gallery-right").remove() + $t.find(".gallery-left").remove() + $t.find(".gallery-right").remove() } }.bind(this)) @@ -87,12 +92,22 @@ var HubView = ScrollableView.extend({ store_link: function(){ app.router.go("store") }, + play_video: function(e){ + var row = $(e.currentTarget).closest('.gallery-video-post').data("row") + window.open(row.link, '_system') + }, - gallery_prev: function(e){ - $(e.currentTarget).closest("hub_item").flickity('prev') + gallery_left: function(e){ + var id = $(e.currentTarget).closest(".hub_item").data('id') + this.galleries[id].previous() + }, + gallery_right: function(e){ + var id = $(e.currentTarget).closest(".hub_item").data('id') + this.galleries[id].next() }, - gallery_next: function(e){ - $(e.currentTarget).closest("hub_item").flickity('next') + + share: function(){ + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/") }, })
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js index aa6ec9e4..f6c7f1f5 100644 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js @@ -2,11 +2,26 @@ var CartConfirm = FormView.extend({ el: "#cart_confirm", + template: $("#cart_confirm .template").html(), + events: { }, initialize: function(opt){ this.parent = opt.parent + this.$rows = this.$(".rows") + this.$subtotal = this.$(".subtotal") + this.$shipping = this.$(".shipping") + this.$tax = this.$(".tax") + this.$total = this.$(".total") + + this.$shipping_address = this.$(".shipping_address") + this.$shipping_method = this.$(".shipping_method") + + this.$payment_name = this.$(".payment_name") + this.$payment_method = this.$(".payment_method") + this.$payment_address = this.$(".payment_address") + this.scroller = new IScroll('#cart_confirm', app.iscroll_options) }, @@ -16,15 +31,144 @@ var CartConfirm = FormView.extend({ app.footer.show("PLACE ORDER", "CANCEL") window.location.hash = "#/cart/confirm" this.deferScrollToTop() + + app.curtain.show("loading") + promise(sdk.cart.get_status).then( this.populate.bind(this) ) }, - populate: function(){ + populate: function(data){ + console.log(data) + + data = data.Cart + + this.$rows.empty() + + data.Items.forEach(function(item){ + var $el = $("<div class='item'><img src='img/spinner.gif'></div>") + this.$rows.append($el) + var code_ten = item.Code10 + var size_id = item.Size + + var code = code_ten.substr(0, 8) + app.product.find(code, function(data, details){ + var descriptions = app.product.get_descriptions( details ) + + var name_partz = descriptions['ModelNames'].split(' ') + var num = name_partz.shift() + var title = name_partz.join(' ') + var type = title_case( descriptions['MicroCategory'] ) + + var color_name, size_name + + details.Item.ModelColors.some(function(color){ + if (color['Code10'] == code_ten) { + color_name = color['ColorDescription'] + return true + } + return false + }) + + details.Item.ModelSizes.some(function(size){ + if (size['SizeId'] == size_id) { + // console.log(size) + size_name = size['Default']['Text'] + size_name = SIZE_LOOKUP[ size_name ] || size_name + if (! size_name && ! size['Default']['Labeled']) { + size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily'] + } + + return true + } + return false + }) + +// size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily + + var t = this.template + .replace(/{{image}}/, sdk.image(item['Code10'], '11_f')) + .replace(/{{sku}}/, num) + .replace(/{{title}}/, title) + .replace(/{{type}}/, type) + .replace(/{{size}}/, size_name || "DEFAULT") + .replace(/{{color}}/, color_name || "DEFAULT") + .replace(/{{quantity}}/, 1) + .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice)) + $el.data("price", details.Item.Price.DiscountedPrice) + $el.html(t) + this.refreshScroller() + }.bind(this)) + }.bind(this)) + + var subtotal = data.Totals.TotalWithoutPromotions + var shipping_cost = data.DeliveryMethod.Selected.Amount.Total + var tax = data.Totals.TotalSalesTax + var total = data.Totals.TotalToPay + + this.$subtotal.html( as_cash(subtotal) ) + this.$shipping.html( as_cash(shipping_cost) ) + this.$tax.html( as_cash(tax) ) + this.$total.html( as_cash(total) ) + + var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") + var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " + address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode + + this.$shipping_address.html(address) + this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + + var cc = data.Payment.CreditCard + var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") + var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + + this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() ) + this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 ) + + app.curtain.hide("loading") }, save: function(){ + promise(sdk.cart.finalize, {}).then(function(){ + app.router.go('cart/thanks') + }.bind(this)).error(function(data){ + // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}} + // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}' + // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The cart cannot be empty.\"\n233"}} + // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}} + // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}} + // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}} + switch (data.StatusCode) { + case 403: // cart already closed + auth.clear_cart(auth.create_cart) + app.router.go('thanks') + break + case 409: // finalization error + this.finalization_error(data) + break + case 440: // genericapierror (credit card error!) + case 441: // genericapierror (credit card empty) + app.router.go('cart/payment') + app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) + break + } + }.bind(this)) + }, + + finalization_error: function(data){ + if (data['Error']['Description'].match(/receiver validation fails/)) { + app.router.go('cart/shipping') + app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) + } + else if (data['Error']['Description'].match(/cart cannot be empty/)) { + app.router.go('cart/summary') + } + else if (data['Error']['Description'].match(/Item has been removed/)) { + app.router.go('cart/error') + app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.") + } }, cancel: function(){ + app.router.go('cart/payment') }, })
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartError.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartError.js new file mode 100644 index 00000000..f9a1963e --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartError.js @@ -0,0 +1,28 @@ +var CartError = View.extend({ + + el: "#cart_error", + + events: { + }, + + initialize: function(opt){ + this.parent = opt.parent + this.$error = this.$(".errrrrrrrrrrrrrrr") + }, + + show: function(){ + document.body.className = "cart" + app.cart.el.className = "error" + app.footer.show("< BACK TO CART") + app.footer.hide() + }, + + show_error: function(msg){ + this.$error.html(msg) + }, + + ok: function(){ + app.router.go("cart/summary") + }, + +})
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js index fec5e1d1..f3c54d55 100644 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js @@ -2,13 +2,14 @@ var CartPayment = FormView.extend({ el: "#cart_payment", - address_template: $("#cart_payment .address_template").html(), + address_template: $("#cart_payment .address_row_template").html(), cc_template: $("#cart_payment .cc_template").html(), action: sdk.cart.set_credit_card, address_list_mode: false, cc_list_mode: false, + data: {}, events: { "change [name=SameAsShipping]": "toggle_shipping", @@ -28,6 +29,7 @@ var CartPayment = FormView.extend({ this.$cc_list = this.$(".cc_list") this.$cc_form = this.$(".cc") this.$cc_dropdown = this.$(".cc_dropdown") + this.$cc_confirm = this.$(".cc_confirm") this.address = new AddressView ({ parent: this, checkPhone: false }) this.cc = new CreditCardView ({ parent: this }) @@ -50,6 +52,7 @@ var CartPayment = FormView.extend({ setTimeout(function(){ var state = this.$same_as_shipping.prop("checked") this.$billing_address_rapper.toggle( ! state ) + this.address.disabled = state }.bind(this)) }, @@ -75,6 +78,7 @@ var CartPayment = FormView.extend({ this.cc.disabled = this.cc_list_mode this.$cc_form.toggle(! this.cc_list_mode) this.$cc_list.toggle(this.cc_list_mode) + this.$cc_confirm.toggle(this.cc_list_mode) }, populate: function(){ @@ -85,65 +89,94 @@ var CartPayment = FormView.extend({ this.toggle_cc( !! app.account.ccs.length ) 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(/{{name}}/g, (cc.Name + " " + cc.Surname).toUpperCase()) + .replace(/{{address}}/g, cc.Address.replace(/\n$/,"").replace("\n", ", ")) .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(/{{number}}/g, cc['Number']) + .replace(/{{type}}/g, cc.Type.toUpperCase()) .replace(/{{exp}}/g, cc.ExpirationMonth + "/" + cc.ExpirationYear) this.$address_list.append(address_t) this.$cc_list.append(cc_t) - }) + }.bind(this)) }, finalize: function(data){ - var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id + var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val() - if (this.list_mode) { - address_id = $("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() + if (this.$same_as_shipping.prop("checked")) { + address_data = app.cart.shipping.data + } + else if (this.address_list_mode) { + address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() address_data = app.account.addressLookup[ address_id ] } else { address_data = data } + if (this.cc_list_mode) { - cc_id = $("[name=CCId]").filter(function(){ return $(this).prop("checked") }).val() + cc_id = this.$("[name=CCId]").filter(function(){ return $(this).prop("checked") }).val() cc_data = app.account.ccLookup[ cc_id ] + + var card_on_file = { + "guid": cc_data.Guid, + "cvv": this.$("[name=CvvConfirm]"), + } + + app.curtain.show("loading") + promise(sdk.cart.use_stored_credit_card, { data: card_on_file }).then(function(data){ + app.curtain.hide("loading") + this.success() + }.bind(this)).error(function(data){ + app.curtain.hide("loading") + console.log(data) + }.bind(this)) + + return } else { cc_data = data } - shipping_info.Name = address_data.Name - shipping_info.Surname = address_data.Surname - shipping_info.Email = auth.user.Email - shipping_info.Phone = address_data.Phone - shipping_info.Mobile = address_data.Phone - shipping_info.StreetWithNumber = address_data.Address - shipping_info.PostalCode = address_data.ZipCode - shipping_info.City = address_data.City - shipping_info.Province = address_data.Province - shipping_info.Region = address_data.Province - shipping_info.CountryCode = "US" + var credit_info = { + "HolderName": address_data.Name, + "HolderSurname": address_data.Surname, + "HolderAddress": address_data.Address || address_data.StreetWithNumber, + "HolderCity": address_data.City, + "HolderProvince": address_data.Province, + "HolderZip": address_data.PostalCode || address_data.ZipCode, + "HolderISOCountry": CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US", + "HolderEmail": auth.user.Email, + "CardNumber": cc_data['Number'], + "Type": cc_data.Type, + "ExpirationMonth": cc_data.ExpirationMonth, + "ExpirationYear": cc_data.ExpirationYear.substr(2,3), + "Cvv": cc_data.Cvv, + } - return shipping_info + console.log( credit_info ) + + return credit_info }, success: function(){ app.router.go('cart/confirm') }, + error: function(data){ + console.log(data) + app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) + }, + cancel: function(){ app.router.go('cart/shipping') }, diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js index 9b8205c1..f17d42d2 100644 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js @@ -5,6 +5,7 @@ var CartShipping = FormView.extend({ action: sdk.cart.set_shipping_address, list_mode: true, + data: {}, template: $("#cart_shipping .template").html(), @@ -44,8 +45,8 @@ var CartShipping = FormView.extend({ app.account.addresses.forEach(function(address){ var t = this.template.replace(/{{id}}/g, address.Id) .replace(/{{checked}}/g, address.IsDefault ? "checked" : "") - .replace(/{{name}}/g, address.Name + " " + address.Surname) - .replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", "<br>")) + .replace(/{{name}}/g, (address.Name + " " + address.Surname).toUpperCase()) + .replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", ", ")) .replace(/{{city}}/g, address.City) .replace(/{{state}}/g, address.Province) .replace(/{{zip}}/g, address.ZipCode) @@ -53,6 +54,22 @@ var CartShipping = FormView.extend({ }.bind(this)) }, + load_form: function(cart_data){ + var data = cart_data.Cart.Receiver + var addy = data.StreetWithNumber.split("\n") + data.Address1 = addy[0] || "" + data.Address2 = addy[1] || "" + data.ZipCode = data.PostalCode + data.Province = data.Region + this.load_data(data) + + this.data = data + if (cart_data.Cart.DeliveryMethod && cart_data.Cart.DeliveryMethod.Selected && cart_data.Cart.DeliveryMethod.Type) { + $("#standard-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 1) + $("#express-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 2) + } + }, + toggle_dropdown: function(state){ if (! app.account.addresses.length) { state = false @@ -84,7 +101,7 @@ var CartShipping = FormView.extend({ }) if (this.list_mode) { - address_id = $("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() + address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() address_data = app.account.addressLookup[ address_id ] } else { @@ -103,6 +120,8 @@ var CartShipping = FormView.extend({ shipping_info.Region = address_data.Province shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US" + this.data = shipping_info + return shipping_info }, diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js index 72c44405..ff1e001f 100644 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js @@ -39,6 +39,7 @@ var CartSummary = ScrollableView.extend({ load: function(){ this.el.className = "loading" app.footer.show("SHIPPING >", "CANCEL") + app.curtain.show("loading") sdk.cart.get_status({ success: this.populate.bind(this), error: this.empty.bind(this), @@ -54,6 +55,7 @@ var CartSummary = ScrollableView.extend({ return this.empty() } + this.parent.$steps.show() this.updateCounts() this.$rows.empty() @@ -119,10 +121,15 @@ var CartSummary = ScrollableView.extend({ }.bind(this)) }.bind(this)) + if (data.Cart.Receiver && data.Cart.Receiver.City) { + app.cart.shipping.load_form( data ) + } + this.updateTotals() this.el.className = "full" this.refreshScroller() + app.curtain.hide("loading") }, updateCounts: function(){ @@ -133,7 +140,7 @@ var CartSummary = ScrollableView.extend({ updateTotals: function(){ var subtotal = this.data.Cart.Totals.TotalWithoutPromotions var shipping_cost = this.data.Cart.DeliveryMethod.Selected.Amount.Total - var tax = 0 + var tax = this.data.Cart.Totals.TotalSalesTax var total = this.data.Cart.Totals.TotalToPay this.$subtotal.html( as_cash(subtotal) ) @@ -148,6 +155,7 @@ var CartSummary = ScrollableView.extend({ this.parent.setHeaderCount( 0 ) this.parent.$itemcount.html("0 ITEMS") this.el.className = "empty" + this.parent.$steps.hide() }, save: function(){ diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js index b57caadd..1b08e418 100644 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js @@ -14,7 +14,9 @@ var CartView = View.extend({ this.shipping = new CartShipping ({ parent: this }) this.confirm = new CartConfirm ({ parent: this }) this.thanks = new CartThanks ({ parent: this }) + this.error = new CartError ({ parent: this }) + this.$steps = this.$(".steps") this.$full_msg = this.$(".full_msg") this.$empty_msg = this.$(".empty_msg") this.$itemcount = this.$(".itemcount") diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js index ba3ac54a..63784618 100644 --- a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js +++ b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js @@ -40,6 +40,7 @@ var CreditCardView = SerializableView.extend({ }, validate_fields: function(data, errors){ + if (this.disabled) { return } var card = this.$number.validateCreditCard(this.cardOptions) if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ]) } if (! data.ExpirationMonth || data.ExpirationMonth == "NONE") { errors.push([ "ExpirationMonth", "Please enter the expiration month." ]) } diff --git a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js index b36c5df2..02193f14 100644 --- a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js @@ -4,8 +4,8 @@ var GalleryView = View.extend({ template: $("#gallery .template").html(), events: { - "click .left": "prev", - "click .right": "next", +// "click .left": "prev", +// "click .right": "next", // "touchstart .gallery": "touchstart", // "touchmove .gallery": "touchmove", // "touchend .gallery": "touchend", @@ -51,10 +51,6 @@ var GalleryView = View.extend({ }) }, - prev: function(){ - }, - next: function(){ - }, touchstart: function(e){ }, touchmove: function(e){ diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js index 92a0e0f7..4789850a 100644 --- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js @@ -47,10 +47,10 @@ var ProductView = ScrollableView.extend({ cache: {}, gallery_prev: function(){ - this.gallery.gallery.flickity('prev') + app.product.gallery.gallery.previous() }, gallery_right: function(){ - this.gallery.gallery.flickity('next') + app.product.gallery.gallery.next() }, find: function(code, cb){ @@ -240,14 +240,18 @@ var ProductView = ScrollableView.extend({ app.last_view = app.cart } else if ( ! auth.has_cart() ) { + app.curtain.show("loading") auth.create_cart(function(){ auth.add_deferred_product_to_cart(function(){ + app.curtain.hide("loading") app.router.go("cart") }) }) } else { + app.curtain.show("loading") auth.add_deferred_product_to_cart(function(){ + app.curtain.hide("loading") if (opt.route) { app.router.go("cart") } @@ -263,6 +267,7 @@ var ProductView = ScrollableView.extend({ }, share: function(){ + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/") }, }) diff --git a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js index b1e095d3..f9abd011 100644 --- a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js +++ b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js @@ -68,9 +68,11 @@ var SerializableView = View.extend({ var data = data || this.serialize() var errors = errors || [] var presence_msgs = this.validate_presence || {} - Object.keys(presence_msgs).forEach(function(k){ - if (! data[k]) errors.push( [ k, presence_msgs[k] ] ) - }) + if (! this.disabled) { + Object.keys(presence_msgs).forEach(function(k){ + if (! data[k]) errors.push( [ k, presence_msgs[k] ] ) + }) + } this.validate_fields && this.validate_fields(data, errors) this.cc && this.cc.validate(data, errors) this.address && this.address.validate(data, errors) @@ -78,6 +80,7 @@ var SerializableView = View.extend({ }, show_errors: function(errors){ + console.log(errors) var msgs = [] errors.forEach(function(e, i){ if (i > 0) { return } |
