mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-01-22 22:08:46 +01:00
[refactor] improve modal module
This commit is contained in:
parent
8ce599a3a9
commit
c1e1b0eabf
@ -82,9 +82,8 @@ var modal = (function() {
|
|||||||
var _makeModal = function() {
|
var _makeModal = function() {
|
||||||
mod.open();
|
mod.open();
|
||||||
var body = helper.e("body");
|
var body = helper.e("body");
|
||||||
var modalWrapper = document.createElement("div");
|
var modal = helper.node("div");
|
||||||
modalWrapper.setAttribute("class", "modal-wrapper");
|
var modalWrapper = helper.node("div|class:modal-wrapper");
|
||||||
var modal = document.createElement("div");
|
|
||||||
if (options.size == "large") {
|
if (options.size == "large") {
|
||||||
modal.setAttribute("class", "modal modal-large");
|
modal.setAttribute("class", "modal modal-large");
|
||||||
} else if (options.size == "small") {
|
} else if (options.size == "small") {
|
||||||
@ -96,39 +95,25 @@ var modal = (function() {
|
|||||||
if (modal.classList.contains("is-opaque")) {
|
if (modal.classList.contains("is-opaque")) {
|
||||||
helper.removeClass(modal, "is-opaque");
|
helper.removeClass(modal, "is-opaque");
|
||||||
helper.addClass(modal, "is-transparent");
|
helper.addClass(modal, "is-transparent");
|
||||||
helper.addClass(modalWrapper, "is-droping-down");
|
|
||||||
} else {
|
} else {
|
||||||
modal.remove();
|
modal.remove();
|
||||||
};
|
};
|
||||||
mod.close();
|
mod.close();
|
||||||
};
|
};
|
||||||
var modalBody = document.createElement("div");
|
var modalBody = helper.node("div|class:modal-body");
|
||||||
modalBody.setAttribute("class", "modal-body");
|
var modalControls = helper.node("div|class:modal-controls");
|
||||||
var modalControls = document.createElement("div");
|
var actionButton = helper.node("button:" + options.actionText + "|class:modal-button button button-primary button-block,tabindex:1");
|
||||||
modalControls.setAttribute("class", "modal-controls");
|
var cancelButton = helper.node("button:" + options.cancelText + "|class:modal-button button button-primary button-block,tabindex:1");
|
||||||
var actionButton = document.createElement("button");
|
|
||||||
actionButton.setAttribute("tabindex", "1");
|
|
||||||
actionButton.setAttribute("class", "modal-button button button-primary button-block");
|
|
||||||
actionButton.textContent = options.actionText;
|
|
||||||
var cancelButton = document.createElement("button");
|
|
||||||
cancelButton.setAttribute("tabindex", "1");
|
|
||||||
cancelButton.setAttribute("class", "modal-button button button-primary button-block");
|
|
||||||
cancelButton.textContent = options.cancelText;
|
|
||||||
modalControls.appendChild(cancelButton);
|
modalControls.appendChild(cancelButton);
|
||||||
modalControls.appendChild(actionButton);
|
modalControls.appendChild(actionButton);
|
||||||
if (options.heading != null) {
|
if (options.heading != null) {
|
||||||
var modalHeading = document.createElement("h1");
|
var modalHeading = helper.node("h1:" + options.heading + "|class:modal-heading,tabindex:1");
|
||||||
modalHeading.setAttribute("tabindex", "1");
|
|
||||||
modalHeading.setAttribute("class", "modal-heading");
|
|
||||||
modalHeading.textContent = options.heading;
|
|
||||||
modalBody.appendChild(modalHeading);
|
modalBody.appendChild(modalHeading);
|
||||||
};
|
};
|
||||||
if (options.content) {
|
if (options.content) {
|
||||||
if (typeof options.content == "string") {
|
if (typeof options.content == "string") {
|
||||||
var container = document.createElement("div");
|
var container = helper.node("div|class:container");
|
||||||
container.setAttribute("class", "container");
|
var para = helper.node("p:options.content");
|
||||||
var para = document.createElement("p");
|
|
||||||
para.textContent = options.content;
|
|
||||||
container.appendChild(para);
|
container.appendChild(para);
|
||||||
modalBody.appendChild(container);
|
modalBody.appendChild(container);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user