diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4269acc..0000000 --- a/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -_site/ -.sass-cache/ -.jekyll-metadata -.DS_Store -.Rproj.user -.Rhistory -.spyproject/ -*__pycache__/ -*.Rproj -Gemfile.lock -deploy_key* -deploy_key*.pub -*.keybase diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f0f2d19..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: ruby -rvm: -- 2.4.0 -dist: trusty -sudo: false -branches: - only: - - master - - develop -env: - global: - - NOKOGIRI_USE_SYSTEM_LIBRARIES=true -# Build. _site directory is the artifact -before_script: -- chmod +x ./scripts/*.sh -- chmod +x ./scripts/deploy/*.sh -script: -- scripts/cibuild.sh -# Deploy. Staging goes back to gh-pages here and prod to external repo -deploy: -- provider: script - script: scripts/deploy/deploy_staging.sh - skip_cleanup: true - on: - branch: develop -- provider: script - script: scripts/deploy/deploy.sh - skip_cleanup: true - on: - branch: master diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index bf80ba7..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "editor.detectIndentation": false, - "editor.tabSize": 2 -} diff --git a/README.md b/README.md index 1750312..af4ec9a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Sustainable Development Goals (SDGs) Website Theme +# Sustainable Development Goals (SDG) - Theme -This Jekyll theme is designed to work with the SDGs national reporting platform. +This is a platform for collecting and disseminating data for the Sustainable Development Goal global indicators. -## Installation +## Documentation -It is assumed this theme is being used via the `remote_theme` setting from the sdg-indicators repository. +See the [docs folder](docs/index.md) for more information. diff --git a/assets/js/accessibility.js b/_includes/assets/js/accessibility.js similarity index 100% rename from assets/js/accessibility.js rename to _includes/assets/js/accessibility.js diff --git a/assets/js/chartjs/rescaler.js b/_includes/assets/js/chartjs/rescaler.js similarity index 100% rename from assets/js/chartjs/rescaler.js rename to _includes/assets/js/chartjs/rescaler.js diff --git a/assets/js/event.js b/_includes/assets/js/event.js similarity index 100% rename from assets/js/event.js rename to _includes/assets/js/event.js diff --git a/assets/js/indicatorController.js b/_includes/assets/js/indicatorController.js similarity index 100% rename from assets/js/indicatorController.js rename to _includes/assets/js/indicatorController.js diff --git a/assets/js/indicatorDataStore.js b/_includes/assets/js/indicatorDataStore.js similarity index 100% rename from assets/js/indicatorDataStore.js rename to _includes/assets/js/indicatorDataStore.js diff --git a/assets/js/indicatorModel.js b/_includes/assets/js/indicatorModel.js similarity index 100% rename from assets/js/indicatorModel.js rename to _includes/assets/js/indicatorModel.js diff --git a/assets/js/indicatorView.js b/_includes/assets/js/indicatorView.js similarity index 91% rename from assets/js/indicatorView.js rename to _includes/assets/js/indicatorView.js index 49d9e51..5aa9f91 100644 --- a/assets/js/indicatorView.js +++ b/_includes/assets/js/indicatorView.js @@ -1,27 +1,27 @@ var indicatorView = function (model, options) { - + "use strict"; - + var view_obj = this; this._model = model; - + this._chartInstance = undefined; this._rootElement = options.rootElement; this._tableColumnDefs = options.tableColumnDefs; this._mapView = undefined; this._legendElement = options.legendElement; - + var chartHeight = screen.height < options.maxChartHeight ? screen.height : options.maxChartHeight; - + $('.plot-container', this._rootElement).css('height', chartHeight + 'px'); - + $(document).ready(function() { $(view_obj._rootElement).find('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { if($(e.target).attr('href') == '#tableview') { setDataTableWidth($(view_obj._rootElement).find('#selectionsTable table')); } else { $($.fn.dataTable.tables(true)).css('width', '100%'); - $($.fn.dataTable.tables(true)).DataTable().columns.adjust().draw(); + $($.fn.dataTable.tables(true)).DataTable().columns.adjust().draw(); } }); @@ -33,30 +33,30 @@ var indicatorView = function (model, options) { meta = ci.getDatasetMeta(index); meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null; - ci.update(); + ci.update(); }); }); - + this._model.onDataComplete.attach(function (sender, args) { - + if(view_obj._model.showData) { - + $('#dataset-size-warning')[args.datasetCountExceedsMax ? 'show' : 'hide'](); - + if(!view_obj._chartInstance) { view_obj.createPlot(args); } else { view_obj.updatePlot(args); } } - + view_obj.createSelectionsTable(args); }); - + this._model.onNoHeadlineData.attach(function() { $('#fields .variable-options :checkbox:eq(0)').trigger('click'); }); - + this._model.onSeriesComplete.attach(function(sender, args) { view_obj.initialiseSeries(args); @@ -78,53 +78,53 @@ var indicatorView = function (model, options) { // selector.parent().removeClass('disabled').removeAttr('title'); // } }); - + this._model.onUnitsComplete.attach(function(sender, args) { view_obj.initialiseUnits(args); }); - + this._model.onUnitsSelectedChanged.attach(function(sender, args) { // update the plot's y axis label // update the data }); - + this._model.onFieldsCleared.attach(function(sender, args) { $(view_obj._rootElement).find(':checkbox').prop('checked', false); $(view_obj._rootElement).find('#clear').addClass('disabled'); - + // reset available/unavailable fields updateWithSelectedFields(); - + // #246 $(view_obj._rootElement).find('.selected').css('width', '0'); // end of #246 }); - + this._model.onSelectionUpdate.attach(function(sender, args) { $(view_obj._rootElement).find('#clear')[args.selectedFields.length ? 'removeClass' : 'addClass']('disabled'); - + // loop through the available fields: $('.variable-selector').each(function(index, element) { var currentField = $(element).data('field'); - + // any info? var match = _.findWhere(args.selectedFields, { field : currentField }); var element = $(view_obj._rootElement).find('.variable-selector[data-field="' + currentField + '"]'); var width = match ? (Number(match.values.length / element.find('.variable-options label').length) * 100) + '%' : '0'; - + $(element).find('.bar .selected').css('width', width); - + // is this an allowed field: $(element)[_.contains(args.allowedFields, currentField) ? 'removeClass' : 'addClass']('disallowed'); }); }); - + this._model.onFieldsStatusUpdated.attach(function (sender, args) { //console.log('updating field states with: ', args); - + // reset: $(view_obj._rootElement).find('label').removeClass('selected possible excluded'); - + _.each(args.data, function(fieldGroup) { _.each(fieldGroup.values, function(fieldItem) { var element = $(view_obj._rootElement).find(':checkbox[value="' + fieldItem.value + '"][data-field="' + fieldGroup.field + '"]'); @@ -133,11 +133,11 @@ var indicatorView = function (model, options) { // Indicate whether the fieldGroup had any data. var fieldGroupElement = $(view_obj._rootElement).find('.variable-selector[data-field="' + fieldGroup.field + '"]'); fieldGroupElement.attr('data-has-data', fieldGroup.hasData); - + // Re-sort the items. view_obj.sortFieldGroup(fieldGroupElement); }); - + _.each(args.selectionStates, function(ss) { // find the appropriate 'bar' var element = $(view_obj._rootElement).find('.variable-selector[data-field="' + ss.field + '"]'); @@ -146,25 +146,25 @@ var indicatorView = function (model, options) { element.find('.bar .excluded').css('width', ss.fieldSelection.excludedState + '%'); }); }); - + $(this._rootElement).on('click', '#clear', function() { view_obj._model.clearSelectedFields(); }); - + $(this._rootElement).on('click', '#fields label', function (e) { - + if(!$(this).closest('.variable-options').hasClass('disallowed')) { $(this).find(':checkbox').trigger('click'); } - + e.preventDefault(); e.stopPropagation(); }); - + $(this._rootElement).on('change', '#units input', function() { view_obj._model.updateSelectedUnit($(this).val()); }); - + // generic helper function, used by clear all/select all and individual checkbox changes: var updateWithSelectedFields = function() { view_obj._model.updateSelectedFields(_.chain(_.map($('#fields input:checked'), function (fieldValue) { @@ -179,11 +179,11 @@ var indicatorView = function (model, options) { }; }).value()); } - + $(this._rootElement).on('click', '.variable-options button', function(e) { var type = $(this).data('type'); var $options = $(this).closest('.variable-options').find(':checkbox'); - + // The clear button can clear all checkboxes. if (type == 'clear') { $options.prop('checked', false); @@ -192,39 +192,39 @@ var indicatorView = function (model, options) { if (type == 'select') { $options.parent().not('[data-has-data=false]').find(':checkbox').prop('checked', true) } - + updateWithSelectedFields(); - + e.stopPropagation(); }); - + $(this._rootElement).on('click', ':checkbox', function(e) { - + // don't permit excluded selections: if($(this).parent().hasClass('excluded') || $(this).closest('.variable-selector').hasClass('disallowed')) { return; } - + updateWithSelectedFields(); - + e.stopPropagation(); }); - + $(this._rootElement).on('click', '.variable-selector', function(e) { - + var options = $(this).find('.variable-options'); var optionsVisible = options.is(':visible'); $(options)[optionsVisible ? 'hide' : 'show'](); - + e.stopPropagation(); }); - + this.initialiseSeries = function(args) { if(args.series.length) { var template = _.template($("#item_template").html()); if(!$('button#clear').length) { - $('').insertBefore('#fields'); + $('').insertBefore('#fields'); } $('#fields').html(template({ @@ -234,42 +234,42 @@ var indicatorView = function (model, options) { })); $(this._rootElement).removeClass('no-series'); - + } else { $(this._rootElement).addClass('no-series'); } }; - + this.initialiseUnits = function(args) { var template = _.template($('#units_template').html()), units = args.units || []; - + $('#units').html(template({ units: units })); if(!units.length) { - $(this._rootElement).addClass('no-units'); + $(this._rootElement).addClass('no-units'); } }; - + this.updatePlot = function(chartInfo) { view_obj._chartInstance.data.datasets = chartInfo.datasets; - + if(chartInfo.selectedUnit) { view_obj._chartInstance.options.scales.yAxes[0].scaleLabel.labelString = chartInfo.selectedUnit; } - + view_obj._chartInstance.update(1000, true); $(this._legendElement).html(view_obj._chartInstance.generateLegend()); }; - + this.createPlot = function (chartInfo) { - + var that = this; - - this._chartInstance = new Chart($(this._rootElement).find('canvas'), { + + var chartConfig = { type: this._model.graphType, data: chartInfo, options: { @@ -299,7 +299,7 @@ var indicatorView = function (model, options) { layout: { padding: { top: 20, - // default of 85, but do a rough line count based on 150 + // default of 85, but do a rough line count based on 150 // characters per line * 20 pixels per row bottom: that._model.footnote ? (20 * (that._model.footnote.length / 150)) + 85 : 85 } @@ -314,7 +314,7 @@ var indicatorView = function (model, options) { text.push(dataset.label); text.push(''); }); - + text.push(''); return text.join(''); }, @@ -332,8 +332,13 @@ var indicatorView = function (model, options) { scaler: {} } } - }); - + }; + if (typeof chartConfigOverrides !== 'undefined') { + $.extend(true, chartConfig, chartConfigOverrides); + } + + this._chartInstance = new Chart($(this._rootElement).find('canvas'), chartConfig); + Chart.pluginService.register({ afterDraw: function(chart) { var $canvas = $(that._rootElement).find('canvas'), @@ -341,22 +346,22 @@ var indicatorView = function (model, options) { canvas = $canvas.get(0), textRowHeight = 20, ctx = canvas.getContext("2d"); - + ctx.font = font; ctx.textAlign = 'left'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#6e6e6e'; - + var getLinesFromText = function(text) { var width = parseInt($canvas.css('width')), //width(), lines = [], line = '', lineTest = '', words = text.split(' '); - + for (var i = 0, len = words.length; i < len; i++) { lineTest = line + words[i] + ' '; - + // Check total width of line or last word if (ctx.measureText(lineTest).width > width) { // Record and reset the current line @@ -366,65 +371,70 @@ var indicatorView = function (model, options) { line = lineTest; } } - + // catch left overs: if (line.length > 0) { lines.push(line.trim()); } - + return lines; }; - + function putTextOutputs(textOutputs, x) { var y = $canvas.height() - 10 - ((textOutputs.length - 1) * textRowHeight); - + _.each(textOutputs, function(textOutput) { ctx.fillText(textOutput, x, y); y += textRowHeight; }); } - + // TODO Merge this with the that.footerFields object used by table - var graphFooterItems = [ - 'Source: ' + (that._model.dataSource ? that._model.dataSource : ''), - 'Geographical Area: ' + (that._model.geographicalArea ? that._model.geographicalArea : ''), - 'Unit of Measurement: ' + (that._model.measurementUnit ? that._model.measurementUnit : '') - ]; - + var graphFooterItems = []; + if (that._model.dataSource) { + graphFooterItems.push(translations.indicator.source + ': ' + that._model.dataSource); + } + if (that._model.geographicalArea) { + graphFooterItems.push(translations.indicator.geographical_area + ': ' + that._model.geographicalArea); + } + if (that._model.measurementUnit) { + graphFooterItems.push(translations.indicator.unit_of_measurement + ': ' + that._model.measurementUnit); + } + if(that._model.footnote) { var footnoteRows = getLinesFromText('Footnote: ' + that._model.footnote); graphFooterItems = graphFooterItems.concat(footnoteRows); - + if(footnoteRows.length > 1) { //that._chartInstance.options.layout.padding.bottom += textRowHeight * footnoteRows.length; that._chartInstance.resize(parseInt($canvas.css('width')), parseInt($canvas.css('height')) + textRowHeight * footnoteRows.length); that._chartInstance.resize(); } } - + putTextOutputs(graphFooterItems, 0); } }); $(this._legendElement).html(view_obj._chartInstance.generateLegend()); }; - + this.toCsv = function (tableData) { var lines = [], headings = _.map(tableData.headings, function(heading) { return '"' + heading + '"'; }); - + lines.push(headings.join(',')); - + _.each(tableData.data, function (dataValues) { var line = []; - + _.each(headings, function (heading, index) { line.push(dataValues[index]); }); - + lines.push(line.join(',')); }); - + return lines.join('\n'); }; @@ -442,11 +452,11 @@ var indicatorView = function (model, options) { } break; } - } + } }); table.removeAttr('style width'); - + var totalWidth = 0; table.find('th').each(function() { if($(this).data('width')) { @@ -465,7 +475,7 @@ var indicatorView = function (model, options) { table.css('width', '100%'); } }; - + var initialiseDataTable = function(el) { var datatables_options = options.datatables_options || { paging: false, @@ -477,12 +487,12 @@ var indicatorView = function (model, options) { }, table = $(el).find('table'); datatables_options.aaSorting = []; - + table.DataTable(datatables_options); setDataTableWidth(table); }; - + this.createSelectionsTable = function(chartInfo) { this.createTable(chartInfo.selectionsTable, chartInfo.indicatorId, '#selectionsTable', true); this.createTableFooter(chartInfo.footerFields, '#selectionsTable'); @@ -493,16 +503,23 @@ var indicatorView = function (model, options) { this.createDownloadButton(chartInfo.selectionsTable, 'Chart', chartInfo.indicatorId, '#chartSelectionDownload'); this.createSourceButton(chartInfo.shortIndicatorId, '#chartSelectionDownload'); }; - + this.createDownloadButton = function(table, name, indicatorId, el) { if(window.Modernizr.blobconstructor) { - $(el).append($('').text('Download ' + name + ' CSV') + var downloadKey = 'download_csv'; + if (name == 'Chart') { + downloadKey = 'download_chart'; + } + if (name == 'Table') { + downloadKey = 'download_table'; + } + $(el).append($('').text(translations.indicator[downloadKey]) .attr({ 'href': URL.createObjectURL(new Blob([this.toCsv(table)], { type: 'text/csv' })), 'download': indicatorId + '.csv', - 'title': 'Download as CSV', + 'title': translations.indicator.download_csv_title, 'class': 'btn btn-primary btn-download', 'tabindex': 0 }) @@ -510,30 +527,30 @@ var indicatorView = function (model, options) { } else { var headlineId = indicatorId.replace('indicator', 'headline'); var id = indicatorId.replace('indicator', ''); - $(el).append($('').text('Download Headline CSV') + $(el).append($('').text(translations.indicator.download_headline) .attr({ - 'href': '{{ site.remotedatabaseurl }}/headline/' + id + '.csv', + 'href': remoteDataBaseUrl + '/headline/' + id + '.csv', 'download': headlineId + '.csv', - 'title': 'Download headline data as CSV', + 'title': translations.indicator.download_headline_title, 'class': 'btn btn-primary btn-download', 'tabindex': 0 })); } } - + this.createSourceButton = function(indicatorId, el) { - $(el).append($('').text('Download Source CSV') + $(el).append($('').text(translations.indicator.download_source) .attr({ - 'href': '{{ site.remotedatabaseurl }}/data/' + indicatorId + '.csv', + 'href': remoteDataBaseUrl + '/data/' + indicatorId + '.csv', 'download': indicatorId + '.csv', - 'title': 'Download source data as CSV', + 'title': translations.indicator.download_source_title, 'class': 'btn btn-primary btn-download', 'tabindex': 0 })); } - + this.createTable = function(table, indicatorId, el) { - + options = options || {}; var that = this, csv_path = options.csv_path, @@ -543,19 +560,19 @@ var indicatorView = function (model, options) { delimiter: '"' }, table_class = options.table_class || 'table table-hover'; - + // clear: $(el).html(''); - + if(table && table.data.length) { var currentTable = $('').attr({ 'class': /*'table-responsive ' +*/ table_class, 'width': '100%' //'id': currentId }); - + currentTable.append(''); - + var table_head = ''; var getHeading = function(heading, index) { @@ -563,15 +580,15 @@ var indicatorView = function (model, options) { var span_heading = '' + heading + ''; return (!index || heading.toLowerCase() == 'units') ? span_heading + span : span + span_heading; }; - + table.headings.forEach(function (heading, index) { table_head += '' + getHeading(heading, index) + ''; }); - + table_head += ''; currentTable.append(table_head); currentTable.append(''); - + table.data.forEach(function (data) { var row_html = ''; table.headings.forEach(function (heading, index) { @@ -580,30 +597,30 @@ var indicatorView = function (model, options) { row_html += ''; currentTable.find('tbody').append(row_html); }); - + $(el).append(currentTable); - + // initialise data table initialiseDataTable(el); - + } else { $(el).append($('

