Skip to content
Snippets Groups Projects
Commit c1e04548 authored by Olivia206's avatar Olivia206
Browse files

fixed js

parent d560189d
No related branches found
No related tags found
No related merge requests found
import './vendors/lightbox';
import './vendors/carousel';
import './theme';
import './theme/';
import './theme/blocks/partners';
// const partnersMap = document.querySelectorAll('.block-partners--map');
// class BlockPartners {
// constructor (block) {
// this.block = block;
// this.content = this.block.querySelector('#map');
// this.partnersList = this.content.querySelectorAll('.organization')
// this.themeMarker = L.icon({
// iconUrl: '/assets/images/map-marker.svg',
// iconSize: [26, 17],
// });
// this.listen();
// }
// listen () {
// console.log("lalala")
// this.map = L.map('map').setView([2.3246629, 48.8862136], 13);
// L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
// maxZoom: 19,
// attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
// }).addTo(map);
// this.partnersList.forEach((partner) => {
// let latitude = parseFloat(partner.getAttribute('data-latitude')),
// longitude = parseFloat(partner.getAttribute('data-longitude'));
// if (!!latitude && !!longitude) {
// setLocation = [latitude, longitude];
// console.log(setLocation)
// }
// newMarker(setLocation);
// });
// }
// newMarker(setLocation) {
// var marker = new L.marker(setLocation, {
// draggable: false
// });
// map.addLayer(marker);
// }
// }
// partnersMap.forEach((partners) => {
// new BlockPartners(partners);
// });
const partnersMaps = document.querySelectorAll('.block-partners--map');
class BlockPartners {
constructor (dom) {
this.dom = dom;
this.init();
}
init() {
this.content = this.dom.querySelector('#map');
this.partnersList = this.content.querySelectorAll('.organization')
this.classPartner = 'organization';
let map = L.map('map').setView([44.833328, -0.56667], 13);
this.themeMarker = L.icon({
iconUrl: '/assets/images/map-marker.svg',
iconSize: [17, 26],
});
this.listen(map);
}
listen (map) {
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
this.partnersList.forEach((partner) => {
this.setLocation(map, partner);
});
}
setLocation(map, partner) {
let latitude = parseFloat(partner.getAttribute('data-latitude')),
longitude = parseFloat(partner.getAttribute('data-longitude'));
if (!!latitude && !!longitude) {
this.mapLocation = [latitude, longitude];
}
this.newMarker(this.mapLocation, map, partner);
}
newMarker(mapLocation, map, partner) {
let marker = new L.marker(mapLocation, {
draggable: false,
icon: this.themeMarker
});
marker.bindPopup('<article class="' + this.classPartner + '">' + partner.innerHTML + '</article>').openPopup();
map.addLayer(marker);
}
}
partnersMaps.forEach((dom) => {
new BlockPartners(dom);
});
\ No newline at end of file
......@@ -26,6 +26,8 @@
&-content-wrapper
border-radius: 0
padding: 0
width: 192px
overflow: hidden
.media
margin-bottom: 0
h3 a
......@@ -34,6 +36,7 @@
padding: half($spacing0)
&-content
margin: 0
width: 100%
z-index: 2
&-close-button
z-index: 4
......
......@@ -2,7 +2,8 @@
{{- $position := .block.position -}}
{{- $title := .block.title -}}
{{- $layout_class := "block-pages--grid" -}}
{{- $class := "block block-partners" -}}
{{- $layout_class := "block-partners--grid" -}}
{{ $logo_index := "logo" }}
{{ $longitude := "longitude" }}
{{ $latitude := "latitude" }}
......
......@@ -25,48 +25,4 @@
)}}
{{ end }}
{{ end -}}
</div>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
<script>
var dom = document.querySelector('#map'),
map = L.map('map').setView([44.833328, -0.56667], 13);
let partners = dom.querySelectorAll('.organization')
const themeMarker = L.icon({
iconUrl: '/assets/images/map-marker.svg',
iconSize: [17, 26],
});
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
partners.forEach((partner) => {
let latitude = parseFloat(partner.getAttribute('data-latitude')),
longitude = parseFloat(partner.getAttribute('data-longitude'));
if (!!latitude && !!longitude) {
setLocation = [latitude, longitude];
function newMarker (setLocation) {
var marker = new L.marker(setLocation, {
draggable: false,
icon: themeMarker
});
marker.bindPopup('<article class="organization">' + partner.innerHTML + '</article>').openPopup();
map.addLayer(marker);
}
newMarker(setLocation)
}
});
</script>
\ No newline at end of file
</div>
\ No newline at end of file
{{ $isLeafletNeeded := false }}
{{ if .Params.blocks }}
{{ range .Params.blocks }}
{{ if eq .template "partners"}}
{{ with .data }}
{{ if eq .layout "map" }}
{{ $isLeafletNeeded := true }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ if $isLeafletNeeded = true }}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
{{ end }}
{{ $js := resources.Get "js/main.js" | js.Build (dict "minify" hugo.IsProduction) | fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment