]> dev.renevier.net Git - syp.git/blobdiff - js/syp.js
place permalink "under" popup
[syp.git] / js / syp.js
index c9f637aa78f615f4fed291c6e4daa11305dfa721..e350d88af3ea303dbe1aeeae820351ff8d6fdc5f 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -1,6 +1,21 @@
 /* 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",
@@ -20,7 +35,7 @@ var SYP = {
                 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")
@@ -96,7 +111,7 @@ var SYP = {
     checkForFeatures: function() {
         var features = this.dataLayer.features;
         if (features.length == 0) {
-            var message = "Il n'y a aucune image enregistrĂ©e sur le site.";
+            var message = SypStrings.noImageRegistered;
             this.Utils.displayUserMessage(message, "warn");
         }
     },
@@ -116,6 +131,11 @@ var SYP = {
     },
 
     onFeatureUnselect: function (feature) {
+        var map = feature.layer.map;
+        var permaControl = map.getControlsByClass("OpenLayers.Control.Permalink");
+        if (permaControl[0]) {
+            permaControl[0].div.style.display = "";
+        }
         var popup = feature.popup;
         if (popup.visible()) {
             popup.hide();
@@ -124,6 +144,10 @@ var SYP = {
 
     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);
@@ -186,6 +210,12 @@ var SYP = {
     }
 };
 
+// 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");