vtfs-884: cleanup of musicians page prepping for bands page clone
This commit is contained in:
parent
7f302a6f0e
commit
c18848fa03
|
|
@ -84,15 +84,19 @@ module JamRuby
|
|||
attr_accessor :user_counters, :page_num, :page_count
|
||||
|
||||
PARAM_MUSICIAN = :srch_m
|
||||
PARAM_BAND = :srch_b
|
||||
|
||||
M_PER_PAGE = 10
|
||||
B_PER_PAGE = M_PER_PAGE = 10
|
||||
M_MILES_DEFAULT = 500
|
||||
B_MILES_DEFAULT = 0
|
||||
|
||||
M_ORDER_FOLLOWS = ['Most Followed', :followed]
|
||||
M_ORDER_PLAYS = ['Most Plays', :plays]
|
||||
M_ORDER_PLAYING = ['Playing Now', :playing]
|
||||
M_ORDERINGS = [M_ORDER_FOLLOWS, M_ORDER_PLAYS, M_ORDER_PLAYING]
|
||||
M_ORDERING_KEYS = M_ORDERINGS.collect { |oo| oo[1] }
|
||||
B_ORDERINGS = M_ORDERINGS = [M_ORDER_FOLLOWS, M_ORDER_PLAYS, M_ORDER_PLAYING]
|
||||
B_ORDERING_KEYS = M_ORDERING_KEYS = M_ORDERINGS.collect { |oo| oo[1] }
|
||||
|
||||
B_DISTANCE_OPTS = M_DISTANCE_OPTS = [['Any', 0], [1000.to_s, 1000], [500.to_s, 500], [250.to_s, 250], [100.to_s, 100], [50.to_s, 50], [25.to_s, 25]]
|
||||
|
||||
def self.musician_order_param(params)
|
||||
ordering = params[:orderby]
|
||||
|
|
@ -106,27 +110,28 @@ module JamRuby
|
|||
.where(['minst.instrument_id = ? AND users.id IS NOT NULL', instrument])
|
||||
end
|
||||
|
||||
location_distance, location_city = params[:distance], params[:city]
|
||||
distance, latlng = nil, []
|
||||
if location_distance && location_city
|
||||
if geo = MaxMindGeo.where(:city => params[:city]).limit(1).first
|
||||
distance, latlng = location_distance, [geo.lat, geo.lng]
|
||||
end
|
||||
elsif current_user
|
||||
if current_user.lat.nil? || current_user.lng.nil?
|
||||
if params[:remote_ip] && (geo = MaxMindGeo.ip_lookup(params[:remote_ip]))
|
||||
latlng = [geo.lat, geo.lng] if geo.lat && geo.lng
|
||||
if 0 < (location_distance = params[:distance].to_i)
|
||||
location_city, distance, latlng = params[:city], nil, []
|
||||
if location_distance && location_city
|
||||
if geo = MaxMindGeo.where(:city => params[:city]).limit(1).first
|
||||
distance, latlng = location_distance, [geo.lat, geo.lng]
|
||||
end
|
||||
else
|
||||
latlng = [current_user.lat, current_user.lng]
|
||||
elsif current_user
|
||||
if current_user.lat.nil? || current_user.lng.nil?
|
||||
if params[:remote_ip] && (geo = MaxMindGeo.ip_lookup(params[:remote_ip]))
|
||||
latlng = [geo.lat, geo.lng] if geo.lat && geo.lng
|
||||
end
|
||||
else
|
||||
latlng = [current_user.lat, current_user.lng]
|
||||
end
|
||||
elsif params[:remote_ip] && (geo = MaxMindGeo.ip_lookup(params[:remote_ip]))
|
||||
latlng = [geo.lat, geo.lng] if geo.lat && geo.lng
|
||||
end
|
||||
if latlng.present?
|
||||
distance ||= location_distance || M_MILES_DEFAULT
|
||||
rel = rel.where(['lat IS NOT NULL AND lng IS NOT NULL'])
|
||||
.within(distance, :origin => latlng)
|
||||
end
|
||||
elsif params[:remote_ip] && (geo = MaxMindGeo.ip_lookup(params[:remote_ip]))
|
||||
latlng = [geo.lat, geo.lng] if geo.lat && geo.lng
|
||||
end
|
||||
if latlng.present?
|
||||
distance ||= location_distance || M_MILES_DEFAULT
|
||||
rel = rel.where(['lat IS NOT NULL AND lng IS NOT NULL'])
|
||||
.within(distance, :origin => latlng)
|
||||
end
|
||||
|
||||
sel_str = 'users.*'
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@
|
|||
var queryString = 'srch_m=1&page='+page_num+'&';
|
||||
|
||||
// order by
|
||||
var orderby = $('.musician-order-by').val();
|
||||
var orderby = $('#musician_order_by').val();
|
||||
if (typeof orderby != 'undefined' && orderby.length > 0) {
|
||||
queryString += "orderby=" + orderby + '&';
|
||||
}
|
||||
// instrument filter
|
||||
var instrument = $('.instrument-list').val();
|
||||
var instrument = $('#musician_instrument').val();
|
||||
if (typeof instrument != 'undefined' && !(instrument === '')) {
|
||||
queryString += "instrument=" + instrument + '&';
|
||||
}
|
||||
|
|
@ -197,6 +197,7 @@
|
|||
}
|
||||
|
||||
function events() {
|
||||
/*
|
||||
$("#musician_query_distance").keypress(function(evt) {
|
||||
if (evt.which === 13) {
|
||||
evt.preventDefault();
|
||||
|
|
@ -204,6 +205,10 @@
|
|||
}
|
||||
});
|
||||
$('#btn-refresh-musicians').on("click", refreshDisplay);
|
||||
*/
|
||||
$('#musician_query_distance').change(refreshDisplay);
|
||||
$('#musician_instrument').change(refreshDisplay);
|
||||
$('#musician_order_by').change(refreshDisplay);
|
||||
|
||||
$('#musician-filter-results').bind('scroll', function() {
|
||||
if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
|
||||
|
|
|
|||
|
|
@ -56,20 +56,9 @@
|
|||
}
|
||||
|
||||
.query-distance-params {
|
||||
float:left;
|
||||
width:50px;
|
||||
float: left;
|
||||
width: 80px;
|
||||
margin-left: 10px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background-color:$ColorTextBoxBackground;
|
||||
border: none;
|
||||
color:#333;
|
||||
font-weight:400;
|
||||
padding:0px 0px 0px 8px;
|
||||
height:18px;
|
||||
line-height:18px;
|
||||
overflow:hidden;
|
||||
-webkit-box-shadow: inset 2px 2px 3px 0px #888;
|
||||
box-shadow: inset 2px 2px 3px 0px #888;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,29 +7,19 @@
|
|||
<%= content_tag(:div, :class => 'filter-element') do -%>
|
||||
<!-- instrument filter -->
|
||||
<%= content_tag(:div, 'Instrument:', :class => 'filter-element') %>
|
||||
<%= content_tag(:div, :class => 'filter-element', :id => "find-musician-instrument") do -%>
|
||||
<%= select_tag(:instrument,
|
||||
options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] })),
|
||||
{:class => 'instrument-list'} ) %>
|
||||
<%= content_tag(:div, :class => 'filter-element') do -%>
|
||||
<%= select_tag(:musician_instrument,
|
||||
options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] }))) %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<!-- distance filter -->
|
||||
<%= content_tag(:div, :class => 'filter-element') do -%>
|
||||
<%= content_tag(:div, 'Within', :class => 'filter-element') %>
|
||||
<%= content_tag(:div, :class => 'query-distance-params', :style => "height:25px;") do -%>
|
||||
<%= text_field_tag(:query_distance,
|
||||
Search::M_MILES_DEFAULT.to_s,
|
||||
:id => :musician_query_distance,
|
||||
:placeholder => Search::M_MILES_DEFAULT.to_s) %>
|
||||
<%= content_tag(:div, :class => 'query-distance-params') do -%>
|
||||
<%= select_tag('musician_query_distance', options_for_select(Search::M_DISTANCE_OPTS, Search::M_MILES_DEFAULT)) %>
|
||||
<% end -%>
|
||||
<%= content_tag(:div, :class => 'filter-element') do -%>
|
||||
miles of <%= content_tag(:span, current_user.current_city(request.remote_ip), :id => 'musician-filter-city') %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<%= content_tag(:div,
|
||||
link_to('REFRESH', '#',
|
||||
:id => 'btn-refresh-musicians',
|
||||
:style => 'text-decoration:none',
|
||||
:class => 'button-grey'),
|
||||
:class => 'right mr10') %>
|
||||
<% end -%>
|
||||
|
|
|
|||
Loading…
Reference in New Issue