2015-03-25 15:33:36 +01:00
|
|
|
define([], function () {
|
|
|
|
return function (el) {
|
2017-03-17 03:14:57 +01:00
|
|
|
var self = this;
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
var sidebar = document.createElement("div");
|
|
|
|
sidebar.classList.add("sidebar");
|
|
|
|
el.appendChild(sidebar);
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
var button = document.createElement("button");
|
|
|
|
sidebar.appendChild(button);
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
button.classList.add("sidebarhandle");
|
2015-03-25 15:33:36 +01:00
|
|
|
button.onclick = function () {
|
2017-03-17 03:14:57 +01:00
|
|
|
sidebar.classList.toggle("hidden");
|
|
|
|
};
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
var container = document.createElement("div");
|
|
|
|
container.classList.add("container");
|
|
|
|
sidebar.appendChild(container);
|
2015-04-04 18:01:57 +02:00
|
|
|
|
2015-03-25 15:33:36 +01:00
|
|
|
self.getWidth = function () {
|
2017-03-17 03:14:57 +01:00
|
|
|
if (sidebar.classList.contains("hidden")) {
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-31 20:32:47 +02:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
var small = window.matchMedia("(max-width: 630pt)");
|
|
|
|
return small.matches ? 0 : sidebar.offsetWidth;
|
|
|
|
};
|
2015-03-25 15:33:36 +01:00
|
|
|
|
|
|
|
self.add = function (d) {
|
2017-03-17 03:14:57 +01:00
|
|
|
d.render(container);
|
|
|
|
};
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2015-07-06 22:30:45 +02:00
|
|
|
self.ensureVisible = function () {
|
2017-03-17 03:14:57 +01:00
|
|
|
sidebar.classList.remove("hidden");
|
|
|
|
};
|
2015-07-06 22:30:45 +02:00
|
|
|
|
2015-07-06 22:27:16 +02:00
|
|
|
self.hide = function () {
|
2017-03-17 03:14:57 +01:00
|
|
|
container.classList.add("hidden");
|
|
|
|
};
|
2015-07-06 22:27:16 +02:00
|
|
|
|
|
|
|
self.reveal = function () {
|
2017-03-17 03:14:57 +01:00
|
|
|
container.classList.remove("hidden");
|
|
|
|
};
|
2015-07-06 22:27:16 +02:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
self.container = sidebar;
|
2015-03-25 15:33:36 +01:00
|
|
|
|
2017-03-17 03:14:57 +01:00
|
|
|
return self;
|
|
|
|
};
|
|
|
|
});
|