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})
15 var locate = L.control.locate({
17 icon: 'icon geolocate',
18 iconLoading: 'icon geolocate',
20 title: I18n.t('javascripts.map.locate.title'),
21 popup: I18n.t('javascripts.map.locate.popup')
25 var locateContainer = locate.getContainer();
28 .removeClass('leaflet-control-locate leaflet-bar')
29 .addClass('control-locate')
32 .removeClass('leaflet-bar-part leaflet-bar-part-single')
33 .addClass('control-button');
36 map.setView([OSM.home.lat, OSM.home.lon], 12);
38 map.setView([0, 0], 0);
41 if ($("#map").hasClass("set_location")) {
42 var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
45 marker.setLatLng([OSM.home.lat, OSM.home.lon]);
49 map.on("click", function (e) {
50 if ($('#updatehome').is(':checked')) {
51 var zoom = map.getZoom(),
52 precision = OSM.zoomPrecision(zoom),
53 location = e.latlng.wrap();
55 $('#homerow').removeClass();
56 $('#home_lat').val(location.lat.toFixed(precision));
57 $('#home_lon').val(location.lng.toFixed(precision));
59 marker.setLatLng(e.latlng);
64 $("[data-user]").each(function () {
65 var user = $(this).data('user');
66 if (user.lon && user.lat) {
67 L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
68 .bindPopup(user.description);
74 function updateAuthUID() {
75 var provider = $("select#user_auth_provider").val();
77 if (provider === "openid") {
78 $("input#user_auth_uid").show().prop("disabled", false);
80 $("input#user_auth_uid").hide().prop("disabled", true);
86 $("select#user_auth_provider").on("change", updateAuthUID);
88 function enableAuth() {
89 $("#auth_prompt").hide();
90 $("#auth_field").show();
91 $("#user_auth_uid").prop("disabled", false);
94 function disableAuth() {
95 $("#auth_prompt").show();
96 $("#auth_field").hide();
97 $("#user_auth_uid").prop("disabled", true);
100 $("#auth_enable").click(enableAuth);
102 if ($("select#user_auth_provider").val() === "") {
108 $("#user_all").change(function () {
109 $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked"));
112 $("#content.user_confirm").each(function () {
114 $(this).find("#confirm").submit();
117 $("input[name=legale]").change(function () {
118 var url = $(this).data("url");
120 $("#contributorTerms").html("<img src='" + OSM.SEARCHING + "' />");
121 $("#contributorTerms").load(url);