Commit dbc270f8
Changed files (1)
app
views
devise
registrations
app/views/devise/registrations/new.html.erb
@@ -1,16 +1,46 @@
<% content_for :head do %>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#accepted').click(function(){
- if( $('#accepted').is(':checked')){
- $('#submit-registration').removeAttr('disabled');
+<script type="text/javascript">
+ $(document).ready(function(){
+ $('#accepted').click(function(){
+ if( $('#accepted').is(':checked')){
+ $('#submit-registration').removeAttr('disabled');
+ }
+ else{
+ $('#submit-registration').attr('disabled', 'disabled');
+ }
+ });
+ $('#user_city').autocomplete({
+ source: function(request, response){
+ $.ajax({
+ url: 'http://ws.geonames.org/searchJSON',
+ dataType: "jsonp",
+ data: {
+ featureClass: "P",
+ style: 'full',
+ maxRows: 12,
+ name_startsWith: request.term
+ },
+ success: function(data){
+ response( $.map(data.geonames, function(item){
+ return {
+ label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
+ value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
+ latitude: item.lat,
+ longitude: item.lng
+ }
+ }));
}
- else{
- $('#submit-registration').attr('disabled', 'disabled');
- }
- });
});
- </script>
+ },
+ minlength:2,
+ select:function(event, ui){
+ var item = ui.item;
+ $('#user_latitude').val(item.latitude);
+ $('#user_longitude').val(item.longitude);
+ }
+ });
+ });
+</script>
<% end %>
<div class="row">
<div class="span12">
@@ -76,6 +106,8 @@
<div class="form-actions">
<%= f.submit "Sign up", :id => 'submit-registration', :class=> "btn btn-primary" %>
</div>
+ <%= f.hidden_field :latitude %>
+ <%= f.hidden_field :longitude %>
<% end %>
</div>
</div>