app/views/layouts/_header.html.erb
<header>
<div id="navbar-wrapper">
<div class="container">
<div id="navbar" class="navbar">
<div class="navbar-inner">
<div id="banner" class="container">
<%= link_to root_path, id: "page-logo" do %>
<picture>
<source srcset="<%= asset_path(Setting.large_banner_path) %>" media="(min-width: 580px)">
<%= image_tag Setting.small_banner_path, class: "img-responsive" %>
</picture>
<% end %>
</div>
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a href="/" class="brand" title="<%= Setting.site_brand%>"><%= Setting.site_brand%></a>
<div class="nav-collapse collapse">
<ul id="button-rack" class="nav nav-pills pull-right">
<li class = "<%= 'active' if current_page?(root_url) || current_page?(volunteer_ops_path) %>">
<%= link_to "Home", root_path %>
</li>
<% if feature_active? :organisations %>
<li class="<%= active_if 'organisations' %>">
<%= link_to "Organisations", organisations_path %>
</li>
<% end %>
<% if feature_active? :events %>
<li class="<%= active_if 'events' %>">
<%= link_to "Events", events_path %>
</li>
<% end %>
<% if feature_active? :services %>
<li class="<%= active_if 'services' %>">
<%= link_to "Services", services_path %>
</li>
<% end %>
<% if feature_active? :volunteer_ops_list %>
<li class="<%= active_if 'volunteer_ops' %>">
<%= link_to "Volunteers", volunteer_ops_path %>
</li>
<% end %>
<% if current_user.nil? %>
<li class="dropdown " id="menuLogin">
<a class="dropdown-toggle" href="#" data-toggle="dropdown" id="navLogin">Login</a>
<div class="dropdown-menu" id="login" style="padding:17px; width: 300px; padding-bottom: 0px;">
<div class="well">
<%= form_for(resource, :class => "collapse", :html => {:id => "loginForm"}, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div>
<label>Login:</label>
<!--[if lt IE 10]>
<label for="user_email">Enter email</label>
<![endif]-->
<%= f.email_field :email, :autofocus => true, :placeholder => "you@example.com" %>
</div>
<div>
<!--[if lt IE 10]>
<label for="user_password">Enter password</label>
<![endif]-->
<%= f.password_field :password, :placeholder => "password" %>
</div>
<% if @organisation %>
<%= f.hidden_field :organisation_id, :value => @organisation.id %>
<% end %>
<% if devise_mapping.rememberable? -%>
<div id = "remember_me"><%= f.check_box :remember_me %> <%= f.label :remember_me, class: "checkbox inline" %></div>
<% end -%>
<div style="display: inline;"><%= f.submit "Sign in", :id => 'signin', :class => "btn btn-primary" %></div>
<%= link_to "Forgot your password?", new_password_path(resource_name) %>
<% end %>
<div id="register">
<%= form_for(resource, :class => "collapse", :html => {:id => "registerForm"}, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<label>Sign up:</label>
<%= devise_error_messages! %>
<!--[if lt IE 10]>
<label for="user_password">Enter email</label>
<![endif]-->
<%= f.email_field :email, :autofocus => true, :id => 'signup_email', :name => 'user[email]', :placeholder => "you@example.com" %>
<!--[if lt IE 10]>
<label for="user_password">Enter password</label>
<![endif]-->
<%= f.password_field :password, :id => 'signup_password', :name => 'user[password]', :placeholder => "password" %>
<!--[if lt IE 10]>
<label for="user_password">Confirm password</label>
<![endif]-->
<%= f.password_field :password_confirmation, :id => 'signup_password_confirmation', :placeholder => 'confirm password' %>
<div style="display: inline;"><%= f.submit "Sign up", :id => 'signup', :class => "btn btn-primary" %></div>
<% end %>
</div>
<form>
<%= link_to('New organisation? Sign up', '#', :id => 'toggle_link', :title => 'Click this link to Sign Up for an account') %>
</form>
</div>
</div>
</li>
<% else %>
<% if current_user.superadmin? %>
<li class="dropdown" id="menuSuperAdmin">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Admin</a>
<ul class="dropdown-menu" >
<li><%= link_to 'Invite Users to become admin of Organisations', organisations_report_path %></li>
<li><%= link_to 'Registered Users', users_report_path %></li>
<li><%= link_to 'Invited Users', invited_users_report_path %></li>
<li><%= link_to 'Deleted Users', deleted_users_report_path %></li>
<li><%= link_to 'Pending Proposed Edits', proposed_organisation_edits_path %></li>
<li><%= link_to 'Pending Proposed Organisations', proposed_organisations_path %></li>
<li><%= link_to 'New Event', new_event_path %></li>
</ul>
</li>
<% end %>
<li class="dropdown">
<a href="#" id="<%= current_user.email %>" class="dropdown-toggle" data-toggle="dropdown" title="Logged in as: <%= current_user.email %>">
<i class="fa fa-user"></i>
<%= current_user.email %>
</a>
<ul class="dropdown-menu">
<li><%= link_to "Log out", destroy_user_session_path, :method => :delete %></li>
</ul>
</li>
<% end %>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<script>
$('#registerForm').collapse('hide');
$('#loginForm').collapse('show');
$('a#toggle_link').on('click', function (e) {
e.preventDefault();
// Get all relevant elements
var $link = $('a#toggle_link');
var $collapse1 = $('#loginForm');
var $collapse2 = $('#registerForm');
// Toggle the collapse of the forms
$collapse1.collapse('toggle');
$collapse2.collapse('toggle');
// Change the link text
if ($link.text() == 'New organisation? Sign up') {
$link.text('Already a member? Log in');
}
else {
$link.text('New organisation? Sign up');
}
});
</script>