PageSourceSearch

https://essft.com/wp-content/plugins/geodirectory/assets/js/geodir-map.js?ver=2.8.180

js essft.com collected 2026-10-03 00:49:20 UTC 11,531 bytes, 305 lines download raw bytes

1window.geodirMapScriptCallback = function() {
2    jQuery(window).trigger('geodirMapScriptCallbackBefore');
3    jQuery(window).trigger('geodirMapScriptCallback');
4    jQuery(window).trigger('geodirMapScriptCallbackAfter');
5};
6
7window.geodirMapScriptOnLoad = function(el) {
8    jQuery(window).trigger('geodirMapScriptOnLoad', el);
9};
10
11window.geodirMapMainScriptOnLoad = function(el) {
12    jQuery(window).trigger('geodirMapMainScriptOnLoad', el);
13};
14
15window.geodirMapScriptOnError = function(el) {
16    jQuery(window).trigger('geodirMapScriptOnError', el);
17};
18
19;(function($, window, document, undefined) {
20    'use strict';
21
22    var $window = $(window),
23        $body = $('body'),
24        windowHeight = parseFloat($window.height()),
25        windowScrollTop = 0,
26
27        geodirDebounce = function(delay, fn) {
28            var timer = null;
29
30            return function() {
31                var context = this,
32                    args = arguments;
33                clearTimeout(timer);
34                timer = setTimeout(function() {
35                    fn.apply(context, args);
36                }, delay);
37            };
38        },
39
40        geodirThrottle = function(delay, fn) {
41            var last, deferTimer;
42            return function() {
43                var context = this,
44                    args = arguments,
45                    now = +new Date;
46                if (last && now < last + delay) {
47                    clearTimeout(deferTimer);
48                    deferTimer = setTimeout(function() {
49                        last = now;
50                        fn.apply(context, args);
51                    }, delay);
52                } else {
53                    last = now;
54                    fn.apply(context, args);
55                }
56            };
57        }
58
59    window.geodirApiLoaded = geodir_map_params.api;
60    window.geodirApiScriptLoaded = false;
61    window.geodirApiScriptLoading = false;
62
63    var $containers = $([]),
64
65        geodirLoadScriptsStyles = function(mainLoaded) {
66            var geodirMapApi, apiStyles, apiScripts, apiCallback;
67
68            if ((window.geodirApiLoaded == 'google' || window.geodirApiLoaded == 'auto') && geodir_map_params.apis.google) {
69                geodirMapApi = geodir_map_params.apis.google;
70            } else if (window.geodirApiLoaded == 'osm' && geodir_map_params.apis.osm) {
71                geodirMapApi = geodir_map_params.apis.osm;
72            }
73
74            if (geodirMapApi) {
75                /* css */
76                if (geodirMapApi.styles) {
77                    apiStyles = geodirMapApi.styles;
78                }
79
80                /* javascript */
81                if (geodirMapApi.scripts) {
82                    apiScripts = geodirMapApi.scripts;
83                }
84
85                /* callback */
86                if (geodirMapApi.callback) {
87                    apiCallback = geodirMapApi.callback;
88                }
89            }
90
91            /* Load styles */
92            if (apiStyles && !mainLoaded) {
93                geodirLoadStyles(apiStyles);
94            }
95
96            /* Load scripts */
97            if (apiScripts && geodirLoadScripts(apiScripts, mainLoaded)) {
98                window.geodirApiScriptLoading = true;
99                if (apiCallback) {
100                    try {
101                        eval(apiCallback);
102                    } catch (err) {
103                        console.log(err.message)
104                    }
105                }
106            }
107            return true;
108        },
109
110        geodirLoadStyles = function(styles) {
111            $(styles).each(function(i, file) {
112                if (!($('link#' + (file.id)).length) && !(typeof file.check !== 'undefined' && file.check === false)) {
113                    var el = document.createElement("link");
114                    el.setAttribute("rel", "stylesheet");
115                    el.setAttribute("type", "text/css");
116                    el.setAttribute("id", file.id);
117                    el.setAttribute("href", file.src);
118                    document.getElementsByTagName("head")[0].appendChild(el);
119                }
120            });
121            return true;
122        },
123
124        geodirLoadScripts = function(scripts, mainLoaded) {
125            $(scripts).each(function(i, file) {
126                if (!($('script#' + (file.id)).length) && !(typeof file.check !== 'undefined' && file.check === false)) {
127                    if (!window.geodirMapScripts) {
128                        window.geodirMapScripts = [];
129                    }
130                    if (!window.geodirMapScripts[window.geodirApiLoaded]) {
131                        window.geodirMapScripts[window.geodirApiLoaded] = [];
132                    }
133                    if ((window.geodirMapScripts[window.geodirApiLoaded]).indexOf(file.id) === -1) {
134                        (window.geodirMapScripts[window.geodirApiLoaded]).push(file.id);
135                    }
136                    if ((i == 0 && !mainLoaded) || (i > 0 && mainLoaded)) {
137                        if (file.callback) {
138                            file.src += ((file.src).indexOf('?') === -1 ? '?' : '&') + 'callback=' + file.callback;
139                        }
140                        var el = document.createElement("script");
141                        el.setAttribute("type", "text/javascript");
142                        el.setAttribute("id", file.id);
143                        el.setAttribute("src", file.src);
144                        el.setAttribute("async", true);
145                        var onLoad = 'javascript:geodirMapScriptOnLoad(this);';
146                        if (file.main) {
147                            onLoad += 'javascript:geodirMapMainScriptOnLoad(this);';
148                        }
149                        if (file.onLoad) {
150                            onLoad += file.onLoad;
151                        }
152                        el.setAttribute("onload", onLoad);
153                        if (file.onError) {
154                            el.setAttribute("onerror", (typeof file.onError == 'string' ? file.onError : 'javascript:geodirMapScriptOnError(this);'));
155                        }
156                        document.getElementsByTagName("head")[0].appendChild(el);
157                    }
158                }
159            });
160            return true;
161        },
162
163        geodirMapInit = function(callback) {
164            windowScrollTop = $window.scrollTop();
165
166            $containers.each(function() {
167                var $this = $(this),
168                    thisOptions = $this.data('options');
169
170                if (geodir_map_params.lazyLoad == 'auto') {
171                    if (!$this.data('loadJS') && $this.offset().top - windowScrollTop > windowHeight * 1) {
172                        return true;
173                    } else {
174                        if ($this.is(':visible') && !$this.data('loadMap') || $this.data('loadJS')) {
175                            $this.data('loadMap', true);
176                        }
177                    }
178                }
179
180                if (!$this.data('loadMap')) {
181                    return true;
182                }
183
184                if (!window.geodirApiScriptLoaded && !window.geodirApiScriptLoading) {
185                    geodirLoadScriptsStyles();
186                }
187
188                if (!window.geodirApiScriptLoaded) {
189                    return false;
190                }
191
192                if (thisOptions.callback !== false) {
193                    thisOptions.callback(this);
194                }
195
196                $containers = $containers.not($this);
197            });
198        };
199
200    $window.on('geodirMapScriptOnLoad', function(el, file) {
201            if (file.id && typeof window.geodirMapScripts == 'object' && window.geodirApiLoaded && typeof window.geodirMapScripts[window.geodirApiLoaded] == 'object') {
202                var $loaded = window.geodirMapScripts[window.geodirApiLoaded];
203                $loaded.splice($loaded.indexOf(file.id), 1);
204                window.geodirMapScripts[window.geodirApiLoaded] = $loaded;
205                if ($loaded.length === 0) {
206                    window.geodirMapAllScriptsLoaded = true;
207                    jQuery(window).trigger('geodirMapAllScriptsLoaded');
208                }
209            }
210        })
211        .on('geodirMapAllScriptsLoaded', function() {
212            geodirMapScriptCallback();
213        })
214        .on('geodirMapScriptCallbackBefore', function() {
215            /* goMap init */
216            geodirGoMapInit();
217        })
218        .on('geodirMapMainScriptOnLoad', function(scripts) {
219            /* Load dependency scripts */
220            geodirLoadScriptsStyles(true);
221        })
222        .on('geodirMapScriptCallback', function() {
223            window.geodirApiScriptLoaded = true;
224
225            geodirMapInit();
226        }).on('geodirMapScriptOnError', function() {
227            /* Load OSM */
228            if (window.geodirApiLoaded == 'auto') {
229                window.geodirApiLoaded = 'osm';
230                window.geodirApiScriptLoading = false;
231
232                geodirMapInit();
233            }
234        })
235        .on('scroll', geodirThrottle(500, function() {
236            geodirMapInit();
237        }))
238        .on('resize', geodirDebounce(1000, function() {
239            windowHeight = $window.height();
240
241            geodirMapInit();
242        }));
243
244    $.fn.geodirLoadMap = function(options) {
245        options = $.extend({
246                map_canvas: '',
247                loadJS: false,
248                callback: false,
249            },
250            options);
251
252        this.each(function() {
253            var $this = $(this), $map_wrap, $loading, $lazyload;
254            $this.data('options', options);
255            $this.data('loadMap', $this.is(':visible'));
256
257            if (geodir_map_params.lazyLoad == 'click') {
258                if (options.map_canvas) {
259                    $this.data('loadMap', false);
260                    $map_wrap = $('.geodir_map_container.' + options.map_canvas);
261
262                    if (!$('.geodir-lazyload-div', $map_wrap).length) {
263                        $loading = $('.loading_div', $map_wrap);
264                        $lazyload = $loading.clone();
265                        $lazyload.css('background-image',"url('"+geodir_map_params.lazyLoadPlaceholder+"')").css('background-size','cover');
266                        $lazyload = $lazyload.html(geodir_map_params.lazyLoadButton);
267                        $lazyload.attr('id', options.map_canvas + '_lazyload_div');
268                        $lazyload.removeClass('loading_div').addClass('geodir-lazyload-div overflow-hidden');
269                        $loading.hide();
270
271                        $lazyload.on('click', function() {
272                            $(this).hide();
273                            $(this).parent().find('.loading_div').show();
274                            $(this).closest('.geodir_map_container').find('.geodir-map-cat-filter-wrap').show();
275
276                            $this.data('loadMap', true);
277
278                            geodirMapInit();
279                        });
280
281                        $loading.after($lazyload);
282                    }
283                } else if (options.forceLoad) {
284                    $this.data('loadMap', true);
285                }
286            }
287
288            if (options.loadJS) {
289                $this.data('loadJS', true);
290            }
291
292            $containers = $containers.add($this);
293        });
294
295        if (geodir_map_params.lazyLoad == 'auto') {
296            geodirMapInit();
297        }
298
299        this.geodirDebounce = geodirDebounce;
300        this.geodirThrottle = geodirThrottle;
301
302        return this;
303    };
304
305})(jQuery, window, document);

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.