diff options
| author | Marc Florisson | 2012-08-21 11:52:36 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-08-21 11:52:36 +0200 |
| commit | 2d756b1c5880986928ae1bc5912ee9038cf9c38f (patch) | |
| tree | ffe014ba1b676af665df9c1626fcd7f93fbbac2d | |
| parent | d53d54ac6cbe9c82b2a14a19b4f5628ba9118ec4 (diff) | |
| download | chouette-core-2d756b1c5880986928ae1bc5912ee9038cf9c38f.tar.bz2 | |
hover on stop points. Refs #61
| -rw-r--r-- | app/assets/javascripts/route.js.coffee | 19 | ||||
| -rw-r--r-- | app/assets/stylesheets/routes.css.scss | 4 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 1 | ||||
| -rw-r--r-- | app/maps/application_map.rb | 10 | ||||
| -rw-r--r-- | app/maps/route_map.rb | 9 | ||||
| -rw-r--r-- | app/maps/style_map/route_style_map.rb | 9 | ||||
| -rw-r--r-- | app/views/routes/_stop_points_detail.html.erb | 10 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 4 | ||||
| -rw-r--r-- | app/views/routes/show.js.erb | 4 | ||||
| -rw-r--r-- | app/views/routes/show.kml.erb | 1 | ||||
| -rw-r--r-- | config/locales/will_paginate.yml | 2 |
11 files changed, 63 insertions, 10 deletions
diff --git a/app/assets/javascripts/route.js.coffee b/app/assets/javascripts/route.js.coffee index a3dd304d3..274e87f77 100644 --- a/app/assets/javascripts/route.js.coffee +++ b/app/assets/javascripts/route.js.coffee @@ -8,8 +8,25 @@ jQuery -> switch_stop_points = (event) -> event.preventDefault() - $('.routes.show .stop_points.content').toggle('slow') + $('.routes.show .stop_points_detail').toggle('slow') $('a.stop_points .switcher').toggle() $('.routes.show a.stop_points').click(switch_stop_points) + select_stop_on_map = (event) -> + if (event.type == 'mouseenter') + if event.target.id.match(/^stop_point_(\w+)$/) + stopAreaId = $("#"+event.target.id+" a").attr('href').match(/\d+$/)[0] + placeMark = selectFeature.layer.getFeatureByFid( stopAreaId) + selectFeature.unselectAll() + selectFeature.select( placeMark) + else + selectFeature.unselectAll() + + $('.routes.show div.stop_points .stop_point').live("hover", select_stop_on_map) + + make_ajax_pagination = () -> + $.get(this.href, null, null, 'script') + false + + $('.routes.show .stop_points_detail .pagination a').live("click", make_ajax_pagination) diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss index f2e3dab4a..72670197b 100644 --- a/app/assets/stylesheets/routes.css.scss +++ b/app/assets/stylesheets/routes.css.scss @@ -57,6 +57,10 @@ .summary p label { font-weight: bold; } + + .stop_points_detail div.page_info { + margin-top: 0px; + } .stop_point:after { @include after_div_for_object; diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 91da5519c..fdad19dd9 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -3,6 +3,7 @@ class RoutesController < ChouetteController respond_to :html, :xml, :json respond_to :kml, :only => :show + respond_to :js, :only => :show belongs_to :referential do belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index f1b1d103d..d87915bc5 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -86,8 +86,10 @@ class ApplicationMap :renderIntent => "temporary", :eventListeners => { :featurehighlighted => JsExpr.new("function(e) { - feature = e.feature ; - popup = new OpenLayers.Popup.AnchoredBubble('chicken', + var feature = e.feature ; + if (feature.attributes.inactive != undefined) + return; + var popup = new OpenLayers.Popup.AnchoredBubble('chicken', new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y), null, \"<div class='popup_hover'><b>\" + feature.attributes.name +\"</b></div> \", null, false, null); @@ -98,7 +100,9 @@ class ApplicationMap map.addPopup(popup); }"), :featureunhighlighted => JsExpr.new("function(e) { - feature = e.feature; + var feature = e.feature; + if (feature.attributes.inactive != undefined) + return; map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; diff --git a/app/maps/route_map.rb b/app/maps/route_map.rb index daa3de23f..70e31e2e2 100644 --- a/app/maps/route_map.rb +++ b/app/maps/route_map.rb @@ -16,8 +16,15 @@ class RouteMap < ApplicationMap page << map.add_layer(google_satellite) #page << map.add_layer(kml_layer(line, :styleMap => StyleMap::LineStyleMap.new( :style => line_style).style_map)) - page << map.add_layer(kml_layer([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new.style_map)) + layer = kml_layer([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new.style_map) + page.assign "routeLayer", layer + selectFeature = OpenLayers::Control::SelectFeature.new( :routeLayer) + + page << map.add_layer( :routeLayer) + page << map.add_control( hover_control_display_name(:routeLayer) ) page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds + + page.assign "selectFeature", selectFeature end end diff --git a/app/maps/style_map/route_style_map.rb b/app/maps/style_map/route_style_map.rb index 136cecba5..81ed483fb 100644 --- a/app/maps/style_map/route_style_map.rb +++ b/app/maps/style_map/route_style_map.rb @@ -5,6 +5,9 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap @style = options[:style].present? ? default_style.merge(options[:style]) : default_style end + def select_style + default_style.merge :externalGraphic => "/assets/icons/stop_area_hover.png" + end def default_style { :label => "${label}", @@ -19,7 +22,7 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap :strokeWidth => 3, :strokeLineCap => "round", :strokeDashstyle => "solid", - :externalGraphic => "/assets/map/${positionType}.png", + :externalGraphic => "/assets/icons/${positionType}.png", :graphicWidth => 12, :graphicHeight => 12, :graphicOpacity => 1, @@ -32,12 +35,12 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap def context context = { :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", - :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'departure'; } else if (feature.attributes.arrival != undefined) { return 'arrival'; } else { return 'interstop'; }} " + :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'stop_area_green'; } else if (feature.attributes.arrival != undefined) { return 'stop_area_red'; } else { return 'stop_area_black'; }} " } end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context})) + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), :select => OpenLayers::Style.new(style.merge( select_style), { :context => context})) end end diff --git a/app/views/routes/_stop_points_detail.html.erb b/app/views/routes/_stop_points_detail.html.erb new file mode 100644 index 000000000..6c9e4afae --- /dev/null +++ b/app/views/routes/_stop_points_detail.html.erb @@ -0,0 +1,10 @@ + <div class="page_info"> + <span class="search"> <%= t("will_paginate.page_entries_info.list") %></span> <%= page_entries_info @stop_points %> + </div> + <div class="stop_points paginated_content"> + <%= render :partial => "stop_points/stop_point", :collection => @stop_points %> + </div> + <div class="pagination"> + <%= will_paginate @stop_points, :container => false %> + </div> + diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index 9980543c7..9fa1aa184 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -71,8 +71,8 @@ <span class="switcher" style="display: none;">-</span> </a> </h3> -<div class="stop_points content" style="display: none;"> - <%= render :partial => "stop_points/stop_point", :collection => @stop_points %> +<div class="stop_points_detail" style="display: none;"> + <%= render :partial => "stop_points_detail" %> </div> <h3 class="route_journey_patterns"><%= t('.journey_patterns') %> diff --git a/app/views/routes/show.js.erb b/app/views/routes/show.js.erb new file mode 100644 index 000000000..aedb0fb9e --- /dev/null +++ b/app/views/routes/show.js.erb @@ -0,0 +1,4 @@ +$(function (){ + $(".stop_points_detail").html("<%= escape_javascript(render(:partial => "stop_points_detail")) %>"); +}); + diff --git a/app/views/routes/show.kml.erb b/app/views/routes/show.kml.erb index 4e90fa963..91ffb9918 100644 --- a/app/views/routes/show.kml.erb +++ b/app/views/routes/show.kml.erb @@ -3,6 +3,7 @@ <Document> <Placemark id="route_<%= @route.id %>" > <name><%= @route.name %></name> + <inactive>true</inactive> <%= @route.geometry.kml_representation.html_safe %> </Placemark> <% @route.stop_areas.where("latitude is not null and longitude is not null").each_with_index do |stop_area, index| %> diff --git a/config/locales/will_paginate.yml b/config/locales/will_paginate.yml index a5f2ebf22..a44d740c0 100644 --- a/config/locales/will_paginate.yml +++ b/config/locales/will_paginate.yml @@ -6,6 +6,7 @@ en: page_entries_info: search: Search + list: Paginated list single_page: zero: "No item found" one: "1 %{model} shown" @@ -26,6 +27,7 @@ fr: page_entries_info: search: Recherche + list: Liste paginée single_page: zero: "Aucun élément trouvé" one: "1 %{model} affiché(e)" |
