]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/sidebar.js
4ef379bf5cef51055d3e1b48ae65470da08bb464
[rails.git] / app / assets / javascripts / sidebar.js
1 var openSidebar;
2
3 (function () {
4   var onclose;
5
6   openSidebar = function(options) {
7     options = options || {};
8
9     if (onclose) {
10       onclose();
11       onclose = null;
12     }
13
14     if (options.title) { $("#sidebar_title").html(options.title); }
15
16     if (options.width) { $("#sidebar").width(options.width); }
17     else { $("#sidebar").width("30%"); }
18
19     $("#sidebar").css("display", "block");
20
21     $("#sidebar").trigger("opened");
22
23     onclose = options.onclose;
24   };
25
26   $(document).ready(function () {
27     $(".sidebar_close").click(function (e) {
28       $("#sidebar").css("display", "none");
29
30       $("#sidebar").trigger("closed");
31
32       if (onclose) {
33         onclose();
34         onclose = null;
35       }
36
37       e.preventDefault();
38     });
39   });
40 })();