mirror of
https://github.com/discourse/discourse-custom-header-links.git
synced 2025-05-06 08:28:19 +00:00
DEV: When decorating home-logo, allow target blank
This commit is contained in:
parent
0a67cc44ea
commit
6c59a269f2
@ -1,5 +1,6 @@
|
|||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "discourse-custom-header-links",
|
name: "discourse-custom-header-links",
|
||||||
@ -22,14 +23,8 @@ export default {
|
|||||||
.split("|")
|
.split("|")
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map((customHeaderLinksArray) => {
|
.map((customHeaderLinksArray) => {
|
||||||
const [
|
const [linkText, linkTitle, linkHref, device, target, keepOnScroll] =
|
||||||
linkText,
|
customHeaderLinksArray
|
||||||
linkTitle,
|
|
||||||
linkHref,
|
|
||||||
device,
|
|
||||||
target,
|
|
||||||
keepOnScroll,
|
|
||||||
] = customHeaderLinksArray
|
|
||||||
.split(",")
|
.split(",")
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map((x) => x.trim());
|
.map((x) => x.trim());
|
||||||
@ -75,6 +70,24 @@ export default {
|
|||||||
dHeader.classList.remove("hide-menus");
|
dHeader.classList.remove("hide-menus");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (settings.links_position === "left") {
|
||||||
|
// if links are aligned left, we need to be able to open in a new tab
|
||||||
|
api.reopenWidget("home-logo", {
|
||||||
|
click(e) {
|
||||||
|
if (e.target.id === "site-logo") {
|
||||||
|
if (wantsNewWindow(e)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
DiscourseURL.routeToTag($(e.target).closest("a")[0]);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user