Now possible to quickly filter 20km around one self

remotes/origin/master
echarp 4 years ago
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

@ -10,9 +10,7 @@
= favicon_link_tag '/favicon.ico'
= auto_discovery_link_tag :rss, controller: '/events', format: :rss
= stylesheet_link_tag 'application', media: 'all',
'data-turbolinks-track' => true
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags

@ -3,18 +3,19 @@
- if params[:tag].present?
= render partial: '/tags/context', locals: { tags: params[:tag] }
- if params[:near].present? && params[:near][:location].present? && params[:near][:distance].present?
- if params[:near].present? && params[:near][:location].present?
%span.near
%em.fa.fa-map-pin
= params[:near][:location]
%em.fa.fa-arrows-alt-h
= params[:near][:distance]
km
- if params[:near][:distance].present?
%em.fa.fa-arrows-alt-h
= params[:near][:distance]
km
%a(href="?near=")
%em.fa.fa-times
- if params[:tag].blank? && (params[:near].blank? || params[:near][:location].blank?)
= link_to page_path('filter') do
= link_to page_path('filter'), class: 'filter' do
= t 'title', scope: 'pages.filter'
= link_to page_path('filter'), title: t('title', scope: 'pages.filter') do

Loading…
Cancel
Save