diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-04-07 04:15:56 +0200 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-04-07 04:15:56 +0200 |
| commit | 0a2932840bd13cde5fb2693b1c612ca0bf817149 (patch) | |
| tree | 4d470e4094ba314386e8fc9b4500d3135ff5df6a /StoneIsland/www/js/lib/products/CollectionView.js | |
| parent | d0e609bf53d071f0ae66682fb1a2c21201b437a4 (diff) | |
improve loading, preserve scroll position on collection view
Diffstat (limited to 'StoneIsland/www/js/lib/products/CollectionView.js')
| -rwxr-xr-x | StoneIsland/www/js/lib/products/CollectionView.js | 18 |
1 files changed, 13 insertions, 5 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) }, |
