X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d6a8aaa3690a86820ecc6198f1d5455d8f6cbbe5..569f3cbe9bac4e0f42313a5c3ed8e2dfe4a0e099:/app/assets/javascripts/sidebar.js diff --git a/app/assets/javascripts/sidebar.js b/app/assets/javascripts/sidebar.js index 4ef379bf5..a5d906980 100644 --- a/app/assets/javascripts/sidebar.js +++ b/app/assets/javascripts/sidebar.js @@ -1,40 +1,24 @@ -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; - } + if (options.width) { $("#sidebar").width(options.width); } + else { $("#sidebar").width("30%"); } - if (options.title) { $("#sidebar_title").html(options.title); } + $("#sidebar").css("display", "block"); - if (options.width) { $("#sidebar").width(options.width); } - else { $("#sidebar").width("30%"); } + $("#sidebar").trigger("opened"); +}; - $("#sidebar").css("display", "block"); +$(document).ready(function () { + $(".sidebar_close").click(function (e) { + $("#sidebar").css("display", "none"); - $("#sidebar").trigger("opened"); + $("#sidebar").trigger("closed"); - 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(); - }); + e.preventDefault(); }); -})(); +});