1(function($) { 2 $(document).ready(function() { 3 if (!!rpw_gapi.enabledGoogleMapsApi && !rpw_gapi.existsGoogleApiKey) { 4 $('.wp-admin .rpw-gm-city').attr('placeholder', rpw_gapi.emptyGoogleApiKeyMessage); 5 initAutocomplete(); 6 } 7 }); 8})(jQuery); 9 10function initMap() { 11 (function($) { 12 $(document).ready(function() { 13 initAutocomplete(); 14 }); 15 })(jQuery); 16} 17 18function initAutocomplete () { 19 (function($) { 20 21 $(document).find('.rpw-gm-city').each(function() { 22 if (typeof this.rpwOwner == 'undefined' && typeof RPwGmLib != 'undefined') { 23 $(this).on('change', function() { 24 var form = $(this).closest('.form'); 25 if (form.length == 0) { 26 form = $(this).closest('form'); 27 } 28 $(form).find('.rpw-gm-city-data').val(''); 29 }); 30 31 if ( rpw_gapi.enabledGoogleMapsApi && rpw_gapi.existsGoogleApiKey ) { 32 var options = { 33 types: ['(cities)'] 34 }; 35 36 var autocomplete = new google.maps.places.Autocomplete($(this).get(0), options); 37 autocomplete.rpwOwner = this; 38 this.rpwOwner = autocomplete; 39 var gm_lib = new RPwGmLib(); 40 google.maps.event.addListener(autocomplete, 'place_changed', gm_lib.placeChanged); 41 } 42 } 43 }); 44 45 })(jQuery); 46} 47 48RPwGmLib.prototype = { 49 placeChanged : function () { 50 var place = this.getPlace(); 51 if (place.address_components) { 52 city = ''; 53 country = '' 54 state = ''; 55 56 for (var i = 0; i < place.address_components.length; i++) { 57 var component = place.address_components[i]; 58 if (!city && (jQuery.inArray('locality', component.types) != -1 || jQuery.inArray('administrative_area_level_3', component.types) != -1)) { 59 city = component.long_name; 60 } 61 if (jQuery.inArray('administrative_area_level_1', component.types) != -1) { 62 state = component.long_name; 63 } 64 if (jQuery.inArray('country', component.types) != -1) { 65 country = component.long_name; 66 } 67 } 68 69 var form = jQuery(this.rpwOwner).closest('.form'); 70 if (form.length == 0) { 71 form = jQuery(this.rpwOwner).closest('form'); 72 } 73 74 jQuery(form).find('.rpw-gm-city-data').val(''); 75 76 if (city) { 77 full_name = city; 78 city_data = 'city=' + city; 79 80 if (state) { 81 full_name = full_name + ', ' + state; 82 city_data = city_data + '&state=' + state; 83 } 84 85 if (country) { 86 full_name = full_name + ', ' + country; 87 city_data = city_data + '&country=' + country; 88 } 89 90 city_data = city_data + '&full_name=' + full_name; 91 city_data = city_data + '&lat=' + place.geometry.location.lat(); 92 city_data = city_data + '&lng=' + place.geometry.location.lng(); 93 94 jQuery(this.rpwOwner).val(full_name); 95 96 97 98 jQuery(form).find('.rpw-gm-city-data').val(city_data); 99 } 100 } 101 } 102}; 103 104function RPwGmLib () { 105}; 106 107 108
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.