]> git.openstreetmap.org Git - rails.git/commitdiff
Use the jQuery data() function to access HTML 5 data attributes
authorTom Hughes <tom@compton.nu>
Thu, 6 Sep 2012 20:29:16 +0000 (21:29 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 6 Sep 2012 20:29:16 +0000 (21:29 +0100)
app/assets/javascripts/key.js
app/assets/javascripts/richtext.js

index daff6eee6981f63fc10c11d03c59fd6309b6ac72..1e4138b70fc7b449b4ba3cae54f5cf8c9b4a93df 100644 (file)
@@ -8,12 +8,10 @@ $(document).ready(function () {
           mapZoom = map.getZoom();
 
       $(".mapkey-table-entry").each(function () {
-        var entryLayer = $(this).attr("data-layer"),
-            entryZoomMin = parseInt($(this).attr("data-zoom-min")),
-            entryZoomMax = parseInt($(this).attr("data-zoom-max"));
+        var data = $(this).data();
 
-        if (mapLayer == entryLayer &&
-            mapZoom >= entryZoomMin && mapZoom <= entryZoomMax) {
+        if (mapLayer == data.layer &&
+            mapZoom >= data.zoomMin && mapZoom <= data.zoomMax) {
           $(this).show();
         } else {
           $(this).hide();
index 474c0806968efb442642dd99969bc58bf4564e3c..78a9d452f92d8d2465594434bb520bb4fb9973c6 100644 (file)
@@ -49,7 +49,7 @@ $(document).ready(function () {
         preview.addClass("loading");
       });
 
-      preview.load(editor.attr("data-preview-url"), { text: editor.val() }, function () {
+      preview.load(editor.data("previewUrl"), { text: editor.val() }, function () {
         preview.stopTime("loading");
         preview.removeClass("loading");
       });