Fix for using non-ascii category name as a link in top_menu

This commit is contained in:
Neil Lalonde 2013-06-14 15:49:48 -04:00
parent f198c814a8
commit 002d4b4e23
1 changed files with 15 additions and 4 deletions

View File

@ -20,12 +20,23 @@ Discourse.NavItem = Discourse.Model.extend({
return split[0] === 'category' ? split[1] : null; return split[0] === 'category' ? split[1] : null;
}.property('name'), }.property('name'),
categorySlug: function() {
var split = this.get('name').split('/');
if (split[0] === 'category' && split[1]) {
var cat = Discourse.Site.instance().categories.findProperty('name', split[1]);
return cat ? Discourse.Category.slugFor(cat) : null;
}
return null;
}.property('name'),
// href from this item // href from this item
href: function() { href: function() {
var name = this.get('name'), var name = this.get('name');
href = Discourse.getURL("/") + name.replace(' ', '-'); if( name.split('/')[0] === 'category' ) {
if (name === 'category') href += "/" + this.get('categoryName'); return Discourse.getURL("/") + 'category/' + this.get('categorySlug');
return href; } else {
return Discourse.getURL("/") + name.replace(' ', '-');
}
}.property('name'), }.property('name'),
count: function() { count: function() {