X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d6a8aaa3690a86820ecc6198f1d5455d8f6cbbe5..b5800b4c2f51e265b51f6b0cd45728b8d7db86aa:/app/assets/javascripts/sidebar.js?ds=sidebyside diff --git a/app/assets/javascripts/sidebar.js b/app/assets/javascripts/sidebar.js index 4ef379bf5..912197b9f 100644 --- a/app/assets/javascripts/sidebar.js +++ b/app/assets/javascripts/sidebar.js @@ -1,40 +1,21 @@ -var openSidebar; +function openSidebar(options) { + options = options || {}; -(function () { - var onclose; + $("#sidebar").trigger("closed"); - openSidebar = function(options) { - options = options || {}; + if (options.title) { $("#sidebar_title").html(options.title); } - if (onclose) { - onclose(); - onclose = null; - } + $("#sidebar").width(options.width || "30%"); + $("#sidebar").css("display", "block").trigger("opened"); +} - if (options.title) { $("#sidebar_title").html(options.title); } +function closeSidebar() { + $("#sidebar").css("display", "none").trigger("closed"); +} - if (options.width) { $("#sidebar").width(options.width); } - else { $("#sidebar").width("30%"); } - - $("#sidebar").css("display", "block"); - - $("#sidebar").trigger("opened"); - - onclose = options.onclose; - }; - - $(document).ready(function () { - $(".sidebar_close").click(function (e) { - $("#sidebar").css("display", "none"); - - $("#sidebar").trigger("closed"); - - if (onclose) { - onclose(); - onclose = null; - } - - e.preventDefault(); - }); +$(document).ready(function () { + $(".sidebar_close").click(function (e) { + closeSidebar(); + e.preventDefault(); }); -})(); +});