2015-02-10 15:35:40 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
/**
|
|
|
|
Output a list of components within a <ul>, making sure each one is contained
|
|
|
|
in an <li> element.
|
|
|
|
*/
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
layoutName: 'components/ui/item-list',
|
|
|
|
tagName: 'ul',
|
|
|
|
|
|
|
|
listItems: Ember.computed('items.[]', function() {
|
|
|
|
var items = this.get('items');
|
|
|
|
if (!Ember.isArray(items)) {
|
|
|
|
return [];
|
|
|
|
}
|
2015-03-05 09:36:40 +08:00
|
|
|
var instances = [];
|
2015-02-10 15:35:40 +08:00
|
|
|
items.forEach(function(item) {
|
2015-03-05 09:36:40 +08:00
|
|
|
item = item.create();
|
|
|
|
item.set('isListItem', item.constructor.proto().tagName === 'li');
|
|
|
|
instances.pushObject(item);
|
2015-02-10 15:35:40 +08:00
|
|
|
});
|
2015-03-05 09:36:40 +08:00
|
|
|
return instances;
|
2015-02-10 15:35:40 +08:00
|
|
|
})
|
|
|
|
});
|