summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-19 23:17:05 -0500
committerJules Laplace <jules@okfoc.us>2015-11-19 23:17:05 -0500
commit0805b9a105f6cb12ffb23349e1458d13ffd90d4f (patch)
treeb3ae97ace949963b0e6d9ae1df6be74046f5fd12 /StoneIsland/www/js
parenteac52234321adbbb0c97c0bfedf4c7bcc64d7397 (diff)
dates and some cart auth
Diffstat (limited to 'StoneIsland/www/js')
-rw-r--r--StoneIsland/www/js/lib/auth/LoginView.js5
-rw-r--r--StoneIsland/www/js/lib/auth/LogoutView.js3
-rw-r--r--StoneIsland/www/js/lib/auth/SignupView.js4
-rw-r--r--StoneIsland/www/js/lib/blogs/HubView.js15
-rw-r--r--StoneIsland/www/js/lib/products/ProductView.js11
-rw-r--r--StoneIsland/www/js/sdk/auth.js10
6 files changed, 43 insertions, 5 deletions
diff --git a/StoneIsland/www/js/lib/auth/LoginView.js b/StoneIsland/www/js/lib/auth/LoginView.js
index 8c875ae8..c4ec8870 100644
--- a/StoneIsland/www/js/lib/auth/LoginView.js
+++ b/StoneIsland/www/js/lib/auth/LoginView.js
@@ -32,9 +32,14 @@ var LoginView = FormView.extend({
},
success: function(data){
+ app.account.logged_in()
},
error: function(data){
},
+
+ cancel: function(){
+ auth.defer_add_to_cart = null
+ },
})
diff --git a/StoneIsland/www/js/lib/auth/LogoutView.js b/StoneIsland/www/js/lib/auth/LogoutView.js
index 62c925eb..feb264dd 100644
--- a/StoneIsland/www/js/lib/auth/LogoutView.js
+++ b/StoneIsland/www/js/lib/auth/LogoutView.js
@@ -8,6 +8,7 @@ var LogoutView = View.extend({
show: function(){
document.body.className = "logout"
app.footer.hide()
+ app.account.log_out()
},
-
+
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/auth/SignupView.js b/StoneIsland/www/js/lib/auth/SignupView.js
index 28d828c3..092bf297 100644
--- a/StoneIsland/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/www/js/lib/auth/SignupView.js
@@ -46,6 +46,10 @@ var SignupView = FormView.extend({
error: function(data){
},
+ cancel: function(){
+ auth.defer_add_to_cart = null
+ },
+
/*
var new_user_data = {
"Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com",
diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js
index 3ed45b7c..3b2900ad 100644
--- a/StoneIsland/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/www/js/lib/blogs/HubView.js
@@ -4,6 +4,7 @@ var HubView = ScrollableView.extend({
template: $("#hub .template").html(),
events: {
+ "click .store": "store_link",
},
initialize: function(){
@@ -22,16 +23,20 @@ var HubView = ScrollableView.extend({
this.data = data
this.$loader.hide()
this.$content.empty()
- // id date subtitle body link image[uri caption]
+ // 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)
- .replace(/{{date}}/, row.date)
+ .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY"))
.replace(/{{title}}/, row.title)
.replace(/{{subtitle}}/, row.subtitle)
.replace(/{{link}}/, row.link)
.replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
- this.$content.append(t)
+ var $t = $(t)
+ if (row.store != "true") {
+ $t.find(".store").remove()
+ }
+ this.$content.append($t)
if (row.image.length > 1) {
// image gallery
@@ -74,5 +79,9 @@ var HubView = ScrollableView.extend({
this.deferScrollToTop()
},
+
+ store_link: function(){
+ app.router.go("store")
+ },
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index e21c28f1..5fe1fe7b 100644
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -185,13 +185,22 @@ var ProductView = ScrollableView.extend({
return this.colors[key]
}.bind(this))
app.selector.select(colors, function(color){
- this.color = color.value
+ this.code = color.code
this.$color.html(color.label)
}.bind(this))
},
save: function(){
// add to cart
+ if ( ! auth.logged_in() ) {
+ auth.defer_add_to_cart = { size: this.size, code: this.code }
+ }
+ else if ( ! auth.has_cart() ) {
+ auth.deferred_product = { size: this.size, code: this.code }
+ auth.create_cart(auth.defer_add_to_cart)
+ }
+ else {
+ }
},
cancel: function(){
diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js
index 548e67f4..5efea20e 100644
--- a/StoneIsland/www/js/sdk/auth.js
+++ b/StoneIsland/www/js/sdk/auth.js
@@ -42,6 +42,11 @@ var auth = sdk.auth = (function(){
user_id = localStorage.getItem("yoox.user_id") || -1
cb && cb()
}
+ auth.clear_user = function(cb){
+ localStorage.removeItem("yoox.access_token")
+ localStorage.removeItem("yoox.user_id")
+ cb && cb()
+ }
auth.set_cart = function(cart_id, cart_token, cb){
localStorage.setItem("yoox.cart_token", cart_token)
@@ -53,6 +58,11 @@ var auth = sdk.auth = (function(){
cart.id = localStorage.getItem("yoox.cart_id") || -1
cb && cb()
}
+ auth.clear_cart = function(cb){
+ localStorage.removeItem("yoox.cart_token")
+ localStorage.removeItem("yoox.cart_id")
+ cb && cb()
+ }
auth.log_out = function(){
auth.access_token = ""