diff --git a/dist/js/toastme.js b/dist/js/toastme.js
index 8988c8c..d46349a 100644
--- a/dist/js/toastme.js
+++ b/dist/js/toastme.js
@@ -6,101 +6,105 @@
* git+https://github.com/alexsegen/toastmejs.git
*/
-(function() {
-function Toastme(
- config = {
- timeout: null,
- distanceX: null,
- distanceY: null,
- positionY: null,
- positionX: null,
- zIndex: null,
- ligh: false
- }
-) {
-
- this.timeout = config.timeout || 5000;
- this.distanceX = config.distanceX || 15;
- this.distanceY = config.distanceY || 15;
- this.positionY = config.positionY || "bottom";
- this.positionX = config.positionX || "right"; //right, left, center
- this.zIndex = config.zIndex || 100;
- this.ligh = config.ligh || false;
-
- this.initToast = function () {
- document.addEventListener("click", (function (e) {
- if (e.target.classList.contains("toastme-close")) {
- e.target.parentNode.remove();
- }
- }));
- };
-
- this.getMessage = function (type, str) {
-
- this.closeAllToasts();
-
- this.initToast();
+(function () {
+ function Toastme(
+ config = {
+ timeout: null,
+ distanceX: null,
+ distanceY: null,
+ positionY: null,
+ positionX: null,
+ zIndex: null,
+ ligh: false
+ }
+ ) {
- var toastme = document.createElement("div");
- toastme.classList.add("toastme", type, this.ligh ? 'ligh' : false);
- this.positionX == 'center' ? (toastme.style.right = '50%', toastme.style.marginRight = '-125px') : (toastme.style[this.positionX] = this.distanceX + "px");
- toastme.style[this.positionY] = this.distanceY + "px";
- toastme.style.zIndex = this.zIndex;
- toastme.innerHTML = `
+ this.timeout = config.timeout || 5000;
+ this.distanceX = config.distanceX || 15;
+ this.distanceY = config.distanceY || 15;
+ this.positionY = config.positionY || "bottom";
+ this.positionX = config.positionX || "right"; //right, left, center
+ this.zIndex = config.zIndex || 100;
+ this.ligh = config.ligh || false;
+
+ this.initToast = function () {
+ document.addEventListener("click", (function (e) {
+ if (e.target.classList.contains("toastme-close")) {
+ e.target.parentNode.remove();
+ }
+ }));
+ };
+
+ this.getMessage = function (type, str) {
+
+ this.closeAllToasts();
+
+ this.initToast();
+
+ var toastme = document.createElement("div");
+ toastme.classList.add("toastme", type, this.ligh ? 'ligh' : false);
+ this.positionX == 'center' ? (toastme.style.right = '50%', toastme.style.marginRight = '-125px') : (toastme.style[this.positionX] = this.distanceX + "px");
+ toastme.style[this.positionY] = this.distanceY + "px";
+ toastme.style.zIndex = this.zIndex;
+ toastme.innerHTML = `
${str}
`;
- setTimeout(() => {
- toastme.remove();
- }, this.timeout);
- return toastme;
- }
+ setTimeout(() => {
+ toastme.remove();
+ }, this.timeout);
+ return toastme;
+ }
- this.success = function (str) {
- document.body.appendChild(this.getMessage("success", str));
- }
- this.error = function (str) {
- document.body.appendChild(this.getMessage("error", str));
- }
- this.warning = function (str) {
- document.body.appendChild(this.getMessage("warning", str));
- }
- this.info = function (str) {
- document.body.appendChild(this.getMessage("info", str));
- }
+ this.default = function (str) {
+ document.body.appendChild(this.getMessage("default", str));
+ }
+
+ this.success = function (str) {
+ document.body.appendChild(this.getMessage("success", str));
+ }
+ this.error = function (str) {
+ document.body.appendChild(this.getMessage("error", str));
+ }
+ this.warning = function (str) {
+ document.body.appendChild(this.getMessage("warning", str));
+ }
+ this.info = function (str) {
+ document.body.appendChild(this.getMessage("info", str));
+ }
- //Toastme Dialog
+ //Toastme Dialog
- this.initDialog = function () {
- document.addEventListener("click", (function (e) {
- if (e.target.classList.contains("--toastme-dialog-action")) {
- let array = document.querySelectorAll(".toastme-dialog-bg");
- array.forEach((function (item) {
- item.childNodes[1].classList.add("toastme-dialog-closing");
- }));
- setTimeout(() => {
+ this.initDialog = function () {
+ document.addEventListener("click", (function (e) {
+ if (e.target.classList.contains("--toastme-dialog-action")) {
let array = document.querySelectorAll(".toastme-dialog-bg");
array.forEach((function (item) {
- item.style.display = "none";
- item.parentNode.removeChild(item);
+ item.childNodes[1].classList.add("toastme-dialog-closing");
}));
- }, 500);
- }
- }));
- }
+ setTimeout(() => {
+ let array = document.querySelectorAll(".toastme-dialog-bg");
+ array.forEach((function (item) {
+ item.style.display = "none";
+ item.parentNode.removeChild(item);
+ }));
+ }, 500);
+ }
+ }));
+ }
- this.buildDialog = function (title, text, textConfirm, textCancel, showCancel, type) {
- var showTitle = title ? `${title}
` : "";
- var showText = text ? `${text}
` : "";
- var showType = this.selectType(type) ? this.selectType(type) : "";
- var btnCancel = showCancel ?
- `` :
- "";
- var dialog = document.createElement("div");
- dialog.setAttribute("id", "toastme-dialog-bg");
- dialog.classList.add("toastme-dialog-bg", "--toastme-dialog-action");
- dialog.innerHTML = `
+ this.buildDialog = function (title, text, textConfirm, textCancel, showCancel, type) {
+ var showTitle = title ? `${title}
` : "";
+ var showText = text ? `${text}
` : "";
+ var showType = this.selectType(type) ? this.selectType(type) : "";
+ var btnCancel = showCancel ?
+ `` :
+ "";
+ var dialog = document.createElement("div");
+ dialog.setAttribute("id", "toastme-dialog-bg");
+ dialog.classList.add("toastme-dialog-bg", "--toastme-dialog-action");
+ dialog.innerHTML = `
${showType} ${showTitle} ${showText}
@@ -110,86 +114,89 @@ function Toastme(
`;
- return dialog;
- }
+ return dialog;
+ }
- this.selectType = function (str) {
- switch (str) {
- case "danger":
- return ``;
- case "success":
- return ``;
- case "info":
- return ``;
- case "warning":
- return ``;
- case "question":
- return ``;
- default:
- return false;
+ this.selectType = function (str) {
+ switch (str) {
+ case "danger":
+ return ``;
+ case "success":
+ return ``;
+ case "info":
+ return ``;
+ case "warning":
+ return ``;
+ case "question":
+ return ``;
+ default:
+ return false;
+ }
}
- }
- this.yesNoDialog = function (
- config = {
- title: null,
- text: null,
- textConfirm: "Confirmar" || "Confirm",
- textCancel: "" || "Cancel",
- showCancel: true,
- type: null || null
- }
- ) {
- this.closeAllDialogs();
- this.initDialog();
- document.body.appendChild(
- this.buildDialog(
- config.title,
- config.text,
- config.textConfirm,
- config.textCancel,
- config.showCancel,
- config.type
- )
- );
-
- return new Promise(function (resolve, reject) {
- document
- .getElementById("toastmeConfirm")
- .addEventListener("click", (function () {
- resolve(true);
- }));
- var btnCancel = document.getElementById("toastmeCancel");
- if (btnCancel) {
- btnCancel.addEventListener("click", (function () {
- resolve(false);
- }));
+ this.yesNoDialog = function (
+ config = {
+ title: null,
+ text: null,
+ textConfirm: "Confirmar" || "Confirm",
+ textCancel: "" || "Cancel",
+ showCancel: true,
+ type: null || null
}
- });
- }
+ ) {
+ this.closeAllDialogs();
+ this.initDialog();
+ document.body.appendChild(
+ this.buildDialog(
+ config.title,
+ config.text,
+ config.textConfirm,
+ config.textCancel,
+ config.showCancel,
+ config.type
+ )
+ );
+
+ return new Promise(function (resolve, reject) {
+ document
+ .getElementById("toastmeConfirm")
+ .addEventListener("click", (function () {
+ resolve(true);
+ }));
+ var btnCancel = document.getElementById("toastmeCancel");
+ if (btnCancel) {
+ btnCancel.addEventListener("click", (function () {
+ resolve(false);
+ }));
+ }
+ });
+ }
- this.closeAllToasts = function () {
- let array = document.querySelectorAll(".toastme");
- array.forEach((function (item) {
- item.parentNode.removeChild(item);
- }));
- }
+ this.closeAllToasts = function () {
+ let array = document.querySelectorAll(".toastme");
+ array.forEach((function (item) {
+ item.parentNode.removeChild(item);
+ }));
+ }
- this.closeAllDialogs = function () {
- let array = document.querySelectorAll(".toastme-dialog-bg");
- array.forEach((function (item) {
- item.style.display = "none";
- item.parentNode.removeChild(item);
- }));
- }
+ this.closeAllDialogs = function () {
+ let array = document.querySelectorAll(".toastme-dialog-bg");
+ array.forEach((function (item) {
+ item.style.display = "none";
+ item.parentNode.removeChild(item);
+ }));
+ }
-}
+ }
var toastme = new Toastme();
-
- if (typeof module !== 'undefined' && typeof module.exports !== 'undefined'){
- module.exports = {Toastme, toastme};
+
+ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
+ module.exports = {
+ Toastme,
+ toastme
+ };
} else {
window.toastme = toastme;
window.Toastme = Toastme;
diff --git a/dist/js/toastme.min.js b/dist/js/toastme.min.js
index c053e39..5674a49 100644
--- a/dist/js/toastme.min.js
+++ b/dist/js/toastme.min.js
@@ -1,2 +1,2 @@
/*! toastmejs v1.0.0 | (c) 2019 alexsegen | MIT License | git+https://github.com/alexsegen/toastmejs.git */
-!(function(){function t(t={timeout:null,distanceX:null,distanceY:null,positionY:null,positionX:null,zIndex:null,ligh:!1}){this.timeout=t.timeout||5e3,this.distanceX=t.distanceX||15,this.distanceY=t.distanceY||15,this.positionY=t.positionY||"bottom",this.positionX=t.positionX||"right",this.zIndex=t.zIndex||100,this.ligh=t.ligh||!1,this.initToast=function(){document.addEventListener("click",(function(t){t.target.classList.contains("toastme-close")&&t.target.parentNode.remove()}))},this.getMessage=function(t,e){this.closeAllToasts(),this.initToast();var i=document.createElement("div");return i.classList.add("toastme",t,!!this.ligh&&"ligh"),"center"==this.positionX?(i.style.right="50%",i.style.marginRight="-125px"):i.style[this.positionX]=this.distanceX+"px",i.style[this.positionY]=this.distanceY+"px",i.style.zIndex=this.zIndex,i.innerHTML=`\n \n \n ${e}
`,setTimeout(()=>{i.remove()},this.timeout),i},this.success=function(t){document.body.appendChild(this.getMessage("success",t))},this.error=function(t){document.body.appendChild(this.getMessage("error",t))},this.warning=function(t){document.body.appendChild(this.getMessage("warning",t))},this.info=function(t){document.body.appendChild(this.getMessage("info",t))},this.initDialog=function(){document.addEventListener("click",(function(t){if(t.target.classList.contains("--toastme-dialog-action")){document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.childNodes[1].classList.add("toastme-dialog-closing")})),setTimeout(()=>{document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.style.display="none",t.parentNode.removeChild(t)}))},500)}}))},this.buildDialog=function(t,e,i,o,s,n){var a=t?`${t}
`:"",l=e?`${e}
`:"",c=this.selectType(n)?this.selectType(n):"",d=s?``:"",u=document.createElement("div");return u.setAttribute("id","toastme-dialog-bg"),u.classList.add("toastme-dialog-bg","--toastme-dialog-action"),u.innerHTML=`\n \n
\n ${c} ${a} ${l}\n
\n \n ${d}\n
\n
\n
`,u},this.selectType=function(t){switch(t){case"danger":return'';case"success":return'';case"info":return'';case"warning":return'';case"question":return'';default:return!1}},this.yesNoDialog=function(t={title:null,text:null,textConfirm:"Confirmar",textCancel:"Cancel",showCancel:!0,type:null}){return this.closeAllDialogs(),this.initDialog(),document.body.appendChild(this.buildDialog(t.title,t.text,t.textConfirm,t.textCancel,t.showCancel,t.type)),new Promise(function(t,e){document.getElementById("toastmeConfirm").addEventListener("click",(function(){t(!0)}));var i=document.getElementById("toastmeCancel");i&&i.addEventListener("click",(function(){t(!1)}))})},this.closeAllToasts=function(){document.querySelectorAll(".toastme").forEach((function(t){t.parentNode.removeChild(t)}))},this.closeAllDialogs=function(){document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.style.display="none",t.parentNode.removeChild(t)}))}}var e=new t;"undefined"!=typeof module&&void 0!==module.exports?module.exports={Toastme:t,toastme:e}:(window.toastme=e,window.Toastme=t)})();
\ No newline at end of file
+!(function(){function t(t={timeout:null,distanceX:null,distanceY:null,positionY:null,positionX:null,zIndex:null,ligh:!1}){this.timeout=t.timeout||5e3,this.distanceX=t.distanceX||15,this.distanceY=t.distanceY||15,this.positionY=t.positionY||"bottom",this.positionX=t.positionX||"right",this.zIndex=t.zIndex||100,this.ligh=t.ligh||!1,this.initToast=function(){document.addEventListener("click",(function(t){t.target.classList.contains("toastme-close")&&t.target.parentNode.remove()}))},this.getMessage=function(t,e){this.closeAllToasts(),this.initToast();var i=document.createElement("div");return i.classList.add("toastme",t,!!this.ligh&&"ligh"),"center"==this.positionX?(i.style.right="50%",i.style.marginRight="-125px"):i.style[this.positionX]=this.distanceX+"px",i.style[this.positionY]=this.distanceY+"px",i.style.zIndex=this.zIndex,i.innerHTML=`\n \n \n ${e}
`,setTimeout(()=>{i.remove()},this.timeout),i},this.default=function(t){document.body.appendChild(this.getMessage("default",t))},this.success=function(t){document.body.appendChild(this.getMessage("success",t))},this.error=function(t){document.body.appendChild(this.getMessage("error",t))},this.warning=function(t){document.body.appendChild(this.getMessage("warning",t))},this.info=function(t){document.body.appendChild(this.getMessage("info",t))},this.initDialog=function(){document.addEventListener("click",(function(t){if(t.target.classList.contains("--toastme-dialog-action")){document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.childNodes[1].classList.add("toastme-dialog-closing")})),setTimeout(()=>{document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.style.display="none",t.parentNode.removeChild(t)}))},500)}}))},this.buildDialog=function(t,e,i,o,s,n){var a=t?`${t}
`:"",l=e?`${e}
`:"",c=this.selectType(n)?this.selectType(n):"",d=s?``:"",u=document.createElement("div");return u.setAttribute("id","toastme-dialog-bg"),u.classList.add("toastme-dialog-bg","--toastme-dialog-action"),u.innerHTML=`\n \n
\n ${c} ${a} ${l}\n
\n \n ${d}\n
\n
\n
`,u},this.selectType=function(t){switch(t){case"danger":return'';case"success":return'';case"info":return'';case"warning":return'';case"question":return'';default:return!1}},this.yesNoDialog=function(t={title:null,text:null,textConfirm:"Confirmar",textCancel:"Cancel",showCancel:!0,type:null}){return this.closeAllDialogs(),this.initDialog(),document.body.appendChild(this.buildDialog(t.title,t.text,t.textConfirm,t.textCancel,t.showCancel,t.type)),new Promise(function(t,e){document.getElementById("toastmeConfirm").addEventListener("click",(function(){t(!0)}));var i=document.getElementById("toastmeCancel");i&&i.addEventListener("click",(function(){t(!1)}))})},this.closeAllToasts=function(){document.querySelectorAll(".toastme").forEach((function(t){t.parentNode.removeChild(t)}))},this.closeAllDialogs=function(){document.querySelectorAll(".toastme-dialog-bg").forEach((function(t){t.style.display="none",t.parentNode.removeChild(t)}))}}var e=new t;"undefined"!=typeof module&&void 0!==module.exports?module.exports={Toastme:t,toastme:e}:(window.toastme=e,window.Toastme=t)})();
\ No newline at end of file
diff --git a/index.html b/index.html
index 56c9ab5..fa264e2 100644
--- a/index.html
+++ b/index.html
@@ -26,6 +26,7 @@ ToastmeJS
Default theme
+
@@ -139,8 +140,11 @@ Customize your dialogs