Compare commits

..
Author SHA1 Message Date
harrybomrah 42075d2552 implementd maps with category filteration and custom color markers. 2013-11-12 21:56:36 +08:00
harrybomrah 50b12c6546 category blank fix 2013-11-12 17:30:48 +08:00
13 changed files with 20 additions and 105 deletions

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@ var banner_index = 0;
$(document).ready(function() { $(document).ready(function() {
$.each($(".dymanic_load"),function(){ $.each($(".dymanic_load"),function(){
if($(this).attr("path")==''){ if($(this).attr("path")==''){
$(this).html(""); $(this).html("App setting Failed");
}else{ }else{
ajax_load_proc($(this),$(this).attr("path")); ajax_load_proc($(this),$(this).attr("path"));
} }
@@ -16,7 +16,7 @@ $(document).ready(function() {
function ajax_load_proc(wapper,url,isBanner){ function ajax_load_proc(wapper,url,isBanner){
$.get(encodeURI(url), {}, function(respText,textSta,XML){ $.get(encodeURI(url), {}, function(respText,textSta,XML){
if (textSta == 'success') { if (textSta == 'success') {
if (respText.indexOf("<title>") == -1) wapper.html(respText); wapper.html(respText);
}; };
if(textSta == 'error') if(textSta == 'error')
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>"); wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
+1 -1
View File
@@ -14,7 +14,7 @@ class OrbitBackendController < ApplicationController
status << 'is_top' status << 'is_top'
status << 'is_hot' status << 'is_hot'
status << 'is_hidden' unless is_guest? status << 'is_hidden' unless is_guest?
if @module_app.is_approvable && (is_manager? || is_sub_manager?) if @module_app.is_approvable && is_manager?
status << 'is_pending' status << 'is_pending'
status << 'is_checked' status << 'is_checked'
status << 'is_rejected' status << 'is_rejected'
+1 -1
View File
@@ -14,7 +14,7 @@ class OrbitMemberController < ApplicationController
status << 'is_top' status << 'is_top'
status << 'is_hot' status << 'is_hot'
status << 'is_hidden' unless is_guest? status << 'is_hidden' unless is_guest?
if @module_app.is_approvable && (is_manager? || is_sub_manager?) if @module_app.is_approvable && is_manager?
status << 'is_pending' status << 'is_pending'
status << 'is_checked' status << 'is_checked'
status << 'is_rejected' status << 'is_rejected'
+2 -2
View File
@@ -12,13 +12,13 @@ module OrbitBackendHelper
def show_form_status_field(object) def show_form_status_field(object)
#by_object = (!object.is_expired? and object.is_pending?) #by_object = (!object.is_expired? and object.is_pending?)
by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin?)
by_user by_user
end end
def show_approval_link(object) def show_approval_link(object)
by_object = (!object.is_expired? and object.is_pending?) by_object = (!object.is_expired? and object.is_pending?)
by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin?)
by_object and by_user by_object and by_user
end end
+1 -1
View File
@@ -47,7 +47,7 @@ module ParserFrontEnd
ret = '' ret = ''
part = PagePart.find(front['part_id']) if front['part_id'] part = PagePart.find(front['part_id']) if front['part_id']
ret << eval("\"#{front['path']}\"") rescue '' ret << eval("\"#{front['path']}\"") rescue ''
ret << (ret.include?("?") ? "&#{args.to_param}" : "?#{args.to_param}") if args.present? ret << (ret.include?("?") ? "&#{args.to_param}" : "?#{args.to_param}") if args
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>") fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
end end
front.swap(fragment) front.swap(fragment)
@@ -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,6 +11,7 @@ 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 = {
@@ -118,10 +119,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";
@@ -1,12 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,40 +0,0 @@
<%= 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>
@@ -1,3 +0,0 @@
<a href="<%= panel_location_front_end_locations_path %>" >
<%= image_tag @url, :width=>"300", :height=>"300" %>
</a>
-6
View File
@@ -9,12 +9,6 @@ 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
+8 -16
View File
@@ -4,17 +4,15 @@ 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 'locations' do # app_page 'bulletins'
frontend_i18n 'location.location' # end
end
end
# category ["BulletinCategory"] # category ["BulletinCategory"]
@@ -35,12 +33,6 @@ 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"
@@ -3,7 +3,7 @@
quick_edit_link type: 'edit', quick_edit_link type: 'edit',
link: 'edit_panel_page_content_back_end_page_context_path' link: 'edit_panel_page_content_back_end_page_context_path'
quick_edit_link type: 'authorization', quick_edit_link type: 'authorization',
link: "admin_authorizations_path(@module_app.key, 'page_context_authorization', object.id)" link: "admin_authorizations_path(@module_app.key, 'page_context', object.id)"
field type: 'associated', field type: 'associated',
db_field: 'page', db_field: 'page',
model_field: 'path', model_field: 'path',