Skip to content

Commit

Permalink
Code Clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
roikle committed Jan 8, 2021
1 parent 32ddca1 commit 66077f8
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 119 deletions.
4 changes: 2 additions & 2 deletions basic-tools/components/evented.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions basic-tools/components/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export default class Tooltip extends Templated {

Template() {
return '<div handle="root" class="tooltip">' +
'<div handle="content"></div>' +
'</div>';
'<div handle="content"></div>' +
'</div>';
}

PositionTarget(target, offset) {
var bbox1, bbox2;
offset = offset || [0,0];

bbox1 = target.getBoundingClientRect();
Expand Down
32 changes: 16 additions & 16 deletions lode-viewer/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ export default class LodeApp extends Templated {
return "<div handle='presentation' class='instructions'>nls(Map_Presentation_1)</div>" +
//"<div handle='presentation' class='instructions'>nls(Map_Presentation_2)</div>" +
"<div class='search-container'>" +
"<span class='wb-inv'>nls(Inv_Search_Instructions)</span>" +
"<label class='search-label'>nls(App_Search_Label)" +
"<div handle='search' class='search'></div>" +
"</label>" +
"<div class='inv-container'>" +
"<a href='#lode-table' class='wb-inv wb-show-onfocus wb-sl'>nls(Inv_Skip_Link)</a>" +
"</div>" +
"</div>" +
"<div class='map-container'>" +
"<div handle='map' class='map'></div>" +
"</div>" +
"<div class='table-container'>" +
"<div handle='table' class='table'></div>" +
"</div>";
"<span class='wb-inv'>nls(Inv_Search_Instructions)</span>" +
"<label class='search-label'>nls(App_Search_Label)" +
"<div handle='search' class='search'></div>" +
"</label>" +
"<div class='inv-container'>" +
"<a href='#lode-table' class='wb-inv wb-show-onfocus wb-sl'>nls(Inv_Skip_Link)</a>" +
"</div>" +
"</div>" +
"<div class='map-container'>" +
"<div handle='map' class='map'></div>" +
"</div>" +
"<div class='table-container'>" +
"<div handle='table' class='table'></div>" +
"</div>";
}

/**
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions lode-viewer/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down
66 changes: 33 additions & 33 deletions lode-viewer/docs/add-dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
```

Expand Down
4 changes: 0 additions & 4 deletions lode-viewer/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,6 @@ body {
background : initial;
}

.lode .table-widget table thead tr {

}

.lode .table-widget table tr {
border-bottom : solid thin silver;
}
Expand Down
38 changes: 1 addition & 37 deletions mapbox-tools/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions mapbox-tools/controls/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<div handle='root' class='download mapboxgl-ctrl'>" +
"<div class='control-label'>" +
"<a handle='link' target='_blank' class='link'>nls(Download_Title)</a>" +
"</div>" +
"</div>";
"<div class='control-label'>" +
"<a handle='link' target='_blank' class='link'>nls(Download_Title)</a>" +
"</div>" +
"</div>";
}
}
24 changes: 12 additions & 12 deletions mapbox-tools/controls/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let n = 0;

export default class Legend extends Control {

constructor(options) {
constructor(options) {
super(options);

this._container = this.Node('root');
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -92,12 +92,12 @@ export default class Legend extends Control {

Template() {
return "<div handle='root' class='legend mapboxgl-ctrl'>" +
"<div handle='banner' class='control-label legend-banner'></div>" +
"<div>" +
"<div handle='title' class='control-label'></div>" +
"<div handle='subtitle' class='control-label legend-subtitle'></div>" +
"</div>" +
"<div handle='legend' class='legend-container'></div>" +
"</div>";
"<div handle='banner' class='control-label legend-banner'></div>" +
"<div>" +
"<div handle='title' class='control-label'></div>" +
"<div handle='subtitle' class='control-label legend-subtitle'></div>" +
"</div>" +
"<div handle='legend' class='legend-container'></div>" +
"</div>";
}
}
8 changes: 4 additions & 4 deletions mapbox-tools/controls/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class Toc extends Control {
super(options);

this._container = this.Node('root');

this.Reload(options.toc);
}

Expand Down Expand Up @@ -57,8 +57,8 @@ export default class Toc extends Control {

Template() {
return "<div handle='root' class='toc mapboxgl-ctrl'>" +
"<div class='control-label'>nls(Toc_Instruction)</div>" +
"<div handle='toc' class='legend-container toc-container'></div>" +
"</div>";
"<div class='control-label'>nls(Toc_Instruction)</div>" +
"<div handle='toc' class='legend-container toc-container'></div>" +
"</div>";
}
}

0 comments on commit 66077f8

Please sign in to comment.