2020-02-05 22:08:45 +01:00
|
|
|
import options from "./options.js";
|
2019-12-23 20:34:29 +01:00
|
|
|
|
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();
|
2020-02-04 20:42:40 +01:00
|
|
|
instance = null;
|
2019-12-23 16:48:34 +01:00
|
|
|
}
|
|
|
|
|
2021-06-03 22:23:11 +02:00
|
|
|
$("#left-pane").toggle(leftPaneVisible);
|
2021-05-22 21:35:25 +02:00
|
|
|
|
|
|
|
if (!leftPaneVisible) {
|
2020-02-04 20:42:40 +01:00
|
|
|
$("#center-pane").css('width', '100%');
|
2019-12-23 16:48:34 +01:00
|
|
|
|
2020-02-04 20:42:40 +01:00
|
|
|
return;
|
2019-12-23 16:48:34 +01:00
|
|
|
}
|
|
|
|
|
2021-02-08 20:51:38 +01:00
|
|
|
let leftPaneWidth = options.getInt('leftPaneWidth');
|
|
|
|
if (!leftPaneWidth || leftPaneWidth < 5) {
|
|
|
|
leftPaneWidth = 5;
|
|
|
|
}
|
|
|
|
|
2021-05-22 21:35:25 +02:00
|
|
|
if (leftPaneVisible) {
|
2021-06-03 22:23:11 +02:00
|
|
|
instance = Split(['#left-pane', '#center-pane'], {
|
2020-02-04 20:42:40 +01:00
|
|
|
sizes: [leftPaneWidth, 100 - leftPaneWidth],
|
|
|
|
gutterSize: 5,
|
2021-05-22 21:35:25 +02:00
|
|
|
onDragEnd: sizes => options.save('leftPaneWidth', Math.round(sizes[0]))
|
2020-02-04 20:42:40 +01:00
|
|
|
});
|
|
|
|
}
|
2019-12-23 16:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2020-02-04 20:42:40 +01:00
|
|
|
setupSplit
|
2021-02-08 20:51:38 +01:00
|
|
|
};
|