FIX: Support using enter to change the hash, clicks should update hash

This commit is contained in:
Robin Ward 2015-09-11 12:44:37 -04:00
parent 7454722247
commit 62cc029886
2 changed files with 4 additions and 1 deletions

View File

@ -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));
} }
}; };

View File

@ -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;
} }