+ $("#home_lat, #home_lon").removeClass("is-invalid");
+ } catch (error) {
+ if (lat && isNaN(lat)) $("#home_lat").addClass("is-invalid");
+ if (lon && isNaN(lon)) $("#home_lon").addClass("is-invalid");
+ }
+
+ $("#home_message").toggleClass("invisible", Boolean(location));
+ $("#home_show").prop("hidden", !location);
+ $("#home_delete").prop("hidden", !location);
+ $("#home_undelete").prop("hidden", !(!location && deleted_lat && deleted_lon));
+ if (location) {
+ marker.setLatLng([lat, lon]);
+ marker.addTo(map);
+ map.panTo([lat, lon]);
+ } else {
+ marker.removeFrom(map);
+ }
+ }
+
+ function isCloseEnoughToMapCenter(location) {
+ var inputPt = map.latLngToContainerPoint(location),
+ centerPt = map.latLngToContainerPoint(map.getCenter());
+
+ return centerPt.distanceTo(inputPt) < 10;
+ }
+
+ function updateAuthUID() {
+ var provider = $("select#user_auth_provider").val();
+
+ if (provider === "openid") {
+ $("input#user_auth_uid").show().prop("disabled", false);
+ } else {
+ $("input#user_auth_uid").hide().prop("disabled", true);
+ }
+ }
+
+ updateAuthUID();
+
+ $("select#user_auth_provider").on("change", updateAuthUID);
+
+ $("input#user_avatar").on("change", function () {
+ $("#user_avatar_action_new").prop("checked", true);
+ });
+
+ function enableAuth() {
+ $("#auth_prompt").hide();
+ $("#auth_field").show();
+ $("#user_auth_uid").prop("disabled", false);
+ }
+
+ function disableAuth() {
+ $("#auth_prompt").show();
+ $("#auth_field").hide();
+ $("#user_auth_uid").prop("disabled", true);
+ }
+
+ $("#auth_enable").click(enableAuth);
+
+ if ($("select#user_auth_provider").val() === "") {
+ disableAuth();