From c47bd13fd7a4617bf530bebf2633712e51342ccd Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 20 Jul 2017 15:39:54 +0200 Subject: [PATCH 1/4] fix message and tooltip --- .../map/templates/legend/legend.handlebars | 2 +- app/assets/javascripts/map/views/LegendView.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/map/templates/legend/legend.handlebars b/app/assets/javascripts/map/templates/legend/legend.handlebars index b0c4db5acb..5fb7d2137f 100644 --- a/app/assets/javascripts/map/templates/legend/legend.handlebars +++ b/app/assets/javascripts/map/templates/legend/legend.handlebars @@ -111,7 +111,7 @@ - {{this.title}} + {{this.title}} {{#if this.allowSubscription}} {{/if}} diff --git a/app/assets/javascripts/map/views/LegendView.js b/app/assets/javascripts/map/views/LegendView.js index 5c9b01c1f2..bc580c6f8e 100644 --- a/app/assets/javascripts/map/views/LegendView.js +++ b/app/assets/javascripts/map/views/LegendView.js @@ -264,6 +264,9 @@ define([ _.each(layers, function(layer) { layer.source = (layer.slug === 'nothing') ? null : layer.source || layer.slug; if (this.detailsTemplates[layer.slug]) { + if (layer.title === 'Tree plantations by type' || layer.title === 'Tree plantations by species') { + layer.title = 'Tree plantations' + } layer.detailsTpl = this.detailsTemplates[layer.slug]({ threshold: options.threshold || 30, hresolution: options.hresolution, @@ -290,6 +293,11 @@ define([ categoriesGlobal = this.statusCategories(this.getLayersByCategory(layersGlobal)); categoriesIso = this.statusCategories(this.getLayersByCategory(layersIso)); + // var title = layer.title; + // if (layer.title === 'Tree plantations by type' || layer.title === 'Tree plantations by species') { + // title = 'Tree plantations' + // } + // Render this.render(this.template({ categories: (_.isEmpty(categoriesGlobal)) ? false : categoriesGlobal, @@ -322,7 +330,7 @@ define([ return _.groupBy(filteredLayers, function(layer) { layer.allowSubscription = layer && subscriptionsAllowed.indexOf(layer.slug) > -1; - // Hack to keep the forest_clearing slug in layers which have to be analyzed but not grouped by the said slug in the legend + // Hack to keep the forest_clearing slug in layers which have to be analyzed but not grouped by the said slug in the legend if (layer.category_slug === 'forest_clearing' && !layer.is_forest_clearing) return 'forest_cover'; return layer.category_slug; }) @@ -466,6 +474,10 @@ define([ var top = position.top - 10; var left = position.left - 92; var text = $(e.target).attr('data-description'); + var dataSource = $(e.target).attr('data-source'); + if (dataSource === 'gfw_plantations') { + left = left + 16; + } if (text != '') { $('body').append('
'+text+'

Click to see more

'); } From cc757ea9378a7988f32eb41829d769a9ce7fb91b Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 20 Jul 2017 15:48:00 +0200 Subject: [PATCH 2/4] fix message and tooltip --- app/assets/javascripts/map/views/LegendView.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/assets/javascripts/map/views/LegendView.js b/app/assets/javascripts/map/views/LegendView.js index bc580c6f8e..185cbe0b40 100644 --- a/app/assets/javascripts/map/views/LegendView.js +++ b/app/assets/javascripts/map/views/LegendView.js @@ -472,12 +472,9 @@ define([ showTooltip: function(e) { var position = $(e.target).offset(); var top = position.top - 10; - var left = position.left - 92; + var left = position.left - 76; var text = $(e.target).attr('data-description'); var dataSource = $(e.target).attr('data-source'); - if (dataSource === 'gfw_plantations') { - left = left + 16; - } if (text != '') { $('body').append('
'+text+'

Click to see more

'); } From c626728384a1117d63fdb6de86147eedead6528c Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 20 Jul 2017 15:52:09 +0200 Subject: [PATCH 3/4] fix tooltip for all layers --- app/assets/javascripts/map/views/LegendView.js | 2 +- app/assets/stylesheets/layouts/_embed-map.scss | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/map/views/LegendView.js b/app/assets/javascripts/map/views/LegendView.js index 185cbe0b40..960be063e8 100644 --- a/app/assets/javascripts/map/views/LegendView.js +++ b/app/assets/javascripts/map/views/LegendView.js @@ -472,7 +472,7 @@ define([ showTooltip: function(e) { var position = $(e.target).offset(); var top = position.top - 10; - var left = position.left - 76; + var left = position.left - 92; var text = $(e.target).attr('data-description'); var dataSource = $(e.target).attr('data-source'); if (text != '') { diff --git a/app/assets/stylesheets/layouts/_embed-map.scss b/app/assets/stylesheets/layouts/_embed-map.scss index cf39d7dc7c..bc6610623a 100644 --- a/app/assets/stylesheets/layouts/_embed-map.scss +++ b/app/assets/stylesheets/layouts/_embed-map.scss @@ -284,6 +284,8 @@ position: absolute; z-index: 1000; max-width: 200px; + min-width: 200px; + width: 200px; padding: 8px; background-color: #fffee2; box-shadow: 0 1px 3px 0 rgba(85, 85, 85, .25); From 6a477f1dbb613cfaf42ca305d58efb454bc33742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Garc=C3=ADa?= Date: Thu, 20 Jul 2017 16:43:58 +0200 Subject: [PATCH 4/4] Remove commented code --- app/assets/javascripts/map/views/LegendView.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/assets/javascripts/map/views/LegendView.js b/app/assets/javascripts/map/views/LegendView.js index 960be063e8..1066fda6c9 100644 --- a/app/assets/javascripts/map/views/LegendView.js +++ b/app/assets/javascripts/map/views/LegendView.js @@ -293,11 +293,6 @@ define([ categoriesGlobal = this.statusCategories(this.getLayersByCategory(layersGlobal)); categoriesIso = this.statusCategories(this.getLayersByCategory(layersIso)); - // var title = layer.title; - // if (layer.title === 'Tree plantations by type' || layer.title === 'Tree plantations by species') { - // title = 'Tree plantations' - // } - // Render this.render(this.template({ categories: (_.isEmpty(categoriesGlobal)) ? false : categoriesGlobal,