From: Tom Hughes Date: Thu, 6 Sep 2012 20:29:16 +0000 (+0100) Subject: Use the jQuery data() function to access HTML 5 data attributes X-Git-Tag: live~5356 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/d76aa13ddd6fbccbac286132b5aca4d93af443fe Use the jQuery data() function to access HTML 5 data attributes --- diff --git a/app/assets/javascripts/key.js b/app/assets/javascripts/key.js index daff6eee6..1e4138b70 100644 --- a/app/assets/javascripts/key.js +++ b/app/assets/javascripts/key.js @@ -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(); diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index 474c08069..78a9d452f 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -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"); });