mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 14:36:28 +08:00
FIX: Support using enter to change the hash, clicks should update hash
This commit is contained in:
parent
7454722247
commit
62cc029886
|
@ -1,8 +1,10 @@
|
||||||
import interceptClick from 'discourse/lib/intercept-click';
|
import interceptClick from 'discourse/lib/intercept-click';
|
||||||
|
import DiscourseURL from 'discourse/lib/url';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "click-interceptor",
|
name: "click-interceptor",
|
||||||
initialize() {
|
initialize() {
|
||||||
$('#main').on('click.discourse', 'a', interceptClick);
|
$('#main').on('click.discourse', 'a', interceptClick);
|
||||||
|
$(window).on('hashchange', () => DiscourseURL.routeTo(document.location.hash));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,7 +105,7 @@ const DiscourseURL = Ember.Object.createWithMixins({
|
||||||
It contains the logic necessary to route within a topic using replaceState to
|
It contains the logic necessary to route within a topic using replaceState to
|
||||||
keep the history intact.
|
keep the history intact.
|
||||||
**/
|
**/
|
||||||
routeTo: function(path, opts) {
|
routeTo(path, opts) {
|
||||||
if (Em.isEmpty(path)) { return; }
|
if (Em.isEmpty(path)) { return; }
|
||||||
|
|
||||||
if (Discourse.get('requiresRefresh')) {
|
if (Discourse.get('requiresRefresh')) {
|
||||||
|
@ -122,6 +122,7 @@ const DiscourseURL = Ember.Object.createWithMixins({
|
||||||
// Scroll to the same page, different anchor
|
// Scroll to the same page, different anchor
|
||||||
if (path.indexOf('#') === 0) {
|
if (path.indexOf('#') === 0) {
|
||||||
this.scrollToId(path);
|
this.scrollToId(path);
|
||||||
|
history.replaceState(undefined, undefined, path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user