mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 18:11:43 +08:00
35 lines
988 B
JavaScript
35 lines
988 B
JavaScript
import DiscourseURL from 'discourse/lib/url';
|
|
|
|
export default Ember.Controller.extend({
|
|
discoveryTopics: Ember.inject.controller('discovery/topics'),
|
|
navigationCategory: Ember.inject.controller('navigation/category'),
|
|
application: Ember.inject.controller(),
|
|
|
|
loading: false,
|
|
|
|
category: Em.computed.alias('navigationCategory.category'),
|
|
noSubcategories: Em.computed.alias('navigationCategory.noSubcategories'),
|
|
|
|
loadedAllItems: Em.computed.not("discoveryTopics.model.canLoadMore"),
|
|
|
|
_showFooter: function() {
|
|
this.set("application.showFooter", this.get("loadedAllItems"));
|
|
}.observes("loadedAllItems"),
|
|
|
|
showMoreUrl(period) {
|
|
let url = '', category = this.get('category');
|
|
if (category) {
|
|
url = '/c/' + Discourse.Category.slugFor(category) + (this.get('noSubcategories') ? '/none' : '') + '/l';
|
|
}
|
|
url += '/top/' + period;
|
|
return url;
|
|
},
|
|
|
|
actions: {
|
|
changePeriod(p) {
|
|
DiscourseURL.routeTo(this.showMoreUrl(p));
|
|
}
|
|
}
|
|
|
|
});
|