summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-05 01:02:20 -0500
committerJules Laplace <jules@okfoc.us>2015-11-05 01:02:20 -0500
commit4a04a1129fffd1e128e53ba7886777c8d7b36b55 (patch)
tree79d394f2e14909e234ce8ffb9e1dfe5244678d23 /StoneIsland/www/js/lib
parent83517eb8d489cfceda8e6b7ab1b104a8f0b1f3a8 (diff)
populate product view
Diffstat (limited to 'StoneIsland/www/js/lib')
-rw-r--r--StoneIsland/www/js/lib/_router.js1
-rw-r--r--StoneIsland/www/js/lib/blogs/ArchiveView.js5
-rw-r--r--StoneIsland/www/js/lib/blogs/BlogView.js6
-rw-r--r--StoneIsland/www/js/lib/blogs/HubView.js5
-rw-r--r--StoneIsland/www/js/lib/blogs/StoryView.js9
-rw-r--r--StoneIsland/www/js/lib/products/CollectionView.js21
-rw-r--r--StoneIsland/www/js/lib/products/ProductView.js15
7 files changed, 44 insertions, 18 deletions
diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js
index 567d1aad..8a117e39 100644
--- a/StoneIsland/www/js/lib/_router.js
+++ b/StoneIsland/www/js/lib/_router.js
@@ -43,6 +43,7 @@ var SiteRouter = Router.extend({
product: function(code){
app.view = app.product
app.product.load(code)
+ app.product.show()
},
hub: function(){
diff --git a/StoneIsland/www/js/lib/blogs/ArchiveView.js b/StoneIsland/www/js/lib/blogs/ArchiveView.js
index 13bacb22..783254cc 100644
--- a/StoneIsland/www/js/lib/blogs/ArchiveView.js
+++ b/StoneIsland/www/js/lib/blogs/ArchiveView.js
@@ -20,11 +20,12 @@ var ArchiveView = View.extend({
this.data = data
this.$loader.hide()
this.$content.empty()
+
+ // id title images[ uri label code caption ]
this.data.forEach(function(row){
- var t = this.template.replace(/{{image}}/, row.image.url)
+ var t = this.template.replace(/{{image}}/, row.images[0].uri)
.replace(/{{code}}/, row.code)
.replace(/{{title}}/, row.title)
- .replace(/{{body}}/, row.body)
this.$content.append(t)
}.bind(this))
},
diff --git a/StoneIsland/www/js/lib/blogs/BlogView.js b/StoneIsland/www/js/lib/blogs/BlogView.js
index 70fc910a..573fe3c3 100644
--- a/StoneIsland/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/www/js/lib/blogs/BlogView.js
@@ -19,13 +19,13 @@ var BlogView = View.extend({
success: function(data){
this.loaded = true
this.data = data
- this.loader.preloadImage(data.archive[0].image.url, function(img){
+ this.loader.preloadImage(data.archive[0].images[0].uri, function(img){
app.archive.populate(data.archive)
})
- this.loader.preloadImage(data.hub[0].image.url, function(img){
+ this.loader.preloadImage(data.hub[0].image.uri, function(img){
app.hub.populate(data.hub)
})
- this.loader.preloadImage(data.story[0].image.url, function(img){
+ this.loader.preloadImage(data.story[0].image.uri, function(img){
app.story.populate(data.story)
})
},
diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js
index 95cdef3f..62e8d10f 100644
--- a/StoneIsland/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/www/js/lib/blogs/HubView.js
@@ -20,14 +20,15 @@ var HubView = View.extend({
this.data = data
this.$loader.hide()
this.$content.empty()
+ // id date subtitle body link image[uri caption]
this.data.forEach(function(row){
- var t = this.template.replace(/{{image}}/, row.image.url)
+ var t = this.template.replace(/{{image}}/, row.images[0].uri)
.replace(/{{date}}/, row.date)
.replace(/{{code}}/, row.code)
.replace(/{{title}}/, row.title)
.replace(/{{subtitle}}/, row.subtitle)
.replace(/{{link}}/, row.link)
- .replace(/{{body}}/, row.body)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
this.$content.append(t)
}.bind(this))
},
diff --git a/StoneIsland/www/js/lib/blogs/StoryView.js b/StoneIsland/www/js/lib/blogs/StoryView.js
index b47b0488..efdd65a7 100644
--- a/StoneIsland/www/js/lib/blogs/StoryView.js
+++ b/StoneIsland/www/js/lib/blogs/StoryView.js
@@ -4,6 +4,7 @@ var StoryView = View.extend({
template: $("#story .template").html(),
events: {
+ "load img": "image_loaded"
},
initialize: function(){
@@ -20,13 +21,17 @@ var StoryView = View.extend({
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(/{{image}}/, row.image.url)
+ var t = this.template.replace(/{{image}}/, row.image.uri)
.replace(/{{date}}/, row.date)
.replace(/{{title}}/, row.title)
- .replace(/{{body}}/, row.body)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
this.$content.append(t)
}.bind(this))
},
+
+ image_loaded: function(){
+ },
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js
index d638171b..a1a506a3 100644
--- a/StoneIsland/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/www/js/lib/products/CollectionView.js
@@ -1,4 +1,5 @@
-var CollectionView = View.extend({
+
+var CollectionView = ScrollableView.extend({
el: "#collection",
template: $("#collection .template").html(),
@@ -25,18 +26,25 @@ var CollectionView = View.extend({
},
fetch: function(){
+ if (this.loaded) return
this.$loader.show()
sdk.product.collection({
- gallery_id: 31617,
+ gallery_id: 32780,
success: this.populate.bind(this)
})
},
populate: function(data){
+ if (this.loaded && ! data) {
+ data = this.data
+ }
+ else {
+ this.data = data
+ }
+ this.loaded = true
this.$loader.hide()
this.$content.empty()
// DefaultCode10
- console.log(data)
data.SearchResponseFull.Results.Items.forEach(function(item){
this.items[ item['Code8'] ] = item
var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f'))
@@ -44,10 +52,9 @@ var CollectionView = View.extend({
this.$content.append(t)
}.bind(this))
- setTimeout(function(){
- this.scroller.refresh()
- app.collection.scroller.scrollTo(0, 0)
- }.bind(this), 0)
+ this.deferScrollToTop()
+
+ this.afterFetchCallback && this.afterFetchCallback()
},
pick: function(e){
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index c0a1ee79..0e4063df 100644
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -8,7 +8,7 @@ var SIZE_LOOKUP = {
"XXXL": "XXX-LARGE",
};
-var ProductView = View.extend({
+var ProductView = ScrollableView.extend({
el: "#product",
@@ -44,7 +44,16 @@ var ProductView = View.extend({
cache: {},
load: function(code, data){
- window.location.href = "#/product/" + code
+ this.show()
+ if (! app.collection.loaded) {
+ app.collection.afterFetchCallback = this.load.bind(this, code, data)
+ app.collection.fetch()
+ return
+ }
+ else {
+ app.collection.afterFetchCallback = null
+ }
+ window.location.href = "#/store/" + code
data = data || app.collection.items[code]
if (code in this.cache) {
return this.populate(data, this.cache[code])
@@ -59,6 +68,8 @@ var ProductView = View.extend({
},
populate: function(data, details){
+ this.show()
+console.log(data, details)
var name_partz = data['ModelNames'].split(' ')
var num = name_partz.shift()
var title = name_partz.join(' ')