diff options
Diffstat (limited to 'StoneIsland/www/js/lib/products')
| -rwxr-xr-x | StoneIsland/www/js/lib/products/CollectionView.js | 18 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/filters/SizeFilter.js | 7 |
2 files changed, 18 insertions, 7 deletions
diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index 803acc76..7b634138 100755 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/www/js/lib/products/CollectionView.js @@ -5,6 +5,7 @@ var CollectionView = ScrollableView.extend({ template: $("#collection .template").html(), loaded: false, data: null, + filtered_items: null, items: {}, events: { @@ -35,10 +36,11 @@ var CollectionView = ScrollableView.extend({ if (sdk.env !== "test" && app.closed.storeIsClosed) { return app.closed.show() } + if (this.data && this.data.SearchResponseFull.Results.Items.length < 4) { app.footer.hide() } - else if (app.store.FilterBy !== "none") { + if (app.store.FilterBy !== "none") { if (app.store.FilterBy === "category") { app.footer.show("FILTER") } @@ -126,16 +128,20 @@ var CollectionView = ScrollableView.extend({ // } console.log( data.SearchResponseFull.Results.Items.length ) + + var items = this.filtered_items || data.SearchResponseFull.Results.Items if (app.store.GroupBy === 'size') { - this.groupBySize( data.SearchResponseFull.Results.Items, is_single_product ) + this.groupBySize( items, is_single_product ) } else { - this.appendItems( data.SearchResponseFull.Results.Items, is_single_product ) + this.appendItems( items, is_single_product ) } - this.deferScrollToTop() + // this.restoreScroll() + // this.deferScrollToTop() } this.afterFetchCallback && this.afterFetchCallback() - app.collection.deferRefresh() + this.deferRefresh() + this.restoreScroll() }, groupBySize: function(items, is_single_product){ @@ -180,6 +186,7 @@ var CollectionView = ScrollableView.extend({ var $t = $(t) if (app.store.ShowProductNameOnCollectionPage) { var $title = $("<span>") + $title.addClass("product-title") $title.html( item['ModelNames'] ) $t.append($title) } @@ -189,6 +196,7 @@ var CollectionView = ScrollableView.extend({ pick: function(e){ var code = $(e.currentTarget).data("code") var data = this.items[code] + this.saveScroll() app.product.load(code, data) }, diff --git a/StoneIsland/www/js/lib/products/filters/SizeFilter.js b/StoneIsland/www/js/lib/products/filters/SizeFilter.js index a009dd15..d0231021 100644 --- a/StoneIsland/www/js/lib/products/filters/SizeFilter.js +++ b/StoneIsland/www/js/lib/products/filters/SizeFilter.js @@ -41,15 +41,18 @@ var SizeFilter = View.extend({ this.parent.$content.empty() if (choice.id == "__remove_filter") { this.last_choice = null + this.parent.filtered_items = 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){ + var items = 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.filtered_items = items + items.forEach(this.parent.append.bind(this.parent)) } this.parent.deferScrollToTop() }, |
