scinote-web/app/views/shared/_navigation.html.erb

162 lines
6.2 KiB
Text
Raw Normal View History

2016-02-12 23:52:43 +08:00
<nav class="navbar navbar-default navbar-fixed-top" id="main-nav">
2018-03-12 23:27:35 +08:00
<div class="container-fluid">
2016-02-12 23:52:43 +08:00
<!-- header -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
2017-06-27 19:46:49 +08:00
<%= link_to(root_path, class: 'navbar-brand', title: t('nav.label.scinote')) do %>
2018-03-12 23:27:35 +08:00
<%= image_tag('/images/scinote_icon.jpg', id: 'logo') %>
<% end %>
2016-02-12 23:52:43 +08:00
</div>
<% if user_signed_in? %>
<div class="collapse navbar-collapse" id="main-menu">
2018-03-12 23:27:35 +08:00
<ul class="nav navbar-nav navbar-left" id="nav-team-switch">
<!-- Global team switch -->
<% if current_user.teams.length > 0 %>
<li id="team-switch">
<div class="btn-group">
<button type="button" class="btn btn-default"><%= truncate_team_name(current_team.name) %></button>
<button type="button"
class="btn btn-default dropdown-toggle"
2018-03-12 23:27:35 +08:00
title="<%= t('nav.label.teams') %>"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<% if current_user.teams.length > 1 || can_create_teams? %>
<ul class="dropdown-menu">
<%= form_for(current_user,
url: user_current_team_path,
method: :post) do |f| %>
<%= hidden_field(:user, :current_team_id) %>
<div class="dropdown-header"><%= t('nav.team_switch_title') %></div>
2018-03-12 23:27:35 +08:00
<% current_user.teams.each do |team| %>
<li class="team-name-item">
<a href="#"
data-id="<%= team.id %>"
class="text-center change-team">
<% if current_team == team %>
<span class="fas fa-check-circle"></span> <strong><%= team.name %></strong>
2018-03-12 23:27:35 +08:00
<% else %>
<span class="team-name"><%= team.name %></span>
<% end %>
</a>
</li>
<% end %>
<% end %>
<% if current_user.teams.length > 1 && can_create_teams? %>
<li>
<%= link_to new_team_path do %>
<span class="fas fa-plus"></span>
2018-03-12 23:27:35 +08:00
<%= t('users.settings.teams.index.new_team') %>
<% end %>
</li>
<% end %>
</ul>
<% end %>
</div>
</li>
<% end %>
2018-03-12 23:27:35 +08:00
</ul>
2018-03-16 22:56:12 +08:00
<!-- profile info -->
<ul class="nav navbar-nav navbar-right">
<!-- search form -->
2016-02-12 23:52:43 +08:00
<li>
2018-03-12 23:27:35 +08:00
<%= form_tag search_path,
method: :get,
id: 'search-bar',
class: 'navbar-form',
role: 'search' do %>
<div class="input-group">
<input class="form-control"
type="text"
name="q"
placeholder="<%= t('nav.search') %>" />
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><%=t 'nav.search_button' %></button>
</span>
</div>
<% end %>
2016-02-12 23:52:43 +08:00
</li>
2018-03-12 23:27:35 +08:00
<!-- greetings -->
<li id="user-account-dropdown" class="dropdown">
<a href="#"
class="dropdown-toggle"
2018-03-12 23:27:35 +08:00
title="<%= t('nav.label.account') %>"
data-toggle="dropdown"
role="button"
aria-haspopup="true"
aria-expanded="false">
<span>
2018-03-12 23:27:35 +08:00
<%= t('nav.user_greeting', full_name: current_user.full_name) %>
</span>
2018-03-12 23:27:35 +08:00
<%= image_tag avatar_path(current_user, :icon_small),
class: "avatar" %>
</a>
2018-03-23 22:14:49 +08:00
<ul class="dropdown-menu" data-hook="navigation-user-menu">
<li>
<%= link_to t('nav.user.logout'),
destroy_user_session_path,
method: :delete %>
</li>
<li role="separator" class="divider">
<li>
<%= link_to '#', data: { trigger: 'about-modal' } do %>
2018-03-23 23:19:06 +08:00
<%= t('nav.user.about') %>
2018-03-23 22:14:49 +08:00
<% end %>
</li>
</ul>
</li>
<!-- notifications -->
<li class="dropdown">
<a href="#"
id="notifications-dropdown"
class="dropdown-toggle"
2017-06-27 19:46:49 +08:00
title="<%= t('nav.label.notifications') %>"
data-toggle="dropdown"
role="button"
aria-haspopup="true"
aria-expanded="false"
data-href="<%= recent_notifications_url(current_user) %>">
2018-03-30 23:03:44 +08:00
<i class="fas fa-bell"></i>
2017-06-27 19:46:49 +08:00
<span class="visible-xs-inline visible-sm-inline"><%= t('nav.label.notifications') %></span>
<span id="count-notifications"
data-href="<%= unseen_notification_url(current_user) %>">
</span>
</a>
<ul class="dropdown-menu dropdown-notifications">
<li class="notifications-dropdown-header">
<span><%= t('notifications.title') %></span>
<span class="pull-right">
<%= link_to t('nav.user.settings'), preferences_path %>
</span>
</li>
<li class="notifications-no-recent">
<em><%= t('notifications.no_recent') %></em>
</li>
<li class="notifications-dropdown-footer">
<%= link_to t('notifications.show_all'), notifications_path %>
</li>
</ul>
</li>
</ul>
2016-02-12 23:52:43 +08:00
</div>
<% end %>
</div>
</nav>
<div id="loading-animation"></div>
<%= javascript_include_tag("navigation") %>