1 2var address_auto_complete = { 3 4 bind: (o) => { 5 if (o.address) { 6 $(o.address).focus(address_auto_complete.load).bind('keydown', (e) => { if ((e.keyCode == 13) && ($('.pac-container:visible').length)) { e.preventDefault(); } }); 7 o.address.address_auto_complete_object = o; 8 } 9 }, 10 11 init: (k) => { 12 address_auto_complete.key = k; 13 }, 14 15 key: null, 16 17 load: (e) => { 18 var t = e.target; 19 if (!window.google || !google.maps || !google.maps) { 20 address_auto_complete.load_object = t; 21 $('head').append('<script src="https://maps.googleapis.com/maps/api/js?key=' + address_auto_complete.key + '&libraries=places&loading=async&callback=address_auto_complete.map_ready" async defer></script>'); 22 return false; 23 } 24 address_auto_complete.setup(t); 25 }, 26 27 load_object: null, 28 29 map_ready: () => { 30 address_auto_complete.setup(address_auto_complete.load_object); 31 }, 32 33 place_changed: (o) => { 34 var place = o.address_auto_complete_places.getPlace(); 35 if (place.address_components) { 36 var obj = o.address_auto_complete_object; 37 var adr = '<div>' + place.adr_address + '</div>'; 38 $(o).val($('.street-address', adr).text()); 39 $(obj.city).val($('.locality', adr).text()); 40 $(obj.state).val($('.region', adr).text()); 41 $(obj.zip).val($('.postal-code', adr).text().split('-')[0]); 42 } 43 }, 44 45 setup: (o) => { 46 if (!o.address_auto_complete_places) { 47 var p = o.address_auto_complete_places = new google.maps.places.Autocomplete(o, { fields: ['address_components', 'adr_address'] }); 48 p.setTypes(['address']); 49 p.addListener('place_changed', () => { address_auto_complete.place_changed(o); }); 50 } 51 } 52 53}
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.