diff --git a/vendor/built_in_modules/location/app/assets/javascripts/gprs/.gitkeep b/vendor/built_in_modules/location/app/assets/javascripts/gprs/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/vendor/built_in_modules/location/app/assets/javascripts/location.js b/vendor/built_in_modules/location/app/assets/javascripts/location.js
new file mode 100644
index 00000000..3edb22cb
--- /dev/null
+++ b/vendor/built_in_modules/location/app/assets/javascripts/location.js
@@ -0,0 +1,131 @@
+var Locations = function(ls){
+ l = this;
+ this.name = "Locations";
+ this.locations = ls;
+ this.markerCounts = 0;
+ var map = null,
+ infowindow = new google.maps.InfoWindow(),
+ default_location = new google.maps.LatLng( 24.8043107, 121.03042159999995 ),
+ infowindow_template = "
",
+ markers = [];
+
+
+ var initialize = function() {
+ google.maps.visualRefresh = true;
+ var location = ( l.locations.length ? new google.maps.LatLng( l.locations[0].latitude, l.locations[0].longitude ) : default_location ),
+ mapOptions = {
+ zoom: 16,
+ center: location,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+
+ map = new google.maps.Map( document.getElementById('map'), mapOptions );
+
+ for( i = 0; i < l.locations.length; i++ ){
+ markers.push( addMarker( new google.maps.LatLng(l.locations[i].latitude, l.locations[i].longitude), l.locations[i].color, i, function( index ){
+
+ }) );
+ }
+
+ }
+
+ var addMarker = function( location, pinColor, index, markerCallback ){
+
+ var pin = getPin(( pinColor.substr( 0, 1 ) == "#" ? pinColor.replace("#","") : pinColor )),
+ marker = new google.maps.Marker({
+ map: map,
+ icon: pin.image,
+ shadow: pin.shadow,
+ position: location,
+ zIndex: 10
+ });
+
+ google.maps.event.addListener( marker, 'click', function() {
+
+ infowindow.setContent( getTemplate( index ) );
+ infowindow.open( map, marker );
+ if( typeof markerCallback == "function" )
+ markerCallback.call( this, index );
+
+ });
+
+ l.markerCounts++;
+ return {"marker" : marker, "category_id" : l.locations[index].category_id};
+ }
+
+
+
+ var getTemplate = function( obj ){
+
+ var object = ( typeof obj == "number" ? l.locations[obj] : ( typeof obj == "object" ? obj : null ) );
+
+ if ( object ){
+
+ var template = $( "
" );
+ template.html( infowindow_template );
+ template.find( '.title' ).text( object.name );
+ template.find( "img.thumbnail" ).attr( "src", object.file.thumb.url );
+ return template.html();
+
+ }else{
+
+ throw new InvalidObjectError();
+ }
+
+ }
+
+ var getPin = function( color ){
+
+ var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + color,
+ new google.maps.Size(21, 34),
+ new google.maps.Point(0,0),
+ new google.maps.Point(10, 34));
+
+ var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
+ new google.maps.Size(40, 37),
+ new google.maps.Point(0, 0),
+ new google.maps.Point(12, 35));
+
+ return {"image":pinImage,"shadow":pinShadow};
+ }
+
+ this.getMarker = function( index ){
+ return markers[index];
+ }
+ this.getAllMarkers = function( ){
+ return markers;
+ }
+
+ this.clearFilter = function(){
+ var m = l.getAllMarkers();
+ for( i = 0; i < m.length; i++ ){
+ m[i].marker.setVisible(true);
+ }
+ }
+
+ this.filterMarkers = function( categories ){
+ var filtered = [],
+ m = l.getAllMarkers();
+
+ for( i = 0; i < m.length; i++ ){
+ m[i].marker.setVisible(false);
+ }
+ for( i = 0; i < categories.length; i++ ){
+ filtered = filtered.concat(m.filter(function(a){return a.category_id == categories[i]}));
+ }
+ for( i = 0; i < filtered.length; i++ ){
+ filtered[i].marker.setVisible(true);
+ }
+ return filtered;
+ }
+ initialize();
+
+}
+
+var InvalidObjectError = function(){
+ this.name = "InvalidObjectError";
+ this.message = "Object not valid";
+}
+
+InvalidObjectError.prototype = new Error();
+InvalidObjectError.prototype.constructor = InvalidObjectError;
diff --git a/vendor/built_in_modules/location/app/assets/javascripts/panel/gprs/back_end/locations.js b/vendor/built_in_modules/location/app/assets/javascripts/panel/gprs/back_end/locations.js
deleted file mode 100644
index dee720fa..00000000
--- a/vendor/built_in_modules/location/app/assets/javascripts/panel/gprs/back_end/locations.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// Place all the behaviors and hooks related to the matching controller here.
-// All this logic will automatically be available in application.js.
diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb
new file mode 100644
index 00000000..7dd5e220
--- /dev/null
+++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb
@@ -0,0 +1,19 @@
+class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendController
+ def index
+ @module_app_id = @module_app.id rescue nil
+ @categories = get_categories_for_index
+ @categories = @categories.page(params[:page]).per(10)
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @categories }
+ end
+ end
+
+ def list
+ @module_app_id = @module_app.id rescue nil
+ @categories = get_categories_for_index
+ @categories = @categories.page(params[:page]).per(10)
+ render :layout => false
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb
index c1a2bab2..e3baf793 100644
--- a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb
+++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb
@@ -1,9 +1,15 @@
class Panel::Location::BackEnd::LocationsController < OrbitBackendController
include AdminHelper
+ open_for_visitor :only => [:get_location_categories, :get_categorywise_locations]
def index
- @location_infos = LocationInfo.all
+ @locations = LocationInfo.all
@categories = get_categories_for_index
+ @location_infos = [];
+ @locations.each do |loc|
+ loc['color'] = Category.find(loc.category_id).custom_value
+ @location_infos << loc
+ end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @locations }
@@ -22,6 +28,8 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
def edit
@location_info = LocationInfo.find(params[:id])
+ @categories = get_categories_for_index
+
end
def show
@@ -34,6 +42,7 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
def create
@location_info = LocationInfo.new(params[:location_info])
+ @categories = get_categories_for_index
if @location_info.save
flash[:success] = "Success!!"
redirect_to panel_location_back_end_locations_url
@@ -81,4 +90,43 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
render :json => JSON.pretty_generate(@data)
end
+
+ def get_location_categories
+ check_mobile_api_openness
+ location_categories = get_categories_for_index
+ @data = Array.new
+
+ location_categories.each do |category|
+ I18n.locale = :en
+ name_en = category.title
+ I18n.locale = :zh_tw
+ name_zh_tw = category.title
+ category_id = category.id.to_s
+ @data << { name_en: name_en, name_zh_tw: name_zh_tw, category_id: category_id, location_link: "http://#{request.host_with_port}"+"/#{panel_location_back_end_locations_get_categorywise_locations_path}"+"?category_id=#{category_id}"}
+ end
+
+ render :json => JSON.pretty_generate(@data)
+ end
+
+ def get_categorywise_locations
+ check_mobile_api_openness
+ location_infos = LocationInfo.where(:category_id => params[:category_id])
+ @data = Array.new
+
+ location_infos.each do |location|
+
+ picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
+ thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
+
+ @data << { id: location.id.to_s,
+ name: location.name,
+ pic_url: picurl,
+ thumb_url: thumburl,
+ longitude: location.longitude,
+ latitude: location.latitude,
+ description: location.description }
+ end
+
+ render :json => JSON.pretty_generate(@data)
+ end
end
diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/front_end/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/front_end/locations_controller.rb
new file mode 100644
index 00000000..4be3e2ec
--- /dev/null
+++ b/vendor/built_in_modules/location/app/controllers/panel/location/front_end/locations_controller.rb
@@ -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
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/widget/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/widget/locations_controller.rb
new file mode 100644
index 00000000..f03e8087
--- /dev/null
+++ b/vendor/built_in_modules/location/app/controllers/panel/location/widget/locations_controller.rb
@@ -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
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb
new file mode 100644
index 00000000..096260c6
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb
@@ -0,0 +1,21 @@
+
+ <% @site_valid_locales.each_with_index do |locale, i| %>
+
+ <%= category.title_translations[locale] %>
+ <% if i == 0 %>
+
+
+ <% if is_admin?%>
+ <%= link_to t(:edit), '#', class: "open-slide", data: {title: t(:edit_category), id: category.id.to_s, module: @module_app_id.to_s, form: category.title_translations.merge(color: category.custom_value)} %>
+ <%= link_to show_toggle_archive_btn(category), toggle_admin_module_app_category_path(@module_app_id, category), method: :post, remote: true, class: "archive_toggle" %>
+ <% end %>
+ <% if is_manager? || is_admin? %>
+ <%= link_to t(:category_auth), admin_authorizations_path(@module_app.key, 'category_authorization', category.id) %>
+ <% end %>
+
+
+ <% end %>
+
+ <% end %>
+ <%= category.custom_value %>
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_form.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_form.html.erb
new file mode 100644
index 00000000..59f9d791
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_form.html.erb
@@ -0,0 +1,12 @@
+<%= flash_messages %>
+<%= f.error_messages %>
+<%= label_tag("color", t("location.color")) %>
+
+ <%= f.text_field :custom_value, id: "color", :class => "color-picker miniColors input-small", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
+
+<%= f.fields_for :title_translations do |f| %>
+ <% @site_valid_locales.each do |locale| %>
+ <%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %>
+ <%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %>
+ <% end %>
+<% end %>
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb
new file mode 100644
index 00000000..2c0ae280
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb
@@ -0,0 +1,66 @@
+<%= stylesheet_link_tag "jquery.miniColors" %>
+
+<%= javascript_include_tag "jquery.miniColors.min" %>
+
+<%= javascript_include_tag "admin/categories" %>
+
+
+
+
+
+
+
+ <%= render partial: 'category', collection: @categories %>
+
+
+
+
+
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
+
+
+
+
+
+
+
+
+
+ <%= form_for :category, url: nil, html:{:id=>"color"}, remote: true do |f| %>
+
+ <%= render :partial => "form", :locals => { :f => f } %>
+
+
+ <% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/list.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/list.html.erb
new file mode 100644
index 00000000..38d45712
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/list.html.erb
@@ -0,0 +1,21 @@
+
+
+
+
+
+ <%= render partial: 'category', collection: @categories %>
+
+
+
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
+
+
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb
index e3d4e53e..41a6560c 100644
--- a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb
@@ -19,8 +19,8 @@
<%= t 'coordinates' %>
+ <%= f.text_field :latitude, :class=>"span2", :placeholder => "Latitude" %>
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
- <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/index.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/index.html.erb
index 3190012b..cbd1c516 100644
--- a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/index.html.erb
+++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/index.html.erb
@@ -1,3 +1,5 @@
+
+<%= javascript_include_tag "location" %>
@@ -28,6 +30,44 @@
<% end %>
+
+ Categories :
+
+
+ <% @categories.each do |category| %>
+ <%= category.title %>
+ <% end %>
+
+Clear Filter
+
<%if is_manager? %>
<%= link_to 'Add', new_panel_location_back_end_location_path, :class => "btn btn-primary pull-right", :id=>"create_event_btn", :ref=>"add-btn"%>
<% end %>
+
diff --git a/vendor/built_in_modules/location/app/views/panel/location/front_end/locations/index.html.erb b/vendor/built_in_modules/location/app/views/panel/location/front_end/locations/index.html.erb
new file mode 100644
index 00000000..58fb2367
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/front_end/locations/index.html.erb
@@ -0,0 +1,40 @@
+<%= javascript_include_tag "location" %>
+
+ Categories :
+ <% @categories.each do |category| %>
+ <%= category.title %>
+ <% end %>
+
+Clear Filter
+
+
+
diff --git a/vendor/built_in_modules/location/app/views/panel/location/widget/locations/location_widget.html.erb b/vendor/built_in_modules/location/app/views/panel/location/widget/locations/location_widget.html.erb
new file mode 100644
index 00000000..8b8cada2
--- /dev/null
+++ b/vendor/built_in_modules/location/app/views/panel/location/widget/locations/location_widget.html.erb
@@ -0,0 +1,3 @@
+
+ <%= image_tag @url, :width=>"300", :height=>"300" %>
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/location/config/routes.rb b/vendor/built_in_modules/location/config/routes.rb
index dac4a423..bc9389bd 100644
--- a/vendor/built_in_modules/location/config/routes.rb
+++ b/vendor/built_in_modules/location/config/routes.rb
@@ -2,12 +2,22 @@ Rails.application.routes.draw do
namespace :panel do
namespace :location do
namespace :back_end do
-
+ match 'location_categories/list' => "location_categories#list"
+ match "locations/get_locations" => "locations#get_locations"
+ match "locations/get_categorywise_locations" => "locations#get_categorywise_locations"
+ match "locations/get_location_categories" => "locations#get_location_categories"
+ resources :location_categories
match "locations/get_locations" => "locations#get_locations"
match "locations/get_categories" => "locations#get_categories"
resources :locations
end
+ namespace :front_end do
+ resources :locations
+ end
+ namespace :widget do
+ match "location_widget" => "locations#location_widget"
+ end
end
end
end
diff --git a/vendor/built_in_modules/location/init.rb b/vendor/built_in_modules/location/init.rb
index a0767bc7..3e71da77 100644
--- a/vendor/built_in_modules/location/init.rb
+++ b/vendor/built_in_modules/location/init.rb
@@ -4,15 +4,17 @@ module Location
base_url File.expand_path File.dirname(__FILE__)
# personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
- # version "0.1"
- # organization "Rulingcom"
- # author "RD dep"
- # intro "I am intro"
- # update_info 'some update_info'
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
- # front_end do
- # app_page 'bulletins'
- # end
+ front_end do
+ app_page 'locations' do
+ frontend_i18n 'location.location'
+ end
+ end
# category ["BulletinCategory"]
@@ -33,31 +35,37 @@ module Location
categorizable
authorizable
+
+ widgets do
+ customize_widget "location_widget" do
+ widget_i18n "location.location"
+ end
+ end
side_bar do
head_label_i18n 'location.location',:icon_class=>"icons-location"
available_for [:admin,:guest,:manager,:sub_manager]
- active_for_controllers ({:private=>['locations']})
+ active_for_controllers ({:private=>['locations','location_categories']})
head_link_path "panel_location_back_end_locations_path"
context_link 'location.all_locations',
:link_path=>"panel_location_back_end_locations_path" ,
:priority=>1,
- :active_for_action=>{:localtions=>:index},
+ :active_for_action=>{:locations=>:index},
:available_for => [:manager]
context_link 'location.add_location',
:link_path=>"new_panel_location_back_end_location_path" ,
:priority=>1,
- :active_for_action=>{:localtions=>:new},
+ :active_for_action=>{:locations=>:new},
:available_for => [:manager]
context_link 'location.categories',
- :link_path=>"admin_module_app_categories_path(get_module_app)" ,
+ :link_path=>"panel_location_back_end_location_categories_path" ,
:priority=>1,
- :active_for_action=>{:localtion_categories=>:index},
+ :active_for_category => 'Location',
:available_for => [:manager]
end