Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions include/codeboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ function CodeBootVM(opts) {
vm.minWidth = get_option_attr('minWidth', 'data-cb-min-width', 575);
vm.minHeight = get_option_attr('minHeight', 'data-cb-min-height', 400);
vm.resizable = get_option_attr('resizable', 'data-cb-resizable', false);
vm.resizeListeners = [] // list of function to call opon resize
vm.editable = get_option_attr('editable', 'data-cb-editable', true);

get_option_attr('showHeader', 'data-cb-show-header', false);
Expand Down Expand Up @@ -3387,7 +3388,12 @@ CodeBootVM.prototype.initCommon = function (opts) {
CodeBootVM.prototype.setupSplitter = function (containerElem, setSize) {

function px(style, property) {
return parseInt(style.getPropertyValue(property).slice(0, -2));
value = style.getPropertyValue(property)
if(value){
return parseInt(value.slice(0, -2));
}
//console.log("valuuuuueee")
return 0;
}

if (!containerElem) return;
Expand Down Expand Up @@ -3419,6 +3425,27 @@ CodeBootVM.prototype.setupSplitter = function (containerElem, setSize) {

rigidElem.style.flexBasis = rigidStyle.getPropertyValue('height');

function setSizeSafe(size){
var rigidSizeMin = px(rigidStyle, sizeMinProp);
var maxSize = px(containerStyle, sizeProp);
var elasticSizeMin = px(elasticStyle, sizeMinProp);
var margins = 8 * 3 // magic values

var size = Math.max(rigidSizeMin, size);
var size = Math.min(maxSize - rigidSizeMin - margins, size);

if (setSize) setSize(size);
rigidElem.style.flexBasis = size + 'px';
}


function resizeParent(){
if(currentSize !== null){
setSizeSafe(currentSize);
}
}


function mouseDown(event) {
startPos = vert ? event.pageY : event.pageX;
startSize = px(rigidStyle, sizeProp);
Expand All @@ -3430,16 +3457,20 @@ CodeBootVM.prototype.setupSplitter = function (containerElem, setSize) {

function mouseMove(event) {
if (event.buttons && startPos !== null) {
var maxSize = px(containerStyle, sizeProp);
var rigidSizeMin = px(rigidStyle, sizeMinProp);
var elasticSizeMin = px(elasticStyle, sizeMinProp);
var elasticSize = px(elasticStyle, sizeProp);


var pos = vert ? event.pageY : event.pageX;
var dist = pos - startPos;
if (rigidPaneLast) dist = -dist;
var delta = Math.min(dist - (currentSize - startSize),
elasticSize - elasticSizeMin);
var size = Math.max(rigidSizeMin, delta + currentSize);
//console.log(elasticSize, pos, dist, delta, size);
rigidElem.style.flexBasis = size + 'px';
if (setSize) setSize(size);
var size = delta + currentSize

if (setSize) setSizeSafe(size);
currentSize = size;
} else {
mouseEnd();
Expand All @@ -3454,6 +3485,9 @@ CodeBootVM.prototype.setupSplitter = function (containerElem, setSize) {
}

splitterElem.addEventListener('mousedown', mouseDown);

var vm = this;
vm.resizeListeners.push(resizeParent)
};

// UI events
Expand Down Expand Up @@ -4090,6 +4124,7 @@ CodeBootVM.prototype.setFloating = function (floating) {
}

change_width_height(elem, width, height);
vm.resizeListeners.forEach(e => e())

var left = 0
var top = 0
Expand Down Expand Up @@ -4219,6 +4254,7 @@ CodeBootVM.prototype.setupMoveRezizeHandlers = function () {
dx = newW - curW;
dy = newH - curH;
change_width_height(elem, newW, newH);
vm.resizeListeners.forEach(e => e())
} else {
var newX = Math.min(maxX-curW/2, Math.max(-curW/2, curX+diffXLeft+dx)) - diffXLeft;
var newY = Math.min(maxY-curH/2, Math.max(0, curY+diffYTop+dy)) - diffYTop;
Expand Down
18 changes: 15 additions & 3 deletions include/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1028,15 +1028,26 @@ CodeBootFileEditorManager.prototype.show = function () {

var fem = this;

// fem.fs.vm.withElem('.cb-editors', function (elem) {
// elem.style.display = 'flex';
// });
fem.fs.vm.withElem('.cb-editors', function (elem) {
elem.style.minHeight = "";
elem.style.marginBottom = "";
});
fem.fs.vm.withElem('.cb-file-tabs', function (elem) {
elem.style.display = "";
});
};

CodeBootFileEditorManager.prototype.hide = function () {

var fem = this;

fem.fs.vm.withElem('.cb-editors', function (elem) {
elem.style.minHeight = "0px";
elem.style.marginBottom = "0px";
});
fem.fs.vm.withElem('.cb-file-tabs', function (elem) {
elem.style.display = "none";
});
// fem.fs.vm.withElem('.cb-editors', function (elem) {
// elem.style.display = 'none';
// });
Expand Down Expand Up @@ -1167,6 +1178,7 @@ CodeBootFileEditor.prototype.removePresentation = function () {
editorsElem.removeChild(fe.fileContainer);
});
});

};

CodeBootFileEditor.prototype.isEnabled = function () {
Expand Down