mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 20:54:00 -06:00
Merge pull request #2050 from verg/unify_scroll_to_first_post
Scroll to Top of Topic instead of Reloading
This commit is contained in:
commit
24356cd807
@ -30,6 +30,13 @@ Discourse.HeaderController = Discourse.Controller.extend({
|
||||
self.set("currentUser.unread_notifications", 0);
|
||||
headerView.showDropdownBySelector("#user-notifications");
|
||||
});
|
||||
},
|
||||
|
||||
jumpToTopPost: function () {
|
||||
var topic = this.get('topic');
|
||||
if (topic) {
|
||||
Discourse.URL.routeTo(topic.get('firstPostUrl'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
||||
|
||||
actions: {
|
||||
jumpTop: function() {
|
||||
Discourse.URL.routeTo(this.get('url'));
|
||||
Discourse.URL.routeTo(this.get('firstPostUrl'));
|
||||
},
|
||||
|
||||
jumpBottom: function() {
|
||||
|
@ -68,7 +68,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||
// Helper to build a Url with a post number
|
||||
urlForPostNumber: function(postNumber) {
|
||||
var url = this.get('url');
|
||||
if (postNumber && (postNumber > 1)) {
|
||||
if (postNumber && (postNumber > 0)) {
|
||||
if (postNumber >= this.get('highest_post_number')) {
|
||||
url += "/last";
|
||||
} else {
|
||||
@ -91,6 +91,10 @@ Discourse.Topic = Discourse.Model.extend({
|
||||
return this.urlForPostNumber(this.get('highest_post_number'));
|
||||
}.property('url', 'highest_post_number'),
|
||||
|
||||
firstPostUrl: function () {
|
||||
return this.urlForPostNumber(1);
|
||||
}.property('url'),
|
||||
|
||||
lastPosterUrl: function() {
|
||||
return Discourse.getURL("/users/") + this.get("last_poster.username");
|
||||
}.property('last_poster'),
|
||||
|
@ -19,7 +19,7 @@
|
||||
{{boundCategoryLink topic.category}}
|
||||
{{#if topic.details.loaded}}
|
||||
{{topicStatus topic=topic}}
|
||||
<a class='topic-link' href='{{unbound topic.url}}'>{{{topic.fancy_title}}}</a>
|
||||
<a class='topic-link' href='{{unbound topic.url}}' {{action jumpToTopPost}}>{{{topic.fancy_title}}}</a>
|
||||
{{else}}
|
||||
{{#if topic.errorLoading}}
|
||||
{{topic.errorTitle}}
|
||||
|
@ -35,7 +35,7 @@
|
||||
{{boundCategoryLink category}}
|
||||
{{#if details.loaded}}
|
||||
{{topicStatus topic=model}}
|
||||
<a href='{{unbound url}}'>
|
||||
<a href='{{unbound url}}' {{action jumpTop}}>
|
||||
{{#if topicSaving}}
|
||||
{{fancy_title}}
|
||||
{{else}}
|
||||
|
Loading…
Reference in New Issue
Block a user