summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js')
-rwxr-xr-xStoneIsland/platforms/ios/www/js/index.js8
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js41
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/etc/push.js2
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/products/CollectionView.js78
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/products/ProductView.js22
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/filters/DepartmentFilter.js1
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/filters/SizeFilter.js57
-rwxr-xr-xStoneIsland/platforms/ios/www/js/sdk/_sdk.js4
8 files changed, 172 insertions, 41 deletions
diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js
index 06bfaaac..43b55b04 100755
--- a/StoneIsland/platforms/ios/www/js/index.js
+++ b/StoneIsland/platforms/ios/www/js/index.js
@@ -4,7 +4,13 @@ var app = (function(){
app.init = function(){
console.log("init")
- sdk.init({ env: "production" })
+ if (window.location.hostname === 'lvh.me' || window.location.hostname === 'stone.giraffe.life') {
+ console.log('launching in test mode')
+ sdk.init({ env: "test" })
+ }
+ else {
+ sdk.init({ env: "production" })
+ }
app.bind()
app.build()
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
index 1bd56908..aa9d1d39 100755
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
@@ -9,8 +9,8 @@ var BlogView = View.extend({
fetch: function(fn){
$.ajax({
method: "GET",
-// url: sdk.env == 'test' ? '/db.json' : "https://stone.sup.land/db.json",
- url: "https://stone.sup.land/db.json",
+ url: sdk.env === 'test' ? '/db.json' : "https://stone.sup.land/db.json",
+ // url: "https://stone.sup.land/db.json",
success: function(data){
this.success(data)
fn && fn()
@@ -31,27 +31,36 @@ var BlogView = View.extend({
this.loaded = true
this.data = data = typeof data == "string" ? JSON.parse(data) : data
- switch (data.store[0].DepartmentStoreStatus) {
+ app.store = data.store[0]
+
+ switch (app.store.DepartmentStoreStatus) {
case "open":
app.closed.storeIsClosed = false
break
case "closed":
app.closed.storeIsClosed = true
- app.closed.storeClosedMessageOne = data.store[0].StoreClosedMessageOne
- app.closed.storeClosedMessageTwo = data.store[0].StoreClosedMessageTwo
+ app.closed.storeClosedMessageOne = app.store.StoreClosedMessageOne
+ app.closed.storeClosedMessageTwo = app.store.StoreClosedMessageTwo
break
}
-
- if (app.closed.storeIsClosed) {
- app.closed.populate(data.store[0].ClosedStoreImages)
+
+ // sdk.env = 'test'
+
+ if (app.closed.storeIsClosed && sdk.env !== 'test') {
+ app.closed.populate(app.store.ClosedStoreImages)
}
else {
- app.departments = data.store[0].Departments
- app.department_id = data.store[0].Departments[0].uri
- $("#collections h1").toggleClass("single-dept", data.store[0].Departments.length == 1)
- app.collection.setCollectionName( data.store[0].Departments[0].text )
+ app.departments = app.store.Departments
+ app.department_id = app.store.Departments[0].uri
+ $("#collections h1").toggleClass("single-dept", app.store.Departments.length == 1)
+ app.collection.setCollectionName( app.store.Departments[0].text )
//// demo department for shoes with weird SizeTypeId
// app.department_id = "NKDrtSC"
+ if (sdk.env === 'test') {
+ app.department_id = window.location.search.substr(1) || app.department_id
+ console.log('using test department id', app.department_id)
+ }
+ // app.department_id = 'TSTD'
app.collection.loaded = false
app.collection.fetch()
}
@@ -72,16 +81,16 @@ var BlogView = View.extend({
app[page.tag].populate(page)
})
- console.log(data.store[0].StoreStatus)
+ console.log(app.store.StoreStatus)
app.product.fitLargeCodes = {}
- if (data.store[0].FittingCodes.length) {
- data.store[0].FittingCodes.split("\n").forEach(function(code){
+ if (app.store.FittingCodes.length) {
+ app.store.FittingCodes.split("\n").forEach(function(code){
app.product.fitLargeCodes[code] = true
})
}
- if (data.store[0].BackgroundIsGray === "true") {
+ if (app.store.BackgroundIsGray === "true") {
app.collection.$el.addClass("gray")
app.product.gallery.$el.addClass("gray")
}
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/push.js b/StoneIsland/platforms/ios/www/js/lib/etc/push.js
index da63fdd1..043a4d75 100755
--- a/StoneIsland/platforms/ios/www/js/lib/etc/push.js
+++ b/StoneIsland/platforms/ios/www/js/lib/etc/push.js
@@ -2,7 +2,7 @@ var push = (function(){
var push = { settings: {}, disabled: false }
var pushPlugin
push.init = function(){
- if (device.platform !== "ios") {
+ if (! ('device' in window) || device.platform !== "ios") {
push.disabled = true
return
}
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
index 3bc2623c..803acc76 100755
--- a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
@@ -22,7 +22,8 @@ var CollectionView = ScrollableView.extend({
this.$content = this.$(".content")
this.$loader = this.$(".loader")
this.scroller = new IScroll('#collection', app.iscroll_options)
- this.filterView = new DepartmentFilter ({ parent: this })
+ this.departmentFilterView = new DepartmentFilter ({ parent: this })
+ this.sizeFilterView = new SizeFilter ({ parent: this })
},
show: function(){
@@ -37,8 +38,13 @@ var CollectionView = ScrollableView.extend({
if (this.data && this.data.SearchResponseFull.Results.Items.length < 4) {
app.footer.hide()
}
- else {
- app.footer.show("FILTER")
+ else if (app.store.FilterBy !== "none") {
+ if (app.store.FilterBy === "category") {
+ app.footer.show("FILTER")
+ }
+ else {
+ app.footer.show("FILTER BY " + app.store.FilterBy.toUpperCase())
+ }
}
document.body.className = "collection"
if (this.loaded) {
@@ -50,8 +56,16 @@ var CollectionView = ScrollableView.extend({
}
},
+ // called when footer is tapped - filter by (x)
save: function(){
- this.filterView.filter()
+ switch (app.store.FilterBy) {
+ case 'none':
+ this.departmentFilterView.filter()
+ break
+ case 'size':
+ this.sizeFilterView.filter()
+ break
+ }
},
fetch: function(){
@@ -112,21 +126,64 @@ var CollectionView = ScrollableView.extend({
// }
console.log( data.SearchResponseFull.Results.Items.length )
- data.SearchResponseFull.Results.Items.forEach(function(item){
- console.log(">>> ITEM")
- this.append(item, is_single_product)
- }.bind(this))
+ if (app.store.GroupBy === 'size') {
+ this.groupBySize( data.SearchResponseFull.Results.Items, is_single_product )
+ }
+ else {
+ this.appendItems( data.SearchResponseFull.Results.Items, is_single_product )
+ }
this.deferScrollToTop()
}
this.afterFetchCallback && this.afterFetchCallback()
app.collection.deferRefresh()
},
+ groupBySize: function(items, is_single_product){
+ var groups = {}
+ items.forEach(function(item){
+ if (! item.Sizes.length) return
+ var size = item.Sizes[0]
+ var id = size['Text']
+ if ( ! (id in groups) ) {
+ groups[id] = {
+ label: SIZE_LOOKUP[ id ],
+ items: [],
+ }
+ }
+ groups[id].items.push( item )
+ }.bind(this))
+
+ Object.keys(groups).sort(function(a,b){
+ var ao = SIZE_ORDER.indexOf( a )
+ var bo = SIZE_ORDER.indexOf( b )
+ return ao - bo
+ }).forEach(function(id){
+ var size = groups[id]
+ var $el = $("<div>")
+ $el.addClass("product-group")
+ $el.html( size.label )
+ this.$content.append($el)
+ this.appendItems( size.items, is_single_product )
+ }.bind(this))
+ },
+
+ appendItems: function(items, is_single_product){
+ items.forEach(function(item){
+ this.append(item, is_single_product)
+ }.bind(this))
+ },
+
append: function(item, is_single_product){
this.items[ item['Code8'] ] = item
var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], is_single_product ? '13_f' : '11_f'))
.replace(/{{code8}}/, item['Code8'])
- this.$content.append(t)
+ var $t = $(t)
+ if (app.store.ShowProductNameOnCollectionPage) {
+ var $title = $("<span>")
+ $title.html( item['ModelNames'] )
+ $t.append($title)
+ }
+ this.$content.append($t)
},
pick: function(e){
@@ -141,9 +198,10 @@ var CollectionView = ScrollableView.extend({
this.$title.html(this.collectionName)
},
+ // filter by department
showDepartmentSelector: function(){
if (this.$("h1").hasClass("single-dept")) {
- this.filterView.filter()
+ this.departmentFilterView.filter()
}
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
index 4ae77c1f..6a61be1b 100755
--- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
@@ -16,7 +16,7 @@ var ProductView = ScrollableView.extend({
this.gallery = new GalleryView ()
this.scroller = new IScroll('#product', app.iscroll_options)
- this.$num = this.$(".num")
+ this.$productHeader = this.$(".product-header")
this.$title = this.$(".title")
this.$type = this.$(".type")
this.$price = this.$(".price")
@@ -113,14 +113,12 @@ var ProductView = ScrollableView.extend({
var descriptions = this.get_descriptions(details)
- var name_partz = data['ModelNames'].split(' ')
- var num = name_partz.shift()
- var title = name_partz.join(' ')
+ var title = data['ModelNames']
var type = title_case( data['MicroCategory'] )
var price = "$" + data['DiscountedPrice'] + ".00"
- var details = descriptions['Details'] || ""
+ var details_description = descriptions['Details'] || ""
var editorial = descriptions['EditorialDescription'] || ""
- var body = details + " " + editorial
+ var body = details_description + " " + editorial
// body = body.replace(/<br>/g, "<br><br>").replace(/(<br>)+$/, "")
var default_color_id = this.populate_selectors(data, details)
@@ -164,11 +162,12 @@ var ProductView = ScrollableView.extend({
console.log( data['DefaultCode10'] )
- this.$num.html(num)
this.$title.html(title)
this.$type.html(type)
this.$price.html(price)
this.$body.html(body)
+
+ this.$productHeader.toggleClass("wide", title.length > 48)
var fits_large = !! this.fitLargeCodes[this.code]
app.product.$fit.toggle( fits_large )
@@ -198,8 +197,11 @@ var ProductView = ScrollableView.extend({
populate_selectors: function(data, details){
var sizes = {}, colors = {}, size_lookup = {}, default_color
- console.log(details['Item']['ModelColors'].length)
- if (! details['Item']['ModelColors'].length) {
+
+ var modelColors = details['Item']['ModelColors'] || []
+ console.log('colors:', modelColors.length || "none")
+
+ if (! modelColors.length) {
this.not_available = true
return
}
@@ -207,7 +209,7 @@ var ProductView = ScrollableView.extend({
this.not_available = false
}
- details['Item']['ModelColors'].forEach(function(color, index){
+ modelColors.forEach(function(color, index){
if (! default_color || color['Code10'] == data['DefaultCode10']) {
default_color = color['ColorId']
}
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/filters/DepartmentFilter.js b/StoneIsland/platforms/ios/www/js/lib/products/filters/DepartmentFilter.js
index cc0d925e..7d5ccf3d 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/filters/DepartmentFilter.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/filters/DepartmentFilter.js
@@ -6,7 +6,6 @@ var DepartmentFilter = View.extend({
filter: function(){
var deps = app.departments.map(function(dep){
- console.log(dep)
return {
id: dep.uri,
label: dep.text,
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/filters/SizeFilter.js b/StoneIsland/platforms/ios/www/js/lib/products/filters/SizeFilter.js
new file mode 100644
index 00000000..a009dd15
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/products/filters/SizeFilter.js
@@ -0,0 +1,57 @@
+var SizeFilter = View.extend({
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ filter: function(){
+ var seen_sizes = {}
+ var sizes = []
+ this.parent.data.SearchResponseFull.Results.Items.forEach(function(item){
+ item.Sizes.forEach(function(size){
+ if (size.Id in seen_sizes) {
+ return
+ }
+ seen_sizes[size.Id] = true
+ sizes.push(size)
+ })
+ })
+ sizes.sort(function(a,b){
+ return a.Id - b.Id
+ })
+
+ var cats = sizes.map(function(cat){
+ return {
+ id: cat.Id,
+ label: cat.Text,
+ }
+ })
+ if (this.last_choice) {
+ cats.push({
+ id: "__remove_filter",
+ label: "REMOVE FILTER",
+ })
+ }
+ app.selector.select("wide", cats, this.pick.bind(this))
+ },
+
+ last_choice: null,
+
+ pick: function(choice){
+ this.parent.$content.empty()
+ if (choice.id == "__remove_filter") {
+ this.last_choice = null
+ this.parent.data.SearchResponseFull.Results.Items.forEach(this.parent.append.bind(this.parent))
+ }
+ else {
+ this.last_choice = choice
+ console.log("filtering for size", choice.id)
+ this.parent.data.SearchResponseFull.Results.Items.filter(function(item){
+ console.log(item.Sizes.map(function(s){ return s }))
+ return item.Sizes.some(function(size){ return size.Id == choice.id })
+ }).forEach(this.parent.append.bind(this.parent))
+ }
+ this.parent.deferScrollToTop()
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
index 017df015..705ca002 100755
--- a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
@@ -9,7 +9,7 @@ var sdk = (function(){
sdk.init = function(opt){
switch (sdk.env = opt.env || "development") {
case 'test':
- endpoint = "http://lvh.me:9090/"
+ endpoint = window.location.origin + "/"
break
default:
case 'development':
@@ -26,7 +26,7 @@ var sdk = (function(){
}
sdk.image = function(code, size){
- return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg"
+ return "https://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg"
}
$.ajaxSetup({