diff --git a/htdocs/js/gridlayout.js b/htdocs/js/gridlayout.js index 60374134528e6c2dfc7a5beab64a9df92aa1a759..ddc02c100a6af2f5f79a67941070f8e2aef350f0 100644 --- a/htdocs/js/gridlayout.js +++ b/htdocs/js/gridlayout.js @@ -57,8 +57,13 @@ function loadGrid(grid, blocks) { // images need time to load before height can be properly calculated window.setTimeout(function(){ - updateBlockSizes(); + // no need to update the blocksizes for hidden timeline views + var id = $(grid.container).attr('id'); + if (typeof id === 'undefined') { + updateBlockSizes(); + } }, 300); + } function initJs() { @@ -70,6 +75,41 @@ function initJs() { if (typeof viewmenuInit !== "undefined") { viewmenuInit(); } + + $(window).on('colresize', function(e) { + var grid = $(e.target).closest('.grid-stack'); + var id = grid.attr('id'); + //check we are not in timeline view + if (typeof id === 'undefined') { + updateBlockSizes(); + } + else { + // on timeline view + grid.gridstack(); + updateBlockSizes(grid); + } + }); + + $(window).on('shown.bs.collapse', function(e) { + var grid = $(e.target).closest('.grid-stack'); + var id = grid.attr('id'); + //check we are not in timeline view + if (typeof id === 'undefined') { + updateBlockSizes(); + } + else { + // on timeline view + grid.gridstack(); + updateBlockSizes(grid); + } + }); + + $(window).on('timelineviewresizeblocks', function() { + var grid = $('.lineli.selected .grid-stack'); + grid = grid.gridstack(); + updateBlockSizes(grid); + }); + } function updateTranslatedGridRows(blocks) { @@ -132,25 +172,27 @@ function updateTranslatedGridRows(blocks) { moveBlocks(updatedGrid); } -function updateBlockSizes() { - $.each($('.grid-stack').children(), function(index, element) { +function updateBlockSizes(grid) { + if (typeof grid == 'undefined') { + grid = $('.grid-stack'); + } + $.each(grid.children(), function(index, element) { if (!$(element).hasClass('staticblock')) { - var width = $($('.grid-stack-item')[index]).attr('data-gs-width'), - prevHeight = $($('.grid-stack-item')[index]).attr('data-gs-height'), + var width = $(element).attr('data-gs-width'), + prevHeight = $(element).attr('data-gs-height'), height = Math.ceil( ( - $('.grid-stack-item-content')[index].scrollHeight + - $('.grid-stack').data('gridstack').opts.verticalMargin + $(element).find('.grid-stack-item-content')[0].scrollHeight + + grid.data('gridstack').opts.verticalMargin ) / ( - $('.grid-stack').data('gridstack').cellHeight() + - $('.grid-stack').data('gridstack').opts.verticalMargin + grid.data('gridstack').cellHeight() + + grid.data('gridstack').opts.verticalMargin ) ); - //height = height.toString(); - if (+prevHeight != height) { - $('.grid-stack').data('gridstack').resize($('.grid-stack-item')[index], +width, height); + if (+prevHeight < height) { + grid.data('gridstack').resize(element, +width, height); } } }); @@ -172,7 +214,11 @@ function addNewWidget(blockContent, blockId, dimensions, grid, blocktypeclass, m // images need time to load before height can be properly calculated window.setTimeout(function(){ - updateBlockSizes(); + // no need to update sizes for timeline views that are hidden + var id = $(grid.container).attr('id'); + if (typeof id == 'undefined') { + updateBlockSizes(); + } }, 300); return el; @@ -245,10 +291,6 @@ function gridInit() { serializeWidgetMap(items); }); - $(window).on('colresize', function() { - updateBlockSizes(); - }); - } function gridRemoveEvents() { diff --git a/htdocs/js/jTLine/js/jtline.js b/htdocs/js/jTLine/js/jtline.js index b4eabfc6a7954440de8521e70a5323586a63f842..e8080199a47e9f1b9455eaebf51b15d810a51a2c 100644 --- a/htdocs/js/jTLine/js/jtline.js +++ b/htdocs/js/jTLine/js/jtline.js @@ -295,6 +295,7 @@ selectedContent.removeClass('enter-left enter-right'); selectedContent.addClass('selected'); evdone = true; + $(window).trigger('timelineviewresizeblocks'); } }); // height of the version changes after it becomes visible @@ -431,6 +432,7 @@ timeline.find('.cd-timeline-navigation').find('.next').addClass('inactive'); } }); + $(window).trigger('timelineviewresizeblocks'); } else { $(obj).html("Error fetching data"); diff --git a/htdocs/theme/raw/templates/view/versioning.tpl b/htdocs/theme/raw/templates/view/versioning.tpl index fa8e9942ada783bc8c1b43a7d7b5c87cac99bae3..dba77e1503e672661af305c7db40cf9f33815bd6 100644 --- a/htdocs/theme/raw/templates/view/versioning.tpl +++ b/htdocs/theme/raw/templates/view/versioning.tpl @@ -41,7 +41,7 @@ formatSubTitle: function (subTitle, obj) { return '
'; }, formatBodyContent: function (bodyCnt, obj) { if (obj.gridlayout) { - var grid = $(''); + var grid = $(''); var options = { verticalMargin: 10, float: true,