mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 16:56:19 +08:00
39 lines
948 B
Plaintext
39 lines
948 B
Plaintext
|
import Ember from 'ember';
|
||
|
import ListItemViewMixin from './list-item-view-mixin';
|
||
|
|
||
|
var get = Ember.get, set = Ember.set;
|
||
|
|
||
|
export default Ember.View.extend(ListItemViewMixin, {
|
||
|
prepareForReuse: Ember.K,
|
||
|
|
||
|
init: function () {
|
||
|
this._super();
|
||
|
var context = Ember.ObjectProxy.create();
|
||
|
this.set('context', context);
|
||
|
this._proxyContext = context;
|
||
|
},
|
||
|
|
||
|
isVisible: Ember.computed('context.content', function () {
|
||
|
return !!this.get('context.content');
|
||
|
}),
|
||
|
|
||
|
updateContext: function (newContext) {
|
||
|
var context = get(this._proxyContext, 'content');
|
||
|
|
||
|
// Support old and new Ember versions
|
||
|
var state = this._state || this.state;
|
||
|
|
||
|
if (context !== newContext) {
|
||
|
if (state === 'inDOM') {
|
||
|
this.prepareForReuse(newContext);
|
||
|
}
|
||
|
|
||
|
set(this._proxyContext, 'content', newContext);
|
||
|
|
||
|
if (newContext && newContext.isController) {
|
||
|
set(this, 'controller', newContext);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|