mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-10 22:14:35 -04:00
PERF: reduce one view, cleaner pattern for component visibility
This commit is contained in:
parent
eab12cc6b8
commit
d7c4987ecb
3 changed files with 24 additions and 10 deletions
app/assets/javascripts/discourse
|
@ -1,4 +1,6 @@
|
|||
export default Ember.Component.extend({
|
||||
import VisibleComponent from "discourse/components/visible-component";
|
||||
|
||||
export default VisibleComponent.extend({
|
||||
|
||||
visible: function () {
|
||||
var bannerKey = this.get("banner.key"),
|
||||
|
@ -20,6 +22,7 @@ export default Ember.Component.extend({
|
|||
Discourse.KeyValueStore.set({ key: "dismissed_banner_key", value: this.get("banner.key") });
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
export default Ember.Component.extend({
|
||||
visibleChanged: function(){
|
||||
this.rerender();
|
||||
}.observes("visible"),
|
||||
|
||||
render: function(buffer){
|
||||
if(!this.get("visible")){
|
||||
return;
|
||||
}
|
||||
|
||||
return this._super(buffer);
|
||||
}
|
||||
});
|
|
@ -1,10 +1,8 @@
|
|||
{{#if visible}}
|
||||
<div class="row">
|
||||
<div id="banner" {{bind-attr class="overlay"}}>
|
||||
<div id="banner-content">
|
||||
<div class="close" {{action "dismiss"}}><i class="fa fa-times" title="{{i18n banner.close}}"></i></div>
|
||||
{{{banner.html}}}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div id="banner" {{bind-attr class="overlay"}}>
|
||||
<div id="banner-content">
|
||||
<div class="close" {{action "dismiss"}}><i class="fa fa-times" title="{{i18n banner.close}}"></i></div>
|
||||
{{{banner.html}}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue