mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 03:35:00 +08:00
Initialize item-lists on init event; allow items to be hidden
This commit is contained in:
parent
109fe23607
commit
98476757ae
|
@ -13,12 +13,12 @@ export default Ember.Component.extend({
|
|||
if (!Ember.isArray(items)) {
|
||||
return [];
|
||||
}
|
||||
var instances = [];
|
||||
items.forEach(function(item) {
|
||||
item.reopenClass({
|
||||
isListItem: item.proto().tagName === 'li',
|
||||
listItemClass: item.proto().listItemClass
|
||||
});
|
||||
item = item.create();
|
||||
item.set('isListItem', item.constructor.proto().tagName === 'li');
|
||||
instances.pushObject(item);
|
||||
});
|
||||
return items;
|
||||
return instances;
|
||||
})
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ import SeparatorItem from 'flarum/components/ui/separator-item';
|
|||
export default Ember.Mixin.create({
|
||||
itemLists: [],
|
||||
|
||||
initItemLists: Ember.on('didInsertElement', function() {
|
||||
initItemLists: Ember.on('init', function() {
|
||||
var self = this;
|
||||
this.get('itemLists').forEach(function(name) {
|
||||
self.initItemList(name);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{{#each item in listItems}}
|
||||
{{#if item.isListItem}}
|
||||
{{view item}}
|
||||
{{else}}
|
||||
<li class="{{item.listItemClass}}">{{view item}}</li>
|
||||
{{/if}}
|
||||
{{#unless item.isHiddenInList}}
|
||||
{{#if item.isListItem}}
|
||||
{{view item}}
|
||||
{{else}}
|
||||
<li class="{{item.listItemClass}}">{{view item}}</li>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
|
|
|
@ -54,12 +54,14 @@ export default Ember.View.extend(HasItemLists, {
|
|||
buttonClass: 'btn-primary',
|
||||
listItemClass: 'primary-control',
|
||||
}), 'controls');
|
||||
},
|
||||
|
||||
items.pushObjectWithTag(StreamScrubber.extend({
|
||||
addStreamScrubber: Ember.on('didInsertElement', function() {
|
||||
this.get('sidebar').pushObjectWithTag(StreamScrubber.extend({
|
||||
streamContent: this.get('streamContent'),
|
||||
listItemClass: 'title-control'
|
||||
}), 'scrubber');
|
||||
},
|
||||
}),
|
||||
|
||||
populateControls: function(items) {
|
||||
var view = this;
|
||||
|
|
Loading…
Reference in New Issue
Block a user