]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.sidebar-pane.js
Create Leaflet sidebar pane control with header writer fn
[rails.git] / app / assets / javascripts / leaflet.sidebar-pane.js
diff --git a/app/assets/javascripts/leaflet.sidebar-pane.js b/app/assets/javascripts/leaflet.sidebar-pane.js
new file mode 100644 (file)
index 0000000..f087cbb
--- /dev/null
@@ -0,0 +1,23 @@
+L.OSM.sidebarPane = function (options) {
+  var control = L.control(options);
+
+  control.makeUI = function (uiClass, paneTitle, toggle) {
+    var $ui = $("<div>")
+      .attr("class", uiClass);
+
+    $("<div>")
+      .attr("class", "sidebar_heading")
+      .appendTo($ui)
+      .append(
+        $("<button type='button' class='btn-close float-end mt-1'>")
+          .attr("aria-label", I18n.t("javascripts.close"))
+          .bind("click", toggle))
+      .append(
+        $("<h4>")
+          .text(I18n.t(paneTitle)));
+
+    return $ui;
+  };
+
+  return control;
+};