kopia lustrzana https://github.com/FacilMap/facilmap
Improve styling of infoBox, do not use layers anymore
rodzic
f2f69e0d37
commit
404f953d88
|
@ -1,9 +1,6 @@
|
|||
<div class="fm-info-box panel panel-default" ng-class="className">
|
||||
<div class="panel-body">
|
||||
<div class="layer" ng-repeat="layer in layers">
|
||||
<div class="cover" ng-if="!$last"></div>
|
||||
<button type="button" class="btn btn-link close-button" ng-click="layer.hide()">×</button>
|
||||
<div fm-info-box-bind="layer"></div>
|
||||
</div>
|
||||
<div class="html"></div>
|
||||
<button type="button" class="btn btn-link close-button" ng-click="hide()">×</button>
|
||||
</div>
|
||||
</div>
|
|
@ -7,7 +7,8 @@ fm.app.factory("fmInfoBox", function($rootScope, $compile, $timeout) {
|
|||
return function(map) {
|
||||
let scope = $rootScope.$new();
|
||||
scope.className = css.className;
|
||||
scope.layers = [];
|
||||
|
||||
let currentObj = null;
|
||||
|
||||
let el = $(require("./infoBox.html"));
|
||||
|
||||
|
@ -16,8 +17,16 @@ fm.app.factory("fmInfoBox", function($rootScope, $compile, $timeout) {
|
|||
$compile(el)(scope);
|
||||
});
|
||||
|
||||
let show = () => {
|
||||
return new Promise((resolve) => {
|
||||
let infoBox = {
|
||||
show(html, htmlScope, onClose) {
|
||||
if(currentObj)
|
||||
currentObj.onClose && currentObj.onClose();
|
||||
|
||||
let htmlEl = $(".html", el).empty().append(html);
|
||||
if(htmlScope !== false)
|
||||
$compile(htmlEl)(htmlScope);
|
||||
|
||||
if(!currentObj) {
|
||||
let legendEl = map.el.find(".fm-map-legend");
|
||||
let legendPanelEl = legendEl.find("> .panel");
|
||||
|
||||
|
@ -33,19 +42,32 @@ fm.app.factory("fmInfoBox", function($rootScope, $compile, $timeout) {
|
|||
legendEl.addClass("fm-infoBox-hidden");
|
||||
el.css("transition", "");
|
||||
el.css("transform", ""); // Gets animated by CSS transition
|
||||
el.one("transitionend", resolve);
|
||||
}, 0);
|
||||
} else {
|
||||
el.css("transition", "all 0s ease 0s");
|
||||
el.fadeIn(700, () => {
|
||||
el.css("transition", "");
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let thisCurrentObj = currentObj = {
|
||||
onClose
|
||||
};
|
||||
|
||||
let hide = () => {
|
||||
return {
|
||||
hide: () => {
|
||||
if(currentObj !== thisCurrentObj)
|
||||
return;
|
||||
|
||||
infoBox.hide();
|
||||
}
|
||||
};
|
||||
},
|
||||
hide() {
|
||||
if(!currentObj)
|
||||
return Promise.resolve();
|
||||
|
||||
return new Promise((resolve) => {
|
||||
let legendEl = map.el.find(".fm-map-legend");
|
||||
let legendPanelEl = legendEl.find("> .panel");
|
||||
|
@ -66,51 +88,14 @@ fm.app.factory("fmInfoBox", function($rootScope, $compile, $timeout) {
|
|||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let infoBox = {
|
||||
show(html, htmlScope, clearOpenLayers, onClose) {
|
||||
let obj = {
|
||||
html,
|
||||
onClose,
|
||||
scope: htmlScope || $rootScope,
|
||||
hide() {
|
||||
let newLayers = scope.layers.filter((it) => (!ng.equals(it, obj))); // Can't use !== because ng-repeat adds $$hashKey
|
||||
onClose && onClose();
|
||||
Promise.resolve().then(() => {
|
||||
if(newLayers.length == 0)
|
||||
return hide();
|
||||
}).then(() => {
|
||||
scope.layers = newLayers;
|
||||
currentObj.onClose && currentObj.onClose();
|
||||
currentObj = null;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if(scope.layers.length == 0)
|
||||
scope.$evalAsync(() => { $timeout(show); });
|
||||
|
||||
if(clearOpenLayers) {
|
||||
scope.layers.forEach((layer) => {
|
||||
layer.onClose && layer.onClose();
|
||||
});
|
||||
scope.layers = [];
|
||||
}
|
||||
|
||||
scope.layers.push(obj);
|
||||
|
||||
return obj;
|
||||
},
|
||||
hideAll() {
|
||||
return hide().then(() => {
|
||||
scope.layers.forEach((layer) => {
|
||||
layer.onClose && layer.onClose();
|
||||
});
|
||||
|
||||
scope.layers = [ ];
|
||||
});
|
||||
}
|
||||
};
|
||||
scope.hide = infoBox.hide;
|
||||
|
||||
return infoBox;
|
||||
};
|
||||
|
@ -126,6 +111,8 @@ fm.app.directive("fmInfoBoxBind", function($compile) {
|
|||
scope.$watchGroup(["layer.html", "layer.scope"], () => {
|
||||
let el = $(scope.layer.html);
|
||||
element.empty().append(el);
|
||||
|
||||
if(scope.layer.scope !== false)
|
||||
$compile(el)(scope.layer.scope);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
.close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
right: 5px;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
font-size: 1.5em;
|
||||
|
@ -37,16 +37,14 @@
|
|||
height: 200px;
|
||||
overflow: auto;
|
||||
|
||||
/* Make space for buttons at the bottom */
|
||||
padding-bottom: 1.5em;
|
||||
|
||||
/* Replace padding by margin to move horizontal scrollbar a bit to the left so that it can be covered by .buttons */
|
||||
/* Make space for close button on the top and don't cover round corners on top and bottom */
|
||||
padding-left: 0;
|
||||
margin: 20px 0 7px 15px;
|
||||
margin: 2px 0 28px 0;
|
||||
padding: 15px;
|
||||
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
font-size: 1.6em;
|
||||
}
|
||||
|
||||
/* Copy dl-horizontal styles, modify sizing, also apply for small screens (as popup size is always the same) */
|
||||
|
|
|
@ -73,7 +73,7 @@ fm.app.factory("fmMapMarkers", function($uibModal, fmUtils, $compile, $timeout,
|
|||
markersUi.deleteMarker(scope.marker);
|
||||
};
|
||||
|
||||
map.infoBox.show(require("./view-marker.html"), scope, true, () => {
|
||||
map.infoBox.show(require("./view-marker.html"), scope, () => {
|
||||
openMarkerId = null;
|
||||
markersById[marker.id].setIcon(fmUtils.createMarkerIcon(marker.colour, marker.size, marker.symbol));
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue