Fixed JavaScript "indent" violations.

This commit is contained in:
Tim Graham 2015-07-17 09:00:01 -04:00
parent 8606bea3bc
commit b647d64408
1 changed files with 348 additions and 349 deletions

View File

@ -1,11 +1,10 @@
/*global OpenLayers*/
/*eslint indent:1*/
(function() {
/**
* Transforms an array of features to a single feature with the merged
* geometry of geom_type
*/
OpenLayers.Util.properFeatures = function(features, geom_type) {
OpenLayers.Util.properFeatures = function(features, geom_type) {
if (features.constructor === Array) {
var geoms = [];
for (var i=0; i<features.length; i++) {
@ -15,13 +14,13 @@ OpenLayers.Util.properFeatures = function(features, geom_type) {
features = new OpenLayers.Feature.Vector(geom);
}
return features;
};
};
/**
/**
* @requires OpenLayers/Format/WKT.js
*/
/**
/**
* Class: OpenLayers.Format.DjangoWKT
* Class for reading Well-Known Text, with workarounds to successfully parse
* geometries and collections as returned by django.contrib.gis.geos.
@ -30,7 +29,7 @@ OpenLayers.Util.properFeatures = function(features, geom_type) {
* - <OpenLayers.Format.WKT>
*/
OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
initialize: function(options) {
OpenLayers.Format.WKT.prototype.initialize.apply(this, [options]);
this.regExes.justComma = /\s*,\s*/;
@ -160,9 +159,9 @@ OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
},
CLASS_NAME: "OpenLayers.Format.DjangoWKT"
});
});
function MapWidget(options) {
function MapWidget(options) {
this.map = null;
this.controls = null;
this.panel = null;
@ -261,9 +260,9 @@ function MapWidget(options) {
} else {
this.enableDrawing();
}
}
}
MapWidget.prototype.create_map = function() {
MapWidget.prototype.create_map = function() {
var map = new OpenLayers.Map(this.options.map_id, this.options.map_options);
if (this.options.base_layer) {
this.layers.base = this.options.base_layer;
@ -272,21 +271,21 @@ MapWidget.prototype.create_map = function() {
}
map.addLayer(this.layers.base);
return map;
};
};
MapWidget.prototype.get_ewkt = function(feat) {
MapWidget.prototype.get_ewkt = function(feat) {
return "SRID=" + this.options.map_srid + ";" + this.wkt_f.write(feat);
};
};
MapWidget.prototype.read_wkt = function(wkt) {
MapWidget.prototype.read_wkt = function(wkt) {
var prefix = 'SRID=' + this.options.map_srid + ';';
if (wkt.indexOf(prefix) === 0) {
wkt = wkt.slice(prefix.length);
}
return this.wkt_f.read(wkt);
};
};
MapWidget.prototype.write_wkt = function(feat) {
MapWidget.prototype.write_wkt = function(feat) {
feat = OpenLayers.Util.properFeatures(feat, this.options.geom_type);
if (this.options.is_collection) {
this.num_geom = feat.geometry.components.length;
@ -294,9 +293,9 @@ MapWidget.prototype.write_wkt = function(feat) {
this.num_geom = 1;
}
document.getElementById(this.options.id).value = this.get_ewkt(feat);
};
};
MapWidget.prototype.add_wkt = function(event) {
MapWidget.prototype.add_wkt = function(event) {
if (this.options.is_collection) {
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
for (var i=0; i<this.layers.vector.features.length; i++) {
@ -311,9 +310,9 @@ MapWidget.prototype.add_wkt = function(event) {
}
this.write_wkt(event.feature);
}
};
};
MapWidget.prototype.modify_wkt = function(event) {
MapWidget.prototype.modify_wkt = function(event) {
if (this.options.is_collection) {
if (this.options.geom_name === 'MultiPoint') {
this.add_wkt(event);
@ -328,42 +327,42 @@ MapWidget.prototype.modify_wkt = function(event) {
} else {
this.write_wkt(event.feature);
}
};
};
MapWidget.prototype.deleteFeatures = function() {
MapWidget.prototype.deleteFeatures = function() {
this.layers.vector.removeFeatures(this.layers.vector.features);
this.layers.vector.destroyFeatures();
};
};
MapWidget.prototype.clearFeatures = function() {
MapWidget.prototype.clearFeatures = function() {
this.deleteFeatures();
document.getElementById(this.options.id).value = '';
this.map.setCenter(this.defaultCenter(), this.options.default_zoom);
};
};
MapWidget.prototype.defaultCenter = function() {
MapWidget.prototype.defaultCenter = function() {
var center = new OpenLayers.LonLat(this.options.default_lon, this.options.default_lat);
if (this.options.map_srid) {
return center.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
}
return center;
};
};
MapWidget.prototype.addSelectControl = function() {
MapWidget.prototype.addSelectControl = function() {
var select = new OpenLayers.Control.SelectFeature(this.layers.vector, {'toggle': true, 'clickout': true});
this.map.addControl(select);
select.activate();
};
};
MapWidget.prototype.enableDrawing = function() {
MapWidget.prototype.enableDrawing = function() {
this.map.getControlsByClass('OpenLayers.Control.DrawFeature')[0].activate();
};
};
MapWidget.prototype.enableEditing = function() {
MapWidget.prototype.enableEditing = function() {
this.map.getControlsByClass('OpenLayers.Control.ModifyFeature')[0].activate();
};
};
MapWidget.prototype.getControls = function(layer) {
MapWidget.prototype.getControls = function(layer) {
this.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
this.controls = [new OpenLayers.Control.Navigation()];
if (!this.options.modifiable && layer.features.length) {
@ -381,6 +380,6 @@ MapWidget.prototype.getControls = function(layer) {
if (this.options.modifiable) {
this.controls.push(new OpenLayers.Control.ModifyFeature(layer, {'displayClass': 'olControlModifyFeature'}));
}
};
window.MapWidget = MapWidget;
};
window.MapWidget = MapWidget;
})();