Automated class transform

npx lebab --replace src --transform class
This commit is contained in:
Tim Schaub
2018-07-16 16:18:16 -06:00
parent 60e85e7d89
commit 7b4a73f3b9
145 changed files with 32887 additions and 33714 deletions
+189 -196
View File
@@ -156,162 +156,223 @@ inherits(SelectEvent, Event);
* @fires SelectEvent
* @api
*/
const Select = function(opt_options) {
class Select {
constructor(opt_options) {
Interaction.call(this, {
handleEvent: handleEvent
});
Interaction.call(this, {
handleEvent: handleEvent
});
const options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.condition_ = options.condition ? options.condition : singleClick;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.condition_ = options.condition ? options.condition : singleClick;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.addCondition_ = options.addCondition ? options.addCondition : never;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.addCondition_ = options.addCondition ? options.addCondition : never;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
/**
* @private
* @type {module:ol/events/condition~Condition}
*/
this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
/**
* @private
* @type {boolean}
*/
this.multi_ = options.multi ? options.multi : false;
/**
* @private
* @type {boolean}
*/
this.multi_ = options.multi ? options.multi : false;
/**
* @private
* @type {module:ol/interaction/Select~FilterFunction}
*/
this.filter_ = options.filter ? options.filter : TRUE;
/**
* @private
* @type {module:ol/interaction/Select~FilterFunction}
*/
this.filter_ = options.filter ? options.filter : TRUE;
/**
* @private
* @type {number}
*/
this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0;
/**
* @private
* @type {number}
*/
this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0;
const featureOverlay = new VectorLayer({
source: new VectorSource({
useSpatialIndex: false,
features: options.features,
wrapX: options.wrapX
}),
style: options.style ? options.style :
getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
const featureOverlay = new VectorLayer({
source: new VectorSource({
useSpatialIndex: false,
features: options.features,
wrapX: options.wrapX
}),
style: options.style ? options.style :
getDefaultStyleFunction(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
/**
* @private
* @type {module:ol/layer/Vector}
*/
this.featureOverlay_ = featureOverlay;
/**
* @private
* @type {module:ol/layer/Vector}
*/
this.featureOverlay_ = featureOverlay;
/** @type {function(module:ol/layer/Layer): boolean} */
let layerFilter;
if (options.layers) {
if (typeof options.layers === 'function') {
layerFilter = options.layers;
/** @type {function(module:ol/layer/Layer): boolean} */
let layerFilter;
if (options.layers) {
if (typeof options.layers === 'function') {
layerFilter = options.layers;
} else {
const layers = options.layers;
layerFilter = function(layer) {
return includes(layers, layer);
};
}
} else {
const layers = options.layers;
layerFilter = function(layer) {
return includes(layers, layer);
};
layerFilter = TRUE;
}
} else {
layerFilter = TRUE;
/**
* @private
* @type {function(module:ol/layer/Layer): boolean}
*/
this.layerFilter_ = layerFilter;
/**
* An association between selected feature (key)
* and layer (value)
* @private
* @type {Object.<number, module:ol/layer/Layer>}
*/
this.featureLayerAssociation_ = {};
const features = this.featureOverlay_.getSource().getFeaturesCollection();
listen(features, CollectionEventType.ADD,
this.addFeature_, this);
listen(features, CollectionEventType.REMOVE,
this.removeFeature_, this);
}
/**
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
* @param {module:ol/layer/Layer} layer Layer.
* @private
* @type {function(module:ol/layer/Layer): boolean}
*/
this.layerFilter_ = layerFilter;
addFeatureLayerAssociation_(feature, layer) {
const key = getUid(feature);
this.featureLayerAssociation_[key] = layer;
}
/**
* An association between selected feature (key)
* and layer (value)
* @private
* @type {Object.<number, module:ol/layer/Layer>}
* Get the selected features.
* @return {module:ol/Collection.<module:ol/Feature>} Features collection.
* @api
*/
this.featureLayerAssociation_ = {};
getFeatures() {
return this.featureOverlay_.getSource().getFeaturesCollection();
}
const features = this.featureOverlay_.getSource().getFeaturesCollection();
listen(features, CollectionEventType.ADD,
this.addFeature_, this);
listen(features, CollectionEventType.REMOVE,
this.removeFeature_, this);
/**
* Returns the Hit-detection tolerance.
* @returns {number} Hit tolerance in pixels.
* @api
*/
getHitTolerance() {
return this.hitTolerance_;
}
};
/**
* Returns the associated {@link module:ol/layer/Vector~Vector vectorlayer} of
* the (last) selected feature. Note that this will not work with any
* programmatic method like pushing features to
* {@link module:ol/interaction/Select~Select#getFeatures collection}.
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature
* @return {module:ol/layer/Vector} Layer.
* @api
*/
getLayer(feature) {
const key = getUid(feature);
return (
/** @type {module:ol/layer/Vector} */ (this.featureLayerAssociation_[key])
);
}
/**
* Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features. This only works for the canvas renderer and
* not for WebGL.
* @param {number} hitTolerance Hit tolerance in pixels.
* @api
*/
setHitTolerance(hitTolerance) {
this.hitTolerance_ = hitTolerance;
}
/**
* Remove the interaction from its current map, if any, and attach it to a new
* map, if any. Pass `null` to just remove the interaction from the current map.
* @param {module:ol/PluggableMap} map Map.
* @override
* @api
*/
setMap(map) {
const currentMap = this.getMap();
const selectedFeatures =
this.featureOverlay_.getSource().getFeaturesCollection();
if (currentMap) {
selectedFeatures.forEach(currentMap.unskipFeature.bind(currentMap));
}
Interaction.prototype.setMap.call(this, map);
this.featureOverlay_.setMap(map);
if (map) {
selectedFeatures.forEach(map.skipFeature.bind(map));
}
}
/**
* @param {module:ol/Collection~CollectionEvent} evt Event.
* @private
*/
addFeature_(evt) {
const map = this.getMap();
if (map) {
map.skipFeature(/** @type {module:ol/Feature} */ (evt.element));
}
}
/**
* @param {module:ol/Collection~CollectionEvent} evt Event.
* @private
*/
removeFeature_(evt) {
const map = this.getMap();
if (map) {
map.unskipFeature(/** @type {module:ol/Feature} */ (evt.element));
}
}
/**
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
* @private
*/
removeFeatureLayerAssociation_(feature) {
const key = getUid(feature);
delete this.featureLayerAssociation_[key];
}
}
inherits(Select, Interaction);
/**
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
* @param {module:ol/layer/Layer} layer Layer.
* @private
*/
Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
const key = getUid(feature);
this.featureLayerAssociation_[key] = layer;
};
/**
* Get the selected features.
* @return {module:ol/Collection.<module:ol/Feature>} Features collection.
* @api
*/
Select.prototype.getFeatures = function() {
return this.featureOverlay_.getSource().getFeaturesCollection();
};
/**
* Returns the Hit-detection tolerance.
* @returns {number} Hit tolerance in pixels.
* @api
*/
Select.prototype.getHitTolerance = function() {
return this.hitTolerance_;
};
/**
* Returns the associated {@link module:ol/layer/Vector~Vector vectorlayer} of
* the (last) selected feature. Note that this will not work with any
* programmatic method like pushing features to
* {@link module:ol/interaction/Select~Select#getFeatures collection}.
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature
* @return {module:ol/layer/Vector} Layer.
* @api
*/
Select.prototype.getLayer = function(feature) {
const key = getUid(feature);
return (
/** @type {module:ol/layer/Vector} */ (this.featureLayerAssociation_[key])
);
};
/**
* Handles the {@link module:ol/MapBrowserEvent map browser event} and may change the
* selected state of features.
@@ -405,40 +466,6 @@ function handleEvent(mapBrowserEvent) {
}
/**
* Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features. This only works for the canvas renderer and
* not for WebGL.
* @param {number} hitTolerance Hit tolerance in pixels.
* @api
*/
Select.prototype.setHitTolerance = function(hitTolerance) {
this.hitTolerance_ = hitTolerance;
};
/**
* Remove the interaction from its current map, if any, and attach it to a new
* map, if any. Pass `null` to just remove the interaction from the current map.
* @param {module:ol/PluggableMap} map Map.
* @override
* @api
*/
Select.prototype.setMap = function(map) {
const currentMap = this.getMap();
const selectedFeatures =
this.featureOverlay_.getSource().getFeaturesCollection();
if (currentMap) {
selectedFeatures.forEach(currentMap.unskipFeature.bind(currentMap));
}
Interaction.prototype.setMap.call(this, map);
this.featureOverlay_.setMap(map);
if (map) {
selectedFeatures.forEach(map.skipFeature.bind(map));
}
};
/**
* @return {module:ol/style/Style~StyleFunction} Styles.
*/
@@ -456,38 +483,4 @@ function getDefaultStyleFunction() {
}
/**
* @param {module:ol/Collection~CollectionEvent} evt Event.
* @private
*/
Select.prototype.addFeature_ = function(evt) {
const map = this.getMap();
if (map) {
map.skipFeature(/** @type {module:ol/Feature} */ (evt.element));
}
};
/**
* @param {module:ol/Collection~CollectionEvent} evt Event.
* @private
*/
Select.prototype.removeFeature_ = function(evt) {
const map = this.getMap();
if (map) {
map.unskipFeature(/** @type {module:ol/Feature} */ (evt.element));
}
};
/**
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
* @private
*/
Select.prototype.removeFeatureLayerAssociation_ = function(feature) {
const key = getUid(feature);
delete this.featureLayerAssociation_[key];
};
export default Select;