PageSourceSearch

https://didierfle.com/wp-content/plugins/wp-acf-vc-bridge/assets/j…vc-acf-field-picker-google-map.js?ver=1.8.7

js didierfle.com collected 2026-10-03 22:04:48 UTC 8,360 bytes, 212 lines download raw bytes

1(function($) {
2
3// Detect Element Resize
4(function(){var attachEvent=document.attachEvent,stylesCreated=false;if(!attachEvent){var requestFrame=function(){var raf=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){return window.setTimeout(fn,20)};return function(fn){return raf(fn)}}();var cancelFrame=function(){var cancel=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout;return function(id){return cancel(id)}}();function resetTriggers(element){var triggers=element.__resizeTriggers__,expand=triggers.firstElementChild,contract=triggers.lastElementChild,expandChild=expand.firstElementChild;contract.scrollLeft=contract.scrollWidth;contract.scrollTop=contract.scrollHeight;expandChild.style.width=expand.offsetWidth+1+"px";expandChild.style.height=expand.offsetHeight+1+"px";expand.scrollLeft=expand.scrollWidth;expand.scrollTop=expand.scrollHeight}function checkTriggers(element){return element.offsetWidth!=element.__resizeLast__.width||element.offsetHeight!=element.__resizeLast__.height}function scrollListener(e){var element=this;resetTriggers(this);if(this.__resizeRAF__)cancelFrame(this.__resizeRAF__);this.__resizeRAF__=requestFrame(function(){if(checkTriggers(element)){element.__resizeLast__.width=element.offsetWidth;element.__resizeLast__.height=element.offsetHeight;element.__resizeListeners__.forEach(function(fn){fn.call(element,e)})}})}var animation=false,animationstring="animation",keyframeprefix="",animationstartevent="animationstart",domPrefixes="Webkit Moz O ms".split(" "),startEvents="webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),pfx="";{var elm=document.createElement("fakeelement");if(elm.style.animationName!==undefined){animation=true}if(animation===false){for(var i=0;i<domPrefixes.length;i++){if(elm.style[domPrefixes[i]+"AnimationName"]!==undefined){pfx=domPrefixes[i];animationstring=pfx+"Animation";keyframeprefix="-"+pfx.toLowerCase()+"-";animationstartevent=startEvents[i];animation=true;break}}}}var animationName="resizeanim";var animationKeyframes="@"+keyframeprefix+"keyframes "+animationName+" { from { opacity: 0; } to { opacity: 0; } } ";var animationStyle=keyframeprefix+"animation: 1ms "+animationName+"; "}function createStyles(){if(!stylesCreated){var css=(animationKeyframes?animationKeyframes:"")+".resize-triggers { "+(animationStyle?animationStyle:"")+"visibility: hidden; opacity: 0; } "+'.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',head=document.head||document.getElementsByTagName("head")[0],style=document.createElement("style");style.type="text/css";if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}head.appendChild(style);stylesCreated=true}}window.wavbAddResizeListener=function(element,fn){if(attachEvent)element.attachEvent("onresize",fn);else{if(!element.__resizeTriggers__){if(getComputedStyle(element).position=="static")element.style.position="relative";createStyles();element.__resizeLast__={};element.__resizeListeners__=[];(element.__resizeTriggers__=document.createElement("div")).className="resize-triggers";element.__resizeTriggers__.innerHTML='<div class="expand-trigger"><div></div></div>'+'<div class="contract-trigger"></div>';element.appendChild(element.__resizeTriggers__);resetTriggers(element);element.addEventListener("scroll",scrollListener,true);animationstartevent&&element.__resizeTriggers__.addEventListener(animationstartevent,function(e){if(e.animationName==animationName)resetTriggers(element)})}element.__resizeListeners__.push(fn)}};window.wavbRemoveResizeListener=function(element,fn){if(attachEvent)element.detachEvent("onresize",fn);else{element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn),1);if(!element.__resizeListeners__.length){element.removeEventListener("scroll",scrollListener);element.__resizeTriggers__=!element.removeChild(element.__resizeTriggers__)}}}})();
5
6/*
7*  new_map
8*
9*  This function will render a Google Map onto the selected jQuery element
10*
11*  @type  function
12*  @date  8/11/2013
13*  @since 4.3.0
14*
15*  @param $el (jQuery element)
16*  @return  n/a
17*/
18
19function new_map( $el ) {
20  
21  // var
22  var $markers = $el.find('.marker');
23  
24  
25  // vars
26  var args = {
27    zoom    : 16,
28    center    : new google.maps.LatLng(0, 0),
29    // mapTypeControl    : true,
30    mapTypeId : google.maps.MapTypeId.ROADMAP
31  };
32  
33  
34  // create map           
35  var map = new google.maps.Map( $el[0], args);
36  
37  
38  // add a markers reference
39  map.markers = [];
40  
41  
42  // add markers
43  $markers.each(function(){
44    
45      add_marker( $(this), map );
46    
47  });
48  
49  
50  // center map
51  center_map( map );
52
53  handleMapInExpandableContainer( $el, map );
54
55  // return
56  return map;
57}
58
59
60function handleMapInExpandableContainer( $el, map ) {
61
62  var isVisible = $el.is( ':visible' );
63  window.wavbAddResizeListener( $el.get( 0 ), function onResize() {
64    if ( isVisible !== $el.is( ':visible' ) ) {
65      isVisible = $el.is( ':visible' );
66      google.maps.event.trigger( map, 'resize' );
67      center_map( map );
68    }
69  });
70
71}
72
73
74/*
75*  add_marker
76*
77*  This function will add a marker to the selected Google Map
78*
79*  @type  function
80*  @date  8/11/2013
81*  @since 4.3.0
82*
83*  @param $marker (jQuery element)
84*  @param map (Google Map object)
85*  @return  n/a
86*/
87
88function add_marker( $marker, map ) {
89
90  // var
91  var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
92
93  // create marker
94  var marker = new google.maps.Marker({
95    position  : latlng,
96    map     : map
97  });
98
99  // add to array
100  map.markers.push( marker );
101
102  // if marker contains HTML, add it to an infoWindow
103  if( $marker.html() )
104  {
105    // create info window
106    var infowindow = new google.maps.InfoWindow({
107      content   : $marker.html()
108    });
109
110    // show info window when marker is clicked
111    google.maps.event.addListener(marker, 'click', function() {
112
113      infowindow.open( map, marker );
114
115    });
116  }
117
118}
119
120/*
121*  center_map
122*
123*  This function will center the map, showing all markers attached to this map
124*
125*  @type  function
126*  @date  8/11/2013
127*  @since 4.3.0
128*
129*  @param map (Google Map object)
130*  @return  n/a
131*/
132
133function center_map( map ) {
134
135  // vars
136  var bounds = new google.maps.LatLngBounds();
137
138  // loop through all markers and create bounds
139  $.each( map.markers, function( i, marker ){
140
141    var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
142
143    bounds.extend( latlng );
144
145  });
146
147  // only 1 marker?
148  if( map.markers.length == 1 )
149  {
150    // set center of map
151      map.setCenter( bounds.getCenter() );
152      map.setZoom( 16 );
153  }
154  else
155  {
156    // fit to bounds
157    map.fitBounds( bounds );
158  }
159
160}
161
162
163function requestGoogleMapsApiSript( callback ) {
164  // If Google Maps API is ready
165  if ( window.google && google.maps ) {
166    setTimeout( callback, 0 );
167    return;
168  }
169
170  // Load Google Maps API Script if not loaded yet and if setting is set to load conditionally
171  if ( ! vcAcfFieldPickerGoogleMap.isGoogleMapsApiScriptLoaded && ( vcAcfFieldPickerGoogleMap.shouldLoadGoogleMapsApiScript == 'auto' ) ) {
172    vcAcfFieldPickerGoogleMap.isGoogleMapsApiScriptLoaded = true;
173    $( '<script>', { 'src': vcAcfFieldPickerGoogleMap.googleApiScriptUrl, 'async':'true', 'defer': 'true' } ).appendTo( $( 'head' ) );
174  }
175
176  // Try again later
177  setTimeout( function () {
178    requestGoogleMapsApiSript( callback );
179  }, 50 );
180}
181
182/*
183*  document ready
184*
185*  This function will render each map when the document is ready (page has loaded)
186*
187*  @type  function
188*  @date  8/11/2013
189*  @since 5.0.0
190*
191*  @param n/a
192*  @return  n/a
193*/
194// global var
195var map = null;
196
197// $(document).ready(function(){
198$(window).load(function(){
199
200  if ( ! vcAcfFieldPickerGoogleMap ) return;
201
202  // Wait for when Google Maps API is ready
203  requestGoogleMapsApiSript( function () {
204    google.maps.visualRefresh = true;
205    $( '.vc-acf-field-picker-google-map' ).each(function(){
206      map = new_map( $( this ) );
207    });
208  });
209
210});
211
212})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.