summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-13 20:23:08 -0500
committerJules Laplace <jules@okfoc.us>2015-11-13 20:23:08 -0500
commita8d09a3420a94531d465057339a3e5b42a05c761 (patch)
tree4a35dd29c3512cd877fc4feb567b4beff9d51f5d
parent93e3a8798987bcc714b6da832ecea849ad904324 (diff)
make size/color filters work
-rw-r--r--StoneIsland/www/index.html2
-rw-r--r--StoneIsland/www/js/lib/products/ProductView.js29
-rw-r--r--StoneIsland/www/js/lib/products/filters/ColorFilter.js16
-rw-r--r--StoneIsland/www/js/lib/products/filters/SizeFilter.js16
4 files changed, 10 insertions, 53 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html
index 22e2792a..6fb061b1 100644
--- a/StoneIsland/www/index.html
+++ b/StoneIsland/www/index.html
@@ -490,8 +490,6 @@
<script src="js/lib/products/CollectionView.js"></script>
<script src="js/lib/products/filters/CategoryFilter.js"></script>
-<script src="js/lib/products/filters/SizeFilter.js"></script>
-<script src="js/lib/products/filters/ColorFilter.js"></script>
<script src="js/lib/products/ProductView.js"></script>
<script src="js/lib/products/GalleryView.js"></script>
<script src="js/lib/products/Selector.js"></script>
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index 829fdc4b..df604d5b 100644
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -20,9 +20,6 @@ var ProductView = ScrollableView.extend({
this.$size = this.$(".size")
this.$color = this.$(".color")
this.$body = this.$(".body")
-
- this.colorFilter = new ColorFilter({ parent: this })
- this.sizeFilter = new SizeFilter({ parent: this })
},
show: function(){
@@ -138,6 +135,7 @@ var ProductView = ScrollableView.extend({
default_color = color['ColorId']
}
colors[ color['ColorId'] ] = {
+ id: color['Code10'],
code: color['Code10'],
label: color['ColorDescription'],
sizes: {},
@@ -147,6 +145,7 @@ var ProductView = ScrollableView.extend({
var label = SIZE_LOOKUP[ size['Default']['Text'] ]
size_lookup[ label ] = size['SizeId']
sizes[ size['SizeId'] ] = {
+ id: label,
label: label,
colors: {},
}
@@ -163,14 +162,10 @@ var ProductView = ScrollableView.extend({
select_size: function(){
if (this.item['Sizes'].length == 0) { return }
- var mapped_sizes = this.item['Sizes'].map(function(size){
- return {
- id: size['Id'],
- label: SIZE_LOOKUP[ size['Text'] ],
- value: size,
- }
- })
- app.selector.select(mapped_sizes, function(size){
+ var sizes = Object.keys(this.sizes).map(function(key){
+ return this.sizes[key]
+ }.bind(this))
+ app.selector.select(sizes, function(size){
this.size = size.value
this.$size.html(size.label)
}.bind(this))
@@ -178,14 +173,10 @@ var ProductView = ScrollableView.extend({
select_color: function(){
if (this.item['Colors'].length == 0) { return }
- var mapped_colors = this.item['Colors'].map(function(color){
- return {
- id: color['Id'],
- label: color['Text'],
- value: color,
- }
- })
- app.selector.select(mapped_colors, function(color){
+ var colors = Object.keys(this.colors).map(function(key){
+ return this.colors[key]
+ }.bind(this))
+ app.selector.select(colors, function(color){
this.color = color.value
this.$color.html(color.label)
}.bind(this))
diff --git a/StoneIsland/www/js/lib/products/filters/ColorFilter.js b/StoneIsland/www/js/lib/products/filters/ColorFilter.js
deleted file mode 100644
index 7b9ab5aa..00000000
--- a/StoneIsland/www/js/lib/products/filters/ColorFilter.js
+++ /dev/null
@@ -1,16 +0,0 @@
-var ColorFilter = View.extend({
-
- initialize: function(opt){
- this.parent = opt.parent
- },
-
- filter: function(){
- var colors = this.find_colors_for_size(this.parent.size)
- app.selector.select(colors, this.pick.bind(this))
- },
-
- pick: function(choice){
- this.parent.color
- },
-
-})
diff --git a/StoneIsland/www/js/lib/products/filters/SizeFilter.js b/StoneIsland/www/js/lib/products/filters/SizeFilter.js
deleted file mode 100644
index 46f1c234..00000000
--- a/StoneIsland/www/js/lib/products/filters/SizeFilter.js
+++ /dev/null
@@ -1,16 +0,0 @@
-var SizeFilter = View.extend({
-
- initialize: function(opt){
- this.parent = opt.parent
- },
-
- filter: function(){
- var sizes = this.find_sizes_for_color(this.parent.color)
- app.selector.select(sizes, this.pick.bind(this))
- },
-
- pick: function(choice){
- this.parent.size
- },
-
-})