Skip to content

Instantly share code, notes, and snippets.

@kennethdavidbuck
Last active December 22, 2015 18:59
Show Gist options
  • Save kennethdavidbuck/6516748 to your computer and use it in GitHub Desktop.
Save kennethdavidbuck/6516748 to your computer and use it in GitHub Desktop.
App.SwagProductDetailsView = App.BaseView.extend({
cssProperties:['width'],
_selectedObserver:function(){
"use strict";
var show = this.get('current.id') === this.get('item.id');
var width = show ? '326px' : '0px';
this.setProperties({ width:width, duration:300 });
}.observes('current.id','item.id').on('didInsertElement')
});
App.SwagRowController = Em.ObjectController.extend({
selected:true,
currentItem:null,
actions:{
selectProduct:function(product){
"use strict";
this.set('currentItem',product);
}
}
});
App.SwagRowProductController = Em.ObjectController.extend({
selected:false,
inStockLabel:Em.computed(function(){
"use strict";
return this.get('inStock') ? 'In Stock' : 'Out of Stock';
}).property('inStock')
});
{{#each row in controller itemController="SwagRow"}}
{{#each item in row.swagProducts itemController="SwagRowProduct"}}
<div class="swag-item" {{action "selectProduct" item}}>
<a class="image">
{{#if row.selected}}
<img {{bindAttr src="item.thumbnailLarge"}}>
{{else}}
<img {{bindAttr src="item.thumbnailSmall"}}>
{{/if}}
</a>
{{App.SwagProductDetailsView
class="swag-item-details"
itemBinding="item"
currentBinding="row.currentItem"}}
{{/each}}
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment