index.js (1085B)
1 import L from 'leaflet'; 2 import './style.css'; 3 4 const CloseButtonMixin = { 5 createCloseButton: function(container) { 6 this.closeButton = L.DomUtil.create('div', 'photo-viewer-button-close', container); 7 L.DomEvent.on(this.closeButton, 'click', this.onCloseClick, this); 8 }, 9 10 onCloseClick: function() { 11 this.fire('closeclick'); 12 }, 13 }; 14 15 function formatDateTime(ts) { 16 const d = new Date(ts); 17 const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 18 return `${d.getDate()} ${months[d.getMonth()]} ${d.getFullYear()}`; 19 } 20 21 const DateLabelMixin = { 22 createDateLabel: function(container) { 23 this.dateLabel = L.DomUtil.create('div', 'mapillary-viewer-date-overlay', container); 24 }, 25 26 updateDateLabel: function(timestamp) { 27 this.dateLabel.innerHTML = formatDateTime(timestamp); 28 } 29 }; 30 31 const Events = { 32 ImageChange: 'ImageChange', 33 BearingChange: 'BearingChange', 34 YawPitchZoomChangeEnd: 'YawPitchZoomChangeEnd', 35 }; 36 37 export {CloseButtonMixin, DateLabelMixin, Events};