diff --git a/include/codeboot.js b/include/codeboot.js index 4b164284..159c614d 100644 --- a/include/codeboot.js +++ b/include/codeboot.js @@ -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); @@ -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; @@ -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); @@ -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(); @@ -3454,6 +3485,9 @@ CodeBootVM.prototype.setupSplitter = function (containerElem, setSize) { } splitterElem.addEventListener('mousedown', mouseDown); + + var vm = this; + vm.resizeListeners.push(resizeParent) }; // UI events @@ -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 @@ -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; diff --git a/include/fs.js b/include/fs.js index 35441d31..c1335ee7 100644 --- a/include/fs.js +++ b/include/fs.js @@ -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'; // }); @@ -1167,6 +1178,7 @@ CodeBootFileEditor.prototype.removePresentation = function () { editorsElem.removeChild(fe.fileContainer); }); }); + }; CodeBootFileEditor.prototype.isEnabled = function () {