discourse-custom-header-links/common/header.html

39 lines
1004 B
HTML
Raw Normal View History

2018-06-24 02:54:36 -04:00
<script type="text/discourse-plugin" version="0.8.20">
let customHeaderLinks = settings.Custom_header_links;
2018-06-24 02:54:36 -04:00
customHeaderLinks.split("|").map(i => {
let seg = $.map(i.split(","), $.trim),
linkText = seg[0],
linkTitle = seg[1],
linkHref = seg[2],
2018-12-08 00:21:28 -05:00
deviceClass = "." + seg[3],
linkTarget = seg[4] === "self" ? "" : "_blank",
2018-12-08 00:21:28 -05:00
keepOnScrollClass = seg[5] === "keep" ? ".keep" : "";
2018-06-24 02:54:36 -04:00
api.decorateWidget("header-buttons:before", helper => {
return helper.h(
2018-12-08 00:21:28 -05:00
"li.headerLink" + deviceClass + keepOnScrollClass,
2018-06-24 02:54:36 -04:00
helper.h(
"a",
{
href: linkHref,
title: linkTitle,
target: linkTarget,
attributes: { "data-auto-route": "true" }
2018-06-24 02:54:36 -04:00
},
linkText
2018-06-24 02:54:36 -04:00
)
);
});
});
api.decorateWidget("home-logo:after", helper => {
let titleVisible = helper.attrs.minimized;
if (titleVisible) {
$(".d-header").addClass("hide-menus");
} else {
$(".d-header").removeClass("hide-menus");
}
});
2018-06-24 02:54:36 -04:00
</script>