').text('There is no data for this breakdown.')); } }; - + this.createTableFooter = function(footerFields, el) { var footdiv = $('

').attr({ 'id': 'selectionTableFooter', 'class': 'table-footer-text' }); - + _.each(footerFields, function(val, key) { if(val) footdiv.append($('

').text(key + ': ' + val)); }); - + $(el).append(footdiv); }; - + this.sortFieldGroup = function(fieldGroupElement) { var sortLabels = function(a, b) { var aObj = { hasData: $(a).attr('data-has-data'), text: $(a).text() }; diff --git a/assets/js/lib/classList.js b/_includes/assets/js/lib/classList.js similarity index 100% rename from assets/js/lib/classList.js rename to _includes/assets/js/lib/classList.js diff --git a/assets/js/lib/d3-simple-slider.min.js b/_includes/assets/js/lib/d3-simple-slider.min.js similarity index 100% rename from assets/js/lib/d3-simple-slider.min.js rename to _includes/assets/js/lib/d3-simple-slider.min.js diff --git a/assets/js/lib/modernizr-custom.js b/_includes/assets/js/lib/modernizr-custom.js similarity index 100% rename from assets/js/lib/modernizr-custom.js rename to _includes/assets/js/lib/modernizr-custom.js diff --git a/assets/js/mapView.js b/_includes/assets/js/mapView.js similarity index 100% rename from assets/js/mapView.js rename to _includes/assets/js/mapView.js diff --git a/assets/js/menu.js b/_includes/assets/js/menu.js similarity index 100% rename from assets/js/menu.js rename to _includes/assets/js/menu.js diff --git a/assets/js/plugins/jquery.sdgMap.js b/_includes/assets/js/plugins/jquery.sdgMap.js similarity index 86% rename from assets/js/plugins/jquery.sdgMap.js rename to _includes/assets/js/plugins/jquery.sdgMap.js index ac9d54a..acdc641 100644 --- a/assets/js/plugins/jquery.sdgMap.js +++ b/_includes/assets/js/plugins/jquery.sdgMap.js @@ -5,7 +5,10 @@ defaults = { serviceUrl: 'https://geoportal1-ons.opendata.arcgis.com/datasets/686603e943f948acaa13fb5d2b0f1275_4.geojson', width: 590, - height: 590 + height: 590, + nameProperty: 'lad16nm', + idProperty: 'lad16cd', + projectionFunc: d3.geoMercator, }; function Plugin(element, options) { @@ -24,14 +27,14 @@ this.currentYear = this.years[0]; this.noValueFillColor = '#f0f0f0'; - + this.init(); } Plugin.prototype = { init: function() { var centered, projection, path, - g, effectLayer, resetButton, + g, effectLayer, resetButton, tooltip, slider, infoPanel, zoomControls, that = this, @@ -51,22 +54,16 @@ return showError.call(that); } - // if(that.options.geoCodeRegEx) { - // mapData.features = _.filter(mapData.features, function(f) { - // return f.properties.lad16cd.match(that.options.geoCodeRegEx); - // }); - // } - var features = mapData.features; initialiseUI.call(that); - projection = d3.geoMercator().fitSize([width, height], mapData); + projection = that.options.projectionFunc().fitSize([width, height], mapData); path = d3.geoPath().projection(projection); // Draw each geographical area as a path that.mapLayer.selectAll('path') - .data(features) + .data(features) .enter().append('path') .attr('d', path) .attr('vector-effect', 'non-scaling-stroke') @@ -78,7 +75,7 @@ .on('click', clicked.bind(that)); appendScale.call(that); - + }); function initialiseUI() { @@ -134,24 +131,10 @@ infoPanel = $('

