diff options
| -rwxr-xr-x | StoneIsland/www/index.html | 1 | ||||
| -rwxr-xr-x | StoneIsland/www/js/lib/blogs/BlogView.js | 26 | ||||
| -rwxr-xr-x | StoneIsland/www/js/lib/products/CollectionView.js | 26 | ||||
| -rwxr-xr-x | StoneIsland/www/js/lib/products/ProductView.js | 13 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/filters/DepartmentFilter.js | 1 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/filters/SizeFilter.js | 42 |
6 files changed, 85 insertions, 24 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 28c4f8c6..59c328fd 100755 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -1138,6 +1138,7 @@ <script src="js/lib/products/CollectionView.js"></script> <script src="js/lib/products/filters/CategoryFilter.js"></script> <script src="js/lib/products/filters/DepartmentFilter.js"></script> +<script src="js/lib/products/filters/SizeFilter.js"></script> <script src="js/lib/products/ClosedStoreView.js"></script> <script src="js/lib/products/ProductView.js"></script> <script src="js/lib/products/GalleryView.js"></script> diff --git a/StoneIsland/www/js/lib/blogs/BlogView.js b/StoneIsland/www/js/lib/blogs/BlogView.js index fe36e025..2f63a5bc 100755 --- a/StoneIsland/www/js/lib/blogs/BlogView.js +++ b/StoneIsland/www/js/lib/blogs/BlogView.js @@ -31,25 +31,27 @@ 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 && sdk.env !== 'test') { - app.closed.populate(data.store[0].ClosedStoreImages) + 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') { @@ -76,16 +78,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/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index 67a3a456..ab4393e6 100755 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/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(){ @@ -98,7 +112,6 @@ var CollectionView = ScrollableView.extend({ if (is_single_product) { console.log("IS SINGLE PRODUCT") var item = data.SearchResponseFull.Results.Items[0] - console.log(item) var url = sdk.image(item['DefaultCode10'], '13_f') console.log(url) var img = new Image () @@ -142,9 +155,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/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 4ae77c1f..1c05c629 100755 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -118,9 +118,9 @@ var ProductView = ScrollableView.extend({ var title = name_partz.join(' ') 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) @@ -198,8 +198,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 +210,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/www/js/lib/products/filters/DepartmentFilter.js b/StoneIsland/www/js/lib/products/filters/DepartmentFilter.js index cc0d925e..7d5ccf3d 100644 --- a/StoneIsland/www/js/lib/products/filters/DepartmentFilter.js +++ b/StoneIsland/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/www/js/lib/products/filters/SizeFilter.js b/StoneIsland/www/js/lib/products/filters/SizeFilter.js new file mode 100644 index 00000000..87409bbb --- /dev/null +++ b/StoneIsland/www/js/lib/products/filters/SizeFilter.js @@ -0,0 +1,42 @@ +var SizeFilter = View.extend({ + + initialize: function(opt){ + this.parent = opt.parent + }, + + filter: function(){ + var cats = this.parent.data.SearchResponseFull.Refinements.Filters.Sizes.map(function(cat){ + return { + id: cat.Id, + label: cat.Value + } + }) + 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.Id == choice.id })) + return item.Sizes.some(function(size){ return size.Id == choice.id }) + }).forEach(this.parent.append.bind(this.parent)) + } + this.parent.deferScrollToTop() + }, + +}) |
