Skip to content

Commit

Permalink
Corrected file according to eslint
Browse files Browse the repository at this point in the history
standardized the format of the .js file
  • Loading branch information
AlexThomasEOG committed Jan 14, 2016
1 parent 37a1c63 commit cdf2533
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions viewer/js/gis/dijit/LayerControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ define([
this.overlayReorder = false;
this.vectorReorder = false;
}
this._addLayerControls(this.layerInfos);
this._subscribeToTopics();
this._addLayerControls(this.layerInfos);
this._subscribeToTopics();
},
_subscribeToTopics() {
_subscribeToTopics: function () {
this._removeLayerControlsHandler = topic.subscribe('layerControl/removeLayerControls', lang.hitch(this, function (layerTitles) {
this._removeLayerControls(layerTitles);
this._removeLayerControls(layerTitles);
}));
this._addLayerControlsHandler = topic.subscribe('layerControl/addLayerControls', lang.hitch(this, function (layerInfos) {
this._addLayerControls(layerInfos);
this._addLayerControls(layerInfos);
}));
},
_addLayerControls: function(layerInfos) {
// load only the modules we need
},
_addLayerControls: function (layerInfos) {
// load only the modules we need
var modules = [];
// push layer control mods
array.forEach(layerInfos, function (layerInfo) {
Expand Down Expand Up @@ -164,32 +164,39 @@ define([
}, this);
this._checkReorder();
}));
},
},
// remove the control given an array of layerTitles
_removeLayerControls: function (layerTitles) {
// helper function to determine which children's title have a match in the layerTitles parameter
var _filterList = function (entry) {
return layerTitles.reduce(function(prior,curr){ return (curr === entry.layerTitle)||prior}, false);
}
// get a list of ALL the layers that meet the criteria
var layerControlList = this._overlayContainer.getChildren().filter( function(c) { return _filterList(c)}).concat(
this._vectorContainer.getChildren().filter( function(c) { return _filterList(c)}).concat(
this.getChildren().filter( function(c) { return _filterList(c)})
)
);
// follow the same logic as when the layers were added
array.forEach(layerControlList, lang.hitch(this, function (layerControl) {
if (this.separated) {
if (layerControl._layerType === 'overlay') {
this._overlayContainer.removeChild(layerControl);
} else {
this._vectorContainer.removeChild(layerControl);
}
}
else {
this.removeChild(layerControl);
}
}));
// helper function to determine which children's title have a match in the layerTitles parameter
function _filterList (entry) {
return layerTitles.reduce(function (prior, curr) {
return (curr === entry.layerTitle) || prior;
}, false);
}
// get a list of ALL the layers that meet the criteria
var layerControlList = this._overlayContainer.getChildren().filter(function (c) {
return _filterList(c);
}).concat(
this._vectorContainer.getChildren().filter(function (c) {
return _filterList(c);
})).concat(
this.getChildren().filter(function (c) {
return _filterList(c);
}));


// follow the same logic as when the layers were added
array.forEach(layerControlList, lang.hitch(this, function (layerControl) {
if (this.separated) {
if (layerControl._layerType === 'overlay') {
this._overlayContainer.removeChild(layerControl);
} else {
this._vectorContainer.removeChild(layerControl);
}
} else {
this.removeChild(layerControl);
}
}));
},
// create layer control and add to appropriate _container
_addControl: function (layerInfo, Control) {
Expand Down

0 comments on commit cdf2533

Please sign in to comment.