').attr('id', 'infoPanel'); $(this.element).append(infoPanel); - - /* - zoomControls = $('
').attr('id', 'zoom'); - zoomControls.append($('').attr({ - 'id': 'zoom-in', - 'href': '#' - }).html('+')); - zoomControls.append($('').attr({ - 'id': 'zoom-out', - 'href': '#' - }).html('-')); - - $(this.element).append(zoomControls); - */ } function appendScale() { - var key = d3.select(this.element).append("svg").attr("id", "key").attr("width", this.options.width).attr("height", 40); + var key = d3.select(this.element).append("svg").attr("id", "key").attr("width", this.options.width).attr("height", 40); var length = 5; var color = d3.scaleLinear().domain([0, length - 1]).range(this.colorRange); @@ -173,7 +156,7 @@ .attr('font-size', 13) .html(Math.floor(value(i))); } - } + } function showError() { $(this.element).html( @@ -184,13 +167,13 @@ // Get area name function getName(d){ - return d && d.properties ? d.properties.lad16nm : null; + return d && d.properties ? d.properties[that.options.nameProperty] : null; } - // Get + // Get function getValue(d) { - var geoDataItem = _.findWhere(this.options.geoData, { - GeoCode: d.properties.lad16cd, + var geoDataItem = _.findWhere(this.options.geoData, { + GeoCode: d.properties[this.options.idProperty], Year: +this.currentYear }); @@ -198,8 +181,8 @@ } function getYearValues(d) { - return _.where(this.options.geoData, { - GeoCode: d.properties.lad16cd + return _.where(this.options.geoData, { + GeoCode: d.properties[this.options.idProperty] }); } @@ -223,12 +206,12 @@ var yearValues = getYearValues.call(this, d), isInScope = this.isInScope(d), content = '

