mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 00:12:45 +08:00
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import ObjectController from 'discourse/controllers/object';
|
|
import TopPeriod from 'discourse/models/top-period';
|
|
|
|
export default ObjectController.extend({
|
|
needs: ['navigation/category', 'discovery/topics', 'application'],
|
|
loading: false,
|
|
|
|
category: Em.computed.alias('controllers.navigation/category.category'),
|
|
noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'),
|
|
|
|
loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"),
|
|
|
|
_showFooter: function() {
|
|
this.set("controllers.application.showFooter", this.get("loadedAllItems"));
|
|
}.observes("loadedAllItems"),
|
|
|
|
showMoreUrl(period) {
|
|
var url = '', category = this.get('category');
|
|
if (category) {
|
|
url = '/c/' + Discourse.Category.slugFor(category) + (this.get('noSubcategories') ? '/none' : '') + '/l';
|
|
}
|
|
url += '/top/' + period;
|
|
return url;
|
|
},
|
|
|
|
periods: function() {
|
|
const self = this,
|
|
periods = [];
|
|
this.site.get('periods').forEach(function(p) {
|
|
periods.pushObject(TopPeriod.create({ id: p,
|
|
showMoreUrl: self.showMoreUrl(p),
|
|
periods }));
|
|
});
|
|
return periods;
|
|
}.property('category', 'noSubcategories'),
|
|
|
|
});
|