implement sidebar toggle [fixes SCI-2232]

This commit is contained in:
zmagod 2018-03-28 14:12:11 +02:00
parent 8f09e1f7a4
commit 7c1390ece2
7 changed files with 73 additions and 15 deletions

View file

@ -12,6 +12,7 @@
//= require jquery-ui/widgets/draggable
//= require jquery-ui/widgets/droppable
//= require jquery.ui.touch-punch.min
//= require jquery-ui/effects/effect-slide
//= require jquery.caret.min
//= require jquery.atwho.min
//= require hammer

View file

@ -0,0 +1,35 @@
(function(global) {
'use strict';
global.SideBarToggle = (function() {
function show() {
$('#sideBarLeft').show();
$('#sideBarRight').hide();
$('#sidebar-wrapper').show(
'slide', { direction: 'right', easing: 'linear' }, 400
);
$('#wrapper').css('paddingLeft', '280px');
$('.navbar-secondary').css(
{ 'margin-left': '-280px', 'padding-left': '280px' }
);
}
function hide() {
$('#sideBarLeft').hide();
$('#sideBarRight').show();
$('#sidebar-wrapper').hide(
'slide', { direction: 'left', easing: 'linear'}, 400
);
$('#wrapper').css('paddingLeft', '0');
$('.navbar-secondary').css({
'margin-left': '0',
'padding-left': '0'
});
}
return Object.freeze({
show: show,
hide: hide
})
})();
})(window);

View file

@ -11,7 +11,7 @@ class RepositoriesController < ApplicationController
before_action :check_create_permissions, only:
%i(create_new_modal create copy_modal copy)
# layout 'fluid'
layout 'fluid'
def index
unless @repositories.length.zero? && current_team

View file

@ -1,23 +1,30 @@
<%= content_for :sidebar do %>
<div id="slide-panel" class="visible">
<div class="sidebar-header">
<div class="sidebar-header-title">
<h5><%=t "libraries.sidebar.title" %></h5>
</div>
</div>
<div class="sidebar-header-toggle">
<a href="" id="toggle-sidebar-link">
<span class="glyphicon glyphicon-play-circle"></span>
</a>
</div>
<div class="tree">
<ul>
<li>
<span class="tree-link line-wrap no-indent">
<strong title="<%= t('libraries.sidebar.title') %>"><%= t('libraries.sidebar.title') %></strong>
</span>
</li>
<% repositories.each do |repository| %>
<% cache repository do %>
<li><%= link_to repository.name, repository_path(repository) %></li>
<li class="<%= 'active' if current_page?(repository_path(repository)) %>" >
<span class="tree-link line-wrap no-indent">
<%= link_to repository.name,
repository_path(repository),
data: { 'no-turbolink' => 'true' } %>
</span>
</li>
<% end %>
<% end %>
</ul>
</div>
</div>
<% end %>
<script>
$(document).ready(function() {
$('#wrapper').show();
})
</script>

View file

@ -1,13 +1,26 @@
<div id="left-menu-bar" class="menu-bar">
<ul class="nav">
<li class="text-center">
<span id="sideBarLeft"
class="glyphicon glyphicon-chevron-left"
aria-hidden="true"
onclick="SideBarToggle.hide()"
></span>
<span id="sideBarRight"
class="glyphicon glyphicon-chevron-right"
aria-hidden="true"
onclick="SideBarToggle.show()"
style="display:none;"
></span>
</li>
<li class="<%= "active" if projects_are_selected? %>">
<%= link_to projects_path, id: "projects-link", class: "toggle-sidebar-link", title: t('left_menu_bar.projects') do %>
<%= link_to projects_path, id: "projects-link", title: t('left_menu_bar.projects') do %>
<span class="glyphicon glyphicon-home"></span>
<span><%= t('left_menu_bar.projects') %></span>
<% end %>
</li>
<li class="<%= "active" if repositories_are_selected? %>">
<%= link_to team_repositories_path(current_team), id: "repositories-link", title: t('left_menu_bar.repositories') do %>
<%= link_to repositories_path, id: "repositories-link", title: t('left_menu_bar.repositories') do %>
<span class="fa fa-cubes" aria-hidden="true"></span>
<span><%= t('left_menu_bar.repositories') %></span>
<% end %>
@ -65,3 +78,5 @@
</li>
</ul>
</div>
<%= javascript_include_tag("sidebar_toggle") %>

View file

@ -1,6 +1,5 @@
<%= content_for :sidebar do %>
<div id="slide-panel" class="visible">
<div class="tree">
<ul>
<% if project_page? && action_name == 'index' ||

View file

@ -84,6 +84,7 @@ Rails.application.config.assets.precompile +=
%w(repositories/my_module_repository.js)
Rails.application.config.assets.precompile += %w(activities/index.js)
Rails.application.config.assets.precompile += %w(repositories/show.js)
Rails.application.config.assets.precompile += %w(sidebar_toggle.js)
# Libraries needed for Handsontable formulas
Rails.application.config.assets.precompile += %w(lodash.js)