2023-09-11 22:10:03 +00:00
|
|
|
{{- $page := .page }}
|
|
|
|
{{- $class := .class | default "" }}
|
|
|
|
{{- $href := (trim .href " ") | default "" }}
|
2023-09-18 18:24:49 +00:00
|
|
|
{{- $onempty := cond (isset . "onempty") .onempty "disable" }}
|
|
|
|
{{- $onwidths := cond (isset . "onwidths") .onwidths "show" }}
|
|
|
|
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
|
|
|
|
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- $target := .target | default "" }}
|
|
|
|
{{- $type := .type | default "" }}
|
|
|
|
{{- $isDisabled := not $href }}
|
|
|
|
{{- $isButton := false }}
|
|
|
|
{{- if or (not $href) (strings.HasPrefix $href "javascript:") }}
|
|
|
|
{{- $isButton = true }}
|
|
|
|
{{- $href = substr $href (len "javascript:") }}
|
|
|
|
{{- if not $type }}
|
|
|
|
{{- $type = "button" }}
|
|
|
|
{{- end }}
|
|
|
|
{{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }}
|
|
|
|
{{- $target = "_blank" }}
|
|
|
|
{{- if isset $page.Site.Params "externallinktarget" }}
|
|
|
|
{{- $target = $page.Site.Params.externalLinkTarget }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- $title := (trim .title " ") | default "" }}
|
|
|
|
{{- $icon := (trim .icon " ") | default "" }}
|
|
|
|
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
|
|
|
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
|
|
|
{{- end }}
|
2023-09-14 22:23:41 +00:00
|
|
|
{{- $content := .content }}
|
2023-09-18 18:24:49 +00:00
|
|
|
<div class="topbar-button {{ $class }}" data-content-empty="{{ $onempty }}" data-width-s="{{ $onwidths }}" data-width-m="{{ $onwidthm }}" data-width-l="{{ $onwidthl }}">
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- if $isDisabled }}
|
2023-09-18 18:24:49 +00:00
|
|
|
<span class="topbar-control">
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- else if $isButton }}
|
2023-09-18 18:24:49 +00:00
|
|
|
<button class="topbar-control"{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }} title="{{ $title }}">
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- else }}
|
2023-09-18 18:24:49 +00:00
|
|
|
<a class="topbar-control"{{ if $href }} href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}{{ end }} title="{{ $title }}">
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- end }}
|
2023-09-12 21:09:14 +00:00
|
|
|
<i class="{{ $icon }}"></i>
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- if $isDisabled }}
|
2023-09-12 21:09:14 +00:00
|
|
|
</span>
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- else if $isButton }}
|
2023-09-12 21:09:14 +00:00
|
|
|
</button>
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- else }}
|
2023-09-12 21:09:14 +00:00
|
|
|
</a>
|
2023-09-14 22:23:41 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- if $content }}
|
2023-09-18 18:24:49 +00:00
|
|
|
<div class="topbar-content">
|
|
|
|
<div class="topbar-content-wrapper">
|
2023-09-14 22:23:41 +00:00
|
|
|
{{- $content }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-11 22:10:03 +00:00
|
|
|
{{- end }}
|
2023-09-12 21:09:14 +00:00
|
|
|
</div>
|