diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-13 19:58:25 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-13 19:58:25 -0500 |
| commit | 35fad4f7cb941b703e63089de599d50f92ed651a (patch) | |
| tree | f8d9c477ec9298ef426581914b2063b3e85285ec /StoneIsland/www/js/lib/products/CollectionView.js | |
| parent | d45eae9bc88525c9332a301ab753491a68253462 (diff) | |
selector. filter main collection.
Diffstat (limited to 'StoneIsland/www/js/lib/products/CollectionView.js')
| -rw-r--r-- | StoneIsland/www/js/lib/products/CollectionView.js | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index dbece93b..652aa92b 100644 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/www/js/lib/products/CollectionView.js @@ -32,7 +32,34 @@ var CollectionView = ScrollableView.extend({ }, ok: function(){ - // this.filter() + var cats = this.data.SearchResponseFull.Refinements.Filters.Categories.map(function(cat){ + return { + id: cat.Id, + label: cat.Value + } + }) + if (this.filter_choice) { + cats.push({ + id: "__remove_filter", + label: "REMOVE FILTER", + }) + } + app.selector.select(cats, this.filter.bind(this)) + }, + filter_choice: null, + filter: function(choice){ + this.$content.empty() + if (choice.id == "__remove_filter") { + this.filter_choice = null + this.data.SearchResponseFull.Results.Items.forEach(this.append.bind(this)) + } + else { + this.filter_choice = choice + this.data.SearchResponseFull.Results.Items.filter(function(item){ + return item.MacroCategory == choice.label + }).forEach(this.append.bind(this)) + } + this.deferScrollToTop() }, fetch: function(){ @@ -56,18 +83,19 @@ var CollectionView = ScrollableView.extend({ this.$loader.hide() this.$content.empty() // DefaultCode10 - data.SearchResponseFull.Results.Items.forEach(function(item){ - this.items[ item['Code8'] ] = item - var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f')) - .replace(/{{code8}}/, item['Code8']) - this.$content.append(t) - }.bind(this)) - + data.SearchResponseFull.Results.Items.forEach(this.append.bind(this)) this.deferScrollToTop() } this.afterFetchCallback && this.afterFetchCallback() }, + append: function(item){ + this.items[ item['Code8'] ] = item + var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f')) + .replace(/{{code8}}/, item['Code8']) + this.$content.append(t) + }, + pick: function(e){ var code = $(e.currentTarget).data("code") var data = this.items[code] |
