Use standard indentation

This commit is contained in:
Tom Hughes 2012-09-20 16:04:25 +01:00
parent 4d91fe3dd9
commit 74543b630e

View file

@ -1,157 +1,157 @@
function addNoteLayer(map, notesUrl, newNoteControls, minZoom) { function addNoteLayer(map, notesUrl, newNoteControls, minZoom) {
var newNotes; var newNotes;
var noteCallback = function (scope, response) { var noteCallback = function (scope, response) {
for (var f = 0; f < response.features.length; f++) { for (var f = 0; f < response.features.length; f++) {
var feature = response.features[f]; var feature = response.features[f];
} }
}; };
var saveNewNotes = function (o) { var saveNewNotes = function (o) {
var layer = o.object; var layer = o.object;
newNotes = layer.getFeaturesByAttribute("status", "new") newNotes = layer.getFeaturesByAttribute("status", "new")
layer.removeFeatures(newNotes, { silent: true }); layer.removeFeatures(newNotes, { silent: true });
}; };
var restoreNewNotes = function (o) { var restoreNewNotes = function (o) {
var layer = o.object; var layer = o.object;
layer.addFeatures(newNotes); layer.addFeatures(newNotes);
newNotes = undefined; newNotes = undefined;
}; };
var noteSelected = function (o) { var noteSelected = function (o) {
var feature = o.feature; var feature = o.feature;
var location = feature.geometry.getBounds().getCenterLonLat(); var location = feature.geometry.getBounds().getCenterLonLat();
feature.popup = new OpenLayers.Popup.FramedCloud( feature.popup = new OpenLayers.Popup.FramedCloud(
feature.attributes.id, location, null, feature.attributes.id, location, null,
"<p>" + feature.attributes.id + "</p>", "<p>" + feature.attributes.id + "</p>",
null, null,
feature.attributes.status !== "new", feature.attributes.status !== "new",
function (e) { map.noteSelector.unselect(feature) } function (e) { map.noteSelector.unselect(feature) }
); );
map.addPopup(feature.popup); map.addPopup(feature.popup);
// feature.popup.show(); // feature.popup.show();
}; };
var noteUnselected = function (o) { var noteUnselected = function (o) {
var feature = o.feature; var feature = o.feature;
map.removePopup(feature.popup); map.removePopup(feature.popup);
delete feature.popup; delete feature.popup;
}; };
var allowNoteReports = function () { var allowNoteReports = function () {
if (map.getZoom() > minZoom) { if (map.getZoom() > minZoom) {
newNoteControls.show(); newNoteControls.show();
} else { } else {
newNoteControls.hide(); newNoteControls.hide();
} }
}; };
var addNote = function () { var addNote = function () {
var lonlat = map.getCenter(); var lonlat = map.getCenter();
var layer = map.noteLayer; var layer = map.noteLayer;
var geometry = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat); var geometry = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var feature = new OpenLayers.Feature.Vector(geometry, { var feature = new OpenLayers.Feature.Vector(geometry, {
status: "new" status: "new"
}); });
layer.addFeatures(feature); layer.addFeatures(feature);
map.noteSelector.unselectAll(); map.noteSelector.unselectAll();
map.noteSelector.select(feature); map.noteSelector.select(feature);
map.noteMover.activate(); map.noteMover.activate();
map.noteLayer.setVisibility(true); map.noteLayer.setVisibility(true);
}; };
map.noteLayer = new OpenLayers.Layer.Vector("Notes", { map.noteLayer = new OpenLayers.Layer.Vector("Notes", {
visibility: false, visibility: false,
displayInLayerSwitcher: false, displayInLayerSwitcher: false,
projection: new OpenLayers.Projection("EPSG:4326"), projection: new OpenLayers.Projection("EPSG:4326"),
styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({ styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({
graphicWidth: 22, graphicWidth: 22,
graphicHeight: 22, graphicHeight: 22,
graphicOpacity: 0.7, graphicOpacity: 0.7,
graphicXOffset: -11, graphicXOffset: -11,
graphicYOffset: -11 graphicYOffset: -11
}, { }, {
rules: [ rules: [
new OpenLayers.Rule({ new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({ filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO, type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "status", property: "status",
value: "new" value: "new"
}), }),
symbolizer: { symbolizer: {
externalGraphic: "<%= image_path 'new_note_marker.png' %>" externalGraphic: "<%= image_path 'new_note_marker.png' %>"
} }
}), }),
new OpenLayers.Rule({ new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({ filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO, type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "status", property: "status",
value: "open" value: "open"
}), }),
symbolizer: { symbolizer: {
externalGraphic: "<%= image_path 'open_note_marker.png' %>" externalGraphic: "<%= image_path 'open_note_marker.png' %>"
} }
}), }),
new OpenLayers.Rule({ new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({ filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO, type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "status", property: "status",
value: "closed" value: "closed"
}), }),
symbolizer: { symbolizer: {
externalGraphic: "<%= image_path 'closed_note_marker.png' %>" externalGraphic: "<%= image_path 'closed_note_marker.png' %>"
} }
})
]
})),
strategies: [
new OpenLayers.Strategy.BBOX()
],
protocol: new OpenLayers.Protocol.HTTP({
url: notesUrl,
format: new OpenLayers.Format.GeoJSON(),
callback: noteCallback
}) })
}); ]
})),
strategies: [
new OpenLayers.Strategy.BBOX()
],
protocol: new OpenLayers.Protocol.HTTP({
url: notesUrl,
format: new OpenLayers.Format.GeoJSON(),
callback: noteCallback
})
});
map.noteLayer.events.register("beforefeaturesremoved", map, saveNewNotes); map.noteLayer.events.register("beforefeaturesremoved", map, saveNewNotes);
map.noteLayer.events.register("featuresremoved", map, restoreNewNotes); map.noteLayer.events.register("featuresremoved", map, restoreNewNotes);
map.noteLayer.events.register("featureselected", map, noteSelected); map.noteLayer.events.register("featureselected", map, noteSelected);
map.noteLayer.events.register("featureunselected", map, noteUnselected); map.noteLayer.events.register("featureunselected", map, noteUnselected);
map.addLayer(map.noteLayer); map.addLayer(map.noteLayer);
map.noteSelector = new OpenLayers.Control.SelectFeature(map.noteLayer, { map.noteSelector = new OpenLayers.Control.SelectFeature(map.noteLayer, {
autoActivate: true autoActivate: true
}); });
map.addControl(map.noteSelector); map.addControl(map.noteSelector);
map.noteMover = new OpenLayers.Control.DragFeature(map.noteLayer, { map.noteMover = new OpenLayers.Control.DragFeature(map.noteLayer, {
onDrag: function (feature, pixel) { onDrag: function (feature, pixel) {
feature.popup.lonlat = feature.geometry.getBounds().getCenterLonLat(); feature.popup.lonlat = feature.geometry.getBounds().getCenterLonLat();
feature.popup.updatePosition(); feature.popup.updatePosition();
}, },
featureCallbacks: { featureCallbacks: {
over: function (feature) { over: function (feature) {
if (feature.attributes.status === "new") { if (feature.attributes.status === "new") {
map.noteMover.overFeature.apply(map.noteMover, [feature]); map.noteMover.overFeature.apply(map.noteMover, [feature]);
}
}
} }
}); }
}
});
map.addControl(map.noteMover); map.addControl(map.noteMover);
newNoteControls.click(addNote); newNoteControls.click(addNote);
map.events.register("zoomend", map, allowNoteReports); map.events.register("zoomend", map, allowNoteReports);
return map.noteLayer; return map.noteLayer;
} }