]> git.openstreetmap.org Git - rails.git/commitdiff
Use the jQuery data() function to access HTML 5 data attributes
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 7 Sep 2012 23:21:01 +0000 (16:21 -0700)
committerTom Hughes <tom@compton.nu>
Sat, 29 Sep 2012 17:00:03 +0000 (18:00 +0100)
app/views/site/_potlatch.html.erb
app/views/site/_potlatch2.html.erb
app/views/site/index.html.erb

index a1c637b79ebf742dcda88bcd77c5e4bf997ecee6..d48fd799d2629ca98a6c3ebdb5b6070c0d97b280 100644 (file)
 
   $(document).ready(function () {
     $("body").on("click", "a.set_position", function () {
 
   $(document).ready(function () {
     $("body").on("click", "a.set_position", function () {
-      var lat = parseFloat($(this).attr("data-lat"));
-      var lon = parseFloat($(this).attr("data-lon"));
-      var zoom = parseInt($(this).attr("data-zoom"));
+      var data = $(this).data();
 
 
-      doSWF(lat, lon, zoom || 15);
+      doSWF(data.lat, data.lon, data.zoom || 15);
     });
   });
 </script>
     });
   });
 </script>
index 73ef782b588004d488f6662f8ec7a580d502650a..1d45d622356f7399a043d0110a87a561d06df77c 100644 (file)
 
   $(document).ready(function () {
     $("body").on("click", "a.set_position", function () {
 
   $(document).ready(function () {
     $("body").on("click", "a.set_position", function () {
-      var lat = parseFloat($(this).attr("data-lat"));
-      var lon = parseFloat($(this).attr("data-lon"));
-      var zoom = parseInt($(this).attr("data-zoom"));
+      var data = $(this).data();
 
       $("#potlatch").each(function () {
 
       $("#potlatch").each(function () {
-        this.setPosition(lat, lon, Math.max(zoom || 15, 13));
+        this.setPosition(data.lat, data.lon, Math.max(data.zoom || 15, 13));
       });
     });
   });
       });
     });
   });
index 8f8d8737be1780be7b1fe12263272c759bb05111..657db8474d17a42939121862769b8c25e5ddcf3d 100644 (file)
     });
 
     $("body").on("click", "a.set_position", function () {
     });
 
     $("body").on("click", "a.set_position", function () {
-      var lat = parseFloat($(this).attr("data-lat"));
-      var lon = parseFloat($(this).attr("data-lon"));
-      var zoom = parseInt($(this).attr("data-zoom"));
-      var min_lon = parseFloat($(this).attr("data-min-lon"));
-      var min_lat = parseFloat($(this).attr("data-min-lat"));
-      var max_lon = parseFloat($(this).attr("data-max-lon"));
-      var max_lat = parseFloat($(this).attr("data-max-lat"));
-      var centre = new OpenLayers.LonLat(lon, lat);
-
-      if (min_lon && min_lat && max_lon && max_lat) {
-        var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
+      var data = $(this).data();
+      var centre = new OpenLayers.LonLat(data.lon, data.lat);
+
+      if (data.minLon && data.minLat && data.maxLon && data.maxLat) {
+        var bbox = new OpenLayers.Bounds(data.minLon, data.minLat, data.maxLon, data.maxLat);
 
         map.zoomToExtent(proj(bbox));
       } else {
 
         map.zoomToExtent(proj(bbox));
       } else {
-        setMapCenter(centre, zoom);
+        setMapCenter(centre, data.zoom);
       }
 
       if (marker) {
       }
 
       if (marker) {