parent
142b125dfb
commit
fab2a3f8e6
@ -0,0 +1,24 @@
|
||||
$(document).on 'turbolinks:load', ->
|
||||
$('.digest .filter').each ->
|
||||
$(this).before '
|
||||
<a id="nearMe" href="#">
|
||||
<em class="fa fa-2x fa-street-view"></em>
|
||||
</a>'
|
||||
$( '#nearMe').click (event) ->
|
||||
event.preventDefault()
|
||||
nearMe()
|
||||
|
||||
nearMe = ->
|
||||
if (navigator.geolocation)
|
||||
navigator.geolocation.getCurrentPosition showPosition
|
||||
|
||||
showPosition = (position) ->
|
||||
coords = "[#{position.coords.latitude}, #{position.coords.longitude}]"
|
||||
url = location.href
|
||||
if location.search
|
||||
url = url.replace 'near=', ''
|
||||
url += '&'
|
||||
else
|
||||
url += '?'
|
||||
url += "near[location]=#{coords}&near[distance]=20"
|
||||
location.replace url
|
Loading…
Reference in new issue