1 //= require leaflet.locate
3 $(document).ready(function () {
4 if ($("#map").length) {
5 var map = L.map("map", {
6 attributionControl: false,
8 }).addLayer(new L.OSM.Mapnik());
10 var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
12 L.OSM.zoom({position: position})
18 title: I18n.t('javascripts.map.locate.title'),
19 popup: I18n.t('javascripts.map.locate.popup')
24 map.setView([OSM.home.lat, OSM.home.lon], 12);
26 map.setView([0, 0], 0);
29 if ($("#map").hasClass("set_location")) {
30 var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
33 marker.setLatLng([OSM.home.lat, OSM.home.lon]);
37 map.on("click", function (e) {
38 if ($('#updatehome').is(':checked')) {
39 var zoom = map.getZoom(),
40 precision = OSM.zoomPrecision(zoom),
41 location = e.latlng.wrap();
43 $('#homerow').removeClass();
44 $('#home_lat').val(location.lat.toFixed(precision));
45 $('#home_lon').val(location.lng.toFixed(precision));
47 marker.setLatLng(e.latlng);
52 $("[data-user]").each(function () {
53 var user = $(this).data('user');
54 if (user.lon && user.lat) {
55 L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
56 .bindPopup(user.description);
62 function updateAuthUID() {
63 var provider = $("select#user_auth_provider").val();
65 if (provider === "openid") {
66 $("input#user_auth_uid").show().prop("disabled", false);
68 $("input#user_auth_uid").hide().prop("disabled", true);
74 $("select#user_auth_provider").on("change", updateAuthUID);
76 function enableAuth() {
77 $("#auth_prompt").hide();
78 $("#auth_field").show();
79 $("#user_auth_uid").prop("disabled", false);
82 function disableAuth() {
83 $("#auth_prompt").show();
84 $("#auth_field").hide();
85 $("#user_auth_uid").prop("disabled", true);
88 $("#auth_enable").click(enableAuth);
90 if ($("select#user_auth_provider").val() === "") {