Commit bab8cacb authored by Bert Leunis's avatar Bert Leunis

ESSENTIALS-1033 change markup of googlemaps templates so the result is always a single dom element

parent 816e4e04
......@@ -52,7 +52,7 @@
(see HSTTWO-3747). To ensure it is also initialiazed when the page is *not* reloaded, the following snippet is
used.
--%>
<c:if test="${editMode}">
<c:if test="${requestScope.editMode}">
<script type="text/javascript">
if (window.jQuery && window.jQuery.fn.carousel) {
jQuery('#${componentId}').carousel();
......
......@@ -2,50 +2,51 @@
<#-- @ftlvariable name="componentId" type="java.lang.String" -->
<#-- @ftlvariable name="cparam" type="org.onehippo.cms7.essentials.components.info.EssentialsGoogleMapsComponentInfo" -->
<div id="map-canvas-${componentId}" style="width: ${cparam.width}px; height: ${cparam.height}px;"></div>
<@hst.headContribution category="htmlBodyEnd">
<script type="text/javascript">
(function(win) {
var he, gm;
if (!win.HippoEssentials) {
win.HippoEssentials = {};
}
he = win.HippoEssentials;
if (!he.GoogleMaps) {
he.GoogleMaps = {
queue: []
};
<div>
<div id="map-canvas-${componentId}" style="width: ${cparam.width}px; height: ${cparam.height}px;"></div>
<@hst.headContribution category="htmlBodyEnd">
<script type="text/javascript">
(function(win) {
var he, gm;
if (!win.HippoEssentials) {
win.HippoEssentials = {};
}
he = win.HippoEssentials;
if (!he.GoogleMaps) {
he.GoogleMaps = {
queue: []
};
}
gm = he.GoogleMaps;
gm.queue.push(function() {
gm.render('map-canvas-${componentId}', '${cparam.address?html}', ${cparam.longitude}, ${cparam.latitude}, ${cparam.zoomFactor}, '${cparam.mapType}');
});
})(window);
</script>
</@hst.headContribution>
<@hst.headContribution keyHint="essentials-google-maps" category="htmlBodyEnd">
<@hst.webfile path="/js/essentials-google-maps.js" var="essentialsGoogleMapsJs" />
<script type="text/javascript" src="${essentialsGoogleMapsJs}"></script>
</@hst.headContribution>
<@hst.headContribution keyHint="google-maps-api" category="htmlBodyEnd">
<#if cparam.apiKey?has_content>
<#assign mapsUrl = "https://maps.googleapis.com/maps/api/js?key=${cparam.apiKey?html}&callback=HippoEssentials.GoogleMaps.init"/>
<#else>
<#assign mapsUrl = "https://maps.googleapis.com/maps/api/js?callback=HippoEssentials.GoogleMaps.init"/>
</#if>
<script type="text/javascript" src="${mapsUrl}" async="async" defer="defer"></script>
</@hst.headContribution>
<#if editMode>
<script type="text/javascript">
if (window.HippoEssentials && window.HippoEssentials.GoogleMaps) {
window.HippoEssentials.GoogleMaps.render('map-canvas-${componentId}', '${cparam.address?html}', ${cparam.longitude}, ${cparam.latitude}, ${cparam.zoomFactor}, '${cparam.mapType}');
}
gm = he.GoogleMaps;
gm.queue.push(function() {
gm.render('map-canvas-${componentId}', '${cparam.address?html}', ${cparam.longitude}, ${cparam.latitude}, ${cparam.zoomFactor}, '${cparam.mapType}');
});
})(window);
</script>
</@hst.headContribution>
<@hst.headContribution keyHint="essentials-google-maps" category="htmlBodyEnd">
<@hst.webfile path="/js/essentials-google-maps.js" var="essentialsGoogleMapsJs" />
<script type="text/javascript" src="${essentialsGoogleMapsJs}"></script>
</@hst.headContribution>
<@hst.headContribution keyHint="google-maps-api" category="htmlBodyEnd">
<#if cparam.apiKey?has_content>
<#assign mapsUrl = "https://maps.googleapis.com/maps/api/js?key=${cparam.apiKey?html}&callback=HippoEssentials.GoogleMaps.init"/>
<#else>
<#assign mapsUrl = "https://maps.googleapis.com/maps/api/js?callback=HippoEssentials.GoogleMaps.init"/>
</script>
</#if>
<script type="text/javascript" src="${mapsUrl}" async="async" defer="defer"></script>
</@hst.headContribution>
<#if editMode>
<script type="text/javascript">
if (window.HippoEssentials && window.HippoEssentials.GoogleMaps) {
window.HippoEssentials.GoogleMaps.render('map-canvas-${componentId}', '${cparam.address?html}', ${cparam.longitude}, ${cparam.latitude}, ${cparam.zoomFactor}, '${cparam.mapType}');
}
</script>
</#if>
</div>
\ No newline at end of file
......@@ -2,53 +2,54 @@
<%--@elvariable id="componentId" type="java.lang.String"--%>
<%--@elvariable id="cparam" type="org.onehippo.cms7.essentials.components.info.EssentialsGoogleMapsComponentInfo"--%>
<div id="map-canvas-${componentId}" style="width: ${requestScope.cparam.width}px; height: ${requestScope.cparam.height}px;"></div>
<hst:headContribution category="htmlBodyEnd">
<script type="text/javascript">
(function(win) {
var he, gm;
if (!win.HippoEssentials) {
win.HippoEssentials = {};
}
he = win.HippoEssentials;
if (!he.GoogleMaps) {
he.GoogleMaps = {
queue: []
};
<div>
<div id="map-canvas-${componentId}" style="width: ${requestScope.cparam.width}px; height: ${requestScope.cparam.height}px;"></div>
<hst:headContribution category="htmlBodyEnd">
<script type="text/javascript">
(function(win) {
var he, gm;
if (!win.HippoEssentials) {
win.HippoEssentials = {};
}
he = win.HippoEssentials;
if (!he.GoogleMaps) {
he.GoogleMaps = {
queue: []
};
}
gm = he.GoogleMaps;
gm.queue.push(function() {
gm.render('map-canvas-${componentId}', '${fn:escapeXml(requestScope.cparam.address)}', ${requestScope.cparam.longitude}, ${requestScope.cparam.latitude}, ${requestScope.cparam.zoomFactor}, '${requestScope.cparam.mapType}');
});
})(window);
</script>
</hst:headContribution>
<hst:headContribution keyHint="essentials-google-maps" category="htmlBodyEnd">
<hst:webfile path="/js/essentials-google-maps.js" var="essentialsGoogleMapsJs" />
<script type="text/javascript" src="${essentialsGoogleMapsJs}"></script>
</hst:headContribution>
<hst:headContribution keyHint="google-maps-api" category="htmlBodyEnd">
<c:choose>
<c:when test="${not empty requestScope.cparam.apiKey}">
<c:set var="mapsUrl">https://maps.googleapis.com/maps/api/js?key=${fn:escapeXml(requestScope.cparam.apiKey)}&callback=HippoEssentials.GoogleMaps.init</c:set>
</c:when>
<c:otherwise>
<c:set var="mapsUrl">https://maps.googleapis.com/maps/api/js?callback=HippoEssentials.GoogleMaps.init</c:set>
</c:otherwise>
</c:choose>
<script type="text/javascript" src="${mapsUrl}" async="async" defer="defer"></script>
</hst:headContribution>
<c:if test="${requestScope.editMode}">
<script type="text/javascript">
if (window.HippoEssentials && window.HippoEssentials.GoogleMaps) {
window.HippoEssentials.GoogleMaps.render('map-canvas-${componentId}', '${fn:escapeXml(requestScope.cparam.address)}', ${requestScope.cparam.longitude}, ${requestScope.cparam.latitude}, ${requestScope.cparam.zoomFactor}, '${requestScope.cparam.mapType}');
}
gm = he.GoogleMaps;
gm.queue.push(function() {
gm.render('map-canvas-${componentId}', '${fn:escapeXml(requestScope.cparam.address)}', ${requestScope.cparam.longitude}, ${requestScope.cparam.latitude}, ${requestScope.cparam.zoomFactor}, '${requestScope.cparam.mapType}');
});
})(window);
</script>
</hst:headContribution>
<hst:headContribution keyHint="essentials-google-maps" category="htmlBodyEnd">
<hst:webfile path="/js/essentials-google-maps.js" var="essentialsGoogleMapsJs" />
<script type="text/javascript" src="${essentialsGoogleMapsJs}"></script>
</hst:headContribution>
<hst:headContribution keyHint="google-maps-api" category="htmlBodyEnd">
<c:choose>
<c:when test="${not empty requestScope.cparam.apiKey}">
<c:set var="mapsUrl">https://maps.googleapis.com/maps/api/js?key=${fn:escapeXml(requestScope.cparam.apiKey)}&callback=HippoEssentials.GoogleMaps.init</c:set>
</c:when>
<c:otherwise>
<c:set var="mapsUrl">https://maps.googleapis.com/maps/api/js?callback=HippoEssentials.GoogleMaps.init</c:set>
</c:otherwise>
</c:choose>
<script type="text/javascript" src="${mapsUrl}" async="async" defer="defer"></script>
</hst:headContribution>
<c:if test="${editMode}">
<script type="text/javascript">
if (window.HippoEssentials && window.HippoEssentials.GoogleMaps) {
window.HippoEssentials.GoogleMaps.render('map-canvas-${componentId}', '${fn:escapeXml(requestScope.cparam.address)}', ${requestScope.cparam.longitude}, ${requestScope.cparam.latitude}, ${requestScope.cparam.zoomFactor}, '${requestScope.cparam.mapType}');
}
</script>
</c:if>
</script>
</c:if>
</div>
\ No newline at end of file
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