36 lines
765 B
JavaScript
Raw Normal View History

import options from "./options.js";
2019-12-23 16:48:34 +01:00
let instance;
2021-05-22 21:35:25 +02:00
function setupSplit(leftPaneVisible) {
2019-12-23 16:48:34 +01:00
if (instance) {
instance.destroy();
instance = null;
2019-12-23 16:48:34 +01:00
}
$("#left-pane").toggle(leftPaneVisible);
2021-05-22 21:35:25 +02:00
if (!leftPaneVisible) {
$("#center-pane").css('width', '100%');
2019-12-23 16:48:34 +01:00
return;
2019-12-23 16:48:34 +01:00
}
let leftPaneWidth = options.getInt('leftPaneWidth');
if (!leftPaneWidth || leftPaneWidth < 5) {
leftPaneWidth = 5;
}
2021-05-22 21:35:25 +02:00
if (leftPaneVisible) {
instance = Split(['#left-pane', '#center-pane'], {
sizes: [leftPaneWidth, 100 - leftPaneWidth],
gutterSize: 5,
2021-05-22 21:35:25 +02:00
onDragEnd: sizes => options.save('leftPaneWidth', Math.round(sizes[0]))
});
}
2019-12-23 16:48:34 +01:00
}
export default {
setupSplit
};