| 1 |
/** |
| 2 |
* Divi functionality |
| 3 |
* |
| 4 |
* @author Epiphyt |
| 5 |
* @license GPL2 |
| 6 |
* @package epiphyt\Embed_Privacy |
| 7 |
*/ |
| 8 |
document.addEventListener( 'DOMContentLoaded', () => { |
| 9 |
// Generate responsive video wrapper for Embed Privacy container |
| 10 |
if ( $.fn.fitVids ) { |
| 11 |
$( '#main-content' ).fitVids( { |
| 12 |
customSelector: ".embed-privacy-container" |
| 13 |
} ); |
| 14 |
} |
| 15 |
|
| 16 |
window.embed_privacy_et_window=$(window); |
| 17 |
window.embed_privacy_et_is_mobile_device=navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/)!==null||'standalone'in window.navigator&&!window.navigator.standalone; |
| 18 |
window.embed_privacy_et_pb_get_current_window_mode = function() { |
| 19 |
var window_width = embed_privacy_et_window.width(); |
| 20 |
var current_mode = 'desktop'; |
| 21 |
if (window_width <= 980 && window_width > 767) { |
| 22 |
current_mode = 'tablet'; |
| 23 |
} else if (window_width <= 767) { |
| 24 |
current_mode = 'phone'; |
| 25 |
} |
| 26 |
return current_mode; |
| 27 |
} |
| 28 |
window.embed_privacy_et_pb_map_init = function(this_map_container) { |
| 29 |
if ('undefined' === typeof google || 'undefined' === typeof google.maps) { |
| 30 |
return; |
| 31 |
} |
| 32 |
var current_mode = embed_privacy_et_pb_get_current_window_mode(); |
| 33 |
et_animation_breakpoint = current_mode; |
| 34 |
var suffix = current_mode !== 'desktop' ? '-'.concat(current_mode) : ''; |
| 35 |
var prev_suffix = 'phone' === current_mode ? '-tablet' : ''; |
| 36 |
var grayscale_value = this_map_container.attr('data-grayscale'.concat(suffix)) || 0; |
| 37 |
if (!grayscale_value) { |
| 38 |
grayscale_value = this_map_container.attr('data-grayscale'.concat(prev_suffix)) || this_map_container.attr('data-grayscale') || 0; |
| 39 |
} |
| 40 |
var this_map = this_map_container.children('.et_pb_map'); |
| 41 |
var this_map_grayscale = grayscale_value; |
| 42 |
var is_draggable = embed_privacy_et_is_mobile_device && this_map.data('mobile-dragging') !== 'off' || !embed_privacy_et_is_mobile_device; |
| 43 |
var infowindow_active; |
| 44 |
if (this_map_grayscale !== 0) { |
| 45 |
this_map_grayscale = '-'.concat(this_map_grayscale.toString()); |
| 46 |
} |
| 47 |
var data_center_lat = parseFloat(this_map.attr('data-center-lat')) || 0; |
| 48 |
var data_center_lng = parseFloat(this_map.attr('data-center-lng')) || 0; |
| 49 |
this_map_container.data('map', new google.maps.Map(this_map[0], { |
| 50 |
zoom: parseInt(this_map.attr('data-zoom')), |
| 51 |
center: new google.maps.LatLng(data_center_lat, data_center_lng), |
| 52 |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
| 53 |
scrollwheel: 'on' == this_map.attr('data-mouse-wheel'), |
| 54 |
draggable: is_draggable, |
| 55 |
panControlOptions: { |
| 56 |
position: this_map_container.is('.et_beneath_transparent_nav') ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP |
| 57 |
}, |
| 58 |
zoomControlOptions: { |
| 59 |
position: this_map_container.is('.et_beneath_transparent_nav') ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP |
| 60 |
}, |
| 61 |
styles: [{ |
| 62 |
stylers: [{ |
| 63 |
saturation: parseInt(this_map_grayscale) |
| 64 |
}] |
| 65 |
}] |
| 66 |
})); |
| 67 |
this_map_container.find('.et_pb_map_pin').each(function() { |
| 68 |
var this_marker = $(this); |
| 69 |
var marker = new google.maps.Marker({ |
| 70 |
position: new google.maps.LatLng(parseFloat(this_marker.attr('data-lat')), parseFloat(this_marker.attr('data-lng'))), |
| 71 |
map: this_map_container.data('map'), |
| 72 |
title: this_marker.attr('data-title'), |
| 73 |
icon: { |
| 74 |
url: ''.concat(et_pb_custom.builder_images_uri, '/marker.png'), |
| 75 |
size: new google.maps.Size(46, 43), |
| 76 |
anchor: new google.maps.Point(16, 43) |
| 77 |
}, |
| 78 |
shape: { |
| 79 |
coord: [1, 1, 46, 43], |
| 80 |
type: 'rect' |
| 81 |
}, |
| 82 |
anchorPoint: new google.maps.Point(0, -45) |
| 83 |
}); |
| 84 |
if (this_marker.find('.infowindow').length) { |
| 85 |
var infowindow = new google.maps.InfoWindow({ |
| 86 |
content: this_marker.html() |
| 87 |
}); |
| 88 |
google.maps.event.addListener(this_map_container.data('map'), 'click', function() { |
| 89 |
infowindow.close(); |
| 90 |
}); |
| 91 |
google.maps.event.addListener(marker, 'click', function() { |
| 92 |
if (infowindow_active) { |
| 93 |
infowindow_active.close(); |
| 94 |
} |
| 95 |
infowindow_active = infowindow; |
| 96 |
infowindow.open(this_map_container.data('map'), marker); |
| 97 |
this_marker.closest('.et_pb_module').trigger('mouseleave'); |
| 98 |
setTimeout(function() { |
| 99 |
this_marker.closest('.et_pb_module').trigger('mouseenter'); |
| 100 |
}, 1); |
| 101 |
}); |
| 102 |
} |
| 103 |
}); |
| 104 |
}; |
| 105 |
} ); |
| 106 |
|