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;
|
|
|
|
|
2020-03-01 20:11:40 +01:00
|
|
|
function setupSplit(left, right) {
|
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
|
|
|
}
|
|
|
|
|
2020-02-04 20:42:40 +01:00
|
|
|
if (!left && !right) {
|
|
|
|
$("#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
let rightPaneWidth = options.getInt('rightPaneWidth');
|
|
|
|
if (!rightPaneWidth || rightPaneWidth < 5) {
|
|
|
|
rightPaneWidth = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(leftPaneWidth, rightPaneWidth);
|
2019-12-23 20:34:29 +01:00
|
|
|
|
2020-02-04 20:42:40 +01:00
|
|
|
if (left && right) {
|
|
|
|
instance = Split(['#left-pane', '#center-pane', '#right-pane'], {
|
|
|
|
sizes: [leftPaneWidth, 100 - leftPaneWidth - rightPaneWidth, rightPaneWidth],
|
|
|
|
gutterSize: 5,
|
|
|
|
onDragEnd: sizes => {
|
2020-02-05 22:08:45 +01:00
|
|
|
options.save('leftPaneWidth', Math.round(sizes[0]));
|
|
|
|
options.save('rightPaneWidth', Math.round(sizes[2]));
|
2020-02-04 20:42:40 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (left) {
|
|
|
|
instance = Split(['#left-pane', '#center-pane'], {
|
|
|
|
sizes: [leftPaneWidth, 100 - leftPaneWidth],
|
|
|
|
gutterSize: 5,
|
|
|
|
onDragEnd: sizes => {
|
2020-02-05 22:08:45 +01:00
|
|
|
options.save('leftPaneWidth', Math.round(sizes[0]));
|
2020-02-04 20:42:40 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (right) {
|
|
|
|
instance = Split(['#center-pane', '#right-pane'], {
|
|
|
|
sizes: [100 - rightPaneWidth, rightPaneWidth],
|
|
|
|
gutterSize: 5,
|
|
|
|
onDragEnd: sizes => {
|
2020-02-05 22:08:45 +01:00
|
|
|
options.save('rightPaneWidth', Math.round(sizes[1]));
|
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
|
|
|
};
|