mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +08:00
implement sidebar toggle [fixes SCI-2232]
This commit is contained in:
parent
8f09e1f7a4
commit
7c1390ece2
7 changed files with 73 additions and 15 deletions
|
@ -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
|
||||
|
|
35
app/assets/javascripts/sidebar_toggle.js.erb
Normal file
35
app/assets/javascripts/sidebar_toggle.js.erb
Normal 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);
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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") %>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<%= content_for :sidebar do %>
|
||||
<div id="slide-panel" class="visible">
|
||||
|
||||
<div class="tree">
|
||||
<ul>
|
||||
<% if project_page? && action_name == 'index' ||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue