completed locations frontend and widget using categories filtering etc.
This commit is contained in:
parent
eeb7f72876
commit
8f3a68b3d7
|
@ -1,6 +1,6 @@
|
||||||
var Locations = function(ls){
|
var Locations = function(ls){
|
||||||
|
|
||||||
l = this;
|
l = this;
|
||||||
|
this.name = "Locations";
|
||||||
this.locations = ls;
|
this.locations = ls;
|
||||||
this.markerCounts = 0;
|
this.markerCounts = 0;
|
||||||
var map = null,
|
var map = null,
|
||||||
|
@ -11,7 +11,6 @@ var Locations = function(ls){
|
||||||
|
|
||||||
|
|
||||||
var initialize = function() {
|
var initialize = function() {
|
||||||
|
|
||||||
google.maps.visualRefresh = true;
|
google.maps.visualRefresh = true;
|
||||||
var location = ( l.locations.length ? new google.maps.LatLng( l.locations[0].latitude, l.locations[0].longitude ) : default_location ),
|
var location = ( l.locations.length ? new google.maps.LatLng( l.locations[0].latitude, l.locations[0].longitude ) : default_location ),
|
||||||
mapOptions = {
|
mapOptions = {
|
||||||
|
@ -119,10 +118,10 @@ var Locations = function(ls){
|
||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
initialize();
|
||||||
google.maps.event.addDomListener(window, 'load', initialize);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var InvalidObjectError = function(){
|
var InvalidObjectError = function(){
|
||||||
this.name = "InvalidObjectError";
|
this.name = "InvalidObjectError";
|
||||||
this.message = "Object not valid";
|
this.message = "Object not valid";
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class Panel::Location::FrontEnd::LocationsController < OrbitWidgetController
|
||||||
|
def index
|
||||||
|
@categories = @module_app.categories.enabled
|
||||||
|
@locations = LocationInfo.all
|
||||||
|
|
||||||
|
@location_infos = [];
|
||||||
|
@locations.each do |loc|
|
||||||
|
loc['color'] = Category.find(loc.category_id).custom_value
|
||||||
|
@location_infos << loc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
vendor/built_in_modules/location/app/controllers/panel/location/widget/locations_controller.rb
vendored
Normal file
17
vendor/built_in_modules/location/app/controllers/panel/location/widget/locations_controller.rb
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class Panel::Location::Widget::LocationsController < OrbitWidgetController
|
||||||
|
def location_widget
|
||||||
|
@categories = params[:category_id]
|
||||||
|
locations = LocationInfo.where(:category_id.in => @categories)
|
||||||
|
@url = "http://maps.googleapis.com/maps/api/staticmap?zoom=16&size=400x400&maptype=roadmap%20&sensor=false&"
|
||||||
|
markers = ""
|
||||||
|
locations.each do |loc|
|
||||||
|
color = Category.find(loc.category_id).custom_value
|
||||||
|
color.gsub!("#","")
|
||||||
|
markers = markers + "markers=color:0x#{color}|#{loc.latitude},#{loc.longitude}&"
|
||||||
|
end
|
||||||
|
@url = @url + markers.chop
|
||||||
|
# http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap%20&markers=color:0xCF2C9B|40.702147,-74.015794&markers=color:CF2C9B|label:G|40.711614,-74.012318%20&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
40
vendor/built_in_modules/location/app/views/panel/location/front_end/locations/index.html.erb
vendored
Normal file
40
vendor/built_in_modules/location/app/views/panel/location/front_end/locations/index.html.erb
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<%= javascript_include_tag "location" %>
|
||||||
|
<div>
|
||||||
|
Categories :
|
||||||
|
<% @categories.each do |category| %>
|
||||||
|
<input type="checkbox" class="btn cat-filter" data-category='<%= category.id %>' /><%= category.title %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<a href="javascript:void(0);" id="clear_filter">Clear Filter</a>
|
||||||
|
<div id="map" style="width: 100%; height: 500px;"></div>
|
||||||
|
<script>
|
||||||
|
var loc = null;
|
||||||
|
var initialize = function(){
|
||||||
|
loc = new Locations(<%= @location_infos.to_json.html_safe %>);
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
var filterCategories = [];
|
||||||
|
$("input.cat-filter").bind( "click",function(){
|
||||||
|
var catid = $( this ).data('category');
|
||||||
|
|
||||||
|
if ( !$( this ).is(':checked') ){
|
||||||
|
|
||||||
|
var index = filterCategories.indexOf(filterCategories.filter(function(a,i){ return a == catid })[0]);
|
||||||
|
filterCategories.splice( index, 1 );
|
||||||
|
}else{
|
||||||
|
|
||||||
|
filterCategories.push( catid );
|
||||||
|
}
|
||||||
|
loc.filterMarkers(filterCategories);
|
||||||
|
})
|
||||||
|
|
||||||
|
$("a#clear_filter").bind( "click", function(){
|
||||||
|
filterCategories = [];
|
||||||
|
$("input.cat-filter").prop('checked',false);
|
||||||
|
loc.clearFilter();
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script src="http://maps.google.com/maps/api/js?sensor=true&callback=initialize"></script>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<a href="<%= panel_location_front_end_locations_path %>" >
|
||||||
|
<%= image_tag @url, :width=>"300", :height=>"300" %>
|
||||||
|
</a>
|
|
@ -9,6 +9,12 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :locations
|
resources :locations
|
||||||
end
|
end
|
||||||
|
namespace :front_end do
|
||||||
|
resources :locations
|
||||||
|
end
|
||||||
|
namespace :widget do
|
||||||
|
match "location_widget" => "locations#location_widget"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,15 +4,17 @@ module Location
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
# personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
|
# personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
|
||||||
|
|
||||||
# version "0.1"
|
version "0.1"
|
||||||
# organization "Rulingcom"
|
organization "Rulingcom"
|
||||||
# author "RD dep"
|
author "RD dep"
|
||||||
# intro "I am intro"
|
intro "I am intro"
|
||||||
# update_info 'some update_info'
|
update_info 'some update_info'
|
||||||
|
|
||||||
# front_end do
|
front_end do
|
||||||
# app_page 'bulletins'
|
app_page 'locations' do
|
||||||
# end
|
frontend_i18n 'location.location'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# category ["BulletinCategory"]
|
# category ["BulletinCategory"]
|
||||||
|
|
||||||
|
@ -34,6 +36,12 @@ module Location
|
||||||
categorizable
|
categorizable
|
||||||
authorizable
|
authorizable
|
||||||
|
|
||||||
|
widgets do
|
||||||
|
customize_widget "location_widget" do
|
||||||
|
widget_i18n "location.location"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'location.location',:icon_class=>"icons-location"
|
head_label_i18n 'location.location',:icon_class=>"icons-location"
|
||||||
available_for [:admin,:guest,:manager,:sub_manager]
|
available_for [:admin,:guest,:manager,:sub_manager]
|
||||||
|
|
Loading…
Reference in New Issue