Commit c5f96d39 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1813987: resizing block when expandig collapsible inside block"

parents 851d5d70 02c6617d
......@@ -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() {
......
......@@ -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");
......
......@@ -41,7 +41,7 @@
formatSubTitle: function (subTitle, obj) { return '<div class="metadata">' + subTitle + '</div>'; },
formatBodyContent: function (bodyCnt, obj) {
if (obj.gridlayout) {
var grid = $('<div class="grid-stack"></div>');
var grid = $('<div id="grid_' + obj.assignID + '" class="grid-stack"></div>');
var options = {
verticalMargin: 10,
float: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment