diff --git a/js/js-snackbar.js b/js/js-snackbar.js index 0c4438f..419ae13 100644 --- a/js/js-snackbar.js +++ b/js/js-snackbar.js @@ -227,7 +227,7 @@ function SnackBar(userOptions) { _Options.fixed = userOptions.fixed; } - _Options.position = userOptions.position ? _userOptions.position : _OptionDefaults.position; + _Options.position = userOptions.position ? userOptions.position : _OptionDefaults.position; } @@ -295,7 +295,6 @@ function SnackBar(userOptions) { }; this.getPositionClass = function() { - console.log(_Options.position) switch(_Options.position) { case "bl": diff --git a/js/js-snackbar.min.js b/js/js-snackbar.min.js index 6f8cd80..f6df64d 100644 --- a/js/js-snackbar.min.js +++ b/js/js-snackbar.min.js @@ -1 +1 @@ -function SnackBar(t) { var s, e, i, n, o, a = this, c = { message: "Operation performed successfully.", dismissible: !0, timeout: 5e3, status: "", actions: [], fixed: !1, position: "br" }, r = c; var d = function (t) { var s = t.children, e = null, i = 0, n = getPositionClass(); for (i = 0; i < s.length; i++)if (1 === (e = s.item(i)).nodeType && e.classList.length > 0 && e.classList.contains("js-snackbar-container") && e.classList.contains(n)) return e; return null }; this.Open = function () { var t = i.firstElementChild.scrollHeight; i.style.height = t + "px", i.style.opacity = 1, i.style.marginTop = "5px", i.style.marginBottom = "5px", i.addEventListener("transitioned", function () { i.removeEventListener("transitioned", arguments.callee), i.style.height = null }) }, this.Close = function () { s && clearInterval(s); var t = i.scrollHeight, e = i.style.transition; i.style.transition = "", requestAnimationFrame(function () { i.style.height = t + "px", i.style.opacity = 1, i.style.marginTop = "0px", i.style.marginBottom = "0px", i.style.transition = e, requestAnimationFrame(function () { i.style.height = "0px", i.style.opacity = 0 }) }), setTimeout(function () { n.removeChild(i) }, 1e3) }, this.getPositionClass = function () { switch (console.log(r.position), r.position) { case "bl": return "js-snackbar-container--bottom-left"; case "tl": return "js-snackbar-container--top-left"; case "tr": return "js-snackbar-container--top-right"; default: return "js-snackbar-container--bottom-right" } }, void 0 !== t && (void 0 !== t.message && (r.message = t.message), void 0 !== t.dismissible && ("string" == typeof t.dismissible ? r.dismissible = "true" === t.dismissible : "boolean" == typeof t.dismissible ? r.dismissible = t.dismissible : console.debug("Invalid option provided for 'dismissable' [" + t.dismissible + "] is of type " + typeof t.dismissible)), void 0 !== t.timeout && ("boolean" == typeof t.timeout && !1 === t.timeout ? r.timeout = !1 : "string" == typeof t.timeout && (r.timeout = parseInt(t.timeout)), "number" == typeof t.timeout && (t.timeout === 1 / 0 ? r.timeout = !1 : t.timeout >= 0 ? r.timeout = t.timeout : console.debug("Invalid timeout entered. Must be greater than or equal to 0."), r.timeout = t.timeout)), void 0 !== t.status && (r.status = t.status), void 0 !== t.actions && (r.actions = t.actions), void 0 === t.container || "string" != typeof t.container && "object" != typeof t.container || (r.container = t.container), void 0 !== t.fixed && (r.fixed = t.fixed), r.position = t.position ? _userOptions.position : c.position), function () { if (null === r.container || void 0 === r.container) o = document.body; else if ("object" == typeof r.container && r.container instanceof Element) n = r.container; else { var t = document.getElementById(r.container); void 0 === t && (console.error("SnackBar: Could not find target container " + r.container), t = document.body), o = t } (n = d(o)) || ((n = document.createElement("div")).classList.add("js-snackbar-container"), r.fixed && n.classList.add("js-snackbar-container--fixed"), o.appendChild(n)), r.fixed ? n.classList.add("js-snackbar-container--fixed") : n.classList.remove("js-snackbar-container--fixed"), n.classList.add(getPositionClass()), (i = document.createElement("div")).classList.add("js-snackbar__wrapper"); var c = document.createElement("div"); if (c.classList.add("js-snackbar", "js-snackbar--show"), r.status) { r.status = r.status.toLowerCase().trim(); var l = document.createElement("span"); l.classList.add("js-snackbar__status"), "success" === r.status || "green" === r.status ? l.classList.add("js-snackbar--success") : "warning" === r.status || "alert" === r.status || "orange" === r.status ? l.classList.add("js-snackbar--warning") : "danger" === r.status || "error" === r.status || "red" === r.status ? l.classList.add("js-snackbar--danger") : l.classList.add("js-snackbar--info"), c.appendChild(l) } if ((e = document.createElement("span")).classList.add("js-snackbar__message"), e.textContent = r.message, c.appendChild(e), void 0 !== r.actions && "object" == typeof r.actions && void 0 !== r.actions.length) for (var u = 0; u < r.actions.length; u++) { var m = r.actions[u]; if (void 0 !== m && void 0 !== m.text && "string" == typeof m.text && (void 0 !== m.function && "function" == typeof m.function || void 0 !== m.dissmiss && "boolean" == typeof m.dissmiss && !0 === m.dissmiss)) { var p = document.createElement("span"); p.classList.add("js-snackbar__action"), void 0 !== m && "function" == typeof m.function ? void 0 !== m.dissmiss && "boolean" == typeof m.dissmiss && !0 === m.dissmiss ? p.onclick = function () { m.function(), a.Close() } : p.onclick = m.function : p.onclick = a.Close, p.textContent = m.text, c.appendChild(p) } } if (r.dismissible) { var f = document.createElement("span"); f.classList.add("js-snackbar__close"), f.innerText = "×", f.onclick = a.Close, c.appendChild(f) } i.style.height = "0px", i.style.opacity = "0", i.style.marginTop = "0px", i.style.marginBottom = "0px", i.appendChild(c), n.appendChild(i), !1 !== r.timeout && (s = setTimeout(a.Close, r.timeout)) }(), a.Open() } \ No newline at end of file +function SnackBar(t) { var s, e, i, n, o, a = this, c = { message: "Operation performed successfully.", dismissible: !0, timeout: 5e3, status: "", actions: [], fixed: !1, position: "br" }, r = c; var d = function (t) { var s = t.children, e = null, i = 0, n = getPositionClass(); for (i = 0; i < s.length; i++)if (1 === (e = s.item(i)).nodeType && e.classList.length > 0 && e.classList.contains("js-snackbar-container") && e.classList.contains(n)) return e; return null }; this.Open = function () { var t = i.firstElementChild.scrollHeight; i.style.height = t + "px", i.style.opacity = 1, i.style.marginTop = "5px", i.style.marginBottom = "5px", i.addEventListener("transitioned", function () { i.removeEventListener("transitioned", arguments.callee), i.style.height = null }) }, this.Close = function () { s && clearInterval(s); var t = i.scrollHeight, e = i.style.transition; i.style.transition = "", requestAnimationFrame(function () { i.style.height = t + "px", i.style.opacity = 1, i.style.marginTop = "0px", i.style.marginBottom = "0px", i.style.transition = e, requestAnimationFrame(function () { i.style.height = "0px", i.style.opacity = 0 }) }), setTimeout(function () { n.removeChild(i) }, 1e3) }, this.getPositionClass = function () { switch (r.position) { case "bl": return "js-snackbar-container--bottom-left"; case "tl": return "js-snackbar-container--top-left"; case "tr": return "js-snackbar-container--top-right"; default: return "js-snackbar-container--bottom-right" } }, void 0 !== t && (void 0 !== t.message && (r.message = t.message), void 0 !== t.dismissible && ("string" == typeof t.dismissible ? r.dismissible = "true" === t.dismissible : "boolean" == typeof t.dismissible ? r.dismissible = t.dismissible : console.debug("Invalid option provided for 'dismissable' [" + t.dismissible + "] is of type " + typeof t.dismissible)), void 0 !== t.timeout && ("boolean" == typeof t.timeout && !1 === t.timeout ? r.timeout = !1 : "string" == typeof t.timeout && (r.timeout = parseInt(t.timeout)), "number" == typeof t.timeout && (t.timeout === 1 / 0 ? r.timeout = !1 : t.timeout >= 0 ? r.timeout = t.timeout : console.debug("Invalid timeout entered. Must be greater than or equal to 0."), r.timeout = t.timeout)), void 0 !== t.status && (r.status = t.status), void 0 !== t.actions && (r.actions = t.actions), void 0 === t.container || "string" != typeof t.container && "object" != typeof t.container || (r.container = t.container), void 0 !== t.fixed && (r.fixed = t.fixed), r.position = t.position ? t.position : c.position), function () { if (null === r.container || void 0 === r.container) o = document.body; else if ("object" == typeof r.container && r.container instanceof Element) n = r.container; else { var t = document.getElementById(r.container); void 0 === t && (console.error("SnackBar: Could not find target container " + r.container), t = document.body), o = t } (n = d(o)) || ((n = document.createElement("div")).classList.add("js-snackbar-container"), r.fixed && n.classList.add("js-snackbar-container--fixed"), o.appendChild(n)), r.fixed ? n.classList.add("js-snackbar-container--fixed") : n.classList.remove("js-snackbar-container--fixed"), n.classList.add(getPositionClass()), (i = document.createElement("div")).classList.add("js-snackbar__wrapper"); var c = document.createElement("div"); if (c.classList.add("js-snackbar", "js-snackbar--show"), r.status) { r.status = r.status.toLowerCase().trim(); var l = document.createElement("span"); l.classList.add("js-snackbar__status"), "success" === r.status || "green" === r.status ? l.classList.add("js-snackbar--success") : "warning" === r.status || "alert" === r.status || "orange" === r.status ? l.classList.add("js-snackbar--warning") : "danger" === r.status || "error" === r.status || "red" === r.status ? l.classList.add("js-snackbar--danger") : l.classList.add("js-snackbar--info"), c.appendChild(l) } if ((e = document.createElement("span")).classList.add("js-snackbar__message"), e.textContent = r.message, c.appendChild(e), void 0 !== r.actions && "object" == typeof r.actions && void 0 !== r.actions.length) for (var u = 0; u < r.actions.length; u++) { var m = r.actions[u]; if (void 0 !== m && void 0 !== m.text && "string" == typeof m.text && (void 0 !== m.function && "function" == typeof m.function || void 0 !== m.dissmiss && "boolean" == typeof m.dissmiss && !0 === m.dissmiss)) { var p = document.createElement("span"); p.classList.add("js-snackbar__action"), void 0 !== m && "function" == typeof m.function ? void 0 !== m.dissmiss && "boolean" == typeof m.dissmiss && !0 === m.dissmiss ? p.onclick = function () { m.function(), a.Close() } : p.onclick = m.function : p.onclick = a.Close, p.textContent = m.text, c.appendChild(p) } } if (r.dismissible) { var f = document.createElement("span"); f.classList.add("js-snackbar__close"), f.innerText = "×", f.onclick = a.Close, c.appendChild(f) } i.style.height = "0px", i.style.opacity = "0", i.style.marginTop = "0px", i.style.marginBottom = "0px", i.appendChild(c), n.appendChild(i), !1 !== r.timeout && (s = setTimeout(a.Close, r.timeout)) }(), a.Open() } \ No newline at end of file