PageSourceSearch

https://dreamjobsafrica.com/wp-content/themes/superio/js/job-map.js?ver=20150330

js dreamjobsafrica.com collected 2026-10-04 15:12:07 UTC 11,360 bytes, 269 lines download raw bytes

1(function($) {
2    "use strict";
3    
4    var map, mapSidebar, markers, CustomHtmlIcon, group;
5    var markerArray = [];
6
7    $.extend($.apusThemeCore, {
8        /**
9         *  Initialize scripts
10         */
11        job_map_init: function() {
12            var self = this;
13
14            if ($('#jobs-google-maps').length) {
15                L.Icon.Default.imagePath = 'wp-content/themes/superio/images/';
16            }
17            
18            setTimeout(function(){
19                self.mapInit();
20            }, 50);
21            
22        },
23        
24        mapInit: function() {
25            var self = this;
26
27            var $window = $(window);
28
29            if (!$('#jobs-google-maps').length) {
30                return;
31            }
32
33            map = L.map('jobs-google-maps', {
34                scrollWheelZoom: false
35            });
36
37            markers = new L.MarkerClusterGroup({
38                showCoverageOnHover: false
39            });
40
41            CustomHtmlIcon = L.HtmlIcon.extend({
42                options: {
43                    html: "<div class='map-popup'></div>",
44                    iconSize: [30, 30],
45                    iconAnchor: [22, 30],
46                    popupAnchor: [0, -30]
47                }
48            });
49
50            $window.on('pxg:refreshmap', function() {
51                map._onResize();
52                setTimeout(function() {
53                    
54                    if(markerArray.length > 0 ){
55                        group = L.featureGroup(markerArray);
56                        map.fitBounds(group.getBounds()); 
57                    }
58                }, 100);
59            });
60
61            $window.on('pxg:simplerefreshmap', function() {
62                map._onResize();
63            });
64
65            if ( superio_job_map_opts.map_service == 'mapbox' ) {
66                var tileLayer = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/'+superio_job_map_opts.mapbox_style+'/tiles/{z}/{x}/{y}?access_token='+ superio_job_map_opts.mapbox_token, {
67                    attribution: " &copy;  <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> &copy;  <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>",
68                    maxZoom: 18,
69                });
70            } else if ( superio_job_map_opts.map_service == 'here' ) {
71
72                var hereTileUrl = 'https://2.base.maps.ls.hereapi.com/maptile/2.1/maptile/newest/'+superio_job_map_opts.here_style+'/{z}/{x}/{y}/512/png8?apiKey='+ superio_job_map_opts.here_map_api_key +'&ppi=320';
73                var tileLayer = L.tileLayer(hereTileUrl, {
74                    attribution: " &copy;  <a href='https://www.mapbox.com/about/maps/'>Here</a> &copy; <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>",
75                    maxZoom: 18,
76                });
77
78            } else if ( superio_job_map_opts.map_service == 'openstreetmap' ) {
79                
80                var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
81                    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
82                });
83
84            } else {
85                if ( superio_job_map_opts.custom_style != '' ) {
86                    try {
87                        var custom_style = $.parseJSON(superio_job_map_opts.custom_style);
88                        var tileLayer = L.gridLayer.googleMutant({
89                            type: 'roadmap',
90                            styles: custom_style
91                        });
92
93                    } catch(err) {
94                        var tileLayer = L.gridLayer.googleMutant({
95                            type: 'roadmap'
96                        });
97                    }
98                } else {
99                    var tileLayer = L.gridLayer.googleMutant({
100                        type: 'roadmap'
101                    });
102                }
103            }
104
105            
106
107            map.addLayer(tileLayer);
108
109            // check archive/single page
110            if ( !$('#jobs-google-maps').is('.single-job-map') ) {
111                self.updateMakerCards();
112            } else {
113                var $item = $('.single-listing-wrapper');
114                
115                if ( $item.data('latitude') !== "" && $item.data('latitude') !== "" ) {
116                    var zoom = (typeof MapWidgetZoom !== "undefined") ? MapWidgetZoom : 15;
117                    self.addMakerToMap($item);
118                    map.addLayer(markers);
119
120                    map.setView([$item.data('latitude'), $item.data('longitude')], zoom);
121                    $(window).on('update:map', function() {
122                        map.setView([$item.data('latitude'), $item.data('longitude')], zoom);
123                    });
124                } else {
125                    $('#jobs-google-maps').hide();
126                }
127            }
128        },
129        updateMakerCards: function() {
130            var self = this;
131            var $items = $('.main-items-wrapper .map-item');
132            
133            if ($('#jobs-google-maps').length && typeof map !== "undefined") {
134
135                if (!$items.length) {
136                    map.setView([superio_job_map_opts.default_latitude, superio_job_map_opts.default_longitude], 12);
137                    return;
138                }
139
140                map.removeLayer(markers);
141                markers = new L.MarkerClusterGroup({
142                    showCoverageOnHover: false
143                });
144                $items.each(function(i, obj) {
145                    self.addMakerToMap($(obj), true);
146                });
147
148                map.addLayer(markers);
149
150                if(markerArray.length > 0 ){
151                    group = L.featureGroup(markerArray);
152                    map.fitBounds(group.getBounds()); 
153                }
154            }
155        },
156        addMakerToMap: function($item, archive) {
157            var self = this;
158            var marker;
159
160            if ( $item.data('latitude') == "" || $item.data('longitude') == "") {
161                return;
162            }
163
164            if ( $item.data('img')) {
165                var img_logo = "<img src='" + $item.data('img') + "' alt=''>";
166                var mapPinHTML = "<div class='map-popup'><div class='icon-wrapper has-img is-job'>" + img_logo + "</div></div>";
167            } else {
168                var mapPinHTML = "<div class='map-popup'><div class='icon-wrapper is-candidate'></div></div>";
169            }
170
171            marker = L.marker([$item.data('latitude'), $item.data('longitude')], {
172                icon: new CustomHtmlIcon({ html: mapPinHTML })
173            });
174
175            if (typeof archive !== "undefined") {
176
177                $item.on('mouseenter', function() {
178                    $(marker._icon).find('.map-popup').addClass('map-popup-selected');
179                }).on('mouseleave', function(){
180                    $(marker._icon).find('.map-popup').removeClass('map-popup-selected');
181                });
182
183                var html_output = '';
184                if ( $item.hasClass('job_listing') ) {
185                    var logo_html = '';
186                    if ( $item.data('img') ) {
187                        logo_html = "<div class='employer-logo'><div class='image-wrapper image-loaded'>" +
188                                    "<img src='" + $item.data('img') + "' alt=''>" +
189                                "</div></div>";
190                    }
191
192                    var title_html = '';
193                    if ( $item.find('.job-title').length ) {
194                        title_html = "<div class='job-title'>" + $item.find('.job-title').html() + "</div>";
195                    }
196                    var category_html = '';
197                    if ( $item.find('.category-job').length ) {
198                        category_html = "<div class='category-job'>" + $item.find('.category-job').html() + "</div>";
199                    }
200                    var location_html = '';
201                    if ( $item.find('.job-location').length ) {
202                        location_html = "<div class='job-location'>" + $item.find('.job-location').html() + "</div>";
203                    }
204                    var meta_html =  "<div class='job-metas'>" + category_html + location_html + "</div>";
205
206                    html_output = "<div class='maps-popup-style job-list'>" +
207                        "<div class='inner'>" + logo_html +
208                            "<div class='job-list-content'>" + title_html + meta_html + "</div>" +
209                        "</div>" + 
210                    "</div>";
211                } else if ( $item.hasClass('employer') ) {
212                    var logo_html = '';
213                    if ( $item.data('img') ) {
214                        logo_html = "<div class='employer-logo'><div class='image-wrapper image-loaded'>" +
215                                    "<img src='" + $item.data('img') + "' alt=''>" +
216                                "</div></div>";
217                    }
218
219                    var title_html = '';
220                    if ( $item.find('.employer-title').length ) {
221                        title_html = "<div class='job-title'>" + $item.find('.employer-title').html() + "</div>";
222                    }
223                    var meta_html = '';
224                    if ( $item.find('.employer-map-metas').length ) {
225                        meta_html = "<div class='job-metas'>" + $item.find('.employer-map-metas').html() + "</div>";
226                    }
227
228                    html_output = "<div class='maps-popup-style job-list'>" +
229                        "<div class='inner'>" + logo_html +
230                            "<div class='job-list-content'>" + title_html + meta_html + "</div>" +
231                        "</div>" + 
232                    "</div>";
233                } else {
234                    var logo_html = '';
235                    if ( $item.data('img') ) {
236                        logo_html = "<div class='employer-logo'><div class='image-wrapper image-loaded'>" +
237                                    "<img src='" + $item.data('img') + "' alt=''>" +
238                                "</div></div>";
239                    }
240
241                    var title_html = '';
242                    if ( $item.find('.candidate-title').length ) {
243                        title_html = "<div class='job-title'>" + $item.find('.candidate-title').html() + "</div>";
244                    }
245                    var meta_html = '';
246                    if ( $item.find('.job-metas').length ) {
247                        meta_html = "<div class='job-metas'>" + $item.find('.job-metas').html() + "</div>";
248                    }
249
250                    html_output = "<div class='maps-popup-style job-list'>" +
251                        "<div class='inner'>" + logo_html +
252                            "<div class='job-list-content'>" + title_html + meta_html + "</div>" +
253                        "</div>" + 
254                    "</div>";
255                }
256
257                marker.bindPopup(html_output).openPopup();
258            }
259
260            markers.addLayer(marker);
261            markerArray.push(L.marker([$item.data('latitude'), $item.data('longitude')]));
262        },
263        
264    });
265
266    $.apusThemeExtensions.job_map = $.apusThemeCore.job_map_init;
267
268    
269})(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.