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
26 changed files with 55 additions and 176 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>");
+21 -21
View File
@@ -111,30 +111,30 @@ function customOpenSlide() {
.closest('.navbar-inner') .closest('.navbar-inner')
.addClass('active'); .addClass('active');
pageslide.find('.content').css('padding', 0); pageslide.find('.content').css('padding', 0);
// iFrameContent() iFrameContent()
} }
}); });
} }
// function iFrameContent() { function iFrameContent() {
// function iFrameFunction(iContents, pc) { function iFrameFunction(iContents, pc) {
// pc.each(function(index, el) { pc.each(function(index, el) {
// if($(this).siblings('*').length == 0) { if($(this).siblings('*').length == 0) {
// var _parentH = $(this).parent('*').outerHeight(); var _parentH = $(this).parent('*').outerHeight();
// $(this).css('min-height', _parentH); $(this).css('height', _parentH);
// } }
// }); });
// iContents.find('#orbit-bar').hide(); iContents.find('#orbit-bar').hide();
// iContents.find('.main_wrap').css('margin-top', 0); iContents.find('.main_wrap').css('margin-top', 0);
// iContents.find('a').not('.edit_link a').on('click', function(event) { iContents.find('a').not('.edit_link a').on('click', function(event) {
// event.preventDefault(); event.preventDefault();
// }).css('cursor', 'default'); }).css('cursor', 'default');
// } }
// $('#pageslide_iframe').load(function() { $('#pageslide_iframe').load(function() {
// var $iContents = $(this).contents(), var $iContents = $(this).contents(),
// $pc = $iContents.find('.page_content'); $pc = $iContents.find('.page_content');
// iFrameFunction($iContents, $pc); iFrameFunction($iContents, $pc);
// }); });
// } }
function pageSetting(id, edit, ps) { function pageSetting(id, edit, ps) {
$pageModule = $('#pageslide #page_module_app_id'); $pageModule = $('#pageslide #page_module_app_id');
@@ -12,8 +12,6 @@ class Admin::PagePartsController < OrbitBackendController
@module_app_categories = @module_app.categories @module_app_categories = @module_app.categories
@module_app_tags = @module_app.tags @module_app_tags = @module_app.tags
@widget_paths = ModuleApp.find(@module_app.id).widgets.map{|name, data| [t(data["i18n"]), name]} rescue [] @widget_paths = ModuleApp.find(@module_app.id).widgets.map{|name, data| [t(data["i18n"]), name]} rescue []
@pages = Page.where(:module_app_id => @module_app.id)
if @part.widget_path.present? if @part.widget_path.present?
if @part.widget_path.eql?("default_widget") if @part.widget_path.eql?("default_widget")
@checked_style = @part.widget_style @checked_style = @part.widget_style
@@ -29,10 +27,7 @@ class Admin::PagePartsController < OrbitBackendController
# @frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil # @frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil
@frontend_styles = @module_app.widgets[@part.widget_path]["style"] rescue nil @frontend_styles = @module_app.widgets[@part.widget_path]["style"] rescue nil
@partial = 'custom_widget' if @frontend_styles.present? @partial = 'custom_widget' if @frontend_styles.present?
end end
@partial = 'more_link' unless @partial
end end
@data_count = @module_app.get_registration.get_data_count.to_a rescue [] @data_count = @module_app.get_registration.get_data_count.to_a rescue []
@no_orbit_bar = @side_bar = @no_header = true @no_orbit_bar = @side_bar = @no_header = true
@@ -79,7 +74,6 @@ class Admin::PagePartsController < OrbitBackendController
def get_display_style def get_display_style
@part = PagePart.find(params[:id]) rescue nil @part = PagePart.find(params[:id]) rescue nil
@module_app = ModuleApp.find(params[:module_id]) rescue nil @module_app = ModuleApp.find(params[:module_id]) rescue nil
@pages = Page.where(:module_app_id => @module_app.id)
if @module_app if @module_app
if params[:val].eql?("default_widget") if params[:val].eql?("default_widget")
@checked_style = @part.widget_path.present? ? @part.widget_style : nil if @part && @part.widget_path.eql?("default_widget") @checked_style = @part.widget_path.present? ? @part.widget_style : nil if @part && @part.widget_path.eql?("default_widget")
@@ -94,8 +88,6 @@ class Admin::PagePartsController < OrbitBackendController
@frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil @frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil
@partial = 'custom_widget' if @frontend_styles.present? @partial = 'custom_widget' if @frontend_styles.present?
end end
@partial = 'more_link' unless @partial
end end
end end
@@ -39,7 +39,6 @@ class DefaultWidgetController< OrbitWidgetController
end end
def default_widget def default_widget
@search = params["search_query"].blank? ? false : true @search = params["search_query"].blank? ? false : true
if !params[:id].blank? and !params["clicked_field_name"].blank? if !params[:id].blank? and !params["clicked_field_name"].blank?
clicked_field_name = params["clicked_field_name"].to_sym clicked_field_name = params["clicked_field_name"].to_sym
@@ -92,8 +91,6 @@ class DefaultWidgetController< OrbitWidgetController
@tag_class = 'default_widget_typeC' @tag_class = 'default_widget_typeC'
@partial = "typeC" @partial = "typeC"
end end
@more_url = Page.find(@page_part.more_link).path rescue nil
# debugger
end end
end end
+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
@@ -70,6 +70,7 @@ class PagesController < ApplicationController
elsif params[:category_id].is_a? String elsif params[:category_id].is_a? String
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
end end
if params[:tag_id].is_a? Array if params[:tag_id].is_a? Array
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id',params[:tag_id])}" unless params[:tag_id].blank? options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id',params[:tag_id])}" unless params[:tag_id].blank?
elsif params[:category_id].is_a? String elsif params[:category_id].is_a? String
@@ -80,7 +81,7 @@ class PagesController < ApplicationController
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank? options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank? options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
uri = URI::escape(url + options) uri = URI::escape(url + options)
# uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&')) #uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&'))
redirect_to(uri)unless save_from_no_lang_for_page redirect_to(uri)unless save_from_no_lang_for_page
end end
@@ -104,7 +105,6 @@ class PagesController < ApplicationController
protected protected
def get_item def get_item
if params[:page_id] if params[:page_id]
@item = Item.find(params[:page_id]) @item = Item.find(params[:page_id])
elsif params[:same_page_id] elsif params[:same_page_id]
+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
View File
@@ -12,7 +12,6 @@ class PagePart
field :widget_path field :widget_path
field :category,type: Array, :default => [] field :category,type: Array, :default => []
field :tag, type: Array,:default => [] field :tag, type: Array,:default => []
field :more_link_page_id
field :widget_style field :widget_style
field :widget_field , :type => Array,:default => [] field :widget_field , :type => Array,:default => []
@@ -4,12 +4,6 @@
<%= select 'page_part', 'widget_style', @frontend_styles, {:selected => (@part && @part[:widget_style])}, class: "input-xlarge" %> <%= select 'page_part', 'widget_style', @frontend_styles, {:selected => (@part && @part[:widget_style])}, class: "input-xlarge" %>
</div> </div>
</div> </div>
<div class="control-group input-content">
<label class="control-label muted">More Link</label>
<div class="controls">
<%= select 'page_part', 'more_link_page_id', options_for_select(@pages.collect{|page|[page.title,page.id]},(@part.more_link_page_id rescue nil)), class: "input-xlarge" %>
</div>
</div>
<div class="control-group input-content"> <div class="control-group input-content">
<% @module_app.widget_options.tap { |widget|%> <% @module_app.widget_options.tap { |widget|%>
@@ -25,8 +19,8 @@
<% else%> <% else%>
<div class="controls"> <div class="controls">
<%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)), class: "input-xlarge" %> <%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)), class: "input-xlarge" %>
</div>
<% end %> <% end %>
</div>
<% end %> <% end %>
<% } %> <% } %>
<% } %> <% } %>
@@ -74,12 +74,6 @@
</table> </table>
</div> </div>
</div> </div>
<div class="control-group input-content">
<label class="control-label muted">More Link</label>
<div class="controls">
<%= select 'page_part', 'more_link_page_id', options_for_select(@pages.collect{|page|[page.title,page.id]},(@part.more_link_page_id rescue nil)), class: "input-xlarge" %>
</div>
</div>
<script> <script>
$('.typesetting li').each(function(index, el) { $('.typesetting li').each(function(index, el) {
@@ -1,6 +0,0 @@
<div class="control-group input-content">
<label class="control-label muted">More Link</label>
<div class="controls">
<%= select 'page_part', 'more_link_page_id', options_for_select(@pages.collect{|page|[page.title,page.id]},(@part.more_link_page_id rescue nil)), class: "input-xlarge" %>
</div>
</div>
@@ -4,10 +4,6 @@
<% if @paginate %> <% if @paginate %>
<%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %> <%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %>
<% elsif @page_part.module_app %> <% elsif @page_part.module_app %>
<%= @page_part.module_app.get_registration.default_widget_setting.link_to_more_tag(request,params) %>
<%#= @page_part.module_app.get_registration.default_widget_setting.link_to_more_tag(request,params) %>
<%= @page_part.module_app.get_registration.default_widget_setting.short_link_to_more(request,@more_url) %>
<% end %> <% end %>
<% end %> <% end %>
+2 -2
View File
@@ -8,13 +8,13 @@ defaults: &defaults
development: development:
<<: *defaults <<: *defaults
database: orbit_site_new database: test_site
test: test:
<<: *defaults <<: *defaults
database: orbit_site_new database: test_site
# set these environment variables on your prod server # set these environment variables on your prod server
production: production:
@@ -12,19 +12,12 @@ module DefaultWidgetTagHelper
if param.is_a?(Array) and !param.blank? if param.is_a?(Array) and !param.blank?
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&") params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
params.delete index params.delete index
params_str = params_str + "&"
end end
end end
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" ) params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
content_tag :div,:class=> 'more' do content_tag :div,:class=> 'more' do
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join() link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
end end
end end
def short_link_to_more(req,url)
@request = req
content_tag :div,:class=> 'more' do
link_to I18n.t(@more_link[:label_i18n]),url
end
end
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',
@@ -11,6 +11,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
def index def index
@part = PagePart.find(params[:part_id]) @part = PagePart.find(params[:part_id])
if @part.widget_data_count if @part.widget_data_count
@page_num = @part.widget_data_count @page_num = @part.widget_data_count
else else
@@ -63,7 +64,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
@web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank? @web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank?
end end
@more_url = Page.find(@part.more_link_page_id).path
end end
def get_categorys def get_categorys
@@ -30,5 +30,9 @@
</div> </div>
<div class="pull_right"> <div class="pull_right">
<%= link_to t(:more_plus), "/"+@more_url %> <% if !params[:category_id].blank? %>
<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path(:category_id => @part.category) %>
<% else %>
<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path %>
<% end %>
</div> </div>