/*! Name: Geopost Dependencies: jQuery, HTML5 Author: Michael Lynch Author URL: http://michaelynch.com Date Created: March 4, 2013 Licensed under the MIT license */ ;(function(a){a.fn.geoPost=function(k){if(!this.length){return this}var d={postalCodeTarget:"#postal-code",success:function(){},error:function(){}};var g=this;var c=a(this);g.settings={};g.settings=a.extend({},d,k);var e;var b;var f;var j=function(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(h,i,{timeout:5000})}else{g.settings.error.call(this);console.log("Your browser does not support Geo Location.")}};function i(){g.settings.error.call(this);console.log("Geo Location failed.")}function h(l){e=new google.maps.Geocoder();b=new google.maps.LatLng(l.coords.latitude,l.coords.longitude);e.geocode({latLng:b},function(n,m){if(m==google.maps.GeocoderStatus.OK){a.each(n,function(o){if(this.types[0]=="postal_code"){f=this["address_components"][0]["long_name"];if(f.length>3){a(g.settings.postalCodeTarget).val(f);g.settings.success.call(this);return false}}})}})}a(this).click(function(l){l.preventDefault();j()})}})(jQuery);