mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add sidebar grip and make drag-openable
This commit is contained in:
parent
59eccb116a
commit
aa4bf4d640
@ -41,50 +41,88 @@ RED.sidebar = function() {
|
||||
$("#sidebar-separator").draggable({
|
||||
axis: "x",
|
||||
start:function(event,ui) {
|
||||
sidebarSeparator.closing = false;
|
||||
sidebarSeparator.opening = false;
|
||||
var winWidth = $(window).width();
|
||||
sidebarSeparator.start = ui.position.left;
|
||||
sidebarSeparator.width = $("#sidebar").width();
|
||||
sidebarSeparator.chartWidth = $("#workspace").width();
|
||||
sidebarSeparator.chartRight = winWidth-$("#workspace").width()-$("#workspace").offset().left-2;
|
||||
sidebarSeparator.closing = false;
|
||||
|
||||
|
||||
if (!btnSidebar.hasClass("active")) {
|
||||
sidebarSeparator.opening = true;
|
||||
var newChartRight = 15;
|
||||
$("#sidebar").addClass("closing");
|
||||
$("#workspace").css("right",newChartRight);
|
||||
$("#chart-zoom-controls").css("right",newChartRight+20);
|
||||
$("#sidebar").width(0);
|
||||
toggleSidebar();
|
||||
RED.view.resize();
|
||||
}
|
||||
|
||||
|
||||
sidebarSeparator.width = $("#sidebar").width();
|
||||
},
|
||||
drag: function(event,ui) {
|
||||
var d = ui.position.left-sidebarSeparator.start;
|
||||
var newSidebarWidth = sidebarSeparator.width-d;
|
||||
if (sidebarSeparator.opening) {
|
||||
newSidebarWidth -= 13;
|
||||
}
|
||||
|
||||
if (newSidebarWidth > 180 && sidebarSeparator.chartWidth+d > 200) {
|
||||
var newChartRight = sidebarSeparator.chartRight-d;
|
||||
$("#workspace").css("right",newChartRight);
|
||||
$("#chart-zoom-controls").css("right",newChartRight+20);
|
||||
$("#sidebar").width(newSidebarWidth);
|
||||
if (newSidebarWidth > 150) {
|
||||
if (sidebarSeparator.chartWidth+d < 200) {
|
||||
ui.position.left = 200+sidebarSeparator.start-sidebarSeparator.chartWidth;
|
||||
d = ui.position.left-sidebarSeparator.start;
|
||||
newSidebarWidth = sidebarSeparator.width-d;
|
||||
}
|
||||
}
|
||||
if (newSidebarWidth < 150 && !sidebarSeparator.closing) {
|
||||
$("#sidebar").addClass("closing");
|
||||
sidebarSeparator.closing = true;
|
||||
}
|
||||
if (newSidebarWidth >= 150 && sidebarSeparator.closing) {
|
||||
|
||||
if (newSidebarWidth < 150) {
|
||||
if (!sidebarSeparator.closing) {
|
||||
$("#sidebar").addClass("closing");
|
||||
sidebarSeparator.closing = true;
|
||||
}
|
||||
if (!sidebarSeparator.opening) {
|
||||
newSidebarWidth = 150;
|
||||
ui.position.left = sidebarSeparator.width-(150 - sidebarSeparator.start);
|
||||
d = ui.position.left-sidebarSeparator.start;
|
||||
}
|
||||
} else if (newSidebarWidth > 150 && (sidebarSeparator.closing || sidebarSeparator.opening)) {
|
||||
sidebarSeparator.closing = false;
|
||||
$("#sidebar").removeClass("closing");
|
||||
}
|
||||
|
||||
var newChartRight = sidebarSeparator.chartRight-d;
|
||||
$("#workspace").css("right",newChartRight);
|
||||
$("#chart-zoom-controls").css("right",newChartRight+20);
|
||||
$("#sidebar").width(newSidebarWidth);
|
||||
|
||||
sidebar_tabs.resize();
|
||||
RED.view.resize();
|
||||
|
||||
},
|
||||
stop:function(event,ui) {
|
||||
$("#sidebar-separator").css("left","auto");
|
||||
$("#sidebar-separator").css("right",($("#sidebar").width()+15)+"px");
|
||||
RED.view.resize();
|
||||
if (sidebarSeparator.closing) {
|
||||
$("#sidebar").removeClass("closing");
|
||||
toggleSidebar();
|
||||
if ($("#sidebar").width() < 180) {
|
||||
$("#sidebar").width(180);
|
||||
$("#workspace").css("right",208);
|
||||
$("#chart-zoom-controls").css("right",228);
|
||||
}
|
||||
}
|
||||
$("#sidebar-separator").css("left","auto");
|
||||
$("#sidebar-separator").css("right",($("#sidebar").width()+13)+"px");
|
||||
}
|
||||
});
|
||||
|
||||
var btnSidebar = $("#btn-sidebar");
|
||||
function toggleSidebar() {
|
||||
//if ($('#sidebar').tabs( "option", "active" ) === false) {
|
||||
// $('#sidebar').tabs( "option", "active",0);
|
||||
//}
|
||||
var btnSidebar = $("#btn-sidebar");
|
||||
btnSidebar.toggleClass("active");
|
||||
|
||||
if (!btnSidebar.hasClass("active")) {
|
||||
|
@ -287,16 +287,17 @@ a.brand img {
|
||||
right: 10px; top: 5px; bottom:10px;
|
||||
}
|
||||
#sidebar-separator {
|
||||
width: 10px;
|
||||
width: 15px;
|
||||
background: url(grip.png) no-repeat 50% 50%;
|
||||
position: absolute;
|
||||
right: 320px; top: 5px; bottom:10px;
|
||||
right: 316px; top: 5px; bottom:10px;
|
||||
cursor: col-resize;
|
||||
}
|
||||
|
||||
.sidebar-closed > #sidebar { display: none; }
|
||||
.sidebar-closed > #sidebar-separator { display: none; }
|
||||
.sidebar-closed > #workspace { right: 10px !important; }
|
||||
.sidebar-closed > #chart-zoom-controls { right: 30px !important; }
|
||||
.sidebar-closed > #sidebar-separator { right: 0px !important; }
|
||||
.sidebar-closed > #workspace { right: 15px !important; }
|
||||
.sidebar-closed > #chart-zoom-controls { right: 35px !important; }
|
||||
|
||||
/* ---------- end layout ---------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user