1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // Creates a modal container, if it doesn't exist, and adds the provided
7 // content element to it
8 function showModalContainer(content) {
9 var container = document.getElementById("eModalContainer");
10 if (container == null) {
11 container = document.createElement("div");
12 container.id = "eModalContainer";
13 container.classList.add("modal_container");
15 var mask = document.createElement("div");
16 mask.id = "eModalMask";
17 mask.classList.add("modal_mask");
19 document.body.appendChild(mask);
20 document.body.appendChild(container);
22 container.hidden = false;
23 document.getElementById("eModalMask").hidden = false;
26 container.appendChild(content);
27 if (content.classList.contains("modal_hide")) {
28 content.classList.replace("modal_hide", "modal_content");
30 content.classList.add("modal_content");
34 // Hides the modal container, and returns the contents back to the caller.
35 // The caller can choose to use the return value to move the contents to
36 // another part of the DOM, or ignore the return value so that the nodes
37 // can be garbage collected.
38 function clearModalContainer() {
39 var container = document.getElementById("eModalContainer");
40 container.hidden = true;
41 document.getElementById("eModalMask").hidden = true;
43 var content = container.firstElementChild;
44 container.removeChild(content);
45 content.classList.replace("modal_content", "modal_hide");