1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
|
$(function(){function j(a,b,c){var j=new google.maps.MarkerImage(c,new google.maps.Size(27,37),new google.maps.Point(0,0),new google.maps.Point(13,18)),k=new google.maps.MarkerImage("/assets/markers/shadow-8e05a2a893ca0812e770d88aed15e961.png",new google.maps.Size(46,37),new google.maps.Point(0,0),new google.maps.Point(13,18)),l=new google.maps.Marker({animation:google.maps.Animation.DROP,icon:j,map:d,position:b,shadow:k});google.maps.event.addListener(l,"click",function(){g&&g.close();var b=new google.maps.InfoWindow({maxWidth:230});google.maps.event.addListener(b,"closeclick",function(){h=!1}),g=b,e=a,f=l,$.ajax({type:"GET",url:"/info_window",data:{thing_id:a},success:function(a){b==g&&(b.setContent(a),b.open(d,l),h=!0)}})}),i.push(a)}function k(b,c){$.ajax({type:"GET",url:"/things.json",data:{utf8:"✓",authenticity_token:$('#address_form input[name="authenticity_token"]').val(),lat:b,lng:c,limit:$('#address_form input[name="limit"]').val()},success:function(e){if(e.errors)$("#address_label").addClass("error",500),$("#address").addClass("error",500),$("#address").focus();else{$("#address_label").removeClass("error",500),$("#address").removeClass("error",500);var f=-1;$(e).each(function(a,b){if($.inArray(b.id,i)==-1)f+=1;else return!0;setTimeout(function(){point=new google.maps.LatLng(b.lat,b.lng),b.user_id?image_path="/assets/markers/green-5583a65ce5266b274e9389fce98ea41a.png":image_path="/assets/markers/red-8f727186ba094dfb33c72aadd204cd5d.png",j(b.id,point,image_path)},f*100)}),a=new google.maps.LatLng(b,c),d.setCenter(a),d.setZoom(18)}}})}function l(){$('#combo-form input[type="text"]:visible, #combo-form input[type="password"]:visible, #combo-form input[type="submit"]:visible, #combo-form button:visible').each(function(a){if($(this).val()===""||$(this).attr("type")==="submit"||this.tagName.toLowerCase()==="button")return $(this).focus(),!1})}var a=new google.maps.LatLng(42.358431,-71.059773),b=15,c={center:a,mapTypeControl:!1,zoomControl:!1,mapTypeId:google.maps.MapTypeId.ROADMAP,panControl:!1,scrollwheel:!1,zoom:b},d=new google.maps.Map(document.getElementById("map"),c),e,f,g,h=!1,i=[];google.maps.event.addListener(d,"dragend",function(){if(h==1)return;a=d.getCenter(),k(a.lat(),a.lng())}),$("#address_form").live("submit",function(){var a=$("#address_form input[type='submit']");$(a).attr("disabled",!0);var b=$(a).attr("value");return $(a).attr("value","Please Wait..."),$("#address").val()===""?($(a).attr("disabled",!1),$(a).attr("value",b),$("#address_label").addClass("error",500),$("#address").addClass("error",500),$("#address").focus()):$.ajax({type:"GET",url:"/address.json",data:{utf8:"✓",authenticity_token:$('#address_form input[name="authenticity_token"]').val(),city_state:$("#city_state").val(),address:$("#address").val()},success:function(c){$(a).attr("disabled",!1),$(a).attr("value",b),c.errors?($("#address_label").addClass("error",500),$("#address").addClass("error",500),$("#address").focus()):k(c[0],c[1])}}),!1}),$('#combo-form input[type="radio"]').live("click",function(){var a=$(this);"new"==a.val()?($("#combo-form").data("state","user_sign_up"),$("#user_forgot_password_fields").slideUp(),$("#user_sign_in_fields").slideUp(),$("#user_sign_up_fields").slideDown(function(){l()})):"existing"==a.val()&&($("#user_sign_up_fields").slideUp(),$("#user_sign_in_fields").slideDown(function(){$("#combo-form").data("state","user_sign_in"),l(),$("#user_forgot_password_link").click(function(){$("#combo-form").data("state","user_forgot_password"),$("#user_sign_in_fields").slideUp(),$("#user_forgot_password_fields").slideDown(function(){l(),$("#user_remembered_password_link").click(function(){$("#combo-form").data("state","user_sign_in"),$("#user_forgot_password_fields").slideUp(),$("#user_sign_in_fields").slideDown(function(){l()})})})})}))}),$("#combo-form").live("submit",function(){var a=$("#combo-form input[type='submit']");$(a).attr("disabled",!0);var b=[];return/[\w\.%\+\]+@[\w\]+\.+[\w]{2,}/.test($("#user_email").val())?($("#user_email_label").removeClass("error"),$("#user_email").removeClass("error")):(b.push
|