This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/models/top_list.js
Régis Hanol 129617b415 Lots of bugfixes
BUGFIX: navigation bar should always activate the right tab (even when diging into a top period)
BUGFIX: /top pages titles
BUGFIX: no "edit category" button on /top page after visiting a category
BUGFIX: properly hide category columns when there is no children category (on both filter + top pages)
BUGFIX: promises not caught when scrolling down a topic list to load more of them
BUGFIX: CSS on category dropdowns
Updated `top_menu` i18n with available filters
2014-01-18 19:27:25 +01:00

33 lines
945 B
JavaScript

/**
A data model representing a list of top topic lists
@class TopList
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
Discourse.TopList = Discourse.Model.extend({});
Discourse.TopList.reopenClass({
find: function(filter) {
return PreloadStore.getAndRemove("top_lists", function() {
var url = Discourse.getURL("/") + (filter || "top") + ".json";
return Discourse.ajax(url);
}).then(function (result) {
var topList = Discourse.TopList.create({ can_create_topic: result.can_create_topic });
Discourse.Site.currentProp('periods').forEach(function(period) {
// if there is a list for that period
if (result[period]) {
// instanciate a new topic list with no sorting
topList.set(period, Discourse.TopicList.from(result[period]));
topList.set(period + ".sortOrder", undefined);
}
});
return topList;
});
}
});