mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Refactor sidebar for "location" display
This commit is contained in:
@ -315,100 +315,3 @@ function setSidebarState(label, state) {
|
||||
// Save the state of this sidebar
|
||||
localStorage.setItem(`inventree-menu-state-${label}`, state);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle left-hand icon menubar display
|
||||
*/
|
||||
function enableNavbarX(options) {
|
||||
|
||||
var resize = true;
|
||||
|
||||
if ('resize' in options) {
|
||||
resize = options.resize;
|
||||
}
|
||||
|
||||
var label = options.label || 'nav';
|
||||
|
||||
label = `navbar-${label}`;
|
||||
|
||||
var stateLabel = `${label}-state`;
|
||||
var widthLabel = `${label}-width`;
|
||||
|
||||
var navId = options.navId || '#sidenav-right';
|
||||
|
||||
var toggleId = options.toggleId;
|
||||
|
||||
// Extract the saved width for this element
|
||||
$(navId).animate({
|
||||
'width': '45px',
|
||||
'min-width': '45px',
|
||||
'display': 'block',
|
||||
}, 50, function() {
|
||||
|
||||
// Make the navbar resizable
|
||||
if (resize) {
|
||||
$(navId).resizable({
|
||||
minWidth: options.minWidth || '100px',
|
||||
maxWidth: options.maxWidth || '500px',
|
||||
handles: 'e, se',
|
||||
grid: [5, 5],
|
||||
stop: function(event, ui) {
|
||||
// Record the new width
|
||||
var width = Math.round(ui.element.width());
|
||||
|
||||
// Reasonably narrow? Just close it!
|
||||
if (width <= 75) {
|
||||
$(navId).animate({
|
||||
width: '45px'
|
||||
}, 50);
|
||||
|
||||
localStorage.setItem(stateLabel, 'closed');
|
||||
} else {
|
||||
localStorage.setItem(widthLabel, `${width}px`);
|
||||
localStorage.setItem(stateLabel, 'open');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var state = localStorage.getItem(stateLabel);
|
||||
|
||||
var width = localStorage.getItem(widthLabel) || '250px';
|
||||
|
||||
if (state && state == 'open') {
|
||||
|
||||
$(navId).animate({
|
||||
width: width
|
||||
}, 100);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Register callback for 'toggle' button
|
||||
if (toggleId) {
|
||||
|
||||
$(toggleId).click(function() {
|
||||
|
||||
var state = localStorage.getItem(stateLabel) || 'closed';
|
||||
var width = localStorage.getItem(widthLabel) || '250px';
|
||||
|
||||
if (state == 'open') {
|
||||
$(navId).animate({
|
||||
width: '45px',
|
||||
minWidth: '45px',
|
||||
}, 50);
|
||||
|
||||
localStorage.setItem(stateLabel, 'closed');
|
||||
|
||||
} else {
|
||||
|
||||
$(navId).animate({
|
||||
'width': width
|
||||
}, 50);
|
||||
|
||||
localStorage.setItem(stateLabel, 'open');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% load i18n %}
|
||||
<a href="#" id='select-{{ label }}' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-selector" data-bs-parent="#sidebar">
|
||||
<a href="#" id='select-{{ label }}' title='{% trans text %}' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-selector" data-bs-parent="#sidebar">
|
||||
<i class="bi bi-bootstrap"></i><span class='sidebar-item-icon fas {{ icon }}'></span><span class='sidebar-item-text' style='display: none;'>{% trans text %}</span>
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user