mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 12:18:54 +02:00
Moved some javascript into events_base.js
This commit is contained in:
parent
fed1621a58
commit
b9a86c6a59
8 changed files with 308 additions and 46 deletions
|
@ -1,5 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
import "patternfly-bootstrap-treeview/src/css/bootstrap-treeview.css"
|
||||
import "patternfly-bootstrap-treeview";
|
||||
|
||||
const SidebarHelper = class {
|
||||
constructor() {
|
||||
this.BASE = $("body").data("base-url");
|
||||
|
@ -9,9 +12,50 @@ const SidebarHelper = class {
|
|||
}
|
||||
console.info("Base path is " + this.BASE);
|
||||
|
||||
this.registerSidebarHideButton();
|
||||
this.fillTrees();
|
||||
}
|
||||
|
||||
registerSidebarHideButton()
|
||||
{
|
||||
let $sidebar = $("#fixed-sidebar");
|
||||
let $container = $("#main");
|
||||
let $toggler = $('#sidebar-toggle-button');
|
||||
|
||||
function sidebarHide() {
|
||||
$sidebar.hide();
|
||||
$container.removeClass('col-md-9 col-lg-10 offset-md-3 offset-lg-2');
|
||||
$container.addClass('col-12');
|
||||
$toggler.html('<i class="fas fa-angle-right"></i>');
|
||||
$toggler.data('hidden', true);
|
||||
localStorage.setItem('sidebarHidden', 'true');
|
||||
}
|
||||
function sidebarShow() {
|
||||
let $sidebar = $("#fixed-sidebar");
|
||||
$sidebar.show();
|
||||
let $container = $("#main");
|
||||
$container.removeClass('col-12');
|
||||
$container.addClass('col-md-9 col-lg-10 offset-md-3 offset-lg-2');
|
||||
$toggler.html('<i class="fas fa-angle-left"></i>');
|
||||
$toggler.data('hidden', false);
|
||||
localStorage.setItem('sidebarHidden', 'false');
|
||||
}
|
||||
|
||||
//Make the state persistent over reloads
|
||||
if(localStorage.getItem('sidebarHidden') === 'true') {
|
||||
sidebarHide();
|
||||
}
|
||||
|
||||
//Register handler
|
||||
$toggler.click(function() {
|
||||
if($(this).data('hidden')) {
|
||||
sidebarShow();
|
||||
} else {
|
||||
sidebarHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the trees with the given data.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue