Skip to content

Commit

Permalink
Allow the href setting to be a function.
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Apr 29, 2016
1 parent a244c33 commit 1ac6dd1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/assets/javascripts/discourse/widgets/home-logo.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export default createWidget('home-logo', {
href: '/'
},

href() {
const href = this.settings.href;
return (typeof href === "function") ? href() : href;
},

logo() {
const { siteSettings } = this;
const mobileView = this.site.mobileView;
Expand Down Expand Up @@ -38,13 +43,13 @@ export default createWidget('home-logo', {
},

html() {
return h('a', { attributes: { href: this.settings.href } }, this.logo());
return h('a', { attributes: { href: this.href(), 'data-auto-route': true } }, this.logo());
},

click(e) {
if (wantsNewWindow(e)) { return false; }
e.preventDefault();
DiscourseURL.routeTo(this.settings.href);
DiscourseURL.routeTo(this.href());
return false;
}

Expand Down

0 comments on commit 1ac6dd1

Please sign in to comment.