From 66077f82f789d46525fef27aa74c3e88aaa60c3e Mon Sep 17 00:00:00 2001 From: Robert Oikle Date: Fri, 8 Jan 2021 05:49:05 -0500 Subject: [PATCH] Code Clean-up --- basic-tools/components/evented.js | 4 +- basic-tools/components/tooltip.js | 5 ++- lode-viewer/application.js | 32 +++++++-------- lode-viewer/configuration.js | 6 +-- lode-viewer/docs/add-dataset.md | 66 +++++++++++++++---------------- lode-viewer/index.css | 4 -- mapbox-tools/components/map.js | 38 +----------------- mapbox-tools/controls/download.js | 10 ++--- mapbox-tools/controls/legend.js | 24 +++++------ mapbox-tools/controls/toc.js | 8 ++-- 10 files changed, 78 insertions(+), 119 deletions(-) diff --git a/basic-tools/components/evented.js b/basic-tools/components/evented.js index 2271f122a..e08904e9a 100644 --- a/basic-tools/components/evented.js +++ b/basic-tools/components/evented.js @@ -20,9 +20,9 @@ export default class Evented { removeEventListener(type, callback){ if (!(type in this.listeners)) return; - + var stack = this.listeners[type]; - + for (var i = 0, l = stack.length; i < l; i++){ if (stack[i].callback === callback){ stack.splice(i, 1); diff --git a/basic-tools/components/tooltip.js b/basic-tools/components/tooltip.js index 159564e1e..cfe744a7e 100644 --- a/basic-tools/components/tooltip.js +++ b/basic-tools/components/tooltip.js @@ -18,11 +18,12 @@ export default class Tooltip extends Templated { Template() { return '
' + - '
' + - '
'; + '
' + + ''; } PositionTarget(target, offset) { + var bbox1, bbox2; offset = offset || [0,0]; bbox1 = target.getBoundingClientRect(); diff --git a/lode-viewer/application.js b/lode-viewer/application.js index 5d3bd0282..2165f898b 100644 --- a/lode-viewer/application.js +++ b/lode-viewer/application.js @@ -44,20 +44,20 @@ export default class LodeApp extends Templated { return "
nls(Map_Presentation_1)
" + //"
nls(Map_Presentation_2)
" + "
" + - "nls(Inv_Search_Instructions)" + - "" + - "
" + - "nls(Inv_Skip_Link)" + - "
" + - "
" + - "
" + - "
" + - "
" + - "
" + - "
" + - "
"; + "nls(Inv_Search_Instructions)" + + "" + + "
" + + "nls(Inv_Skip_Link)" + + "
" + + "" + + "
" + + "
" + + "
" + + "
" + + "
" + + "
"; } /** @@ -243,8 +243,8 @@ export default class LodeApp extends Templated { } if (layerType === 'symbol') { - this.map.ChoroplethVarOpac( [this.current.LayerIDs[i]] , 'text-color', this.current.Legend, opacities); - this.map.ChoroplethVarOpac( [this.current.LayerIDs[i]] , 'text-halo-color', this.current.Legend, opacities); + this.map.ChoroplethVarOpac( [this.current.LayerIDs[i]] , 'text-color', this.current.Legend, opacities); + this.map.ChoroplethVarOpac( [this.current.LayerIDs[i]] , 'text-halo-color', this.current.Legend, opacities); } } } diff --git a/lode-viewer/configuration.js b/lode-viewer/configuration.js index 2a40915e4..3e26bb327 100644 --- a/lode-viewer/configuration.js +++ b/lode-viewer/configuration.js @@ -133,7 +133,7 @@ export default class Configuration { * Get a list of layer ids for selected layers * @returns - List of selected layers ids. */ - get SelectedLayerIDs()  { + get SelectedLayerIDs() { var layers = this.SelectedLayers; return layers && layers.map(l => l.id); @@ -186,9 +186,7 @@ export default class Configuration { * @returns - list of legend item objects. */ get Legend() { - if (this.legend) { - return this.MapLegendItems(this.legend); - } + return this.legend && this.MapLegendItems(this.legend); } /** diff --git a/lode-viewer/docs/add-dataset.md b/lode-viewer/docs/add-dataset.md index 50ca760ba..09998ac3b 100644 --- a/lode-viewer/docs/add-dataset.md +++ b/lode-viewer/docs/add-dataset.md @@ -120,45 +120,45 @@ The rest of the `config.map.[dataset name].json` should be updated to reflect th Group Example: ``` "legend": [ - { - "color": [255, 0, 0], - "label": { - "en": "A", - "fr": "A" - }, - "value": ["==", ["get", "type"], "A"] - }, - { - "group": { - "en": "B Group", - "fr": "Groupe B" + { + "color": [255, 0, 0], + "label": { + "en": "A", + "fr": "A" + }, + "value": ["==", ["get", "type"], "A"] + }, + { + "group": { + "en": "B Group", + "fr": "Groupe B" }, "items": [ { - "color": [0, 0, 128], - "label": { - "en": "B-1", - "fr": "B-1" - }, - "value": ["==", ["get", "type"], "B-1"] - }, + "color": [0, 0, 128], + "label": { + "en": "B-1", + "fr": "B-1" + }, + "value": ["==", ["get", "type"], "B-1"] + }, { - "color": [0, 0, 255], - "label": { - "en": "B-2", - "fr": "B-2" - }, - "value": ["==", ["get", "type"], "B-2"] - } + "color": [0, 0, 255], + "label": { + "en": "B-2", + "fr": "B-2" + }, + "value": ["==", ["get", "type"], "B-2"] + } ] }, - { - "color": [0, 255, 0], - "label": { - "en": "Other", - "fr": "Autres" - } - } + { + "color": [0, 255, 0], + "label": { + "en": "Other", + "fr": "Autres" + } + } ] ``` diff --git a/lode-viewer/index.css b/lode-viewer/index.css index 9db6db51f..7195475ca 100644 --- a/lode-viewer/index.css +++ b/lode-viewer/index.css @@ -450,10 +450,6 @@ body { background : initial; } -.lode .table-widget table thead tr { - -} - .lode .table-widget table tr { border-bottom : solid thin silver; } diff --git a/mapbox-tools/components/map.js b/mapbox-tools/components/map.js index 4665a42ee..76dd875e3 100644 --- a/mapbox-tools/components/map.js +++ b/mapbox-tools/components/map.js @@ -153,7 +153,7 @@ export default class Map extends Evented { filter: options.filter, paint: options.circle_paint }); - + // Add cluster count labels layer this.map.addLayer({ id: (options.id || options.source) + '_cluster-count', @@ -244,42 +244,6 @@ export default class Map extends Evented { return layerPaintProperty; } - /** - * Get the layer color paint property name based on layer type - * @param {string} layerType - The layer type - */ - GetLayerColorPropertyByType(layerType) { - let layerPaintProperty; - - switch (layerType) { - case 'circle': - layerPaintProperty = 'circle-color'; - break; - case 'line': - layerPaintProperty = 'line-color'; - break; - case 'fill': - layerPaintProperty = 'fill-color'; - break; - case 'symbol': - layerPaintProperty = 'icon-color'; - break; - case 'background': - layerPaintProperty = 'background-color'; - break; - case 'heatmap': - layerPaintProperty = 'heatmap-color'; - break; - case 'fill-extrusion': - layerPaintProperty = 'fill-extrusion-color'; - break; - default: - layerPaintProperty = 'circle-color'; - } - - return layerPaintProperty; - } - /** * Method to update a style property for a layer * @param {string} layerId - Name of the map layer diff --git a/mapbox-tools/controls/download.js b/mapbox-tools/controls/download.js index d89b0c7df..606b5e056 100644 --- a/mapbox-tools/controls/download.js +++ b/mapbox-tools/controls/download.js @@ -8,15 +8,15 @@ export default class Download extends Control { super(options); this._container = this.Node('root'); - + if (options.link) this.Node('link').setAttribute('href', options.link); } Template() { return "
" + - "
" + - "nls(Download_Title)" + - "
" + - "
"; + "
" + + "nls(Download_Title)" + + "
" + + ""; } } \ No newline at end of file diff --git a/mapbox-tools/controls/legend.js b/mapbox-tools/controls/legend.js index 1023c076e..eeb6812c9 100644 --- a/mapbox-tools/controls/legend.js +++ b/mapbox-tools/controls/legend.js @@ -6,7 +6,7 @@ let n = 0; export default class Legend extends Control { - constructor(options) { + constructor(options) { super(options); this._container = this.Node('root'); @@ -17,7 +17,7 @@ export default class Legend extends Control { this.Reload(options.legend, options.title, options.banner, options.subtitle); } - Reload(legend, title, banner, subtitle) { + Reload(legend, title, banner, subtitle) { this.LoadLegend(legend); if (banner) this.Node('banner').innerHTML = banner; @@ -75,11 +75,11 @@ export default class Legend extends Control { lbl.setAttribute("for", id); this.chkBoxes.push(chkBox) - + chkBox.addEventListener("change", this.OnCheckbox_Checked.bind(this)); - + icn.setAttribute('fill', `rgb(${item.color.join(",")})`); - + this.chkBoxesState.push({ item:item, checkbox:chkBox }); return div; @@ -92,12 +92,12 @@ export default class Legend extends Control { Template() { return "
" + - "
" + - "
" + - "
" + - "
" + - "
" + - "
" + - "
"; + "
" + + "
" + + "
" + + "
" + + "
" + + "
" + + ""; } } \ No newline at end of file diff --git a/mapbox-tools/controls/toc.js b/mapbox-tools/controls/toc.js index ba26b72a2..895bf0fbc 100644 --- a/mapbox-tools/controls/toc.js +++ b/mapbox-tools/controls/toc.js @@ -8,7 +8,7 @@ export default class Toc extends Control { super(options); this._container = this.Node('root'); - + this.Reload(options.toc); } @@ -57,8 +57,8 @@ export default class Toc extends Control { Template() { return "
" + - "
nls(Toc_Instruction)
" + - "
" + - "
"; + "
nls(Toc_Instruction)
" + + "
" + + ""; } } \ No newline at end of file