MAPG-169 set mapContainer's inners' height dynamically to be identical in a row
This commit is contained in:
parent
394c8b8830
commit
19aa4098e5
@ -38,6 +38,7 @@ div.mapItem>div.imgContainer {
|
|||||||
div.mapItem>div.inner {
|
div.mapItem>div.inner {
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
padding: 10px 8px;
|
padding: 10px 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.mapItem>div.inner>div.info {
|
div.mapItem>div.inner>div.info {
|
||||||
|
@ -63,6 +63,10 @@ $cssFiles = [
|
|||||||
(function () {
|
(function () {
|
||||||
const GOOGLE_MAPS_JS_API_KEY = '<?= $_ENV['GOOGLE_MAPS_JS_API_KEY'] ?>';
|
const GOOGLE_MAPS_JS_API_KEY = '<?= $_ENV['GOOGLE_MAPS_JS_API_KEY'] ?>';
|
||||||
|
|
||||||
|
var Maps = {
|
||||||
|
innerDivs: null,
|
||||||
|
|
||||||
|
addStaticMaps: function () {
|
||||||
var imgContainers = document.getElementById('mapContainer').getElementsByClassName('imgContainer');
|
var imgContainers = document.getElementById('mapContainer').getElementsByClassName('imgContainer');
|
||||||
for (var i = 0; i < imgContainers.length; i++) {
|
for (var i = 0; i < imgContainers.length; i++) {
|
||||||
var imgContainer = imgContainers[i];
|
var imgContainer = imgContainers[i];
|
||||||
@ -75,6 +79,64 @@ $cssFiles = [
|
|||||||
|
|
||||||
imgContainer.style.backgroundImage = 'url("' + imgSrc + '")';
|
imgContainer.style.backgroundImage = 'url("' + imgSrc + '")';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initializeInnerDivs: function () {
|
||||||
|
Maps.innerDivs = document.getElementById('mapContainer').getElementsByClassName('inner');
|
||||||
|
|
||||||
|
for (var i = 0; i < Maps.innerDivs.length; i++) {
|
||||||
|
var inner = Maps.innerDivs[i];
|
||||||
|
var boundingClientRect = inner.getBoundingClientRect();
|
||||||
|
|
||||||
|
inner.defaultHeight = boundingClientRect.height;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
calculateInnerDivHeights: function () {
|
||||||
|
var currentY;
|
||||||
|
var rows = [];
|
||||||
|
for (var i = 0; i < Maps.innerDivs.length; i++) {
|
||||||
|
var inner = Maps.innerDivs[i];
|
||||||
|
var boundingClientRect = inner.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (currentY !== boundingClientRect.y) {
|
||||||
|
rows.push([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rows[rows.length - 1].push(inner);
|
||||||
|
|
||||||
|
currentY = boundingClientRect.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
var row = rows[i];
|
||||||
|
|
||||||
|
var maxHeight = 0;
|
||||||
|
for (var j = 0; j < row.length; j++) {
|
||||||
|
var inner = row[j];
|
||||||
|
|
||||||
|
if (inner.defaultHeight > maxHeight) {
|
||||||
|
maxHeight = inner.defaultHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < row.length; j++) {
|
||||||
|
var inner = row[j];
|
||||||
|
|
||||||
|
inner.style.height = maxHeight + 'px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Maps.addStaticMaps();
|
||||||
|
|
||||||
|
Maps.initializeInnerDivs();
|
||||||
|
Maps.calculateInnerDivHeights();
|
||||||
|
|
||||||
|
window.onresize = function () {
|
||||||
|
Maps.calculateInnerDivHeights();
|
||||||
|
};
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<?php if ($isAdmin): ?>
|
<?php if ($isAdmin): ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user