mirror of
https://github.com/django/django.git
synced 2025-08-08 19:09:15 +00:00
Fixed JavaScript "indent" violations.
This commit is contained in:
parent
8606bea3bc
commit
b647d64408
@ -1,11 +1,10 @@
|
|||||||
/*global OpenLayers*/
|
/*global OpenLayers*/
|
||||||
/*eslint indent:1*/
|
|
||||||
(function() {
|
(function() {
|
||||||
/**
|
/**
|
||||||
* Transforms an array of features to a single feature with the merged
|
* Transforms an array of features to a single feature with the merged
|
||||||
* geometry of geom_type
|
* geometry of geom_type
|
||||||
*/
|
*/
|
||||||
OpenLayers.Util.properFeatures = function(features, geom_type) {
|
OpenLayers.Util.properFeatures = function(features, geom_type) {
|
||||||
if (features.constructor === Array) {
|
if (features.constructor === Array) {
|
||||||
var geoms = [];
|
var geoms = [];
|
||||||
for (var i=0; i<features.length; i++) {
|
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);
|
features = new OpenLayers.Feature.Vector(geom);
|
||||||
}
|
}
|
||||||
return features;
|
return features;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Format/WKT.js
|
* @requires OpenLayers/Format/WKT.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Format.DjangoWKT
|
* Class: OpenLayers.Format.DjangoWKT
|
||||||
* Class for reading Well-Known Text, with workarounds to successfully parse
|
* Class for reading Well-Known Text, with workarounds to successfully parse
|
||||||
* geometries and collections as returned by django.contrib.gis.geos.
|
* 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.WKT>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
|
OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
OpenLayers.Format.WKT.prototype.initialize.apply(this, [options]);
|
OpenLayers.Format.WKT.prototype.initialize.apply(this, [options]);
|
||||||
this.regExes.justComma = /\s*,\s*/;
|
this.regExes.justComma = /\s*,\s*/;
|
||||||
@ -160,9 +159,9 @@ OpenLayers.Format.DjangoWKT = OpenLayers.Class(OpenLayers.Format.WKT, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Format.DjangoWKT"
|
CLASS_NAME: "OpenLayers.Format.DjangoWKT"
|
||||||
});
|
});
|
||||||
|
|
||||||
function MapWidget(options) {
|
function MapWidget(options) {
|
||||||
this.map = null;
|
this.map = null;
|
||||||
this.controls = null;
|
this.controls = null;
|
||||||
this.panel = null;
|
this.panel = null;
|
||||||
@ -261,9 +260,9 @@ function MapWidget(options) {
|
|||||||
} else {
|
} else {
|
||||||
this.enableDrawing();
|
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);
|
var map = new OpenLayers.Map(this.options.map_id, this.options.map_options);
|
||||||
if (this.options.base_layer) {
|
if (this.options.base_layer) {
|
||||||
this.layers.base = 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);
|
map.addLayer(this.layers.base);
|
||||||
return map;
|
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);
|
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 + ';';
|
var prefix = 'SRID=' + this.options.map_srid + ';';
|
||||||
if (wkt.indexOf(prefix) === 0) {
|
if (wkt.indexOf(prefix) === 0) {
|
||||||
wkt = wkt.slice(prefix.length);
|
wkt = wkt.slice(prefix.length);
|
||||||
}
|
}
|
||||||
return this.wkt_f.read(wkt);
|
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);
|
feat = OpenLayers.Util.properFeatures(feat, this.options.geom_type);
|
||||||
if (this.options.is_collection) {
|
if (this.options.is_collection) {
|
||||||
this.num_geom = feat.geometry.components.length;
|
this.num_geom = feat.geometry.components.length;
|
||||||
@ -294,9 +293,9 @@ MapWidget.prototype.write_wkt = function(feat) {
|
|||||||
this.num_geom = 1;
|
this.num_geom = 1;
|
||||||
}
|
}
|
||||||
document.getElementById(this.options.id).value = this.get_ewkt(feat);
|
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) {
|
if (this.options.is_collection) {
|
||||||
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
||||||
for (var i=0; i<this.layers.vector.features.length; i++) {
|
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);
|
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.is_collection) {
|
||||||
if (this.options.geom_name === 'MultiPoint') {
|
if (this.options.geom_name === 'MultiPoint') {
|
||||||
this.add_wkt(event);
|
this.add_wkt(event);
|
||||||
@ -328,42 +327,42 @@ MapWidget.prototype.modify_wkt = function(event) {
|
|||||||
} else {
|
} else {
|
||||||
this.write_wkt(event.feature);
|
this.write_wkt(event.feature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MapWidget.prototype.deleteFeatures = function() {
|
MapWidget.prototype.deleteFeatures = function() {
|
||||||
this.layers.vector.removeFeatures(this.layers.vector.features);
|
this.layers.vector.removeFeatures(this.layers.vector.features);
|
||||||
this.layers.vector.destroyFeatures();
|
this.layers.vector.destroyFeatures();
|
||||||
};
|
};
|
||||||
|
|
||||||
MapWidget.prototype.clearFeatures = function() {
|
MapWidget.prototype.clearFeatures = function() {
|
||||||
this.deleteFeatures();
|
this.deleteFeatures();
|
||||||
document.getElementById(this.options.id).value = '';
|
document.getElementById(this.options.id).value = '';
|
||||||
this.map.setCenter(this.defaultCenter(), this.options.default_zoom);
|
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);
|
var center = new OpenLayers.LonLat(this.options.default_lon, this.options.default_lat);
|
||||||
if (this.options.map_srid) {
|
if (this.options.map_srid) {
|
||||||
return center.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
|
return center.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
|
||||||
}
|
}
|
||||||
return center;
|
return center;
|
||||||
};
|
};
|
||||||
|
|
||||||
MapWidget.prototype.addSelectControl = function() {
|
MapWidget.prototype.addSelectControl = function() {
|
||||||
var select = new OpenLayers.Control.SelectFeature(this.layers.vector, {'toggle': true, 'clickout': true});
|
var select = new OpenLayers.Control.SelectFeature(this.layers.vector, {'toggle': true, 'clickout': true});
|
||||||
this.map.addControl(select);
|
this.map.addControl(select);
|
||||||
select.activate();
|
select.activate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MapWidget.prototype.enableDrawing = function() {
|
MapWidget.prototype.enableDrawing = function() {
|
||||||
this.map.getControlsByClass('OpenLayers.Control.DrawFeature')[0].activate();
|
this.map.getControlsByClass('OpenLayers.Control.DrawFeature')[0].activate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MapWidget.prototype.enableEditing = function() {
|
MapWidget.prototype.enableEditing = function() {
|
||||||
this.map.getControlsByClass('OpenLayers.Control.ModifyFeature')[0].activate();
|
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.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
|
||||||
this.controls = [new OpenLayers.Control.Navigation()];
|
this.controls = [new OpenLayers.Control.Navigation()];
|
||||||
if (!this.options.modifiable && layer.features.length) {
|
if (!this.options.modifiable && layer.features.length) {
|
||||||
@ -381,6 +380,6 @@ MapWidget.prototype.getControls = function(layer) {
|
|||||||
if (this.options.modifiable) {
|
if (this.options.modifiable) {
|
||||||
this.controls.push(new OpenLayers.Control.ModifyFeature(layer, {'displayClass': 'olControlModifyFeature'}));
|
this.controls.push(new OpenLayers.Control.ModifyFeature(layer, {'displayClass': 'olControlModifyFeature'}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.MapWidget = MapWidget;
|
window.MapWidget = MapWidget;
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user