spee.ch/views/partials/navBar.handlebars
2018-01-24 09:27:36 -08:00

66 lines
3.8 KiB
Handlebars

<div class="row row--wide nav-bar">
<div class="row row--padded row--short flex-container--row flex-container--space-between-center">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" height="24px" viewBox="0 0 80 31" enable-background="new 0 0 80 31" xml:space="preserve" class="nav-bar-logo">
<a href="/">
<title>Logo</title>
<desc>Spee.ch logo</desc>
<g id="About">
<g id="Publish-Form-V2-_x28_filled_x29_" transform="translate(-42.000000, -23.000000)">
<g id="Group-17" transform="translate(42.000000, 22.000000)">
<text transform="matrix(1 0 0 1 0 20)" font-size="25" font-family="Roboto">Spee&lt;h</text>
<g id="Group-16" transform="translate(0.000000, 30.000000)">
<path id="Line-8" fill="none" stroke="#09F911" stroke-width="1" stroke-linecap="square" d="M0.5,1.5h15"/>
<path id="Line-8-Copy" fill="none" stroke="#029D74" stroke-width="1" stroke-linecap="square" d="M16.5,1.5h15"/>
<path id="Line-8-Copy-2" fill="none" stroke="#E35BD8" stroke-width="1" stroke-linecap="square" d="M32.5,1.5h15"/>
<path id="Line-8-Copy-3" fill="none" stroke="#4156C5" stroke-width="1" stroke-linecap="square" d="M48.5,1.5h15"/>
<path id="Line-8-Copy-4" fill="none" stroke="#635688" stroke-width="1" stroke-linecap="square" d="M64.5,1.5h15"/>
</g>
</g>
</g>
</g>
</a>
</svg>
<div class="nav-bar--center">
<span class="nav-bar-tagline">Open-source, decentralized image and video sharing.</span>
</div>
<div class="nav-bar--right">
<a class="nav-bar-link link--nav" href="/">Publish</a>
<!--<a class="nav-bar-link link--nav" href="/popular">Popular</a>-->
<a class="nav-bar-link link--nav" href="/about">About</a>
{{#if user }}
<select type="text" id="nav-bar-channel-select" class="select select--arrow link--nav" onchange="toggleNavBarSelection(event)">
<option id="nav-bar-channel-select-channel-option" >{{user.channelName}}</option>
<option value="VIEW" data-channelUrl="/{{user.channelName}}:{{user.channelClaimId}}">View</option>
<option value="LOGOUT">Logout</option>
</select>
{{else}}
<a id="nav-bar-login-link" class="nav-bar-link link--nav" href="/login">Channel</a>
{{/if}}
</div>
</div>
</div>
<script type="text/javascript">
// highlight the link for the current page
const navBarLinks = document.getElementsByClassName('link--nav');
for (let i = 0; i < navBarLinks.length; i++){
const link = navBarLinks[i];
if (link.href == window.location.href) {
link.setAttribute('class', 'nav-bar-link link--nav-active');
} else if (`/${link.value}` === window.location.pathname) {
link.setAttribute('class', 'select select--arrow link--nav-active');
}
}
// function to send user to their channel if selected
function toggleNavBarSelection (event) {
console.log('toggleNavBarSelection event', event);
const selectedOption = event.target.selectedOptions[0].value;
if (selectedOption === 'LOGOUT') {
// send logout request to server
window.location.href = '/logout';
} else if (selectedOption === 'VIEW') {
// redirect to channel page
window.location.href = event.target.selectedOptions[0].dataset.channelUrl;
}
}
</script>