From 2d62beefbdec76cd4b33bda9682d33b39b59a97e Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 17:44:15 +0100 Subject: [PATCH 01/19] Attempt to apply f72a088 without syntax improvements --- .../irv/static/irv/js/irv_viewer.js | 112 +++++++++--------- .../irv/static/irv/js/irv_viewer_PCP_theme.js | 3 +- .../irv/static/irv/js/irv_viewer_d3_tree.js | 3 +- .../irv/templates/irv/irv_viewer.html | 43 ++++--- 4 files changed, 83 insertions(+), 78 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index b1c1c0797..1d2674373 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -53,6 +53,24 @@ $(document).ready(function() { $('.alert-unscaled-data').hide(); }); +function setWidgetsToDefault(){ + $('#pdSelection').empty(); + // set tabs back default + $("#iri-chart-widget").tabs("enable", 2); + $("#cat-chart-widget").tabs("enable", 3); + + $('#project-def-widget').tabs('option', 'active', 0); + $('#projectDef-spinner').text('Loading ...'); + $('#projectDef-spinner').append(''); + $('#projectDef-spinner').show(); + $('#iri-spinner').show(); + $('#regionSelectionDialog').empty(); + $('#projectDef-tree').empty(); + $('#iri-chart').empty(); + $('#cat-chart').empty(); + $('#primary-chart').empty(); +} + function scaleTheData() { // Create a list of primary indicators that need to be scaled // We are not scaling any of the IR indicators @@ -765,7 +783,7 @@ function processIndicators(layerAttributes, projectDef) { iriPcpData.push(SVI); } else { // Disable the primary tab. - $("#themeTabs").tabs("disable", 3); + $("#cat-chart-widget").tabs("disable", 3); } if (riskIndicators !== undefined) { @@ -793,9 +811,9 @@ function scale(IndicatorObj) { if (tempMax == tempMin) { scaledValues = [1]; // Disable the chart tabs - $("#themeTabs").tabs("disable", 1); - $("#themeTabs").tabs("disable", 2); - $("#themeTabs").tabs("disable", 3); + $("#project-def-widget").tabs("disable", 1); + $("#iri-chart-widget").tabs("disable", 2); + $("#cat-chart-widget").tabs("disable", 3); } else { scaledValues.push( (ValueArray[j] - tempMin) / (tempMax - tempMin) ); } @@ -1258,6 +1276,7 @@ function thematicMapCreation() { } function whenProjDefSelected() { + $('#pdSelection').prop("disabled", true); $('#projectDef-spinner').show(); var pdSelection = $('#pdSelection').val(); for (var i = 0; i < tempProjectDef.length; i++) { @@ -1270,6 +1289,7 @@ function whenProjDefSelected() { processIndicators(layerAttributes, sessionProjectDef); } } + $('#pdSelection').prop("disabled", false); } function getGeoServerLayers() { @@ -1401,21 +1421,33 @@ var startApp = function() { webGl = webglDetect(); - - // Theme tabs behavior - $('#themeTabs').resizable({ - minHeight: 220, - minWidth: 220 - }); - - $('#themeTabs').tabs({ - collapsible: false, - selected: -1, - active: false, - }); - - $( "#themeTabs" ).draggable({ - cancel: "#project-def" + $.each(['#project-def-widget', + '#iri-chart-widget', + '#cat-chart-widget', + '#primary-tab-widget'], function(i, widget) { + // Theme tabs behavior + $(widget).resizable({ + minHeight: 220, + minWidth: 220 + }); + + $(widget).tabs({ + collapsible: false, + selected: -1, + active: false, + }); + + $(widget).draggable({ + cancel: "#project-def" + }); + $(widget).css({ + 'width': '700px', + 'height': '600px', + 'overflow': 'auto', + 'position': 'fixed', + 'left': '10px', + 'top': '110px' + }); }); $('#cover').remove(); @@ -1496,21 +1528,7 @@ var startApp = function() { }); $('#loadProjectBtn').click(function() { - $('#pdSelection').empty(); - // set tabs back default - $("#themeTabs").tabs("enable", 2); - $("#themeTabs").tabs("enable", 3); - - $('#themeTabs').tabs('option', 'active', 0); - $('#projectDef-spinner').text('Loading ...'); - $('#projectDef-spinner').append(''); - $('#projectDef-spinner').show(); - $('#iri-spinner').show(); - $('#regionSelectionDialog').empty(); - $('#projectDef-tree').empty(); - $('#iri-chart').empty(); - $('#cat-chart').empty(); - $('#primary-chart').empty(); + setWidgetsToDefault(); // FIXME This will not work if the title contains '(' or ')' // Get the selected layer @@ -1556,15 +1574,6 @@ var startApp = function() { 'z-index': 6 }); - $('#themeTabs').css({ - 'width': '700px', - 'height': '600px', - 'overflow': 'hidden', - 'position': 'fixed', - 'left': '10px', - 'top': '110px' - }); - $('#loadProjectdialogBtn').css({ 'position': 'fixed', 'left': '50px' @@ -1605,23 +1614,8 @@ var startApp = function() { }; function loadProject() { - $('#pdSelection').empty(); - // set tabs to back default - $("#themeTabs").tabs("enable", 2); - $("#themeTabs").tabs("enable", 3); - - $('#themeTabs').tabs('option', 'active', 0); + setWidgetsToDefault(); $('#thematic-map-selection').show(); - $('#projectDef-spinner').text('Loading ...'); - $('#projectDef-spinner').append(''); - $('#projectDef-spinner').show(); - $('#iri-spinner').show(); - $('#regionSelectionDialog').empty(); - $('#projectDef-tree').empty(); - $('#iri-chart').empty(); - $('#cat-chart').empty(); - $('#primary-chart').empty(); - attributeInfoRequest(selectedLayer); } diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js index 9c08a5cb8..3b1e94afe 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js @@ -39,7 +39,8 @@ function Theme_PCP_Chart(themeData) { if (themeCount <= 2) { // Disable the theme tab. - $("#themeTabs").tabs("disable", 2); + // FIXME: disable the whole widget instead + $("#iri-chart-widget").tabs("disable", 2); // Stop the function from continuing. return; } diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js index 5a8524002..4007a1c55 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js @@ -45,14 +45,13 @@ //////////////////////////////////////////// function loadPD(selectedPDef) { - // Rebuild the d3 tree, based on the given project definition // default tab window size var winH = 600; var winW = 700; // detect tab window resize - $('#themeTabs').resize(function(event) { + $('#project-def-widget').resize(function(event) { winH = event.clientY; winW = event.clientX; }); diff --git a/openquakeplatform/openquakeplatform/irv/templates/irv/irv_viewer.html b/openquakeplatform/openquakeplatform/irv/templates/irv/irv_viewer.html index 333c61cf6..3c1d40760 100644 --- a/openquakeplatform/openquakeplatform/irv/templates/irv/irv_viewer.html +++ b/openquakeplatform/openquakeplatform/irv/templates/irv/irv_viewer.html @@ -69,28 +69,40 @@ - -
+
-
- -
-
-
-
-
+ +
+
+
+
+
+
+ +
+
Loading ...
+
+ +
+
+
+ +
+
@@ -104,9 +116,8 @@

- -
+
{% endblock middle %} From 470459c3590420aff2ff70f98155a8a5aedf5157 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 17:48:56 +0100 Subject: [PATCH 02/19] Attempt to cherry-pick hunks from eaf3831 --- .../irv/static/irv/js/irv_viewer.js | 60 ++++++++++++++++++- .../irv/static/irv/js/irv_viewer_d3_tree.js | 1 + 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 1d2674373..3a4b772cd 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -56,6 +56,7 @@ $(document).ready(function() { function setWidgetsToDefault(){ $('#pdSelection').empty(); // set tabs back default + // FIXME: all widgets will have only 1 tab; handle things accordingly $("#iri-chart-widget").tabs("enable", 2); $("#cat-chart-widget").tabs("enable", 3); @@ -1276,7 +1277,6 @@ function thematicMapCreation() { } function whenProjDefSelected() { - $('#pdSelection').prop("disabled", true); $('#projectDef-spinner').show(); var pdSelection = $('#pdSelection').val(); for (var i = 0; i < tempProjectDef.length; i++) { @@ -1289,7 +1289,6 @@ function whenProjDefSelected() { processIndicators(layerAttributes, sessionProjectDef); } } - $('#pdSelection').prop("disabled", false); } function getGeoServerLayers() { @@ -1438,9 +1437,12 @@ var startApp = function() { }); $(widget).draggable({ + stack: "div", // put on top of the others when dragging + distance: 0, // do it even if it's not actually moved cancel: "#project-def" }); $(widget).css({ + 'display': 'none', 'width': '700px', 'height': '600px', 'overflow': 'auto', @@ -1475,6 +1477,19 @@ var startApp = function() { $('#map-tools').append( '' ); + $('#map-tools').append( + '' + ); + $('#map-tools').append( + '' + ); + $('#map-tools').append( + '' + ); + $('#map-tools').append( + '' + ); + if (webGl === false) { $('#map-tools').append( @@ -1515,6 +1530,36 @@ var startApp = function() { $('#loadProjectDialog').dialog('open'); }); + function toggleWidget(widget, btn) { + // toggle widget and change text on the corresponding button + var widgetIsVisible = widget.is(':visible'); + var btnText = btn.html(); + if (btnText.indexOf('Hide ') >= 0) { // Change Hide -> Show + btnText = 'Show ' + btnText.slice(5); + } else { // Change Show -> Hide + btnText = 'Hide ' + btnText.slice(5); + } + if (widgetIsVisible) { + widget.hide(); + } else { + widget.show(); + } + btn.html(btnText); + } + + $('#toggleProjDefWidgetBtn').click(function() { + toggleWidget($('#project-def-widget'), $('#toggleProjDefWidgetBtn')); + }); + $('#toggleIriChartWidgetBtn').click(function() { + toggleWidget($('#iri-chart-widget'), $('#toggleIriChartWidgetBtn')); + }); + $('#toggleSviThemeWidgetBtn').click(function() { + toggleWidget($('#cat-chart-widget'), $('#toggleSviThemeWidgetBtn')); + }); + $('#toggleCompIndWidgetBtn').click(function() { + toggleWidget($('#primary-tab-widget'), $('#toggleCompIndWidgetBtn')); + }); + // TODO check these are all needed $('#region-selection-list').hide(); $('#svir-project-list').hide(); @@ -1579,6 +1624,17 @@ var startApp = function() { 'left': '50px' }); + $.each(['#toggleProjDefWidgetBtn', + '#toggleIriChartWidgetBtn', + '#toggleSviThemeWidgetBtn', + '#toggleCompIndWidgetBtn'], function(i, widget) { + $(widget).css({ + 'position': 'relative', + 'float': 'right', + 'margin-left': '2px' + }); + }); + $('#base-map-menu').css({ 'position': 'fixed', 'left': '390px' diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js index 4007a1c55..230823d62 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_d3_tree.js @@ -45,6 +45,7 @@ //////////////////////////////////////////// function loadPD(selectedPDef) { + // Rebuild the d3 tree, based on the given project definition // default tab window size var winH = 600; From 0b10677b6a5e8e162c4c31021edb8af56263d28b Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 13:50:38 +0100 Subject: [PATCH 03/19] Remove duplicated code --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 3a4b772cd..855b6d3f7 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -20,6 +20,10 @@ $(document).ready(function() { $('.alert-unscaled-data').hide(); $('#absoluteSpinner').hide(); $('#loadProjectBtn').show(); + $('#toggleCompIndWidgetBtn').show(); + $('#toggleSviThemeWidgetBtn').show(); + $('#toggleIriChartWidgetBtn').show(); + $('#toggleProjDefWidgetBtn').show(); }); var layerAttributes; @@ -48,11 +52,6 @@ var baseMapUrl = new L.TileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x var app = new OQLeaflet.OQLeafletApp(baseMapUrl); var indicatorChildrenKey = []; -$(document).ready(function() { - $('#cover').remove(); - $('.alert-unscaled-data').hide(); -}); - function setWidgetsToDefault(){ $('#pdSelection').empty(); // set tabs back default From a93cfeb8e020b94cae09248226b6cd5f81727cf1 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 13:51:22 +0100 Subject: [PATCH 04/19] Fix median text in primary PCP chart --- .../irv/static/irv/js/irv_viewer_PCP_primary.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js index 27cd46ce2..f357eab68 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js @@ -287,6 +287,12 @@ function Primary_PCP_Chart(projectDef, layerAttributes, selectedRegion) { sumMeanArray.push(sumMean); + var textTop = svg.append('text') + .attr("class", "text90") + .style('font-size','30px') + .style('font-style', 'bold') + .text(''); + // Plot the median line meanPath = svg.append("g") .attr("class", "PI-meanPath") @@ -295,7 +301,10 @@ function Primary_PCP_Chart(projectDef, layerAttributes, selectedRegion) { .enter().append("path") .attr("d", path) .attr('id', function(d) { return d.region; }) - .on('mouseover', function() { + .on('mouseover', function(d) { + textTop.attr('x', d.x); + textTop.attr('y', d.y); + textTop.attr('dy', '.35em'); textTop.text('Median'); }).on('mouseout', function() { textTop.text(''); From c05abcb30f7439b4985a8c2fd0e6e593599e14e2 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 14:27:01 +0100 Subject: [PATCH 05/19] Fix median text in IRI PCP chart and fix indentation and editor warnings --- .../irv/static/irv/js/irv_viewer_PCP_IRI.js | 81 ++++++++++--------- .../irv/static/irv/js/irv_viewer_PCP_theme.js | 6 +- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js index 8b764189f..3eaed12c1 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js @@ -210,42 +210,51 @@ function IRI_PCP_Chart(iriPcpData) { //// Median line //// ////////////////////// - // Build skeleton array - for (var t in iriPcpData[0]) { - sum[t] = 0; - } - - // Sum all the paths - // Access the objects contained in the theme data array - for (var region_idx = 0; region_idx < iriPcpData.length; region_idx++) { - // iterate over the each - for (var elementName in iriPcpData[region_idx]) { - // This will sum all the values inside each theme object - sum[elementName] += iriPcpData[region_idx][elementName]; - } - } - - // Get the mean - for (var f in sum) { - var thisSum = sum[f]; - sumMean[f] = (thisSum / iriPcpData.length); - } - - sumMeanArray.push(sumMean); - - // Plot the median line - meanPath = svg.append("g") - .attr("class", "PI-meanPath") - .selectAll("path") - .data(sumMeanArray) - .enter().append("path") - .attr("d", path) - .attr('id', function(d) { return d.region; }) - .on('mouseover', function() { - textTop.text('Median'); - }).on('mouseout', function() { - textTop.text(''); - }); + // Build skeleton array + for (var t in iriPcpData[0]) { + sum[t] = 0; + } + + // Sum all the paths + // Access the objects contained in the theme data array + for (var region_idx = 0; region_idx < iriPcpData.length; region_idx++) { + // iterate over the each + for (var elementName in iriPcpData[region_idx]) { + // This will sum all the values inside each theme object + sum[elementName] += iriPcpData[region_idx][elementName]; + } + } + + // Get the mean + for (var f in sum) { + var thisSum = sum[f]; + sumMean[f] = (thisSum / iriPcpData.length); + } + + sumMeanArray.push(sumMean); + + var textTop = svg.append('text') + .attr("class", "text90") + .style('font-size','30px') + .style('font-style', 'bold') + .text(''); + + // Plot the median line + meanPath = svg.append("g") + .attr("class", "PI-meanPath") + .selectAll("path") + .data(sumMeanArray) + .enter().append("path") + .attr("d", path) + .attr('id', function(d) { return d.region; }) + .on('mouseover', function(d) { + textTop.attr('x', d.x); + textTop.attr('y', d.y); + textTop.attr('dy', '.35em'); + textTop.text('Median'); + }).on('mouseout', function() { + textTop.text(''); + }); // Handles a brush event, toggling the display of foreground lines. function brush() { diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js index 3b1e94afe..f346b7ce7 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js @@ -65,9 +65,9 @@ function Theme_PCP_Chart(themeData) { } } - for (var i = 0; i < eachElementInThemeData.length; i++) { - if (!isNaN(parseFloat(eachElementInThemeData[i])) && isFinite(eachElementInThemeData[i])) { - eachValueInThemeData.push(eachElementInThemeData[i]); + for (var j = 0; j < eachElementInThemeData.length; j++) { + if (!isNaN(parseFloat(eachElementInThemeData[j])) && isFinite(eachElementInThemeData[j])) { + eachValueInThemeData.push(eachElementInThemeData[j]); } } From 8552079a2dc8c9631d2034eea6d4c974a51bd615 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 14:46:46 +0100 Subject: [PATCH 06/19] When loading a project, make the proj def widget visible --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 855b6d3f7..31fbd34fe 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1672,6 +1672,9 @@ function loadProject() { setWidgetsToDefault(); $('#thematic-map-selection').show(); attributeInfoRequest(selectedLayer); + if (!$('#project-def-widget').is(':visible')) { + $('#toggleProjDefWidgetBtn').click(); + } } function attributeInfoRequest(selectedLayer) { From 50ea2f65056e186702141d069977a4030a9c7cae Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Wed, 10 Feb 2016 18:11:51 +0100 Subject: [PATCH 07/19] Enable project-related buttons only after a project is selected --- .../irv/static/irv/js/irv_viewer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 31fbd34fe..9053f6848 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -20,10 +20,6 @@ $(document).ready(function() { $('.alert-unscaled-data').hide(); $('#absoluteSpinner').hide(); $('#loadProjectBtn').show(); - $('#toggleCompIndWidgetBtn').show(); - $('#toggleSviThemeWidgetBtn').show(); - $('#toggleIriChartWidgetBtn').show(); - $('#toggleProjDefWidgetBtn').show(); }); var layerAttributes; @@ -1477,16 +1473,16 @@ var startApp = function() { '' ); $('#map-tools').append( - '' + '' ); $('#map-tools').append( - '' + '' ); $('#map-tools').append( - '' + '' ); $('#map-tools').append( - '' + '' ); @@ -1672,6 +1668,10 @@ function loadProject() { setWidgetsToDefault(); $('#thematic-map-selection').show(); attributeInfoRequest(selectedLayer); + $('#toggleProjDefWidgetBtn').prop('disabled', false); + $('#toggleIriChartWidgetBtn').prop('disabled', false); + $('#toggleSviThemeWidgetBtn').prop('disabled', false); + $('#toggleCompIndWidgetBtn').prop('disabled', false); if (!$('#project-def-widget').is(':visible')) { $('#toggleProjDefWidgetBtn').click(); } From 4f6ba49de7f3a513121d9045105a594ad00342c9 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Thu, 11 Feb 2016 10:37:34 +0100 Subject: [PATCH 08/19] Show widgets slightly translated, avoiding complete overlapping --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 9053f6848..6591a5b5d 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1442,8 +1442,8 @@ var startApp = function() { 'height': '600px', 'overflow': 'auto', 'position': 'fixed', - 'left': '10px', - 'top': '110px' + 'left': (10 + i * 40) + 'px', + 'top': (110 + i * 40) + 'px' }); }); From f3c281a479ba7ef381acc19dfe259946e4ed7131 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 12:12:39 +0100 Subject: [PATCH 09/19] Failing factorization --- .../irv/static/irv/js/irv_viewer.js | 175 ++++++++++-------- .../irv/static/irv/js/irv_viewer_PCP_theme.js | 5 +- 2 files changed, 96 insertions(+), 84 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 6591a5b5d..30e623466 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -14,6 +14,21 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ +var widgetsAndButtons = { + 'projDef': {'widget': $('#project-def-widget'), + 'button': $('#toggleProjDefWidgetBtn'), + 'buttonText': 'Show Project Definition'}, + 'iri': {'widget': $('#iri-chart-widget'), + 'button': $('#toggleIriChartWidgetBtn'), + 'buttonText': 'Show IRI Chart Widget'}, + 'svi': {'widget': $('#cat-chart-widget'), + 'button': $('#toggleSviThemeWidgetBtn'), + 'buttonText': 'Show SVI Theme Chart'}, + 'indicators': {'widget': $('#primary-tab-widget'), + 'button': $('#toggleCompIndWidgetBtn'), + 'buttonText': 'Show Composite Indicator Chart'} +}; + $(document).ready(function() { $('#cover').remove(); @@ -52,10 +67,10 @@ function setWidgetsToDefault(){ $('#pdSelection').empty(); // set tabs back default // FIXME: all widgets will have only 1 tab; handle things accordingly - $("#iri-chart-widget").tabs("enable", 2); - $("#cat-chart-widget").tabs("enable", 3); + widgetsAndButtons.iri.widget.tabs("enable", 2); + widgetsAndButtons.svi.widget.tabs("enable", 3); - $('#project-def-widget').tabs('option', 'active', 0); + widgetsAndButtons.projDef.widget.tabs('option', 'active', 0); $('#projectDef-spinner').text('Loading ...'); $('#projectDef-spinner').append(''); $('#projectDef-spinner').show(); @@ -779,7 +794,7 @@ function processIndicators(layerAttributes, projectDef) { iriPcpData.push(SVI); } else { // Disable the primary tab. - $("#cat-chart-widget").tabs("disable", 3); + widgetsAndButtons.svi.widget.tabs("disable", 3); } if (riskIndicators !== undefined) { @@ -792,6 +807,15 @@ function processIndicators(layerAttributes, projectDef) { } // End processIndicators +function disableWidget(widgetAndBtn) { + // if the widget is visible, click the button to toggle it + if (widgetAndBtn.widget.is(':visible')) { + widgetAndBtn.button.click(); + } + // in any case, disable the button that shows the widget + widgetAndBtn.button.prop('disabled', true); +} + function scale(IndicatorObj) { var ValueArray = []; var scaledValues = []; @@ -807,9 +831,13 @@ function scale(IndicatorObj) { if (tempMax == tempMin) { scaledValues = [1]; // Disable the chart tabs - $("#project-def-widget").tabs("disable", 1); - $("#iri-chart-widget").tabs("disable", 2); - $("#cat-chart-widget").tabs("disable", 3); + // $("#project-def-widget").tabs("disable", 1); + // $("#iri-chart-widget").tabs("disable", 2); + // $("#cat-chart-widget").tabs("disable", 3); + // FIXME: check what actually needs to be disabled + $.each(['indicators', 'svi', 'iri'], function(i, widgetName) { + disableWidget(widgetsAndButtons[widgetName]); + }); } else { scaledValues.push( (ValueArray[j] - tempMin) / (tempMax - tempMin) ); } @@ -1415,36 +1443,35 @@ var startApp = function() { webGl = webglDetect(); - $.each(['#project-def-widget', - '#iri-chart-widget', - '#cat-chart-widget', - '#primary-tab-widget'], function(i, widget) { - // Theme tabs behavior - $(widget).resizable({ - minHeight: 220, - minWidth: 220 - }); - - $(widget).tabs({ - collapsible: false, - selected: -1, - active: false, - }); - - $(widget).draggable({ - stack: "div", // put on top of the others when dragging - distance: 0, // do it even if it's not actually moved - cancel: "#project-def" - }); - $(widget).css({ - 'display': 'none', - 'width': '700px', - 'height': '600px', - 'overflow': 'auto', - 'position': 'fixed', - 'left': (10 + i * 40) + 'px', - 'top': (110 + i * 40) + 'px' - }); + // using the list, otherwise we would lose the order + $.each(['projDef', 'iri', 'svi', 'indicators'], function(i, widgetName) { + // Theme tabs behavior + var widget = widgetsAndButtons[widgetName].widget; + widget.resizable({ + minHeight: 220, + minWidth: 220 + }); + + widget.tabs({ + collapsible: false, + selected: -1, + active: false, + }); + + widget.draggable({ + stack: "div", // put on top of the others when dragging + distance: 0, // do it even if it's not actually moved + cancel: "#project-def" + }); + widget.css({ + 'display': 'none', + 'width': '700px', + 'height': '600px', + 'overflow': 'auto', + 'position': 'fixed', + 'left': (10 + i * 40) + 'px', + 'top': (110 + i * 40) + 'px' + }); }); $('#cover').remove(); @@ -1472,19 +1499,15 @@ var startApp = function() { $('#map-tools').append( '' ); - $('#map-tools').append( - '' - ); - $('#map-tools').append( - '' - ); - $('#map-tools').append( - '' - ); - $('#map-tools').append( - '' - ); - + // Using the list in order to keep the order + $.each(['indicators', 'svi', 'iri', 'projDef'], function(i, widgetName) { + // slice(1) removes the heading # from the selector + var buttonId = widgetsAndButtons[widgetName].button.selector.slice(1); + var buttonText = widgetsAndButtons[widgetName].buttonText; + $('#map-tools').append( + '' + ); + }); if (webGl === false) { $('#map-tools').append( @@ -1525,34 +1548,23 @@ var startApp = function() { $('#loadProjectDialog').dialog('open'); }); - function toggleWidget(widget, btn) { + function toggleWidget(widgetAndBtn) { // toggle widget and change text on the corresponding button - var widgetIsVisible = widget.is(':visible'); - var btnText = btn.html(); + var btnText = widgetAndBtn.button.html(); if (btnText.indexOf('Hide ') >= 0) { // Change Hide -> Show btnText = 'Show ' + btnText.slice(5); - } else { // Change Show -> Hide + } else { // Change Show -> Hide btnText = 'Hide ' + btnText.slice(5); } - if (widgetIsVisible) { - widget.hide(); - } else { - widget.show(); - } - btn.html(btnText); + widgetAndBtn.widget.toggle(); + widgetAndBtn.button.html(btnText); } - $('#toggleProjDefWidgetBtn').click(function() { - toggleWidget($('#project-def-widget'), $('#toggleProjDefWidgetBtn')); - }); - $('#toggleIriChartWidgetBtn').click(function() { - toggleWidget($('#iri-chart-widget'), $('#toggleIriChartWidgetBtn')); - }); - $('#toggleSviThemeWidgetBtn').click(function() { - toggleWidget($('#cat-chart-widget'), $('#toggleSviThemeWidgetBtn')); - }); - $('#toggleCompIndWidgetBtn').click(function() { - toggleWidget($('#primary-tab-widget'), $('#toggleCompIndWidgetBtn')); + // FIXME: suspect inner definition of click + $.each(widgetsAndButtons, function(key, widgetAndBtn) { + widgetAndBtn.button.click(function() { + toggleWidget(widgetAndBtn); + }); }); // TODO check these are all needed @@ -1619,11 +1631,9 @@ var startApp = function() { 'left': '50px' }); - $.each(['#toggleProjDefWidgetBtn', - '#toggleIriChartWidgetBtn', - '#toggleSviThemeWidgetBtn', - '#toggleCompIndWidgetBtn'], function(i, widget) { - $(widget).css({ + // FIXME: for some reason, this is not styling the buttons + $.each(widgetsAndButtons, function(key, widgetAndBtn) { + widgetAndBtn.button.css({ 'position': 'relative', 'float': 'right', 'margin-left': '2px' @@ -1668,12 +1678,13 @@ function loadProject() { setWidgetsToDefault(); $('#thematic-map-selection').show(); attributeInfoRequest(selectedLayer); - $('#toggleProjDefWidgetBtn').prop('disabled', false); - $('#toggleIriChartWidgetBtn').prop('disabled', false); - $('#toggleSviThemeWidgetBtn').prop('disabled', false); - $('#toggleCompIndWidgetBtn').prop('disabled', false); - if (!$('#project-def-widget').is(':visible')) { - $('#toggleProjDefWidgetBtn').click(); + $.each(widgetsAndButtons, function(key, widgetAndBtn) { + // just enable buttons without opening widgets + widgetAndBtn.button.prop('disabled', false); + }); + // open the project definition widget if it's not already open + if (!widgetsAndButtons.projDef.widget.is(':visible')) { + widgetsAndButtons.projDef.button.click(); } } diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js index f346b7ce7..0ff91e822 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js @@ -39,10 +39,11 @@ function Theme_PCP_Chart(themeData) { if (themeCount <= 2) { // Disable the theme tab. - // FIXME: disable the whole widget instead - $("#iri-chart-widget").tabs("disable", 2); + disableWidget(widgetsAndButtons.svi); // Stop the function from continuing. return; + } else { + widgetsAndButtons.svi.button.prop('disabled', false); } var data = themeData; From 87de4b99ceb450b21b69c51815f91e6e5277038c Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 14:24:15 +0100 Subject: [PATCH 10/19] Fixed factorization of buttons and widgets --- .../irv/static/irv/js/irv_viewer.js | 50 +++++++++---------- .../irv/static/irv/js/irv_viewer_PCP_theme.js | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 30e623466..cc14f5760 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -15,17 +15,17 @@ along with this program. If not, see . */ var widgetsAndButtons = { - 'projDef': {'widget': $('#project-def-widget'), - 'button': $('#toggleProjDefWidgetBtn'), + 'projDef': {'widget': '#project-def-widget', + 'button': '#toggleProjDefWidgetBtn', 'buttonText': 'Show Project Definition'}, - 'iri': {'widget': $('#iri-chart-widget'), - 'button': $('#toggleIriChartWidgetBtn'), + 'iri': {'widget': '#iri-chart-widget', + 'button': '#toggleIriChartWidgetBtn', 'buttonText': 'Show IRI Chart Widget'}, - 'svi': {'widget': $('#cat-chart-widget'), - 'button': $('#toggleSviThemeWidgetBtn'), + 'svi': {'widget': '#cat-chart-widget', + 'button': '#toggleSviThemeWidgetBtn', 'buttonText': 'Show SVI Theme Chart'}, - 'indicators': {'widget': $('#primary-tab-widget'), - 'button': $('#toggleCompIndWidgetBtn'), + 'indicators': {'widget': '#primary-tab-widget', + 'button': '#toggleCompIndWidgetBtn', 'buttonText': 'Show Composite Indicator Chart'} }; @@ -67,10 +67,10 @@ function setWidgetsToDefault(){ $('#pdSelection').empty(); // set tabs back default // FIXME: all widgets will have only 1 tab; handle things accordingly - widgetsAndButtons.iri.widget.tabs("enable", 2); - widgetsAndButtons.svi.widget.tabs("enable", 3); + $(widgetsAndButtons.iri.widget).tabs("enable", 2); + $(widgetsAndButtons.svi.widget).tabs("enable", 3); - widgetsAndButtons.projDef.widget.tabs('option', 'active', 0); + $(widgetsAndButtons.projDef.widget).tabs('option', 'active', 0); $('#projectDef-spinner').text('Loading ...'); $('#projectDef-spinner').append(''); $('#projectDef-spinner').show(); @@ -794,7 +794,7 @@ function processIndicators(layerAttributes, projectDef) { iriPcpData.push(SVI); } else { // Disable the primary tab. - widgetsAndButtons.svi.widget.tabs("disable", 3); + $(widgetsAndButtons.svi.widget).tabs("disable", 3); } if (riskIndicators !== undefined) { @@ -809,11 +809,11 @@ function processIndicators(layerAttributes, projectDef) { function disableWidget(widgetAndBtn) { // if the widget is visible, click the button to toggle it - if (widgetAndBtn.widget.is(':visible')) { - widgetAndBtn.button.click(); + if ($(widgetAndBtn.widget).is(':visible')) { + $(widgetAndBtn.button).click(); } // in any case, disable the button that shows the widget - widgetAndBtn.button.prop('disabled', true); + $(widgetAndBtn.button).prop('disabled', true); } function scale(IndicatorObj) { @@ -1446,7 +1446,7 @@ var startApp = function() { // using the list, otherwise we would lose the order $.each(['projDef', 'iri', 'svi', 'indicators'], function(i, widgetName) { // Theme tabs behavior - var widget = widgetsAndButtons[widgetName].widget; + var widget = $(widgetsAndButtons[widgetName].widget); widget.resizable({ minHeight: 220, minWidth: 220 @@ -1502,7 +1502,7 @@ var startApp = function() { // Using the list in order to keep the order $.each(['indicators', 'svi', 'iri', 'projDef'], function(i, widgetName) { // slice(1) removes the heading # from the selector - var buttonId = widgetsAndButtons[widgetName].button.selector.slice(1); + var buttonId = widgetsAndButtons[widgetName].button.slice(1); var buttonText = widgetsAndButtons[widgetName].buttonText; $('#map-tools').append( '' @@ -1550,19 +1550,19 @@ var startApp = function() { function toggleWidget(widgetAndBtn) { // toggle widget and change text on the corresponding button - var btnText = widgetAndBtn.button.html(); + var btnText = $(widgetAndBtn.button).html(); if (btnText.indexOf('Hide ') >= 0) { // Change Hide -> Show btnText = 'Show ' + btnText.slice(5); } else { // Change Show -> Hide btnText = 'Hide ' + btnText.slice(5); } - widgetAndBtn.widget.toggle(); - widgetAndBtn.button.html(btnText); + $(widgetAndBtn.widget).toggle(); + $(widgetAndBtn.button).html(btnText); } // FIXME: suspect inner definition of click $.each(widgetsAndButtons, function(key, widgetAndBtn) { - widgetAndBtn.button.click(function() { + $(widgetAndBtn.button).click(function() { toggleWidget(widgetAndBtn); }); }); @@ -1633,7 +1633,7 @@ var startApp = function() { // FIXME: for some reason, this is not styling the buttons $.each(widgetsAndButtons, function(key, widgetAndBtn) { - widgetAndBtn.button.css({ + $(widgetAndBtn.button).css({ 'position': 'relative', 'float': 'right', 'margin-left': '2px' @@ -1680,11 +1680,11 @@ function loadProject() { attributeInfoRequest(selectedLayer); $.each(widgetsAndButtons, function(key, widgetAndBtn) { // just enable buttons without opening widgets - widgetAndBtn.button.prop('disabled', false); + $(widgetAndBtn.button).prop('disabled', false); }); // open the project definition widget if it's not already open - if (!widgetsAndButtons.projDef.widget.is(':visible')) { - widgetsAndButtons.projDef.button.click(); + if (!$(widgetsAndButtons.projDef.widget).is(':visible')) { + $(widgetsAndButtons.projDef.button).click(); } } diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js index 0ff91e822..f7da66e37 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js @@ -43,7 +43,7 @@ function Theme_PCP_Chart(themeData) { // Stop the function from continuing. return; } else { - widgetsAndButtons.svi.button.prop('disabled', false); + $(widgetsAndButtons.svi.button).prop('disabled', false); } var data = themeData; From 7b67510d7bcfa9594ae528057bc755e3036e0792 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 15:56:58 +0100 Subject: [PATCH 11/19] irv: avoid overlapping mapInfo div with widget buttons and keep it invisible until any feature is selected --- .../openquakeplatform/irv/static/irv/css/irv_legend.css | 4 +++- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/css/irv_legend.css b/openquakeplatform/openquakeplatform/irv/static/irv/css/irv_legend.css index 991d4fcd5..455a63ea2 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/css/irv_legend.css +++ b/openquakeplatform/openquakeplatform/irv/static/irv/css/irv_legend.css @@ -7,10 +7,12 @@ #mapInfo { position: fixed; + margin-top: 40px; right: 20px; padding: 10px 10px 15px; background-color: whitesmoke; border-radius: 15px; + visibility: hidden; } .my-legend .legend-title { @@ -47,4 +49,4 @@ } .my-legend a { color: #777; - } \ No newline at end of file + } diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index be9c4f054..593031024 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1162,6 +1162,7 @@ function mapboxGlLayerCreation() { map.featuresAt(e.point, { radius : 6}, function(err, features) { if (err) throw err; $('#mapInfo').empty(); + $('#mapInfo').css({'visibility': 'visible'}); if (typeof features[0] === 'undefined') { $('#mapInfo').append('No data available'); } else { From 133a82296c55ddc06861bbd0715ed9f5eb091256 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 16:39:25 +0100 Subject: [PATCH 12/19] Remove old references to tabs enabling/disabling --- .../irv/static/irv/js/irv_viewer.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 593031024..26066f57e 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1,3 +1,4 @@ +// TODO: let all widgets overlap the others when selected /* Copyright (c) 2015, GEM Foundation. @@ -67,11 +68,6 @@ var indicatorChildrenKey = []; function setWidgetsToDefault(){ $('#pdSelection').empty(); // set tabs back default - // FIXME: all widgets will have only 1 tab; handle things accordingly - $(widgetsAndButtons.iri.widget).tabs("enable", 2); - $(widgetsAndButtons.svi.widget).tabs("enable", 3); - - $(widgetsAndButtons.projDef.widget).tabs('option', 'active', 0); $('#projectDef-spinner').text('Loading ...'); $('#projectDef-spinner').append(''); $('#projectDef-spinner').show(); @@ -794,8 +790,8 @@ function processIndicators(layerAttributes, projectDef) { SVI.plotElement = "SVI"; // Label within the object iriPcpData.push(SVI); } else { - // Disable the primary tab. - $(widgetsAndButtons.svi.widget).tabs("disable", 3); + disableWidget(widgetsAndButtons.svi); + disableWidget(widgetsAndButtons.indicators); } if (riskIndicators !== undefined) { @@ -832,10 +828,6 @@ function scale(IndicatorObj) { if (tempMax == tempMin) { scaledValues = [1]; // Disable the chart tabs - // $("#project-def-widget").tabs("disable", 1); - // $("#iri-chart-widget").tabs("disable", 2); - // $("#cat-chart-widget").tabs("disable", 3); - // FIXME: check what actually needs to be disabled $.each(['indicators', 'svi', 'iri'], function(i, widgetName) { disableWidget(widgetsAndButtons[widgetName]); }); From 22a32c32ffac608a3fc2f11552aead0f848c2a7a Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 17:04:07 +0100 Subject: [PATCH 13/19] Put also loadProjectDialog on top when dragging it --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 26066f57e..1772119ec 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1,4 +1,4 @@ -// TODO: let all widgets overlap the others when selected +// TODO: Re-enable Show Composite Indicator Chart when a different project definition is selected /* Copyright (c) 2015, GEM Foundation. @@ -1567,7 +1567,6 @@ var startApp = function() { $(widgetAndBtn.button).html(btnText); } - // FIXME: suspect inner definition of click $.each(widgetsAndButtons, function(key, widgetAndBtn) { $(widgetAndBtn.button).click(function() { toggleWidget(widgetAndBtn); @@ -1624,6 +1623,11 @@ var startApp = function() { closeOnEscape: true }); + $('#loadProjectDialog').draggable({ + stack: "div", // put on top of the others when dragging + distance: 0, // do it even if it's not actually moved + }); + $('#map-tools').css({ 'padding': '6px', 'position': 'absolute', @@ -1638,7 +1642,6 @@ var startApp = function() { 'left': '50px' }); - // FIXME: for some reason, this is not styling the buttons $.each(widgetsAndButtons, function(key, widgetAndBtn) { $(widgetAndBtn.button).css({ 'position': 'relative', From 78cd561bffabbf9af1e25990cb02d89ed1e787d2 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 17:26:05 +0100 Subject: [PATCH 14/19] Enable Indicator Chart when a projdef with indicators is selected --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 2 +- .../irv/static/irv/js/irv_viewer_PCP_primary.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 1772119ec..745b60397 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1,4 +1,4 @@ -// TODO: Re-enable Show Composite Indicator Chart when a different project definition is selected +// FIXME: Enable selecting a different theme in the Composite Indicator Chart /* Copyright (c) 2015, GEM Foundation. diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js index f357eab68..009ed5360 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js @@ -38,6 +38,9 @@ function Primary_PCP_Chart(projectDef, layerAttributes, selectedRegion) { // continue } } + if (themesWithChildren) { + $(widgetsAndButtons.indicators.button).prop('disabled', false); + } $('#primary_indicator').empty(); $('#primary_indicator').append(''); From 52a6731e432702ce6f88665681b5159c40385840 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 15 Feb 2016 17:35:24 +0100 Subject: [PATCH 15/19] Disable dreaggable when clicking inside chart areas --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 745b60397..b6c9f5c73 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1,4 +1,3 @@ -// FIXME: Enable selecting a different theme in the Composite Indicator Chart /* Copyright (c) 2015, GEM Foundation. @@ -1468,7 +1467,7 @@ var startApp = function() { widget.draggable({ stack: "div", // put on top of the others when dragging distance: 0, // do it even if it's not actually moved - cancel: "#project-def" + cancel: "#project-def, #primary-tab, #cat-chart, #iri-chart" }); widget.css({ 'display': 'none', From 8c825c7792bae69ff28a61af1871104f168125d2 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 16 Feb 2016 10:12:36 +0100 Subject: [PATCH 16/19] Add a comment and make the logic slightly more intuitive --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index b6c9f5c73..9a70ea49b 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1557,13 +1557,16 @@ var startApp = function() { function toggleWidget(widgetAndBtn) { // toggle widget and change text on the corresponding button var btnText = $(widgetAndBtn.button).html(); + // If the widget is visible, the button text is 'Hide Widgetname' + // Otherwise it is 'Show Widgetname' + // Let's change the button text before toggling the widget if (btnText.indexOf('Hide ') >= 0) { // Change Hide -> Show btnText = 'Show ' + btnText.slice(5); } else { // Change Show -> Hide btnText = 'Hide ' + btnText.slice(5); } - $(widgetAndBtn.widget).toggle(); $(widgetAndBtn.button).html(btnText); + $(widgetAndBtn.widget).toggle(); } $.each(widgetsAndButtons, function(key, widgetAndBtn) { From 8cc39466c192fc1c90bbe2876b9bfcaff3160f90 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 16 Feb 2016 10:19:18 +0100 Subject: [PATCH 17/19] Remove scrollbars from widgets --- .../openquakeplatform/irv/static/irv/js/irv_viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js index 9a70ea49b..200338892 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer.js @@ -1473,7 +1473,7 @@ var startApp = function() { 'display': 'none', 'width': '700px', 'height': '600px', - 'overflow': 'auto', + 'overflow': 'hidden', 'position': 'fixed', 'left': (10 + i * 40) + 'px', 'top': (110 + i * 40) + 'px' From 2ceb1b58009762eb4c4b09ad2f3e78f36f360b56 Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 16 Feb 2016 11:26:17 +0100 Subject: [PATCH 18/19] Enable zooming/panning also for the PCP charts --- .../irv/static/irv/js/irv_viewer_PCP_IRI.js | 6 ++++++ .../irv/static/irv/js/irv_viewer_PCP_primary.js | 7 +++++++ .../irv/static/irv/js/irv_viewer_PCP_theme.js | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js index 3eaed12c1..bef1ee949 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_IRI.js @@ -69,10 +69,16 @@ function IRI_PCP_Chart(iriPcpData) { .scale(x); $("#iri-chart").empty(); + $("#iri-chart").css({'height': '100%'}); var svg = d3.select("#iri-chart").append("svg") + .attr("width", "100%") + .attr("height", "100%") .attr("viewBox", "-30 -20 " +winW+" " + (winH +20)) .attr("id", "IRI-svg-element") + .call(d3.behavior.zoom().scaleExtent([0.1, 5]).on("zoom", function () { + svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); + })) .append("svg:g") .attr("transform", "translate(" + m[3] + ",5)"); diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js index 009ed5360..eea9b6f5f 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_primary.js @@ -99,6 +99,7 @@ function Primary_PCP_Chart(projectDef, layerAttributes, selectedRegion) { } } + $('#primary-tab').css({'height': '100%'}); $('#primary-tab').append('
'); @@ -144,10 +145,16 @@ function Primary_PCP_Chart(projectDef, layerAttributes, selectedRegion) { .scale(x); $("#primary-chart").empty(); + $("#primary-chart").css({'height': '100%'}); var svg = d3.select("#primary-chart").append("svg") + .attr("width", "100%") + .attr("height", "100%") .attr("viewBox", "-30 -20 " +winW+" " + (winH +20)) .attr("id", "primary-svg-element") + .call(d3.behavior.zoom().scaleExtent([0.1, 5]).on("zoom", function () { + svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); + })) .append("svg:g") .attr("transform", "translate(" + m[3] + ",5)"); diff --git a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js index f7da66e37..3facb9a5e 100644 --- a/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js +++ b/openquakeplatform/openquakeplatform/irv/static/irv/js/irv_viewer_PCP_theme.js @@ -85,10 +85,16 @@ function Theme_PCP_Chart(themeData) { foreground; $('#cat-chart').empty(); + $("#cat-chart").css({'height': '100%'}); var svg = d3.select('#cat-chart').append('svg') + .attr("width", "100%") + .attr("height", "100%") .attr("viewBox", "100 20 " +(winW -400)+" " +winH) .attr("id", "CI-svg-element") + .call(d3.behavior.zoom().scaleExtent([0.1, 5]).on("zoom", function () { + svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); + })) .append('g') .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); From 6605949955e4b2af9e2c5d9fcd39d88244aa170b Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 16 Feb 2016 11:58:28 +0100 Subject: [PATCH 19/19] Update changelog --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7d04f3444..9501040ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,9 @@ * irv: let the d3 tree layout look like in the QGIS IRMT plugin * irv: handle case in which a zone with no available data is clicked on the map * irv: when switching project definition, restyle the map accordingly + * irv: display charts in separate widgets instead of tabs + * irv: fix displaying the 'median' text when moving the mouse over a median line + * irv: enable zooming/panning for all d3 charts python-oq-platform (1.3.1)