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

38 lines
954 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],
deviceClass = " ." + seg[3],
linkTarget = seg[4] === "self" ? "" : "_blank",
keepOnScrollClass = seg[5] === "keep" ? " .keep" : "";
2018-06-24 02:54:36 -04:00
api.decorateWidget("header-buttons:before", helper => {
return helper.h(
"li.headerLink." + deviceClass + keepOnScrollClass,
2018-06-24 02:54:36 -04:00
helper.h(
"a",
{
href: linkHref,
title: linkTitle,
target: linkTarget
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>