summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarton Kiss <marton.kiss@gmail.com>2017-08-01 13:22:41 +0200
committerMarton Kiss <marton.kiss@gmail.com>2017-08-01 13:22:41 +0200
commit7f67c8b9c15f90d3eca4a18c490592502f97e706 (patch)
tree4c988d373ddb946ca3269603721094c816980e59
parent49ccaea54fe53822d061deb6a6df9cab9b7a7466 (diff)
Add absolute urls to embedded map0.48
The embedded map /map now provides absolute urls for group pages instead of relative ones. The map marker's title contains plain text, and the click event on marker icon redirects to group page directly instead of showing a balloon popup. Change-Id: Ib4c1e35b20bc287b275b072e65369de18e574b7b
Notes
Notes (review): Code-Review+2: Marton Kiss <marton.kiss@gmail.com> Workflow+1: Marton Kiss <marton.kiss@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 01 Aug 2017 11:49:11 +0000 Reviewed-on: https://review.openstack.org/489568 Project: openstack-infra/groups Branch: refs/heads/master
-rw-r--r--modules/groups/groups_directory/groups_directory.module9
-rw-r--r--modules/groups/groups_directory/groups_directory.views_default.inc12
-rw-r--r--modules/groups/groups_directory/js/groups_directory_map.js28
3 files changed, 48 insertions, 1 deletions
diff --git a/modules/groups/groups_directory/groups_directory.module b/modules/groups/groups_directory/groups_directory.module
index 7140e7a..8c655e2 100644
--- a/modules/groups/groups_directory/groups_directory.module
+++ b/modules/groups/groups_directory/groups_directory.module
@@ -184,4 +184,13 @@ function groups_directory_filter_form_submit($form, &$form_state) {
184function groups_directory_filter_form_clear_filters($form, &$form_state) { 184function groups_directory_filter_form_clear_filters($form, &$form_state) {
185 $path=$GLOBALS['base_url'].strtok($_SERVER["REQUEST_URI"],'?'); 185 $path=$GLOBALS['base_url'].strtok($_SERVER["REQUEST_URI"],'?');
186 drupal_goto($path); 186 drupal_goto($path);
187}
188
189/**
190 * Implements hook_leaflet_map_prebuild_alter()
191 *
192 * Add custom map js to override marker hover and popup balloon behavior.
193 */
194function groups_directory_leaflet_map_prebuild_alter(&$vars) {
195 drupal_add_js(drupal_get_path('module', 'groups_directory') . '/js/groups_directory_map.js');
187} \ No newline at end of file 196} \ No newline at end of file
diff --git a/modules/groups/groups_directory/groups_directory.views_default.inc b/modules/groups/groups_directory/groups_directory.views_default.inc
index b0fb3aa..4c7432d 100644
--- a/modules/groups/groups_directory/groups_directory.views_default.inc
+++ b/modules/groups/groups_directory/groups_directory.views_default.inc
@@ -105,7 +105,7 @@ function groups_directory_views_default_views() {
105 $handler->display->display_options['style_plugin'] = 'leaflet'; 105 $handler->display->display_options['style_plugin'] = 'leaflet';
106 $handler->display->display_options['style_options']['data_source'] = 'field_geofield'; 106 $handler->display->display_options['style_options']['data_source'] = 'field_geofield';
107 $handler->display->display_options['style_options']['name_field'] = 'title'; 107 $handler->display->display_options['style_options']['name_field'] = 'title';
108 $handler->display->display_options['style_options']['description_field'] = '#rendered_entity'; 108 $handler->display->display_options['style_options']['description_field'] = 'path';
109 $handler->display->display_options['style_options']['view_mode'] = 'teaser'; 109 $handler->display->display_options['style_options']['view_mode'] = 'teaser';
110 $handler->display->display_options['style_options']['map'] = 'leaflet-mapbox'; 110 $handler->display->display_options['style_options']['map'] = 'leaflet-mapbox';
111 /* Field: Content: Title */ 111 /* Field: Content: Title */
@@ -115,6 +115,7 @@ function groups_directory_views_default_views() {
115 $handler->display->display_options['fields']['title']['label'] = ''; 115 $handler->display->display_options['fields']['title']['label'] = '';
116 $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; 116 $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
117 $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; 117 $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
118 $handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
118 /* Field: Content: geofield */ 119 /* Field: Content: geofield */
119 $handler->display->display_options['fields']['field_geofield']['id'] = 'field_geofield'; 120 $handler->display->display_options['fields']['field_geofield']['id'] = 'field_geofield';
120 $handler->display->display_options['fields']['field_geofield']['table'] = 'field_data_field_geofield'; 121 $handler->display->display_options['fields']['field_geofield']['table'] = 'field_data_field_geofield';
@@ -125,6 +126,15 @@ function groups_directory_views_default_views() {
125 $handler->display->display_options['fields']['field_geofield']['settings'] = array( 126 $handler->display->display_options['fields']['field_geofield']['settings'] = array(
126 'data' => 'full', 127 'data' => 'full',
127 ); 128 );
129 /* Field: Content: Path */
130 $handler->display->display_options['fields']['path']['id'] = 'path';
131 $handler->display->display_options['fields']['path']['table'] = 'node';
132 $handler->display->display_options['fields']['path']['field'] = 'path';
133 $handler->display->display_options['fields']['path']['label'] = '';
134 $handler->display->display_options['fields']['path']['alter']['alter_text'] = TRUE;
135 $handler->display->display_options['fields']['path']['alter']['text'] = '[path]';
136 $handler->display->display_options['fields']['path']['element_label_colon'] = FALSE;
137 $handler->display->display_options['fields']['path']['absolute'] = TRUE;
128 /* Filter criterion: Content: Published */ 138 /* Filter criterion: Content: Published */
129 $handler->display->display_options['filters']['status']['id'] = 'status'; 139 $handler->display->display_options['filters']['status']['id'] = 'status';
130 $handler->display->display_options['filters']['status']['table'] = 'node'; 140 $handler->display->display_options['filters']['status']['table'] = 'node';
diff --git a/modules/groups/groups_directory/js/groups_directory_map.js b/modules/groups/groups_directory/js/groups_directory_map.js
new file mode 100644
index 0000000..256d8dc
--- /dev/null
+++ b/modules/groups/groups_directory/js/groups_directory_map.js
@@ -0,0 +1,28 @@
1(function ($) {
2
3 /**
4 * For leafleat API docs, see:
5 * http://leafletjs.com/reference.html
6 **/
7
8 var cnt = 0;
9 // Attach to Leaflet object via its API
10 $(document).bind('leaflet.feature', function(e, lFeature, feature) {
11 // Remove default click event (infoWindow Popup) and add our own
12 if (feature.label) {
13 var contents = feature.contents;
14 lFeature.on('click', function() {
15 var img = $(lFeature._icon);
16 img.addClass('active').siblings().removeClass('active');
17 redirectMarkerURL(feature);
18 });
19 lFeature.unbindPopup();
20 cnt++;
21 }
22 });
23
24 function redirectMarkerURL(marker) {
25 window.top.location.href = marker.popup;
26 }
27
28})(jQuery);