diff options
| -rw-r--r-- | StoneIsland/www/index.html | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/StoryView.js | 6 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/nav/NavView.js | 16 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 5 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/auth.js | 12 | ||||
| -rw-r--r-- | StoneIsland/www/js/vendor/loader.js | 6 |
6 files changed, 26 insertions, 21 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index edbad059..27426df0 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -125,8 +125,6 @@ <div class="content"> <script type="text/html" class="template"> <div data-id="{{id}}"> - <!-- NOTE: span.title removed since latest update - <!-- <span class="title">{{title}}</span> --> <div class="body">{{body}}</div> </div> </script> diff --git a/StoneIsland/www/js/lib/blogs/StoryView.js b/StoneIsland/www/js/lib/blogs/StoryView.js index 70ac061f..84684ff7 100644 --- a/StoneIsland/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/www/js/lib/blogs/StoryView.js @@ -1,5 +1,7 @@ var StoryView = ScrollableView.extend({ + loaded: false, + el: "#story", template: $("#story .template").html(), @@ -23,19 +25,19 @@ var StoryView = ScrollableView.extend({ }, populate: function(data){ + if (this.loaded) { console.warn("populate called twice"); return } + this.loaded = true this.data = data this.$loader.hide() this.$content.empty() // id title image[uri caption] body this.data.forEach(function(row){ var t = this.template.replace(/{{id}}/, row.id) - .replace(/{{title}}/, row.title) .replace(/{{body}}/, row.body.replace(/\n/g, "<br>")) var li = document.createElement("li") li.dataset.id = row.id li.innerHTML = row.title this.sections[row.id] = row - //console.log("ok"); this.$links.append(li) this.$content.append(t) }.bind(this)) diff --git a/StoneIsland/www/js/lib/nav/NavView.js b/StoneIsland/www/js/lib/nav/NavView.js index baa4df69..55865abb 100644 --- a/StoneIsland/www/js/lib/nav/NavView.js +++ b/StoneIsland/www/js/lib/nav/NavView.js @@ -11,6 +11,7 @@ var NavView = View.extend({ "click .archive": "archive", "click .login": "login", + "click .account": "account", "click .faq": "faq", "click .search": "search", @@ -74,15 +75,14 @@ var NavView = View.extend({ }, login: function(){ - if (auth.logged_in()) { - this.el.className = "account" - } - else { - this.hide() - app.router.go("account/login") - } + this.hide() + auth.last_view = app.view + app.router.go("account/login") }, - + account: function(){ + this.el.className = "account" + }, + back: function(){ this.el.className = "" }, diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 5fe1fe7b..84889db1 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -193,13 +193,14 @@ var ProductView = ScrollableView.extend({ save: function(){ // add to cart if ( ! auth.logged_in() ) { - auth.defer_add_to_cart = { size: this.size, code: this.code } + auth.deferred_product = { 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 { + else { + // ADD TO CART! } }, diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js index 5efea20e..294a862c 100644 --- a/StoneIsland/www/js/sdk/auth.js +++ b/StoneIsland/www/js/sdk/auth.js @@ -63,7 +63,17 @@ var auth = sdk.auth = (function(){ localStorage.removeItem("yoox.cart_id") cb && cb() } - + auth.create_cart = function(cb){ + cart.initialize().done(function(){ + cart.set_user().done(function(){ + auth.set_cart(sdk.cart.id, sdk.cart.token, function(){ + cb && cb() + }) + }) + }) + } + auth.defer_add_to_cart = function(){ + } auth.log_out = function(){ auth.access_token = "" auth.user_id = -1 diff --git a/StoneIsland/www/js/vendor/loader.js b/StoneIsland/www/js/vendor/loader.js index eeb4337e..cc9644f8 100644 --- a/StoneIsland/www/js/vendor/loader.js +++ b/StoneIsland/www/js/vendor/loader.js @@ -3,13 +3,7 @@ var Loader = Loader || (function(){ this.assets = {}; this.images = []; this.readyCallback = readyCallback; - // - // NOTE: there is some sort of race condition happening here.. the 'Story' page has duplicate - // title links as 'app.story.populate(data.story)' is being triggered twice in BlogView.js.. - // i changed 'this.count' below to 1 just to test it and it fixed it for a second.. but then it - // quit working again.. so something is awry this.count = 0 - // this.view = view this.loaded = false } |
