/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
* license. */
+OpenLayers.Control.SypAttribution = OpenLayers.Class (OpenLayers.Control.Attribution, {
+ updateAttribution: function() {
+ var attributions = [SypStrings.propulsedByLink];
+ if (this.map && this.map.layers) {
+ for(var i=0, len=this.map.layers.length; i<len; i++) {
+ var layer = this.map.layers[i];
+ if (layer.attribution && layer.getVisibility()) {
+ attributions.push( layer.attribution );
+ }
+ }
+ this.div.innerHTML = attributions.join(this.separator);
+ }
+ }
+});
+
var SYP = {
Settings: {
MARKER_ICON: "openlayers/img/marker-blue.png",
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.Permalink(),
- new OpenLayers.Control.Attribution()
+ new OpenLayers.Control.SypAttribution()
],
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
checkForFeatures: function() {
var features = this.dataLayer.features;
if (features.length == 0) {
- var message = "Il n'y a aucune photo enregistrée sur le site.";
+ var message = SypStrings.noImageRegistered;
this.Utils.displayUserMessage(message, "warn");
}
},
},
onFeatureUnselect: function (feature) {
- var popup = feature.popup;
+ var map = feature.layer.map;
+ var permaControl = map.getControlsByClass("OpenLayers.Control.Permalink");
+ if (permaControl[0]) {
+ permaControl[0].div.style.display = "";
+ }
+ if (!feature.popup) {
+ this.map.events.unregister("movestart", this, this._unselect);
+ return;
+ }
+ popup = feature.popup;
if (popup.visible()) {
popup.hide();
}
onFeatureSelect: function(feature) {
var map = feature.layer.map;
+ var permaControl = map.getControlsByClass("OpenLayers.Control.Permalink");
+ if (permaControl[0]) {
+ permaControl[0].div.style.display = "none";
+ }
var popup = feature.popup;
var brCorner = SYP.Utils.brCorner(map, 8);
// we cannot reuse popup; we need to recreate it in order for IE
// expressions to work. Otherwise, we get a 0x0 image on second view.
- if (popup) {
+ if (popup) {
popup.destroy();
}
var contentHTML;
} else {
contentHTML = feature.attributes.description;
}
+ if (!contentHTML || !contentHTML.length) {
+ this.map.events.register("movestart", this, this._unselect = function () { this.unselect(feature)});
+ return;
+ }
popup = SYP.createPopup(brCorner, contentHTML);
var control = this;
popup.hide = function () {
}
};
+// if possible, determine language with HTTP_ACCEPT_LANGUAGE instead of
+// navigator.language
+if (OpenLayers.Lang[SypStrings.language]) {
+ OpenLayers.Lang.setCode(SypStrings.language);
+}
+
// avoid alerts
OpenLayers.Console.userError = function(error) {
SYP.Utils.displayUserMessage(error, "error");