' + getName(d) + '

'; - + if(yearValues.length) { content += '
' + that._model.chartTitle + '
' + - _.map(_.pluck(yearValues, 'Year'), function(year) { return ''; }).join('') + - '' + - _.map(_.pluck(yearValues, 'Value'), function(value) { return ''; }).join('') + + _.map(_.pluck(yearValues, 'Year'), function(year) { return ''; }).join('') + + '' + + _.map(_.pluck(yearValues, 'Value'), function(value) { return ''; }).join('') + '
' + year + '
' + value + '' + year + '
' + value + '
'; } else { if(!isInScope) { @@ -254,7 +237,7 @@ function clicked(d) { var x, y, k; - if(!this.isInScope(d)) { + if(!that.isInScope(d)) { return; } @@ -285,8 +268,8 @@ // Highlight the clicked area this.mapLayer .selectAll('path') - .style('stroke', function(d) { - return centered && d === centered ? '#000' : '#ccc'; + .style('stroke', function(d) { + return centered && d === centered ? '#000' : '#ccc'; }) .attr('class', function(d) { return centered && d === centered ? 'selected' : ''; @@ -299,12 +282,12 @@ } function mouseover(d){ - // ensure that this element doesn't go after a selected element, if any: + // ensure that this element doesn't go after a selected element, if any: var selected = d3.select('path.selected').node(); if(selected) { d3.select(this.parentNode.insertBefore(this, selected)).style('stroke', '#000'); - + } else { d3.select(this.parentNode.appendChild(this)) .style('stroke', '#000'); @@ -329,8 +312,8 @@ } }, isInScope: function(d) { - return d === null ? true : d.properties.lad16cd.match(this.options.geoCodeRegEx); - } + return d === null ? true : d.properties[this.options.idProperty].match(this.options.geoCodeRegEx); + } }; // A really lightweight plugin wrapper around the constructor, diff --git a/assets/js/reportingStatus.js b/_includes/assets/js/reportingStatus.js similarity index 100% rename from assets/js/reportingStatus.js rename to _includes/assets/js/reportingStatus.js diff --git a/assets/js/search.js b/_includes/assets/js/search.js similarity index 90% rename from assets/js/search.js rename to _includes/assets/js/search.js index 56628ec..5929138 100644 --- a/assets/js/search.js +++ b/_includes/assets/js/search.js @@ -28,7 +28,7 @@ var indicatorSearch = function(inputElement, indicatorDataStore) { }; if($('#main-content').hasClass('search-results')) { - + var results = [], that = this, searchString = unescape(location.search.substring(1)); @@ -38,7 +38,7 @@ var indicatorSearch = function(inputElement, indicatorDataStore) { $('#main-content h1 span').text(searchString); $('#main-content h1').show(); - + this.indicatorDataStore.getData().then(function(data) { that.processData(data); @@ -52,7 +52,7 @@ var indicatorSearch = function(inputElement, indicatorDataStore) { // goal // indicators // goal - // indicators + // indicators _.each(searchResults, function(result) { var goal = _.findWhere(results, { goalId: result.goalId }), @@ -100,7 +100,6 @@ indicatorSearch.prototype = { $(function() { - $('#main-nav').append(''); var $el = $('#indicator_search'); new indicatorSearch($el, new indicatorDataStore($el.data('url'))); diff --git a/_includes/components/breadcrumb.html b/_includes/components/breadcrumb.html index 4be8eee..b3a6c17 100644 --- a/_includes/components/breadcrumb.html +++ b/_includes/components/breadcrumb.html @@ -1,9 +1,9 @@ \ No newline at end of file diff --git a/_includes/components/charts/binary.html b/_includes/components/charts/binary.html new file mode 100644 index 0000000..6339490 --- /dev/null +++ b/_includes/components/charts/binary.html @@ -0,0 +1,45 @@ +{% assign unit_label = page.variable_unit_label %} + + diff --git a/_includes/components/charts/chart.html b/_includes/components/charts/chart.html index f45a612..0748f0a 100644 --- a/_includes/components/charts/chart.html +++ b/_includes/components/charts/chart.html @@ -1,11 +1,11 @@ -{% if meta.graph_type == 'bar' or meta.graph_type == 'line' %} +{% if meta.graph_type %} {% assign graph_type = meta.graph_type %} {% if meta.graph_type == 'longitudinal' %} {% assign graph_type = 'line' %} {% endif %} {% assign graph_template = 'components/charts/' | append: graph_type | append: '.html' %} @@ -14,6 +14,6 @@
-
- +
+ {% endif %} diff --git a/_includes/components/dev-disclaimer.html b/_includes/components/dev-disclaimer.html index 8b82b2d..aacfec3 100644 --- a/_includes/components/dev-disclaimer.html +++ b/_includes/components/dev-disclaimer.html @@ -1,6 +1,6 @@
-
\ No newline at end of file + diff --git a/_includes/components/fields-template.html b/_includes/components/fields-template.html index b893b19..789d0d6 100644 --- a/_includes/components/fields-template.html +++ b/_includes/components/fields-template.html @@ -7,8 +7,8 @@
- - + +
<% _.each(seriesItem.values, function(item) { %> @@ -17,10 +17,13 @@ <% if(allowedFields.indexOf(seriesItem.field) == -1) { %>
- Available when '<%= _.findWhere(edges, { To: seriesItem.field }).From %>' is selected + {%- capture var_hint_replacement -%} + {% raw %}<%= _.findWhere(edges, { To: seriesItem.field }).From %>{% endraw %} + {%- endcapture -%} + {{ t.indicator.variable_hint | replace_first: '%field', var_hint_replacement }}
- No options available because of filters above + {{ t.indicator.no_data_hint }}
<% }%> diff --git a/_includes/components/headline.html b/_includes/components/headline.html index 4eec3a9..1d71e40 100644 --- a/_includes/components/headline.html +++ b/_includes/components/headline.html @@ -5,9 +5,9 @@
- Download Headline CSV + {{ t.indicator.download_headline }} - Download Source CSV + {{ t.indicator.download_source }}

Headline data

@@ -39,16 +39,16 @@

Headline data

{% if page.source_organisation_1.size %} -

Source: {{ page.source_organisation_1 }}

+

{{ t.indicator.source }}: {{ page.source_organisation_1 }}

{% endif %} {% if page.national_geographical_coverage.size %} -

Geographical Area: {{ page.national_geographical_coverage }}

+

{{ t.indicator.geographical_area }}: {{ page.national_geographical_coverage }}

{% endif %} {% if page.computation_units.size %} -

Unit of Measurement: {{ page.computation_units }}

+

{{ t.indicator.unit_of_measurement }}: {{ page.computation_units }}

{% endif %} {% if page.data_footnote.size %} -

Footnote: {{ page.data_footnote }}

+

{{ t.indicator.footnote }}: {{ page.data_footnote }}

{% endif %}
diff --git a/_includes/components/indicator-content.html b/_includes/components/indicator-content.html new file mode 100644 index 0000000..68db61d --- /dev/null +++ b/_includes/components/indicator-content.html @@ -0,0 +1,3 @@ +
+ {{ meta.page_content | markdownify }} +
diff --git a/_includes/components/language-toggle.html b/_includes/components/language-toggle.html new file mode 100644 index 0000000..00c1610 --- /dev/null +++ b/_includes/components/language-toggle.html @@ -0,0 +1,24 @@ + + + {{ t.languages[current_language] }} + + + + diff --git a/_includes/components/loading.html b/_includes/components/loading.html index 9e55eee..82181e6 100644 --- a/_includes/components/loading.html +++ b/_includes/components/loading.html @@ -1,3 +1,3 @@
- Loading search results + {{ t.general.loading }}
diff --git a/_includes/components/metadata.html b/_includes/components/metadata.html index e4a9b35..6392433 100644 --- a/_includes/components/metadata.html +++ b/_includes/components/metadata.html @@ -1,9 +1,14 @@ {% for indicator_metadata in site.data.schema %} + {%- if t.metadata_fields[indicator_metadata.name] -%} + {%- assign metadata_label = t.metadata_fields[indicator_metadata.name] -%} + {%- else -%} + {%- assign metadata_label = indicator_metadata.field.label -%} + {%- endif -%} {% if indicator_metadata.field.scope == include.scope %} {% unless indicator_metadata.name contains "_url_text" or indicator_metadata.name contains "_link_text" %} - +
{{ indicator_metadata.field.label }} {{ metadata_label }} {% if indicator_metadata.name contains "_url" or indicator_metadata.name contains "_link" %} {% assign url_text_name = indicator_metadata.name | replace_first:'_url','_url_text' %} @@ -15,10 +20,10 @@ {% if meta[indicator_metadata.name] contains "http" or meta[indicator_metadata.name] contains "mailto" %} - {{ url_text }} opens in a new window + {{ url_text }} {{ t.general.opens_new_window }} {% endif %} - + {% else %} {{ meta[indicator_metadata.name] }} {% endif %} diff --git a/_includes/components/post-categories.html b/_includes/components/post-categories.html index d2338bc..290a65a 100644 --- a/_includes/components/post-categories.html +++ b/_includes/components/post-categories.html @@ -1,10 +1,10 @@