This repository has been archived on 2023-03-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
osr-discourse-src/app/assets/javascripts/discourse/views/discovery_topics_view.js
T
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

46 lines
1.1 KiB
JavaScript

/**
This view handles rendering of a list of topics under discovery, with support
for loading more as well as remembering your scroll position.
@class ComboboxView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.DiscoveryTopicsView = Discourse.View.extend(Discourse.LoadMore, {
eyelineSelector: '.topic-list-item',
_scrollTop: function() {
Em.run.schedule('afterRender', function() {
$(document).scrollTop(0);
});
}.on('didInsertElement'),
actions: {
loadMore: function() {
var self = this;
Discourse.notifyTitle(0);
this.get('controller').loadMoreTopics().then(function (hasMoreResults) {
Em.run.schedule('afterRender', function() {
self.saveScrollPosition();
});
if (!hasMoreResults) {
self.get('eyeline').flushRest();
}
});
}
},
// Remember where we were scrolled to
saveScrollPosition: function() {
Discourse.Session.current().set('topicListScrollPosition', $(window).scrollTop());
},
// When the topic list is scrolled
scrolled: function() {
this._super();
this.saveScrollPosition();
}
});