//= require richtext
//= require querystring
-var querystring = require('querystring-component');
+var querystring = require("querystring-component");
/*
* Called as the user scrolls/zooms around to maniplate hrefs of the
}
var query = querystring.stringify(args);
- if (query) href += '?' + query;
+ if (query) href += "?" + query;
args = {
lat: loc.lat,
- lon: 'lon' in loc ? loc.lon : loc.lng,
+ lon: "lon" in loc ? loc.lon : loc.lng,
zoom: zoom
};
});
var editDisabled = zoom < 13;
- $('#edit_tab')
- .tooltip({placement: 'bottom'})
- .off('click.minzoom')
- .on('click.minzoom', function() { return !editDisabled; })
- .toggleClass('disabled', editDisabled)
- .attr('data-original-title', editDisabled ?
- I18n.t('javascripts.site.edit_disabled_tooltip') : '');
+ $("#edit_tab")
+ .tooltip({placement: "bottom"})
+ .off("click.minzoom")
+ .on("click.minzoom", function() { return !editDisabled; })
+ .toggleClass("disabled", editDisabled)
+ .attr("data-original-title", editDisabled ?
+ I18n.t("javascripts.site.edit_disabled_tooltip") : "");
};
window.maximiseMap = function () {
}
marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
- .bindPopup(I18n.t('diary_entries.edit.marker_text'));
+ .bindPopup(I18n.t("diary_entries.edit.marker_text"));
}
$("#usemap").click(function (e) {
var params = $("#map").data();
var centre = [params.lat, params.lon];
- var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
+ var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
map = L.map("map", {
attributionControl: false,
if ($("#latitude").val() && $("#longitude").val()) {
marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
- .bindPopup(I18n.t('diary_entries.edit.marker_text'));
+ .bindPopup(I18n.t("diary_entries.edit.marker_text"));
}
map.on("click", setLocation);
$(document).ready(function() {
var params = OSM.params();
- var url = '/note/new';
+ var url = "/note/new";
if (params.lat && params.lon) {
params.lat = parseFloat(params.lat);
params.lon = parseFloat(params.lon);
params.zoom = params.zoom || 17;
url += OSM.formatHash(params);
}
- $('.icon.note').attr('href', url);
+ $(".icon.note").attr("href", url);
});
document.addEventListener("DOMContentLoaded", function() {
var container = document.getElementById("id-container");
- if (typeof iD === 'undefined' || !iD.Detect().support) {
- container.innerHTML = 'This editor is supported ' +
- 'in Firefox, Chrome, Safari, Opera, Edge, and Internet Explorer 11. ' +
- 'Please upgrade your browser or use Potlatch 2 to edit the map.';
- container.className = 'unsupported';
+ if (typeof iD === "undefined" || !iD.Detect().support) {
+ container.innerHTML = "This editor is supported " +
+ "in Firefox, Chrome, Safari, Opera, Edge, and Internet Explorer 11. " +
+ "Please upgrade your browser or use Potlatch 2 to edit the map.";
+ container.className = "unsupported";
} else {
var id = iD.Context()
.embed(true)
oauth_token_secret: container.dataset.tokenSecret
});
- id.map().on('move.embed', parent.$.throttle(250, function() {
+ id.map().on("move.embed", parent.$.throttle(250, function() {
if (id.inIntro()) return;
var zoom = ~~id.map().zoom(),
center = id.map().center(),
clearTimeout(loaderTimeout);
loaderTimeout = setTimeout(function() {
- $('#sidebar_loader').show();
+ $("#sidebar_loader").show();
}, 200);
// IE<10 doesn't respect Vary: X-Requested-With header, so
// prevent caching the XHR response as a full-page URL.
- if (path.indexOf('?') >= 0) {
- path += '&xhr=1';
+ if (path.indexOf("?") >= 0) {
+ path += "&xhr=1";
} else {
- path += '?xhr=1';
+ path += "?xhr=1";
}
- $('#sidebar_content')
+ $("#sidebar_content")
.empty();
$.ajax({
dataType: "html",
complete: function(xhr) {
clearTimeout(loaderTimeout);
- $('#flash').empty();
- $('#sidebar_loader').hide();
+ $("#flash").empty();
+ $("#sidebar_loader").hide();
var content = $(xhr.responseText);
- if (xhr.getResponseHeader('X-Page-Title')) {
- var title = xhr.getResponseHeader('X-Page-Title');
+ if (xhr.getResponseHeader("X-Page-Title")) {
+ var title = xhr.getResponseHeader("X-Page-Title");
document.title = decodeURIComponent(title);
}
- $('head')
- .find('link[type="application/atom+xml"]')
+ $("head")
+ .find("link[type=\"application/atom+xml\"]")
.remove();
- $('head')
- .append(content.filter('link[type="application/atom+xml"]'));
+ $("head")
+ .append(content.filter("link[type=\"application/atom+xml\"]"));
- $('#sidebar_content').html(content.not('link[type="application/atom+xml"]'));
+ $("#sidebar_content").html(content.not("link[type=\"application/atom+xml\"]"));
if (callback) {
callback();
var params = OSM.mapParams();
- map.attributionControl.setPrefix('');
+ map.attributionControl.setPrefix("");
map.updateLayers(params.layers);
}
});
- var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
+ var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
L.OSM.zoom({position: position})
.addTo(map);
var locate = L.control.locate({
position: position,
- icon: 'icon geolocate',
- iconLoading: 'icon geolocate',
+ icon: "icon geolocate",
+ iconLoading: "icon geolocate",
strings: {
- title: I18n.t('javascripts.map.locate.title'),
- popup: I18n.t('javascripts.map.locate.popup')
+ title: I18n.t("javascripts.map.locate.title"),
+ popup: I18n.t("javascripts.map.locate.popup")
}
}).addTo(map);
var locateContainer = locate.getContainer();
$(locateContainer)
- .removeClass('leaflet-control-locate leaflet-bar')
- .addClass('control-locate')
+ .removeClass("leaflet-control-locate leaflet-bar")
+ .addClass("control-locate")
.children("a")
- .attr('href', '#')
- .removeClass('leaflet-bar-part leaflet-bar-part-single')
- .addClass('control-button');
+ .attr("href", "#")
+ .removeClass("leaflet-bar-part leaflet-bar-part-single")
+ .addClass("control-button");
- var sidebar = L.OSM.sidebar('#map-ui')
+ var sidebar = L.OSM.sidebar("#map-ui")
.addTo(map);
L.OSM.layers({
OSM.initializeContextMenu(map);
- if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
+ if (OSM.STATUS !== "api_offline" && OSM.STATUS !== "database_offline") {
OSM.initializeNotes(map);
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
map.addLayer(map.noteLayer);
}
}
- var placement = $('html').attr('dir') === 'rtl' ? 'right' : 'left';
- $('.leaflet-control .control-button').tooltip({placement: placement, container: 'body'});
+ var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
+ $(".leaflet-control .control-button").tooltip({placement: placement, container: "body"});
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
- map.on('moveend layeradd layerremove', function() {
+ map.on("moveend layeradd layerremove", function() {
updateLinks(
map.getCenter().wrap(),
map.getZoom(),
map.getLayersCode(),
map._object);
- $.removeCookie('_osm_location');
- $.cookie('_osm_location', OSM.locationCookie(map), { expires: expiry, path: '/' });
+ $.removeCookie("_osm_location");
+ $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
});
- if ($.cookie('_osm_welcome') !== 'hide') {
- $('.welcome').addClass('visible');
+ if ($.cookie("_osm_welcome") !== "hide") {
+ $(".welcome").addClass("visible");
}
- $('.welcome .close-wrap').on('click', function() {
- $('.welcome').removeClass('visible');
- $.cookie('_osm_welcome', 'hide', { expires: expiry, path: '/' });
+ $(".welcome .close-wrap").on("click", function() {
+ $(".welcome").removeClass("visible");
+ $.cookie("_osm_welcome", "hide", { expires: expiry, path: "/" });
});
var bannerExpiry = new Date();
bannerExpiry.setYear(bannerExpiry.getFullYear() + 1);
- $('#banner .close-wrap').on('click', function(e) {
+ $("#banner .close-wrap").on("click", function(e) {
var cookieId = e.target.id;
- $('#banner').hide();
+ $("#banner").hide();
e.preventDefault();
if (cookieId) {
- $.cookie(cookieId, 'hide', { expires: bannerExpiry, path: '/' });
+ $.cookie(cookieId, "hide", { expires: bannerExpiry, path: "/" });
}
});
if (OSM.PIWIK) {
- map.on('layeradd', function (e) {
+ map.on("layeradd", function (e) {
if (e.layer.options) {
var goal = OSM.PIWIK.goals[e.layer.options.keyid];
if (goal) {
- $('body').trigger('piwikgoal', goal);
+ $("body").trigger("piwikgoal", goal);
}
}
});
bottom: bbox.getSouth() - 0.0001
};
- if (location.protocol === 'http' ||
+ if (location.protocol === "http" ||
bowser.check({chrome: "53", firefox: "55"})) {
url = "http://127.0.0.1:8111/load_and_zoom?";
} else {
if (object) query.select = object.type + object.id;
- var iframe = $('<iframe>')
+ var iframe = $("<iframe>")
.hide()
- .appendTo('body')
+ .appendTo("body")
.attr("src", url + querystring.stringify(query))
- .on('load', function() {
+ .on("load", function() {
$(this).remove();
loaded = true;
});
setTimeout(function () {
if (!loaded) {
- alert(I18n.t('site.index.remote_failed'));
+ alert(I18n.t("site.index.remote_failed"));
iframe.remove();
}
}, 1000);
});
if (OSM.params().edit_help) {
- $('#editanchor')
- .removeAttr('title')
+ $("#editanchor")
+ .removeAttr("title")
.tooltip({
- placement: 'bottom',
- title: I18n.t('javascripts.edit_help')
+ placement: "bottom",
+ title: I18n.t("javascripts.edit_help")
})
- .tooltip('show');
+ .tooltip("show");
- $('body').one('click', function() {
- $('#editanchor').tooltip('hide');
+ $("body").one("click", function() {
+ $("#editanchor").tooltip("hide");
});
}
page.pushstate = page.popstate = function() {
map.setSidebarOverlaid(true);
- document.title = I18n.t('layouts.project_name.title');
+ document.title = I18n.t("layouts.project_name.title");
};
page.load = function() {
"/history": history,
"/user/:display_name/history": history,
"/note/:id": OSM.Note(map),
- "/node/:id(/history)": OSM.Browse(map, 'node'),
- "/way/:id(/history)": OSM.Browse(map, 'way'),
- "/relation/:id(/history)": OSM.Browse(map, 'relation'),
+ "/node/:id(/history)": OSM.Browse(map, "node"),
+ "/way/:id(/history)": OSM.Browse(map, "way"),
+ "/relation/:id(/history)": OSM.Browse(map, "relation"),
"/changeset/:id": OSM.Changeset(map),
"/query": OSM.Query(map)
});
onSelect(e.layer);
});
- map.on('layeradd', function (e) {
+ map.on("layeradd", function (e) {
if (e.layer === dataLayer) {
map.on("moveend", updateData);
updateData();
}
});
- map.on('layerremove', function (e) {
+ map.on("layerremove", function (e) {
if (e.layer === dataLayer) {
map.off("moveend", updateData);
- $('#browse_status').empty();
+ $("#browse_status").empty();
}
});
}
function displayFeatureWarning(count, limit, add, cancel) {
- $('#browse_status').html(
+ $("#browse_status").html(
$("<p class='warning'></p>")
.text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit }))
.prepend(
.click(cancel))
.append(
$("<input type='submit'>")
- .val(I18n.t('browse.start_rjs.load_data'))
+ .val(I18n.t("browse.start_rjs.load_data"))
.click(add)));
}
var features = dataLayer.buildFeatures(xml);
function addFeatures() {
- $('#browse_status').empty();
+ $("#browse_status").empty();
dataLayer.addData(features);
browseBounds = bounds;
}
function cancelAddFeatures() {
- $('#browse_status').empty();
+ $("#browse_status").empty();
}
if (features.length < maxFeatures) {
// Redraw in selected style
layer.originalStyle = layer.options;
- layer.setStyle({color: '#0000ff', weight: 8});
+ layer.setStyle({color: "#0000ff", weight: 8});
- OSM.router.route('/' + layer.feature.type + '/' + layer.feature.id);
+ OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);
// Stash the currently drawn feature
selectedLayer = layer;
OSM.Changeset = function (map) {
var page = {},
- content = $('#sidebar_content'),
+ content = $("#sidebar_content"),
currentChangesetId;
page.pushstate = page.popstate = function(path, id) {
};
function addChangeset(id, center) {
- map.addObject({type: 'changeset', id: parseInt(id, 10)}, function(bounds) {
+ map.addObject({type: "changeset", id: parseInt(id, 10)}, function(bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
}
});
- content.find("textarea").val('').trigger("input");
+ content.find("textarea").val("").trigger("input");
}
page.unload = function() {
var popup = L.popup({autoPanPadding: [100, 100]});
var polyline = L.polyline([], {
- color: '#03f',
+ color: "#03f",
opacity: 0.3,
weight: 10
});
var highlight = L.polyline([], {
- color: '#ff0',
+ color: "#ff0",
opacity: 0.5,
weight: 12
});
var engines = OSM.Directions.engines;
engines.sort(function (a, b) {
- a = I18n.t('javascripts.directions.engines.' + a.id);
- b = I18n.t('javascripts.directions.engines.' + b.id);
+ a = I18n.t("javascripts.directions.engines." + a.id);
+ b = I18n.t("javascripts.directions.engines." + b.id);
return a.localeCompare(b);
});
- var select = $('select.routing_engines');
+ var select = $("select.routing_engines");
engines.forEach(function(engine, i) {
- select.append("<option value='" + i + "'>" + I18n.t('javascripts.directions.engines.' + engine.id) + "</option>");
+ select.append("<option value='" + i + "'>" + I18n.t("javascripts.directions.engines." + engine.id) + "</option>");
});
function Endpoint(input, iconUrl) {
autoPan: true
});
- endpoint.marker.on('drag dragend', function (e) {
- var dragging = (e.type === 'drag');
+ endpoint.marker.on("drag dragend", function (e) {
+ var dragging = (e.type === "drag");
if (dragging && !chosenEngine.draggable) return;
if (dragging && awaitingRoute) return;
endpoint.setLatLng(e.target.getLatLng());
endpoint.awaitingGeocode = true;
- $.getJSON(OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) {
+ $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json", function (json) {
endpoint.awaitingGeocode = false;
endpoint.hasGeocode = true;
if (json.length === 0) {
input.addClass("error");
- alert(I18n.t('javascripts.directions.errors.no_place', {place: endpoint.value}));
+ alert(I18n.t("javascripts.directions.errors.no_place", {place: endpoint.value}));
return;
}
var m = Math.round(s / 60);
var h = Math.floor(m / 60);
m -= h * 60;
- return h + ":" + (m < 10 ? '0' : '') + m;
+ return h + ":" + (m < 10 ? "0" : "") + m;
}
function findEngine(id) {
OSM.router.replace("/directions?" + querystring.stringify({
engine: chosenEngine.id,
- route: o.lat.toFixed(precision) + ',' + o.lng.toFixed(precision) + ';' +
- d.lat.toFixed(precision) + ',' + d.lng.toFixed(precision)
+ route: o.lat.toFixed(precision) + "," + o.lng.toFixed(precision) + ";" +
+ d.lat.toFixed(precision) + "," + d.lng.toFixed(precision)
}));
// copy loading item to sidebar and display it. we copy it, rather than
// just using it in-place and replacing it in case it has to be used
// again.
- $('#sidebar_content').html($('.directions_form .loader_copy').html());
+ $("#sidebar_content").html($(".directions_form .loader_copy").html());
map.setSidebarOverlaid(false);
awaitingRoute = chosenEngine.getRoute([o, d], function (err, route) {
map.removeLayer(polyline);
if (reportErrors) {
- $('#sidebar_content').html('<p class="search_results_error">' + I18n.t('javascripts.directions.errors.no_route') + '</p>');
+ $("#sidebar_content").html("<p class=\"search_results_error\">" + I18n.t("javascripts.directions.errors.no_route") + "</p>");
}
return;
map.fitBounds(polyline.getBounds().pad(0.05));
}
- var html = '<h2><a class="geolink" href="#">' +
- '<span class="icon close"></span></a>' + I18n.t('javascripts.directions.directions') +
- '</h2><p id="routing_summary">' +
- I18n.t('javascripts.directions.distance') + ': ' + formatDistance(route.distance) + '. ' +
- I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.';
- if (typeof route.ascend !== 'undefined' && typeof route.descend !== 'undefined') {
- html += '<br />' +
- I18n.t('javascripts.directions.ascend') + ': ' + Math.round(route.ascend) + 'm. ' +
- I18n.t('javascripts.directions.descend') + ': ' + Math.round(route.descend) +'m.';
+ var html = "<h2><a class=\"geolink\" href=\"#\">" +
+ "<span class=\"icon close\"></span></a>" + I18n.t("javascripts.directions.directions") +
+ "</h2><p id=\"routing_summary\">" +
+ I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " +
+ I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".";
+ if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
+ html += "<br />" +
+ I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
+ I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) +"m.";
}
- html += '</p><table id="turnbyturn" />';
+ html += "</p><table id=\"turnbyturn\" />";
- $('#sidebar_content')
+ $("#sidebar_content")
.html(html);
// Add each row
row.append("<td class='instruction'>" + instruction);
row.append("<td class='distance'>" + dist);
- row.on('click', function () {
+ row.on("click", function () {
popup
.setLatLng(ll)
.setContent("<p>" + instruction + "</p>")
map.removeLayer(highlight);
});
- $('#turnbyturn').append(row);
+ $("#turnbyturn").append(row);
});
- $('#sidebar_content').append('<p id="routing_credit">' +
- I18n.t('javascripts.directions.instructions.courtesy', {link: chosenEngine.creditline}) +
- '</p>');
+ $("#sidebar_content").append("<p id=\"routing_credit\">" +
+ I18n.t("javascripts.directions.instructions.courtesy", {link: chosenEngine.creditline}) +
+ "</p>");
- $('#sidebar_content a.geolink').on('click', function(e) {
+ $("#sidebar_content a.geolink").on("click", function(e) {
e.preventDefault();
map.removeLayer(polyline);
- $('#sidebar_content').html('');
+ $("#sidebar_content").html("");
map.setSidebarOverlaid(true);
// TODO: collapse width of sidebar back to previous
});
});
}
- var chosenEngineIndex = findEngine('fossgis_osrm_car');
- if ($.cookie('_osm_directions_engine')) {
- chosenEngineIndex = findEngine($.cookie('_osm_directions_engine'));
+ var chosenEngineIndex = findEngine("fossgis_osrm_car");
+ if ($.cookie("_osm_directions_engine")) {
+ chosenEngineIndex = findEngine($.cookie("_osm_directions_engine"));
}
setEngine(chosenEngineIndex);
select.on("change", function (e) {
chosenEngine = engines[e.target.selectedIndex];
- $.cookie('_osm_directions_engine', chosenEngine.id, { expires: expiry, path: '/' });
+ $.cookie("_osm_directions_engine", chosenEngine.id, { expires: expiry, path: "/" });
if (map.hasLayer(polyline)) {
getRoute(true, true);
}
getRoute(true, true);
});
- $(".routing_marker").on('dragstart', function (e) {
+ $(".routing_marker").on("dragstart", function (e) {
var dt = e.originalEvent.dataTransfer;
- dt.effectAllowed = 'move';
- var dragData = { type: $(this).data('type') };
- dt.setData('text', JSON.stringify(dragData));
+ dt.effectAllowed = "move";
+ var dragData = { type: $(this).data("type") };
+ dt.setData("text", JSON.stringify(dragData));
if (dt.setDragImage) {
var img = $("<img>").attr("src", $(e.originalEvent.target).attr("src"));
dt.setDragImage(img.get(0), 12, 21);
$(".search_form").hide();
$(".directions_form").show();
- $("#map").on('dragend dragover', function (e) {
+ $("#map").on("dragend dragover", function (e) {
e.preventDefault();
});
- $("#map").on('drop', function (e) {
+ $("#map").on("drop", function (e) {
e.preventDefault();
var oe = e.originalEvent;
- var dragData = JSON.parse(oe.dataTransfer.getData('text'));
+ var dragData = JSON.parse(oe.dataTransfer.getData("text"));
var type = dragData.type;
var pt = L.DomEvent.getMousePosition(oe, map.getContainer()); // co-ordinates of the mouse pointer at present
pt.y += 20;
var ll = map.containerPointToLatLng(pt);
- endpoints[type === 'from' ? 0 : 1].setLatLng(ll);
+ endpoints[type === "from" ? 0 : 1].setLatLng(ll);
getRoute(true, true);
});
var params = querystring.parse(location.search.substring(1)),
- route = (params.route || '').split(';'),
- from = route[0] && L.latLng(route[0].split(',')),
- to = route[1] && L.latLng(route[1].split(','));
+ route = (params.route || "").split(";"),
+ from = route[0] && L.latLng(route[0].split(",")),
+ to = route[1] && L.latLng(route[1].split(","));
if (params.engine) {
var engineIndex = findEngine(params.engine);
page.unload = function() {
$(".search_form").show();
$(".directions_form").hide();
- $("#map").off('dragend dragover drop');
+ $("#map").off("dragend dragover drop");
map
.removeLayer(popup)
return {
id: id,
- creditline: '<a href="https://routing.openstreetmap.de/about.html" target="_blank">FOSSGIS Routing Service</a>',
+ creditline: "<a href=\"https://routing.openstreetmap.de/about.html\" target=\"_blank\">FOSSGIS Routing Service</a>",
draggable: true,
_transformSteps: function(input_steps, line) {
var INSTRUCTION_TEMPLATE = {
- 'continue': 'javascripts.directions.instructions.continue',
- 'merge right': 'javascripts.directions.instructions.merge_right',
- 'merge left': 'javascripts.directions.instructions.merge_left',
- 'off ramp right': 'javascripts.directions.instructions.offramp_right',
- 'off ramp left': 'javascripts.directions.instructions.offramp_left',
- 'on ramp right': 'javascripts.directions.instructions.onramp_right',
- 'on ramp left': 'javascripts.directions.instructions.onramp_left',
- 'fork right': 'javascripts.directions.instructions.fork_right',
- 'fork left': 'javascripts.directions.instructions.fork_left',
- 'end of road right': 'javascripts.directions.instructions.endofroad_right',
- 'end of road left': 'javascripts.directions.instructions.endofroad_left',
- 'turn straight': 'javascripts.directions.instructions.continue',
- 'turn slight right': 'javascripts.directions.instructions.slight_right',
- 'turn right': 'javascripts.directions.instructions.turn_right',
- 'turn sharp right': 'javascripts.directions.instructions.sharp_right',
- 'turn uturn': 'javascripts.directions.instructions.uturn',
- 'turn sharp left': 'javascripts.directions.instructions.sharp_left',
- 'turn left': 'javascripts.directions.instructions.turn_left',
- 'turn slight left': 'javascripts.directions.instructions.slight_left',
- 'roundabout': 'javascripts.directions.instructions.roundabout',
- 'rotary': 'javascripts.directions.instructions.roundabout',
- 'exit roundabout': 'javascripts.directions.instructions.exit_roundabout',
- 'exit rotary': 'javascripts.directions.instructions.exit_roundabout',
- 'depart': 'javascripts.directions.instructions.start',
- 'arrive': 'javascripts.directions.instructions.destination',
+ "continue": "javascripts.directions.instructions.continue",
+ "merge right": "javascripts.directions.instructions.merge_right",
+ "merge left": "javascripts.directions.instructions.merge_left",
+ "off ramp right": "javascripts.directions.instructions.offramp_right",
+ "off ramp left": "javascripts.directions.instructions.offramp_left",
+ "on ramp right": "javascripts.directions.instructions.onramp_right",
+ "on ramp left": "javascripts.directions.instructions.onramp_left",
+ "fork right": "javascripts.directions.instructions.fork_right",
+ "fork left": "javascripts.directions.instructions.fork_left",
+ "end of road right": "javascripts.directions.instructions.endofroad_right",
+ "end of road left": "javascripts.directions.instructions.endofroad_left",
+ "turn straight": "javascripts.directions.instructions.continue",
+ "turn slight right": "javascripts.directions.instructions.slight_right",
+ "turn right": "javascripts.directions.instructions.turn_right",
+ "turn sharp right": "javascripts.directions.instructions.sharp_right",
+ "turn uturn": "javascripts.directions.instructions.uturn",
+ "turn sharp left": "javascripts.directions.instructions.sharp_left",
+ "turn left": "javascripts.directions.instructions.turn_left",
+ "turn slight left": "javascripts.directions.instructions.slight_left",
+ "roundabout": "javascripts.directions.instructions.roundabout",
+ "rotary": "javascripts.directions.instructions.roundabout",
+ "exit roundabout": "javascripts.directions.instructions.exit_roundabout",
+ "exit rotary": "javascripts.directions.instructions.exit_roundabout",
+ "depart": "javascripts.directions.instructions.start",
+ "arrive": "javascripts.directions.instructions.destination",
};
var ICON_MAP = {
- 'continue': 0,
- 'merge right': 21,
- 'merge left': 20,
- 'off ramp right': 24,
- 'off ramp left': 25,
- 'on ramp right': 2,
- 'on ramp left': 6,
- 'fork right': 18,
- 'fork left': 19,
- 'end of road right': 22,
- 'end of road left': 23,
- 'turn straight': 0,
- 'turn slight right': 1,
- 'turn right': 2,
- 'turn sharp right': 3,
- 'turn uturn': 4,
- 'turn slight left': 5,
- 'turn left': 6,
- 'turn sharp left': 7,
- 'roundabout': 10,
- 'rotary': 10,
- 'exit roundabout': 10,
- 'exit rotary': 10,
- 'depart': 8,
- 'arrive': 14
+ "continue": 0,
+ "merge right": 21,
+ "merge left": 20,
+ "off ramp right": 24,
+ "off ramp left": 25,
+ "on ramp right": 2,
+ "on ramp left": 6,
+ "fork right": 18,
+ "fork left": 19,
+ "end of road right": 22,
+ "end of road left": 23,
+ "turn straight": 0,
+ "turn slight right": 1,
+ "turn right": 2,
+ "turn sharp right": 3,
+ "turn uturn": 4,
+ "turn slight left": 5,
+ "turn left": 6,
+ "turn sharp left": 7,
+ "roundabout": 10,
+ "rotary": 10,
+ "exit roundabout": 10,
+ "exit rotary": 10,
+ "depart": 8,
+ "arrive": 14
};
var numToWord = function(num) {
return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1];
// special case handling
switch (step.maneuver.type) {
- case 'on ramp':
- case 'off ramp':
- case 'merge':
- case 'end of road':
- case 'fork':
- maneuver_id = step.maneuver.type + ' ' + (step.maneuver.modifier.indexOf('left') >= 0 ? 'left' : 'right');
+ case "on ramp":
+ case "off ramp":
+ case "merge":
+ case "end of road":
+ case "fork":
+ maneuver_id = step.maneuver.type + " " + (step.maneuver.modifier.indexOf("left") >= 0 ? "left" : "right");
break;
- case 'depart':
- case 'arrive':
- case 'roundabout':
- case 'rotary':
- case 'exit roundabout':
- case 'exit rotary':
+ case "depart":
+ case "arrive":
+ case "roundabout":
+ case "rotary":
+ case "exit roundabout":
+ case "exit rotary":
maneuver_id = step.maneuver.type;
break;
- case 'roundabout turn':
- case 'turn':
+ case "roundabout turn":
+ case "turn":
maneuver_id = "turn " + step.maneuver.modifier;
break;
// for unknown types the fallback is turn
} else if (step.ref) {
name = "<b>" + step.ref + "</b>";
} else {
- name = I18n.t('javascripts.directions.instructions.unnamed');
+ name = I18n.t("javascripts.directions.instructions.unnamed");
namedRoad = false;
}
} else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) {
if (step.maneuver.exit) {
if (step.maneuver.exit <= 10) {
- instText += I18n.t(template + '_with_exit_ordinal', { exit: I18n.t('javascripts.directions.instructions.exit_counts.' + numToWord(step.maneuver.exit)), name: name });
+ instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t("javascripts.directions.instructions.exit_counts." + numToWord(step.maneuver.exit)), name: name });
} else {
- instText += I18n.t(template + '_with_exit', { exit: step.maneuver.exit, name: name });
+ instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name });
}
} else {
- instText += I18n.t(template + '_without_exit', { name: name });
+ instText += I18n.t(template + "_without_exit", { name: name });
}
} else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) {
var params = {};
}
instText += I18n.t(template, params);
} else {
- instText += I18n.t(template + '_without_exit', { name: name });
+ instText += I18n.t(template + "_without_exit", { name: name });
}
return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry];
});
}
var encoded_coords = points.map(function(p) {
- return p.lng + ',' + p.lat;
- }).join(';');
+ return p.lng + "," + p.lat;
+ }).join(";");
var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords;
var onResponse = function (data) {
- if (data.code !== 'Ok')
+ if (data.code !== "Ok")
return callback(true);
cachedHints = data.waypoints.map(function(wp) {
return {
id: id,
- creditline: '<a href="https://www.graphhopper.com/" target="_blank">Graphhopper</a>',
+ creditline: "<a href=\"https://www.graphhopper.com/\" target=\"_blank\">Graphhopper</a>",
draggable: false,
getRoute: function (points, callback) {
.on("mousedown", "[data-changeset]", function () {
var moved = false;
$(this).one("click", function (e) {
- if (!moved && !$(e.target).is('a')) {
+ if (!moved && !$(e.target).is("a")) {
clickChangeset($(this).data("changeset").id, e);
}
}).one("mousemove", function () {
}
function update() {
- var data = {list: '1'};
+ var data = {list: "1"};
- if (window.location.pathname === '/history') {
+ if (window.location.pathname === "/history") {
data.bbox = map.getBounds().wrap().toBBoxString();
}
method: "GET",
data: data,
success: function(html) {
- $('#sidebar_content .changesets').html(html);
+ $("#sidebar_content .changesets").html(html);
updateMap();
}
});
- var feedLink = $('link[type="application/atom+xml"]'),
- feedHref = feedLink.attr('href').split('?')[0];
+ var feedLink = $("link[type=\"application/atom+xml\"]"),
+ feedHref = feedLink.attr("href").split("?")[0];
- feedLink.attr('href', feedHref + '?bbox=' + data.bbox);
+ feedLink.attr("href", feedHref + "?bbox=" + data.bbox);
}
function loadMore(e) {
function updateMap() {
changesets = $("[data-changeset]").map(function (index,element) {
- return $(element).data('changeset');
+ return $(element).data("changeset");
}).get().filter(function (changeset) {
return changeset.bbox;
});
updateBounds();
- if (window.location.pathname !== '/history') {
+ if (window.location.pathname !== "/history") {
var bounds = group.getBounds();
if (bounds.isValid()) map.fitBounds(bounds);
}
page.load = function() {
map.addLayer(group);
- if (window.location.pathname === '/history') {
+ if (window.location.pathname === "/history") {
map.on("moveend", update);
}
OSM.NewNote = function(map) {
var noteLayer = map.noteLayer,
- content = $('#sidebar_content'),
+ content = $("#sidebar_content"),
page = {},
addNoteButton = $(".control-note .control-button"),
newNote,
e.preventDefault();
e.stopPropagation();
- if ($(this).hasClass('disabled')) return;
+ if ($(this).hasClass("disabled")) return;
- OSM.router.route('/note/new');
+ OSM.router.route("/note/new");
});
function createNote(marker, form, url) {
newNote = null;
noteLayer.removeLayer(marker);
addNoteButton.removeClass("active");
- OSM.router.route('/note/' + feature.properties.id);
+ OSM.router.route("/note/" + feature.properties.id);
}
}
};
function newHalo(loc, a) {
- if (a === 'dragstart' && map.hasLayer(halo)) {
+ if (a === "dragstart" && map.hasLayer(halo)) {
map.removeLayer(halo);
} else {
if (map.hasLayer(halo)) map.removeLayer(halo);
map.addLayer(noteLayer);
- var params = querystring.parse(path.substring(path.indexOf('?') + 1));
+ var params = querystring.parse(path.substring(path.indexOf("?") + 1));
var markerLatlng;
if (params.lat && params.lon) {
$(e.target.form.add).prop("disabled", $(e.target).val() === "");
}
- content.find('input[type=submit]').on('click', function (e) {
+ content.find("input[type=submit]").on("click", function (e) {
e.preventDefault();
- createNote(newNote, e.target.form, '/api/0.6/notes.json');
+ createNote(newNote, e.target.form, "/api/0.6/notes.json");
});
return map.getState();
OSM.Note = function (map) {
- var content = $('#sidebar_content'),
+ var content = $("#sidebar_content"),
page = {},
halo, currentNote;
page.pushstate = page.popstate = function (path) {
OSM.loadSidebarContent(path, function() {
initialize(function() {
- var data = $('.details').data(),
- latLng = L.latLng(data.coordinates.split(','));
+ var data = $(".details").data(),
+ latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) moveToNote();
});
});
}
});
- content.find("textarea").val('').trigger("input");
+ content.find("textarea").val("").trigger("input");
- var data = $('.details').data(),
- latLng = L.latLng(data.coordinates.split(','));
+ var data = $(".details").data(),
+ latLng = L.latLng(data.coordinates.split(","));
if (!map.hasLayer(halo)) {
halo = L.circleMarker(latLng, {
}
function moveToNote() {
- var data = $('.details').data(),
- latLng = L.latLng(data.coordinates.split(','));
+ var data = $(".details").data(),
+ latLng = L.latLng(data.coordinates.split(","));
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
OSM.router.withoutMoveListener(function () {
}
});
- noteLayer.on('click', function(e) {
+ noteLayer.on("click", function(e) {
if (e.layer.id) {
- OSM.router.route('/note/' + e.layer.id);
+ OSM.router.route("/note/" + e.layer.id);
}
});
OSM.Query = function(map) {
var url = OSM.OVERPASS_URL,
queryButton = $(".control-query .control-button"),
- uninterestingTags = ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid', 'KSJ2:curve_id', 'KSJ2:lat', 'KSJ2:lon', 'KSJ2:coordinate', 'KSJ2:filename', 'note:ja'],
+ uninterestingTags = ["source", "source_ref", "source:ref", "history", "attribution", "created_by", "tiger:county", "tiger:tlid", "tiger:upload_uuid", "KSJ2:curve_id", "KSJ2:lat", "KSJ2:lon", "KSJ2:coordinate", "KSJ2:filename", "note:ja"],
marker;
var featureStyle = {
var geometry = $(this).data("geometry");
if (geometry) map.removeLayer(geometry);
- if (!$(e.target).is('a')) {
+ if (!$(e.target).is("a")) {
$(this).find("a").simulate("click", e);
}
}
};
page.load = function(path, noCentre) {
- var params = querystring.parse(path.substring(path.indexOf('?') + 1)),
+ var params = querystring.parse(path.substring(path.indexOf("?") + 1)),
latlng = L.latLng(params.lat, params.lon);
if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {
.on("mousedown", "p.search_results_entry:has(a.set_position)", function () {
var moved = false;
$(this).one("click", function (e) {
- if (!moved && !$(e.target).is('a')) {
+ if (!moved && !$(e.target).is("a")) {
$(this).find("a.set_position").simulate("click", e);
}
}).one("mousemove", function () {
var page = {};
page.pushstate = page.popstate = function(path) {
- var params = querystring.parse(path.substring(path.indexOf('?') + 1));
+ var params = querystring.parse(path.substring(path.indexOf("?") + 1));
$(".search_form input[name=query]").val(params.query);
$(".describe_location").hide();
OSM.loadSidebarContent(path, page.load);
var entry = $(this);
$.ajax({
url: entry.data("href"),
- method: 'GET',
+ method: "GET",
data: {
zoom: map.getZoom(),
minlon: map.getBounds().getWest(),
entry.html(html);
// go to first result of first geocoder
if (index === 0) {
- var firstResult = entry.find('*[data-lat][data-lon]:first').first();
+ var firstResult = entry.find("*[data-lat][data-lon]:first").first();
if (firstResult.length) {
panToSearchResult(firstResult.data());
}
var control = L.control(options);
control.onAdd = function (map) {
- var $container = $('<div>')
- .attr('class', 'control-key');
-
- var button = $('<a>')
- .attr('class', 'control-button')
- .attr('href', '#')
- .html('<span class="icon key"></span>')
- .on('click', toggle)
+ var $container = $("<div>")
+ .attr("class", "control-key");
+
+ var button = $("<a>")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .html("<span class=\"icon key\"></span>")
+ .on("click", toggle)
.appendTo($container);
- var $ui = $('<div>')
- .attr('class', 'key-ui');
+ var $ui = $("<div>")
+ .attr("class", "key-ui");
- $('<div>')
- .attr('class', 'sidebar_heading')
+ $("<div>")
+ .attr("class", "sidebar_heading")
.appendTo($ui)
.append(
- $('<span>')
- .text(I18n.t('javascripts.close'))
- .attr('class', 'icon close')
- .bind('click', toggle))
+ $("<span>")
+ .text(I18n.t("javascripts.close"))
+ .attr("class", "icon close")
+ .bind("click", toggle))
.append(
- $('<h4>')
- .text(I18n.t('javascripts.key.title')));
+ $("<h4>")
+ .text(I18n.t("javascripts.key.title")));
- var $section = $('<div>')
- .attr('class', 'section')
+ var $section = $("<div>")
+ .attr("class", "section")
.appendTo($ui);
options.sidebar.addPane($ui);
$ui
- .on('show', shown)
- .on('hide', hidden);
+ .on("show", shown)
+ .on("hide", hidden);
- map.on('baselayerchange', updateButton);
+ map.on("baselayerchange", updateButton);
updateButton();
function shown() {
- map.on('zoomend baselayerchange', update);
- $section.load('/key', update);
+ map.on("zoomend baselayerchange", update);
+ $section.load("/key", update);
}
function hidden() {
- map.off('zoomend baselayerchange', update);
+ map.off("zoomend baselayerchange", update);
}
function toggle(e) {
e.stopPropagation();
e.preventDefault();
- if (!button.hasClass('disabled')) {
+ if (!button.hasClass("disabled")) {
options.sidebar.togglePane($ui, button);
}
- $('.leaflet-control .control-button').tooltip('hide');
+ $(".leaflet-control .control-button").tooltip("hide");
}
function updateButton() {
- var disabled = ['mapnik', 'cyclemap'].indexOf(map.getMapBaseLayerId()) === -1;
+ var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1;
button
- .toggleClass('disabled', disabled)
- .attr('data-original-title',
+ .toggleClass("disabled", disabled)
+ .attr("data-original-title",
I18n.t(disabled ?
- 'javascripts.key.tooltip_disabled' :
- 'javascripts.key.tooltip'));
+ "javascripts.key.tooltip_disabled" :
+ "javascripts.key.tooltip"));
}
function update() {
var layer = map.getMapBaseLayerId(),
zoom = map.getZoom();
- $('.mapkey-table-entry').each(function () {
+ $(".mapkey-table-entry").each(function () {
var data = $(this).data();
if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
$(this).show();
control.onAdd = function (map) {
var layers = options.layers;
- var $container = $('<div>')
- .attr('class', 'control-layers');
-
- var button = $('<a>')
- .attr('class', 'control-button')
- .attr('href', '#')
- .attr('title', I18n.t('javascripts.map.layers.title'))
- .html('<span class="icon layers"></span>')
- .on('click', toggle)
+ var $container = $("<div>")
+ .attr("class", "control-layers");
+
+ var button = $("<a>")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .attr("title", I18n.t("javascripts.map.layers.title"))
+ .html("<span class=\"icon layers\"></span>")
+ .on("click", toggle)
.appendTo($container);
- var $ui = $('<div>')
- .attr('class', 'layers-ui');
+ var $ui = $("<div>")
+ .attr("class", "layers-ui");
- $('<div>')
- .attr('class', 'sidebar_heading')
+ $("<div>")
+ .attr("class", "sidebar_heading")
.appendTo($ui)
.append(
- $('<span>')
- .text(I18n.t('javascripts.close'))
- .attr('class', 'icon close')
- .bind('click', toggle))
+ $("<span>")
+ .text(I18n.t("javascripts.close"))
+ .attr("class", "icon close")
+ .bind("click", toggle))
.append(
- $('<h4>')
- .text(I18n.t('javascripts.map.layers.header')));
+ $("<h4>")
+ .text(I18n.t("javascripts.map.layers.header")));
- var baseSection = $('<div>')
- .attr('class', 'section base-layers')
+ var baseSection = $("<div>")
+ .attr("class", "section base-layers")
.appendTo($ui);
- var baseLayers = $('<ul>')
+ var baseLayers = $("<ul>")
.appendTo(baseSection);
layers.forEach(function(layer) {
- var item = $('<li>')
+ var item = $("<li>")
.appendTo(baseLayers);
if (map.hasLayer(layer)) {
- item.addClass('active');
+ item.addClass("active");
}
- var div = $('<div>')
+ var div = $("<div>")
.appendTo(item);
map.whenReady(function() {
miniMap.scrollWheelZoom.disable();
$ui
- .on('show', shown)
- .on('hide', hide);
+ .on("show", shown)
+ .on("hide", hide);
function shown() {
miniMap.invalidateSize();
setView({animate: false});
- map.on('moveend', moved);
+ map.on("moveend", moved);
}
function hide() {
- map.off('moveend', moved);
+ map.off("moveend", moved);
}
function moved() {
}
});
- var label = $('<label>')
+ var label = $("<label>")
.appendTo(item);
- var input = $('<input>')
- .attr('type', 'radio')
- .prop('checked', map.hasLayer(layer))
+ var input = $("<input>")
+ .attr("type", "radio")
+ .prop("checked", map.hasLayer(layer))
.appendTo(label);
label.append(layer.options.name);
- item.on('click', function() {
+ item.on("click", function() {
layers.forEach(function(other) {
if (other === layer) {
map.addLayer(other);
map.removeLayer(other);
}
});
- map.fire('baselayerchange', {layer: layer});
+ map.fire("baselayerchange", {layer: layer});
});
- item.on('dblclick', toggle);
+ item.on("dblclick", toggle);
- map.on('layeradd layerremove', function() {
- item.toggleClass('active', map.hasLayer(layer));
- input.prop('checked', map.hasLayer(layer));
+ map.on("layeradd layerremove", function() {
+ item.toggleClass("active", map.hasLayer(layer));
+ input.prop("checked", map.hasLayer(layer));
});
});
- if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
- var overlaySection = $('<div>')
- .attr('class', 'section overlay-layers')
+ if (OSM.STATUS !== "api_offline" && OSM.STATUS !== "database_offline") {
+ var overlaySection = $("<div>")
+ .attr("class", "section overlay-layers")
.appendTo($ui);
- $('<p>')
- .text(I18n.t('javascripts.map.layers.overlays'))
+ $("<p>")
+ .text(I18n.t("javascripts.map.layers.overlays"))
.attr("class", "deemphasize")
.appendTo(overlaySection);
- var overlays = $('<ul>')
+ var overlays = $("<ul>")
.appendTo(overlaySection);
var addOverlay = function (layer, name, maxArea) {
- var item = $('<li>')
+ var item = $("<li>")
.tooltip({
- placement: 'top'
+ placement: "top"
})
.appendTo(overlays);
- var label = $('<label>')
+ var label = $("<label>")
.appendTo(item);
var checked = map.hasLayer(layer);
- var input = $('<input>')
- .attr('type', 'checkbox')
- .prop('checked', checked)
+ var input = $("<input>")
+ .attr("type", "checkbox")
+ .prop("checked", checked)
.appendTo(label);
- label.append(I18n.t('javascripts.map.layers.' + name));
+ label.append(I18n.t("javascripts.map.layers." + name));
- input.on('change', function() {
- checked = input.is(':checked');
+ input.on("change", function() {
+ checked = input.is(":checked");
if (checked) {
map.addLayer(layer);
} else {
map.removeLayer(layer);
}
- map.fire('overlaylayerchange', {layer: layer});
+ map.fire("overlaylayerchange", {layer: layer});
});
- map.on('layeradd layerremove', function() {
- input.prop('checked', map.hasLayer(layer));
+ map.on("layeradd layerremove", function() {
+ input.prop("checked", map.hasLayer(layer));
});
- map.on('zoomend', function() {
+ map.on("zoomend", function() {
var disabled = map.getBounds().getSize() >= maxArea;
- $(input).prop('disabled', disabled);
+ $(input).prop("disabled", disabled);
- if (disabled && $(input).is(':checked')) {
- $(input).prop('checked', false)
- .trigger('change');
+ if (disabled && $(input).is(":checked")) {
+ $(input).prop("checked", false)
+ .trigger("change");
checked = true;
- } else if (!disabled && !$(input).is(':checked') && checked) {
- $(input).prop('checked', true)
- .trigger('change');
+ } else if (!disabled && !$(input).is(":checked") && checked) {
+ $(input).prop("checked", true)
+ .trigger("change");
}
- $(item).attr('class', disabled ? 'disabled' : '');
- item.attr('data-original-title', disabled ?
- I18n.t('javascripts.site.map_' + name + '_zoom_in_tooltip') : '');
+ $(item).attr("class", disabled ? "disabled" : "");
+ item.attr("data-original-title", disabled ?
+ I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip") : "");
});
};
- addOverlay(map.noteLayer, 'notes', OSM.MAX_NOTE_REQUEST_AREA);
- addOverlay(map.dataLayer, 'data', OSM.MAX_REQUEST_AREA);
- addOverlay(map.gpsLayer, 'gps', Number.POSITIVE_INFINITY);
+ addOverlay(map.noteLayer, "notes", OSM.MAX_NOTE_REQUEST_AREA);
+ addOverlay(map.dataLayer, "data", OSM.MAX_REQUEST_AREA);
+ addOverlay(map.gpsLayer, "gps", Number.POSITIVE_INFINITY);
}
options.sidebar.addPane($ui);
e.stopPropagation();
e.preventDefault();
options.sidebar.togglePane($ui, button);
- $('.leaflet-control .control-button').tooltip('hide');
+ $(".leaflet-control .control-button").tooltip("hide");
}
return $container[0];
initialize: function(id, options) {
L.Map.prototype.initialize.call(this, id, options);
- var copyright = I18n.t('javascripts.map.copyright', {copyright_url: '/copyright'});
- var donate = I18n.t('javascripts.map.donate_link_text', {donate_url: 'https://donate.openstreetmap.org'});
+ var copyright = I18n.t("javascripts.map.copyright", {copyright_url: "/copyright"});
+ var donate = I18n.t("javascripts.map.donate_link_text", {donate_url: "https://donate.openstreetmap.org"});
this.baseLayers = [];
}));
this.noteLayer = new L.FeatureGroup();
- this.noteLayer.options = {code: 'N'};
+ this.noteLayer.options = {code: "N"};
this.dataLayer = new L.OSM.DataLayer(null);
- this.dataLayer.options.code = 'D';
+ this.dataLayer.options.code = "D";
this.gpsLayer = new L.OSM.GPS({
pane: "overlayPane",
},
getLayersCode: function () {
- var layerConfig = '';
+ var layerConfig = "";
this.eachLayer(function (layer) {
if (layer.options && layer.options.code) {
layerConfig += layer.options.code;
params.mlon = latLng.lng.toFixed(precision);
}
- var url = window.location.protocol + '//' + OSM.SERVER_URL + '/',
+ var url = window.location.protocol + "//" + OSM.SERVER_URL + "/",
query = querystring.stringify(params),
hash = OSM.formatHash(this);
- if (query) url += '?' + query;
+ if (query) url += "?" + query;
if (hash) url += hash;
return url;
var zoom = this.getZoom(),
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
- window.location.protocol + '//osm.org/go/' :
- window.location.protocol + '//' + window.location.hostname + '/go/',
+ window.location.protocol + "//osm.org/go/" :
+ window.location.protocol + "//" + window.location.hostname + "/go/",
char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
}
var params = {};
- var layers = this.getLayersCode().replace('M', '');
+ var layers = this.getLayersCode().replace("M", "");
if (layers) {
params.layers = layers;
}
if (marker && this.hasLayer(marker)) {
- params.m = '';
+ params.m = "";
}
if (this._object) {
var query = querystring.stringify(params);
if (query) {
- str += '?' + query;
+ str += "?" + query;
}
return str;
params.lon = latLng.lng.toFixed(precision);
params.zoom = this.getZoom();
- return 'geo:' + params.lat + ',' + params.lon + '?z=' + params.zoom;
+ return "geo:" + params.lat + "," + params.lon + "?z=" + params.zoom;
},
addObject: function(object, callback) {
var changesetStyle = {
weight: 4,
- color: '#FF9500',
+ color: "#FF9500",
opacity: 1,
fillOpacity: 0,
interactive: false
var control = L.control(options);
control.onAdd = function (map) {
- var $container = $('<div>')
- .attr('class', 'control-note');
+ var $container = $("<div>")
+ .attr("class", "control-note");
- var link = $('<a>')
- .attr('class', 'control-button')
- .attr('href', '#')
- .html('<span class="icon note"></span>')
+ var link = $("<a>")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .html("<span class=\"icon note\"></span>")
.appendTo($container);
- map.on('zoomend', update);
+ map.on("zoomend", update);
function update() {
var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
link
- .toggleClass('disabled', disabled)
- .attr('data-original-title', I18n.t(disabled ?
- 'javascripts.site.createnote_disabled_tooltip' :
- 'javascripts.site.createnote_tooltip'));
+ .toggleClass("disabled", disabled)
+ .attr("data-original-title", I18n.t(disabled ?
+ "javascripts.site.createnote_disabled_tooltip" :
+ "javascripts.site.createnote_tooltip"));
}
update();
var control = L.control(options);
control.onAdd = function (map) {
- var $container = $('<div>')
- .attr('class', 'control-query');
+ var $container = $("<div>")
+ .attr("class", "control-query");
- var link = $('<a>')
- .attr('class', 'control-button')
- .attr('href', '#')
- .html('<span class="icon query"></span>')
+ var link = $("<a>")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .html("<span class=\"icon query\"></span>")
.appendTo($container);
- map.on('zoomend', update);
+ map.on("zoomend", update);
update();
function update() {
- var wasDisabled = link.hasClass('disabled'),
+ var wasDisabled = link.hasClass("disabled"),
isDisabled = map.getZoom() < 14;
link
- .toggleClass('disabled', isDisabled)
- .attr('data-original-title', I18n.t(isDisabled ?
- 'javascripts.site.queryfeature_disabled_tooltip' :
- 'javascripts.site.queryfeature_tooltip'));
+ .toggleClass("disabled", isDisabled)
+ .attr("data-original-title", I18n.t(isDisabled ?
+ "javascripts.site.queryfeature_disabled_tooltip" :
+ "javascripts.site.queryfeature_tooltip"));
if (isDisabled && !wasDisabled) {
- link.trigger('disabled');
+ link.trigger("disabled");
} else if (wasDisabled && !isDisabled) {
- link.trigger('enabled');
+ link.trigger("enabled");
}
}
});
control.onAdd = function (map) {
- var $container = $('<div>')
- .attr('class', 'control-share');
-
- var button = $('<a>')
- .attr('class', 'control-button')
- .attr('href', '#')
- .attr('title', I18n.t('javascripts.share.title'))
- .html('<span class="icon share"></span>')
- .on('click', toggle)
+ var $container = $("<div>")
+ .attr("class", "control-share");
+
+ var button = $("<a>")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .attr("title", I18n.t("javascripts.share.title"))
+ .html("<span class=\"icon share\"></span>")
+ .on("click", toggle)
.appendTo($container);
- var $ui = $('<div>')
- .attr('class', 'share-ui');
+ var $ui = $("<div>")
+ .attr("class", "share-ui");
- $('<div>')
- .attr('class', 'sidebar_heading')
+ $("<div>")
+ .attr("class", "sidebar_heading")
.appendTo($ui)
.append(
- $('<span>')
- .text(I18n.t('javascripts.close'))
- .attr('class', 'icon close')
- .bind('click', toggle))
+ $("<span>")
+ .text(I18n.t("javascripts.close"))
+ .attr("class", "icon close")
+ .bind("click", toggle))
.append(
- $('<h4>')
- .text(I18n.t('javascripts.share.title')));
+ $("<h4>")
+ .text(I18n.t("javascripts.share.title")));
// Link / Embed
- var $linkSection = $('<div>')
- .attr('class', 'section share-link')
+ var $linkSection = $("<div>")
+ .attr("class", "section share-link")
.appendTo($ui);
- $('<h4>')
- .text(I18n.t('javascripts.share.link'))
+ $("<h4>")
+ .text(I18n.t("javascripts.share.link"))
.appendTo($linkSection);
- var $form = $('<form>')
- .attr('class', 'standard-form')
+ var $form = $("<form>")
+ .attr("class", "standard-form")
.appendTo($linkSection);
- $('<div>')
- .attr('class', 'form-row')
+ $("<div>")
+ .attr("class", "form-row")
.appendTo($form)
.append(
- $('<label>')
- .attr('for', 'link_marker')
+ $("<label>")
+ .attr("for", "link_marker")
.append(
- $('<input>')
- .attr('id', 'link_marker')
- .attr('type', 'checkbox')
- .bind('change', toggleMarker))
- .append(I18n.t('javascripts.share.include_marker')));
-
- $('<div>')
- .attr('class', 'share-tabs')
+ $("<input>")
+ .attr("id", "link_marker")
+ .attr("type", "checkbox")
+ .bind("change", toggleMarker))
+ .append(I18n.t("javascripts.share.include_marker")));
+
+ $("<div>")
+ .attr("class", "share-tabs")
.appendTo($form)
- .append($('<a>')
- .attr('class', 'active')
- .attr('for', 'long_input')
- .attr('id', 'long_link')
- .text(I18n.t('javascripts.share.long_link')))
- .append($('<a>')
- .attr('for', 'short_input')
- .attr('id', 'short_link')
- .text(I18n.t('javascripts.share.short_link')))
- .append($('<a>')
- .attr('for', 'embed_html')
- .attr('href', '#')
- .text(I18n.t('javascripts.share.embed')))
- .on('click', 'a', function(e) {
+ .append($("<a>")
+ .attr("class", "active")
+ .attr("for", "long_input")
+ .attr("id", "long_link")
+ .text(I18n.t("javascripts.share.long_link")))
+ .append($("<a>")
+ .attr("for", "short_input")
+ .attr("id", "short_link")
+ .text(I18n.t("javascripts.share.short_link")))
+ .append($("<a>")
+ .attr("for", "embed_html")
+ .attr("href", "#")
+ .text(I18n.t("javascripts.share.embed")))
+ .on("click", "a", function(e) {
e.preventDefault();
- var id = '#' + $(this).attr('for');
- $linkSection.find('.share-tabs a')
- .removeClass('active');
- $(this).addClass('active');
- $linkSection.find('.share-tab')
+ var id = "#" + $(this).attr("for");
+ $linkSection.find(".share-tabs a")
+ .removeClass("active");
+ $(this).addClass("active");
+ $linkSection.find(".share-tab")
.hide();
- $linkSection.find('.share-tab:has(' + id + ')')
+ $linkSection.find(".share-tab:has(" + id + ")")
.show()
- .find('input, textarea')
+ .find("input, textarea")
.select();
});
- $('<div>')
- .attr('class', 'form-row share-tab')
- .css('display', 'block')
+ $("<div>")
+ .attr("class", "form-row share-tab")
+ .css("display", "block")
.appendTo($form)
- .append($('<input>')
- .attr('id', 'long_input')
- .attr('type', 'text')
- .on('click', select));
+ .append($("<input>")
+ .attr("id", "long_input")
+ .attr("type", "text")
+ .on("click", select));
- $('<div>')
- .attr('class', 'form-row share-tab')
+ $("<div>")
+ .attr("class", "form-row share-tab")
.appendTo($form)
- .append($('<input>')
- .attr('id', 'short_input')
- .attr('type', 'text')
- .on('click', select));
+ .append($("<input>")
+ .attr("id", "short_input")
+ .attr("type", "text")
+ .on("click", select));
- $('<div>')
- .attr('class', 'form-row share-tab')
+ $("<div>")
+ .attr("class", "form-row share-tab")
.appendTo($form)
.append(
- $('<textarea>')
- .attr('id', 'embed_html')
- .on('click', select))
+ $("<textarea>")
+ .attr("id", "embed_html")
+ .on("click", select))
.append(
- $('<p>')
- .attr('class', 'deemphasize')
- .text(I18n.t('javascripts.share.paste_html'))
+ $("<p>")
+ .attr("class", "deemphasize")
+ .text(I18n.t("javascripts.share.paste_html"))
.appendTo($linkSection));
// Geo URI
- var $geoUriSection = $('<div>')
- .attr('class', 'section share-geo-uri')
+ var $geoUriSection = $("<div>")
+ .attr("class", "section share-geo-uri")
.appendTo($ui);
- $('<h4>')
- .text(I18n.t('javascripts.share.geo_uri'))
+ $("<h4>")
+ .text(I18n.t("javascripts.share.geo_uri"))
.appendTo($geoUriSection);
- $('<div>')
+ $("<div>")
.appendTo($geoUriSection)
- .append($('<a>')
- .attr('id', 'geo_uri'));
+ .append($("<a>")
+ .attr("id", "geo_uri"));
// Image
- var $imageSection = $('<div>')
- .attr('class', 'section share-image')
+ var $imageSection = $("<div>")
+ .attr("class", "section share-image")
.appendTo($ui);
- $('<h4>')
- .text(I18n.t('javascripts.share.image'))
+ $("<h4>")
+ .text(I18n.t("javascripts.share.image"))
.appendTo($imageSection);
- $('<div>')
- .attr('id', 'export-warning')
- .attr('class', 'deemphasize')
- .text(I18n.t('javascripts.share.only_standard_layer'))
+ $("<div>")
+ .attr("id", "export-warning")
+ .attr("class", "deemphasize")
+ .text(I18n.t("javascripts.share.only_standard_layer"))
.appendTo($imageSection);
- $form = $('<form>')
- .attr('id', 'export-image')
- .attr('class', 'standard-form')
- .attr('action', '/export/finish')
- .attr('method', 'post')
+ $form = $("<form>")
+ .attr("id", "export-image")
+ .attr("class", "standard-form")
+ .attr("action", "/export/finish")
+ .attr("method", "post")
.appendTo($imageSection);
- $('<div>')
- .attr('class', 'form-row')
+ $("<div>")
+ .attr("class", "form-row")
.appendTo($form)
.append(
- $('<label>')
- .attr('for', 'image_filter')
+ $("<label>")
+ .attr("for", "image_filter")
.append(
- $('<input>')
- .attr('id', 'image_filter')
- .attr('type', 'checkbox')
- .bind('change', toggleFilter))
- .append(I18n.t('javascripts.share.custom_dimensions')));
-
- $('<div>')
- .attr('class', 'form-row')
+ $("<input>")
+ .attr("id", "image_filter")
+ .attr("type", "checkbox")
+ .bind("change", toggleFilter))
+ .append(I18n.t("javascripts.share.custom_dimensions")));
+
+ $("<div>")
+ .attr("class", "form-row")
.appendTo($form)
.append(
- $('<label>')
- .attr('for', 'mapnik_format')
- .text(I18n.t('javascripts.share.format')))
- .append($('<select>')
- .attr('name', 'mapnik_format')
- .attr('id', 'mapnik_format')
- .append($('<option>').val('png').text('PNG').prop('selected', true))
- .append($('<option>').val('jpeg').text('JPEG'))
- .append($('<option>').val('svg').text('SVG'))
- .append($('<option>').val('pdf').text('PDF')));
-
- $('<div>')
- .attr('class', 'form-row')
+ $("<label>")
+ .attr("for", "mapnik_format")
+ .text(I18n.t("javascripts.share.format")))
+ .append($("<select>")
+ .attr("name", "mapnik_format")
+ .attr("id", "mapnik_format")
+ .append($("<option>").val("png").text("PNG").prop("selected", true))
+ .append($("<option>").val("jpeg").text("JPEG"))
+ .append($("<option>").val("svg").text("SVG"))
+ .append($("<option>").val("pdf").text("PDF")));
+
+ $("<div>")
+ .attr("class", "form-row")
.appendTo($form)
- .append($('<label>')
- .attr('for', 'mapnik_scale')
- .text(I18n.t('javascripts.share.scale')))
- .append('1 : ')
- .append($('<input>')
- .attr('name', 'mapnik_scale')
- .attr('id', 'mapnik_scale')
- .attr('type', 'text')
- .on('change', update));
-
- ['minlon', 'minlat', 'maxlon', 'maxlat'].forEach(function(name) {
- $('<input>')
- .attr('id', 'mapnik_' + name)
- .attr('name', name)
- .attr('type', 'hidden')
+ .append($("<label>")
+ .attr("for", "mapnik_scale")
+ .text(I18n.t("javascripts.share.scale")))
+ .append("1 : ")
+ .append($("<input>")
+ .attr("name", "mapnik_scale")
+ .attr("id", "mapnik_scale")
+ .attr("type", "text")
+ .on("change", update));
+
+ ["minlon", "minlat", "maxlon", "maxlat"].forEach(function(name) {
+ $("<input>")
+ .attr("id", "mapnik_" + name)
+ .attr("name", name)
+ .attr("type", "hidden")
.appendTo($form);
});
- $('<input>')
- .attr('name', 'format')
- .attr('value', 'mapnik')
- .attr('type', 'hidden')
+ $("<input>")
+ .attr("name", "format")
+ .attr("value", "mapnik")
+ .attr("type", "hidden")
.appendTo($form);
var csrf_param = $("meta[name=csrf-param]").attr("content"),
csrf_token = $("meta[name=csrf-token]").attr("content");
- $('<input>')
- .attr('name', csrf_param)
- .attr('value', csrf_token)
- .attr('type', 'hidden')
+ $("<input>")
+ .attr("name", csrf_param)
+ .attr("value", csrf_token)
+ .attr("type", "hidden")
.appendTo($form);
- $('<p>')
- .attr('class', 'deemphasize')
- .html(I18n.t('javascripts.share.image_size') + ' <span id="mapnik_image_width"></span> x <span id="mapnik_image_height"></span>')
+ $("<p>")
+ .attr("class", "deemphasize")
+ .html(I18n.t("javascripts.share.image_size") + " <span id=\"mapnik_image_width\"></span> x <span id=\"mapnik_image_height\"></span>")
.appendTo($form);
- $('<input>')
- .attr('type', 'submit')
- .attr('value', I18n.t('javascripts.share.download'))
+ $("<input>")
+ .attr("type", "submit")
+ .attr("value", I18n.t("javascripts.share.download"))
.appendTo($form);
locationFilter
- .on('change', update)
+ .on("change", update)
.addTo(map);
- marker.on('dragend', movedMarker);
- map.on('move', movedMap);
- map.on('moveend layeradd layerremove', update);
+ marker.on("dragend", movedMarker);
+ map.on("move", movedMap);
+ map.on("moveend layeradd layerremove", update);
options.sidebar.addPane($ui);
$ui
- .on('hide', hidden);
+ .on("hide", hidden);
function hidden() {
map.removeLayer(marker);
e.stopPropagation();
e.preventDefault();
- $('#mapnik_scale').val(getScale());
+ $("#mapnik_scale").val(getScale());
marker.setLatLng(map.getCenter());
update();
options.sidebar.togglePane($ui, button);
- $('.leaflet-control .control-button').tooltip('hide');
+ $(".leaflet-control .control-button").tooltip("hide");
}
function toggleMarker() {
- if ($(this).is(':checked')) {
+ if ($(this).is(":checked")) {
marker.setLatLng(map.getCenter());
map.addLayer(marker);
- map.options.scrollWheelZoom = map.options.doubleClickZoom = 'center';
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = "center";
} else {
map.removeLayer(marker);
map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
}
function toggleFilter() {
- if ($(this).is(':checked')) {
+ if ($(this).is(":checked")) {
locationFilter.setBounds(map.getBounds().pad(-0.2));
locationFilter.enable();
} else {
function movedMarker() {
if (map.hasLayer(marker)) {
- map.off('move', movedMap);
- map.on('moveend', updateOnce);
+ map.off("move", movedMap);
+ map.on("moveend", updateOnce);
map.panTo(marker.getLatLng());
}
}
function updateOnce() {
- map.off('moveend', updateOnce);
- map.on('move', movedMap);
+ map.off("moveend", updateOnce);
+ map.on("move", movedMap);
update();
}
function escapeHTML(string) {
var htmlEscapes = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": '''
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ "\"": """,
+ "'": "'"
};
- return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
+ return string === null ? "" : (string + "").replace(/[&<>"']/g, function(match) {
return htmlEscapes[match];
});
}
function update() {
var bounds = map.getBounds();
- $('#link_marker')
- .prop('checked', map.hasLayer(marker));
+ $("#link_marker")
+ .prop("checked", map.hasLayer(marker));
- $('#image_filter')
- .prop('checked', locationFilter.isEnabled());
+ $("#image_filter")
+ .prop("checked", locationFilter.isEnabled());
// Link / Embed
- $('#short_input').val(map.getShortUrl(marker));
- $('#long_input').val(map.getUrl(marker));
- $('#short_link').attr('href', map.getShortUrl(marker));
- $('#long_link').attr('href', map.getUrl(marker));
+ $("#short_input").val(map.getShortUrl(marker));
+ $("#long_input").val(map.getUrl(marker));
+ $("#short_link").attr("href", map.getShortUrl(marker));
+ $("#long_link").attr("href", map.getUrl(marker));
var params = {
bbox: bounds.toBBoxString(),
if (map.hasLayer(marker)) {
var latLng = marker.getLatLng().wrap();
- params.marker = latLng.lat + ',' + latLng.lng;
+ params.marker = latLng.lat + "," + latLng.lng;
}
- $('#embed_html').val(
- '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
- escapeHTML(OSM.SERVER_PROTOCOL + '://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params)) +
- '" style="border: 1px solid black"></iframe><br/>' +
- '<small><a href="' + escapeHTML(map.getUrl(marker)) + '">' +
- escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '</a></small>');
+ $("#embed_html").val(
+ "<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"" +
+ escapeHTML(OSM.SERVER_PROTOCOL + "://" + OSM.SERVER_URL + "/export/embed.html?" + $.param(params)) +
+ "\" style=\"border: 1px solid black\"></iframe><br/>" +
+ "<small><a href=\"" + escapeHTML(map.getUrl(marker)) + "\">" +
+ escapeHTML(I18n.t("javascripts.share.view_larger_map")) + "</a></small>");
// Geo URI
- $('#geo_uri')
- .attr('href', map.getGeoUri(marker))
+ $("#geo_uri")
+ .attr("href", map.getGeoUri(marker))
.html(map.getGeoUri(marker));
// Image
L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
- $('#mapnik_minlon').val(bounds.getWest());
- $('#mapnik_minlat').val(bounds.getSouth());
- $('#mapnik_maxlon').val(bounds.getEast());
- $('#mapnik_maxlat').val(bounds.getNorth());
+ $("#mapnik_minlon").val(bounds.getWest());
+ $("#mapnik_minlat").val(bounds.getSouth());
+ $("#mapnik_maxlon").val(bounds.getEast());
+ $("#mapnik_maxlat").val(bounds.getNorth());
if (scale < maxScale) {
scale = roundScale(maxScale);
$("#mapnik_image_width").text(Math.round(size.x / scale / 0.00028));
$("#mapnik_image_height").text(Math.round(size.y / scale / 0.00028));
- if (map.getMapBaseLayerId() === 'mapnik') {
- $('#export-image').show();
- $('#export-warning').hide();
+ if (map.getMapBaseLayerId() === "mapnik") {
+ $("#export-image").show();
+ $("#export-warning").hide();
} else {
- $('#export-image').hide();
- $('#export-warning').show();
+ $("#export-image").hide();
+ $("#export-warning").show();
}
}
control.togglePane = function(pane, button) {
current
.hide()
- .trigger('hide');
+ .trigger("hide");
currentButton
- .removeClass('active');
+ .removeClass("active");
if (current === pane) {
$(sidebar).hide();
current
.show()
- .trigger('show');
+ .trigger("show");
currentButton
- .addClass('active');
+ .addClass("active");
};
return control;
L.OSM.Zoom = L.Control.extend({
options: {
- position: 'topright'
+ position: "topright"
},
onAdd: function (map) {
- var zoomName = 'zoom',
- container = L.DomUtil.create('div', zoomName);
+ var zoomName = "zoom",
+ container = L.DomUtil.create("div", zoomName);
this._map = map;
this._zoomInButton = this._createButton(
- '', I18n.t('javascripts.map.zoom.in'), zoomName + 'in', container, this._zoomIn, this);
+ "", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
this._zoomOutButton = this._createButton(
- '', I18n.t('javascripts.map.zoom.out'), zoomName + 'out', container, this._zoomOut, this);
+ "", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
- map.on('zoomend zoomlevelschange', this._updateDisabled, this);
+ map.on("zoomend zoomlevelschange", this._updateDisabled, this);
return container;
},
onRemove: function (map) {
- map.off('zoomend zoomlevelschange', this._updateDisabled, this);
+ map.off("zoomend zoomlevelschange", this._updateDisabled, this);
},
_zoomIn: function (e) {
},
_createButton: function (html, title, className, container, fn, context) {
- var link = L.DomUtil.create('a', 'control-button ' + className, container);
+ var link = L.DomUtil.create("a", "control-button " + className, container);
link.innerHTML = html;
- link.href = '#';
+ link.href = "#";
link.title = title;
- L.DomUtil.create('span', 'icon ' + className, link);
+ L.DomUtil.create("span", "icon " + className, link);
var stop = L.DomEvent.stopPropagation;
L.DomEvent
- .on(link, 'click', stop)
- .on(link, 'mousedown', stop)
- .on(link, 'dblclick', stop)
- .on(link, 'click', L.DomEvent.preventDefault)
- .on(link, 'click', fn, context);
+ .on(link, "click", stop)
+ .on(link, "mousedown", stop)
+ .on(link, "dblclick", stop)
+ .on(link, "click", L.DomEvent.preventDefault)
+ .on(link, "click", fn, context);
return link;
},
_updateDisabled: function () {
var map = this._map,
- className = 'disabled';
+ className = "disabled";
L.DomUtil.removeClass(this._zoomInButton, className);
L.DomUtil.removeClass(this._zoomOutButton, className);
var application_data = $("head").data();
function makeAbsolute(url) {
- var a = document.createElement('a');
+ var a = document.createElement("a");
a.href = url;
return a.href;
}
var splatParam = /\*\w+/g;
function Route(path, controller) {
- var regexp = new RegExp('^' +
- path.replace(escapeRegExp, '\\$&')
- .replace(optionalParam, '(?:$1)?')
+ var regexp = new RegExp("^" +
+ path.replace(escapeRegExp, "\\$&")
+ .replace(optionalParam, "(?:$1)?")
.replace(namedParam, function(match, optional){
- return optional ? match : '([^\/]+)';
+ return optional ? match : "([^\/]+)";
})
- .replace(splatParam, '(.*?)') + '(?:\\?.*)?$');
+ .replace(splatParam, "(.*?)") + "(?:\\?.*)?$");
var route = {};
}
};
- var currentPath = window.location.pathname.replace(/(.)\/$/, '$1') + window.location.search,
+ var currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search,
currentRoute = routes.recognize(currentPath),
currentHash = location.hash || OSM.formatHash(map);
var router = {};
if (window.history && window.history.pushState) {
- $(window).on('popstate', function(e) {
+ $(window).on("popstate", function(e) {
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
var path = window.location.pathname + window.location.search,
route = routes.recognize(path);
if (path === currentPath) return;
- currentRoute.run('unload', null, route === currentRoute);
+ currentRoute.run("unload", null, route === currentRoute);
currentPath = path;
currentRoute = route;
- currentRoute.run('popstate', currentPath);
+ currentRoute.run("popstate", currentPath);
map.setState(e.originalEvent.state, {animate: false});
});
router.route = function (url) {
- var path = url.replace(/#.*/, ''),
+ var path = url.replace(/#.*/, ""),
route = routes.recognize(path);
if (!route) return false;
- currentRoute.run('unload', null, route === currentRoute);
+ currentRoute.run("unload", null, route === currentRoute);
var state = OSM.parseHash(url);
map.setState(state);
window.history.pushState(state, document.title, url);
currentPath = path;
currentRoute = route;
- currentRoute.run('pushstate', currentPath);
+ currentRoute.run("pushstate", currentPath);
return true;
};
router.withoutMoveListener = function (callback) {
function disableMoveListener() {
- map.off('moveend', router.updateHash);
- map.once('moveend', function () {
- map.on('moveend', router.updateHash);
+ map.off("moveend", router.updateHash);
+ map.once("moveend", function () {
+ map.on("moveend", router.updateHash);
});
}
- map.once('movestart', disableMoveListener);
+ map.once("movestart", disableMoveListener);
callback();
- map.off('movestart', disableMoveListener);
+ map.off("movestart", disableMoveListener);
};
router.load = function() {
- var loadState = currentRoute.run('load', currentPath);
+ var loadState = currentRoute.run("load", currentPath);
router.stateChange(loadState || {});
};
currentRoute = routes.recognize(currentPath);
};
- map.on('moveend baselayerchange overlaylayerchange', router.updateHash);
- $(window).on('hashchange', router.hashUpdated);
+ map.on("moveend baselayerchange overlaylayerchange", router.updateHash);
+ $(window).on("hashchange", router.hashUpdated);
return router;
};
zoomControl: false
}).addLayer(new L.OSM.Mapnik());
- var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
+ var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
L.OSM.zoom({position: position})
.addTo(map);
var locate = L.control.locate({
position: position,
- icon: 'icon geolocate',
- iconLoading: 'icon geolocate',
+ icon: "icon geolocate",
+ iconLoading: "icon geolocate",
strings: {
- title: I18n.t('javascripts.map.locate.title'),
- popup: I18n.t('javascripts.map.locate.popup')
+ title: I18n.t("javascripts.map.locate.title"),
+ popup: I18n.t("javascripts.map.locate.popup")
}
}).addTo(map);
var locateContainer = locate.getContainer();
$(locateContainer)
- .removeClass('leaflet-control-locate leaflet-bar')
- .addClass('control-locate')
+ .removeClass("leaflet-control-locate leaflet-bar")
+ .addClass("control-locate")
.children("a")
- .attr('href', '#')
- .removeClass('leaflet-bar-part leaflet-bar-part-single')
- .addClass('control-button');
+ .attr("href", "#")
+ .removeClass("leaflet-bar-part leaflet-bar-part-single")
+ .addClass("control-button");
if (OSM.home) {
map.setView([OSM.home.lat, OSM.home.lon], 12);
}
map.on("click", function (e) {
- if ($('#updatehome').is(':checked')) {
+ if ($("#updatehome").is(":checked")) {
var zoom = map.getZoom(),
precision = OSM.zoomPrecision(zoom),
location = e.latlng.wrap();
- $('#homerow').removeClass();
- $('#home_lat').val(location.lat.toFixed(precision));
- $('#home_lon').val(location.lng.toFixed(precision));
+ $("#homerow").removeClass();
+ $("#home_lat").val(location.lat.toFixed(precision));
+ $("#home_lon").val(location.lng.toFixed(precision));
marker.setLatLng(e.latlng);
marker.addTo(map);
});
} else {
$("[data-user]").each(function () {
- var user = $(this).data('user');
+ var user = $(this).data("user");
if (user.lon && user.lat) {
L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
.bindPopup(user.description);
params.lon = parseFloat(params.lon);
params.zoom = params.zoom || 17;
- var url = '/edit';
+ var url = "/edit";
if (params.editor) {
- url += '?editor=' + params.editor;
+ url += "?editor=" + params.editor;
}
url += OSM.formatHash(params);
- $('.start-mapping').attr('href', url);
+ $(".start-mapping").attr("href", url);
} else {
var geoSuccess = function (position) {
- window.location = '/edit' + OSM.formatHash({
+ window.location = "/edit" + OSM.formatHash({
zoom: 17,
lat: position.coords.latitude,
lon: position.coords.longitude
});
};
- $('.start-mapping').on('click', function(e) {
+ $(".start-mapping").on("click", function(e) {
e.preventDefault();
- $('.start-mapping').addClass('loading');
+ $(".start-mapping").addClass("loading");
if (navigator.geolocation) {
// handle firefox's weird implementation
}
function manualEdit() {
- window.location = '/?edit_help=1';
+ window.location = "/?edit_help=1";
}
});
"no-void": "error",
"no-warning-comments": "warn",
"no-with": "error",
+ "quotes": ["error", "double"],
"radix": ["error", "always"],
"semi": ["error", "always"],
"semi-spacing": "error",