mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
BUGFIX: clicking on the Logo generates a javascript error
This commit is contained in:
@ -25,6 +25,19 @@ Discourse.ListController = Discourse.Controller.extend({
|
|||||||
});
|
});
|
||||||
}.property("category"),
|
}.property("category"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Refresh our current topic list
|
||||||
|
@method refresh
|
||||||
|
**/
|
||||||
|
refresh: function() {
|
||||||
|
debugger;
|
||||||
|
var listTopicsController = this.get('controllers.listTopics');
|
||||||
|
listTopicsController.set('model.loaded', false);
|
||||||
|
this.load(this.get('filterMode')).then(function (topicList) {
|
||||||
|
listTopicsController.set('model', topicList);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load a list based on a filter
|
Load a list based on a filter
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
@param {String} path The path we are replacing our history state with.
|
@param {String} path The path we are replacing our history state with.
|
||||||
**/
|
**/
|
||||||
replaceState: function(path) {
|
replaceState: function(path) {
|
||||||
|
|
||||||
if (window.history &&
|
if (window.history &&
|
||||||
window.history.pushState &&
|
window.history.pushState &&
|
||||||
window.history.replaceState &&
|
window.history.replaceState &&
|
||||||
@ -48,7 +47,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
@param {String} path The path we are routing to.
|
@param {String} path The path we are routing to.
|
||||||
**/
|
**/
|
||||||
routeTo: function(path) {
|
routeTo: function(path) {
|
||||||
|
|
||||||
var oldPath = window.location.pathname;
|
var oldPath = window.location.pathname;
|
||||||
path = path.replace(/https?\:\/\/[^\/]+/, '');
|
path = path.replace(/https?\:\/\/[^\/]+/, '');
|
||||||
|
|
||||||
@ -120,7 +118,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
@param {String} path the path we're navigating to
|
@param {String} path the path we're navigating to
|
||||||
**/
|
**/
|
||||||
navigatedToPost: function(oldPath, path) {
|
navigatedToPost: function(oldPath, path) {
|
||||||
|
|
||||||
var newMatches = this.TOPIC_REGEXP.exec(path),
|
var newMatches = this.TOPIC_REGEXP.exec(path),
|
||||||
newTopicId = newMatches ? newMatches[2] : null;
|
newTopicId = newMatches ? newMatches[2] : null;
|
||||||
|
|
||||||
@ -168,7 +165,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
@param {String} path the path we're navigating to
|
@param {String} path the path we're navigating to
|
||||||
**/
|
**/
|
||||||
navigatedToHome: function(oldPath, path) {
|
navigatedToHome: function(oldPath, path) {
|
||||||
|
|
||||||
var defaultFilter = "/" + Discourse.ListController.filters[0];
|
var defaultFilter = "/" + Discourse.ListController.filters[0];
|
||||||
|
|
||||||
if (path === "/" && (oldPath === "/" || oldPath === defaultFilter)) {
|
if (path === "/" && (oldPath === "/" || oldPath === defaultFilter)) {
|
||||||
@ -217,5 +213,4 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
return Discourse.__container__.lookup('controller:' + name);
|
return Discourse.__container__.lookup('controller:' + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
18
test/javascripts/lib/url_test.js
Normal file
18
test/javascripts/lib/url_test.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module("Discourse.URL");
|
||||||
|
|
||||||
|
test("navigatedToHome", function() {
|
||||||
|
var fakeListController = { refresh: function() { return true; } };
|
||||||
|
var mock = sinon.mock(fakeListController);
|
||||||
|
this.stub(Discourse.URL, "controllerFor").returns(fakeListController);
|
||||||
|
|
||||||
|
mock.expects("refresh").twice();
|
||||||
|
ok(Discourse.URL.navigatedToHome("/", "/"));
|
||||||
|
|
||||||
|
var defaultFilter = "/" + Discourse.ListController.filters[0];
|
||||||
|
ok(Discourse.URL.navigatedToHome(defaultFilter, "/"));
|
||||||
|
|
||||||
|
ok(!Discourse.URL.navigatedToHome("/old", "/new"));
|
||||||
|
|
||||||
|
// make sure we called the .refresh() method
|
||||||
|
mock.verify();
|
||||||
|
});
|
Reference in New Issue
Block a user