This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/app/assets/javascripts/discourse/controllers/discovery.js.es6
2014-11-10 21:51:55 +01:00

35 lines
1.2 KiB
JavaScript

import ObjectController from 'discourse/controllers/object';
import TopPeriod from 'discourse/models/top-period';
export default ObjectController.extend({
needs: ['navigation/category', 'discovery/topics'],
loading: false,
loadingSpinner: false,
scheduledSpinner: null,
category: Em.computed.alias('controllers.navigation/category.category'),
noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'),
loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"),
showMoreUrl: function(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() {
var self = this,
periods = [];
Discourse.Site.currentProp('periods').forEach(function(p) {
periods.pushObject(TopPeriod.create({ id: p,
showMoreUrl: self.showMoreUrl(p),
periods: periods }));
});
return periods;
}.property('category', 'noSubcategories'),
});