From 334db50f2127b21a857183c495ca30aad14b2939 Mon Sep 17 00:00:00 2001 From: 5um17 <5um17.mail@gmail.com> Date: Fri, 24 Jun 2016 19:01:24 +0530 Subject: [PATCH] version 1.1 with background overlay settings --- README.md | 24 ++++++-- example/modernAlert.min.js | 4 +- modernAlert.js | 112 +++++++++++++++++++++++++++++++------ modernAlert.min.js | 4 +- 4 files changed, 120 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 35539ae..e048c80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # modernAlert.js # A small JavaScript snippet to override native js functions **alert**, **confirm** and **prompt**. -It provides customizable HTML pop-ups instead of browser based pop-ups which can be styled using number of arguments and traditional way of using CSS. +It provides customizable HTML pop-ups instead of browser based pop-ups which can be styled using number of arguments and traditional way of using CSS. + +### [Demo](http://www.secretsofgeeks.com/2015/09/modernAlert.html#modernAlertExamples) + ### Installation Include ```modernAlert.min.js``` in the head tag of your project. ```html @@ -72,19 +75,34 @@ function callback_function(valueFromPrompt, promptTime) { You can pass color combinations and other settings in calling constructor. Default arguments are: ```javascript +/* Default arguments */ modernAlert({ backgroundColor: '#fff', color: '#555', borderColor: '#ccc', titleBackgroundColor: '#e8a033', titleColor: '#fff', - defaultButtonsText: {ok : 'Ok', cancel : 'Cancel'} + defaultButtonsText: {ok : 'Ok', cancel : 'Cancel'}, + overlayColor: 'rgba(0, 0, 0, 0.5)', + overlayBlur: 2 //Set false to disable it or interger for pixle }); + /* Change the title background color and title color */ modernAlert({ titleBackgroundColor: 'blue', titleColor: 'white' }); + +/* Change overlay color */ +modernAlert({ + overlayColor: 'rgba(255, 255, 255, 0.3)' + }); + +/* Disable background blur */ +modernAlert({ + overlayBlur: false + }); + ``` Change button values ```javascript @@ -98,5 +116,3 @@ confirm('Confirm Message', 'Confirm title', callback_function, null, {ok : 'text ``` ```modernAlert()``` return internal object of itself. - -[Examples](http://www.secretsofgeeks.com/2015/09/modernAlert.html#modernAlertExamples) diff --git a/example/modernAlert.min.js b/example/modernAlert.min.js index f819d2a..38b3dc8 100644 --- a/example/modernAlert.min.js +++ b/example/modernAlert.min.js @@ -3,6 +3,6 @@ * Native functions are replaced with customizable pop-ups. * * @author Sumit Singh - * @version 1.0 + * @version 1.1 **/ -!function(){this.modernAlert=function(){var t={init:function(){if("object"==typeof arguments[0])for(var t in arguments[0])this.args.hasOwnProperty(t)&&(this.args[t]=arguments[0][t]);return this.head.insertBefore(this.getStyleTag(),this.head.firstChild),window.alert=this.alert,window.confirm=this.confirm,window.prompt=this.prompt,this},args:{backgroundColor:"#fff",color:"#555",borderColor:"#ccc",titleBackgroundColor:"#e8a033",titleColor:"#fff",defaultButtonsText:{ok:"Ok",cancel:"Cancel"}},head:document.head||document.getElementsByTagName("head")[0],getStyleTag:function(){var t=document.createElement("style");return t.type="text/css",t.appendChild(document.createTextNode(this.getCSS())),t},getCSS:function(){var t=".modernAlertWrapper {background: "+this.args.backgroundColor+"; color: "+this.args.color+"; border: 1px solid "+this.args.borderColor+"; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); left: 50%; min-height: 120px; min-width: 240px; position: fixed; text-align: center; top: 50%; z-index: 999;font-size:14px;padding-bottom: 15px;}";return t+=".modernAlertWrapper h4 {background: "+this.args.titleBackgroundColor+"; color: "+this.args.titleColor+"; margin: 0; padding: 5px; font-size:16px;}",t+=".modernAlertWrapper p {margin: 0;padding: 5px 10px;}",t+=".maInputWrapper input {width: 100%; max-width: 300px;}"},extract_vars:function(t,e){e="undefined"!=typeof e?e:"confirm";var n=new Object;return n.msg=t[0]||"",n.title=t[1]||"Message","alert"===e?(n.extra_var="undefined"!=typeof t[2]?t[2]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof t[3]?t[3]:this.args.defaultButtonsText):(n.callback="function"==typeof t[2]?t[2]:function(){console.warn("Callback function is missing!")},n.extra_var="undefined"!=typeof t[3]?t[3]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof t[4]?t[4]:this.args.defaultButtonsText),n},alert:function(){var e,n;e=t.extract_vars(arguments,"alert"),n="

"+e.title+"

"+e.msg+'

',t.createInsertHtml("div","modernAlertWrapper",n)},confirm:function(){var e,n,a,r,o;e=t.extract_vars(arguments),n="

"+e.title+"

"+e.msg+'

\n \n ',a=t.createInsertHtml("div","modernAlertWrapper",n),r=a.getElementsByClassName("maYes"),o=a.getElementsByClassName("maNo"),r[0].onclick=function(){e.callback(!0,e.extra_var),this.parentNode.remove()},o[0].onclick=function(){e.callback(!1,e.extra_var),this.parentNode.remove()}},prompt:function(){var e,n,a,r,o,s;e=t.extract_vars(arguments),n="

"+e.title+"

"+e.msg+'

\n

\n \n ',a=t.createInsertHtml("div","modernAlertWrapper",n),r=a.getElementsByClassName("maYes"),o=a.getElementsByClassName("maNo"),s=a.getElementsByClassName("maInput"),r[0].onclick=function(){e.callback(s[0].value,e.extra_var),this.parentNode.remove()},o[0].onclick=function(){e.callback(!1,e.extra_var),this.parentNode.remove()}},createInsertHtml:function(t,e,n){var a=document.createElement(t);return a.className=e,a.innerHTML=n,document.body.appendChild(a),a.style.cssText="margin-left: -"+a.offsetWidth/2+"px; margin-top: -"+a.offsetHeight/2+"px;",a}};return t.init(arguments[0])}}(); \ No newline at end of file +!function(){this.modernAlert=function(){var e={init:function(){if("object"==typeof arguments[0])for(var e in arguments[0])this.args.hasOwnProperty(e)&&(this.args[e]=arguments[0][e]);return this.head.insertBefore(this.getStyleTag(),this.head.firstChild),window.alert=this.alert,window.confirm=this.confirm,window.prompt=this.prompt,this},args:{backgroundColor:"#fff",color:"#555",borderColor:"#ccc",titleBackgroundColor:"#e8a033",titleColor:"#fff",defaultButtonsText:{ok:"Ok",cancel:"Cancel"},overlayColor:"rgba(0, 0, 0, 0.5)",overlayBlur:2},head:document.head||document.getElementsByTagName("head")[0],getStyleTag:function(){var e=document.createElement("style");return e.type="text/css",e.appendChild(document.createTextNode(this.getCSS())),e},getCSS:function(){var e=".modernAlertWrapper {background: "+this.args.backgroundColor+"; color: "+this.args.color+"; border: 1px solid "+this.args.borderColor+"; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); left: 50%; min-height: 120px; min-width: 240px; position: fixed; text-align: center; top: 50%; z-index: 999;font-size:14px;padding-bottom: 15px;}";return e+=".modernAlertWrapper h4 {background: "+this.args.titleBackgroundColor+"; color: "+this.args.titleColor+"; margin: 0; padding: 5px; font-size:16px;}",e+=".modernAlertWrapper p {margin: 0;padding: 5px 10px;}",e+=".maInputWrapper input {width: 100%; max-width: 300px;}",e+=".modernAlertOverlay {background: "+this.args.overlayColor+"; cursor: wait;height: 100%;left: 0;position: fixed;top: 0;width: 100%;z-index: 998;}",this.args.overlayBlur!==!1&&(e+="body.maActive > *:not(script):not(link):not(.modernAlertOverlay):not(.modernAlertWrapper) {-webkit-filter: blur("+this.args.overlayBlur+"px); filter: blur("+this.args.overlayBlur+"px);}"),e},extract_vars:function(e,t){t="undefined"!=typeof t?t:"confirm";var n=new Object;return n.msg=e[0]||"",n.title=e[1]||"Message","alert"===t?(n.extra_var="undefined"!=typeof e[2]?e[2]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof e[3]?e[3]:this.args.defaultButtonsText):(n.callback="function"==typeof e[2]?e[2]:function(){console.warn("Callback function is missing!")},n.extra_var="undefined"!=typeof e[3]?e[3]:"You can use this var by passing value as fourth parameter in confirm and prompt function.",n.buttons="object"==typeof e[4]?e[4]:this.args.defaultButtonsText),n},generateId:function(){var e=(new Date).getTime();return"modernAlert"+e},alert:function(){var t,n,r;r=e.generateId(),t=e.extract_vars(arguments,"alert"),n="

"+t.title+"

"+t.msg+'

',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),e.createInsertHtml("div","modernAlertWrapper",n,r)},confirm:function(){var t,n,r,a,o,l;l=e.generateId(),t=e.extract_vars(arguments),n="

"+t.title+"

"+t.msg+'

\n \n ',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),r=e.createInsertHtml("div","modernAlertWrapper",n,l),a=r.getElementsByClassName("maYes"),o=r.getElementsByClassName("maNo"),a[0].onclick=function(){window.modernAlert.close(l),t.callback(!0,t.extra_var)},o[0].onclick=function(){window.modernAlert.close(l),t.callback(!1,t.extra_var)}},prompt:function(){var t,n,r,a,o,l,s;s=e.generateId(),t=e.extract_vars(arguments),n="

"+t.title+"

"+t.msg+'

\n

\n \n ',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),r=e.createInsertHtml("div","modernAlertWrapper",n,s),a=r.getElementsByClassName("maYes"),o=r.getElementsByClassName("maNo"),l=r.getElementsByClassName("maInput"),a[0].onclick=function(){window.modernAlert.close(s),t.callback(l[0].value,t.extra_var)},o[0].onclick=function(){window.modernAlert.close(s),t.callback(!1,t.extra_var)}},createInsertHtml:function(e,t,n,r,a){a="undefined"!=typeof a?a:!1,r="undefined"!=typeof r?r:!1;var o=document.createElement(e);return o.className=t,r!==!1&&(o.id=r),o.innerHTML=n,document.body.appendChild(o),a===!1&&(o.style.cssText="margin-left: -"+o.offsetWidth/2+"px; margin-top: -"+o.offsetHeight/2+"px;"),o}};return e.init(arguments[0])},this.modernAlert.close=function(e){var t=document.getElementsByClassName("modernAlertOverlay"),n=!1;window.modernAlert.addRemoveClass("maActive",!0),e&&(n=document.getElementById(e))&&n.remove(),"object"==typeof t[0]&&t[0].remove()},this.modernAlert.addRemoveClass=function(e,t,n){return"undefined"==typeof e?!1:(t="undefined"!=typeof t?t:!1,n="undefined"!=typeof n?n:document.body||document.getElementsByTagName("body")[0],void(t===!0?n.classList.remove(e):n.classList.add(e)))}}(); \ No newline at end of file diff --git a/modernAlert.js b/modernAlert.js index 946fe05..1a22a29 100644 --- a/modernAlert.js +++ b/modernAlert.js @@ -3,7 +3,7 @@ * Native functions are replaced with customizable pop-ups. * * @author Sumit Singh - * @version 1.0 + * @version 1.1 **/ (function (){ this.modernAlert = function () { @@ -36,7 +36,9 @@ borderColor: '#ccc', titleBackgroundColor: '#e8a033', titleColor: '#fff', - defaultButtonsText: {ok : 'Ok', cancel : 'Cancel'} + defaultButtonsText: {ok : 'Ok', cancel : 'Cancel'}, + overlayColor: 'rgba(0, 0, 0, 0.5)', + overlayBlur: 2 }, /** @@ -64,6 +66,11 @@ css += ".modernAlertWrapper h4 {background: "+this.args.titleBackgroundColor+"; color: "+this.args.titleColor+"; margin: 0; padding: 5px; font-size:16px;}"; css += ".modernAlertWrapper p {margin: 0;padding: 5px 10px;}"; css += ".maInputWrapper input {width: 100%; max-width: 300px;}"; + css += ".modernAlertOverlay {background: "+this.args.overlayColor+"; cursor: wait;height: 100%;left: 0;position: fixed;top: 0;width: 100%;z-index: 998;}"; + if (this.args.overlayBlur !== false) { + css += "body.maActive > *:not(script):not(link):not(.modernAlertOverlay):not(.modernAlertWrapper) {-webkit-filter: blur("+this.args.overlayBlur+"px); filter: blur("+this.args.overlayBlur+"px);}"; + } + return css; }, @@ -84,22 +91,36 @@ args.buttons = typeof fun_args[3] === 'object' ? fun_args[3] : this.args.defaultButtonsText; } else { args.callback = typeof fun_args[2] === 'function' ? fun_args[2] : function () { console.warn('Callback function is missing!'); }; - args.extra_var = typeof fun_args[3] !== 'undefined' ? fun_args[3] : 'You can use this var by passing value as fourth parameter in confirm function.'; + args.extra_var = typeof fun_args[3] !== 'undefined' ? fun_args[3] : 'You can use this var by passing value as fourth parameter in confirm and prompt function.'; args.buttons = typeof fun_args[4] === 'object' ? fun_args[4] : this.args.defaultButtonsText; } return args; }, + /** + * Generate and return a unique ID + * @returns {String} unique ID + */ + generateId : function () { + var time = new Date().getTime(); + return 'modernAlert' + time; + }, + /** * Custom alert function * @returns {NULL} */ alert : function () { - var args, html; + var args, html, id; + + id = modernAlert.generateId(); args = modernAlert.extract_vars(arguments, 'alert'); - html = '

'+args.title+'

'+args.msg+'

'; - modernAlert.createInsertHtml('div', 'modernAlertWrapper', html); + html = '

'+args.title+'

'+args.msg+'

'; + + window.modernAlert.addRemoveClass('maActive'); + modernAlert.createInsertHtml('div', 'modernAlertOverlay', '', false, true); + modernAlert.createInsertHtml('div', 'modernAlertWrapper', html, id); }, /** @@ -107,19 +128,22 @@ * @returns {NULL} */ confirm : function () { - var args, html, wrapper, inputYes, inputNo; + var args, html, wrapper, inputYes, inputNo, id; + id = modernAlert.generateId(); args = modernAlert.extract_vars(arguments); html = '

'+args.title+'

'+args.msg+'

\n\ \n\ '; - wrapper = modernAlert.createInsertHtml('div', 'modernAlertWrapper', html); + window.modernAlert.addRemoveClass('maActive'); + modernAlert.createInsertHtml('div', 'modernAlertOverlay', '', false, true); + wrapper = modernAlert.createInsertHtml('div', 'modernAlertWrapper', html, id); inputYes = wrapper.getElementsByClassName('maYes'); inputNo = wrapper.getElementsByClassName('maNo'); - inputYes[0].onclick = function () { args.callback(true, args.extra_var); this.parentNode.remove(); }; - inputNo[0].onclick = function () { args.callback(false, args.extra_var); this.parentNode.remove(); }; + inputYes[0].onclick = function () { window.modernAlert.close(id); args.callback(true, args.extra_var); }; + inputNo[0].onclick = function () { window.modernAlert.close(id); args.callback(false, args.extra_var); }; }, /** @@ -127,21 +151,24 @@ * @returns {NULL} */ prompt : function () { - var args, html, wrapper, inputYes, inputNo, inputStr; + var args, html, wrapper, inputYes, inputNo, inputStr, id; + id = modernAlert.generateId(); args = modernAlert.extract_vars(arguments); html = '

'+args.title+'

'+args.msg+'

\n\

\n\ \n\ '; - wrapper = modernAlert.createInsertHtml('div', 'modernAlertWrapper', html); + window.modernAlert.addRemoveClass('maActive'); + modernAlert.createInsertHtml('div', 'modernAlertOverlay', '', false, true); + wrapper = modernAlert.createInsertHtml('div', 'modernAlertWrapper', html, id); inputYes = wrapper.getElementsByClassName('maYes'); inputNo = wrapper.getElementsByClassName('maNo'); inputStr = wrapper.getElementsByClassName('maInput'); - inputYes[0].onclick = function () { args.callback(inputStr[0].value, args.extra_var); this.parentNode.remove(); }; - inputNo[0].onclick = function () { args.callback(false, args.extra_var); this.parentNode.remove(); }; + inputYes[0].onclick = function () { window.modernAlert.close(id); args.callback(inputStr[0].value, args.extra_var); }; + inputNo[0].onclick = function () { window.modernAlert.close(id); args.callback(false, args.extra_var); }; }, /** @@ -149,14 +176,23 @@ * @param {string} elementType tagname * @param {string} cssClass class name for element * @param {string} html inner html + * @param {string} id ID of popup + * @param {boolean} is_overlay Flag to include an overlay * @returns {object} created element */ - createInsertHtml : function (elementType, cssClass, html) { + createInsertHtml : function (elementType, cssClass, html, id, is_overlay) { + is_overlay = ( typeof is_overlay !== 'undefined' ) ? is_overlay : false; + id = ( typeof id !== 'undefined' ) ? id : false; var wrapper = document.createElement(elementType); wrapper.className = cssClass; + if (id !== false) { + wrapper.id = id; + } wrapper.innerHTML = html; document.body.appendChild(wrapper); - wrapper.style.cssText = "margin-left: -"+(wrapper.offsetWidth / 2)+"px; margin-top: -"+(wrapper.offsetHeight / 2)+"px;"; + if (is_overlay === false) { + wrapper.style.cssText = "margin-left: -"+(wrapper.offsetWidth / 2)+"px; margin-top: -"+(wrapper.offsetHeight / 2)+"px;"; + } return wrapper; } }; @@ -166,4 +202,48 @@ */ return modernAlert.init(arguments[0]); }; + + /* Public functions */ + + /** + * Close popup + * @param {string} ID of popup to close + * @returns {NULL} + */ + this.modernAlert.close = function (elemId) { + var overlay = document.getElementsByClassName('modernAlertOverlay'); + var elem = false; + + window.modernAlert.addRemoveClass('maActive', true); + + if (elemId && (elem = document.getElementById(elemId))) { + elem.remove(); + } + + if (typeof overlay[0] === 'object') { + overlay[0].remove(); + } + }, + + /** + * Add or remove CSS class from given element + * @param {string} className Name of the CSS class to add or remove. + * @param {boolean} remove Flag weather to remove or add default is true. + * @param {object} tag Element object default is body + * @returns {NULL} + */ + this.modernAlert.addRemoveClass = function (className, remove, tag) { + if (typeof className === 'undefined') { + return false; + } + + remove = typeof remove !== 'undefined' ? remove : false; + tag = typeof tag !== 'undefined' ? tag : (document.body || document.getElementsByTagName('body')[0]); + + if (remove === true) { + tag.classList.remove(className); + } else { + tag.classList.add(className); + } + } })(); \ No newline at end of file diff --git a/modernAlert.min.js b/modernAlert.min.js index f819d2a..38b3dc8 100644 --- a/modernAlert.min.js +++ b/modernAlert.min.js @@ -3,6 +3,6 @@ * Native functions are replaced with customizable pop-ups. * * @author Sumit Singh - * @version 1.0 + * @version 1.1 **/ -!function(){this.modernAlert=function(){var t={init:function(){if("object"==typeof arguments[0])for(var t in arguments[0])this.args.hasOwnProperty(t)&&(this.args[t]=arguments[0][t]);return this.head.insertBefore(this.getStyleTag(),this.head.firstChild),window.alert=this.alert,window.confirm=this.confirm,window.prompt=this.prompt,this},args:{backgroundColor:"#fff",color:"#555",borderColor:"#ccc",titleBackgroundColor:"#e8a033",titleColor:"#fff",defaultButtonsText:{ok:"Ok",cancel:"Cancel"}},head:document.head||document.getElementsByTagName("head")[0],getStyleTag:function(){var t=document.createElement("style");return t.type="text/css",t.appendChild(document.createTextNode(this.getCSS())),t},getCSS:function(){var t=".modernAlertWrapper {background: "+this.args.backgroundColor+"; color: "+this.args.color+"; border: 1px solid "+this.args.borderColor+"; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); left: 50%; min-height: 120px; min-width: 240px; position: fixed; text-align: center; top: 50%; z-index: 999;font-size:14px;padding-bottom: 15px;}";return t+=".modernAlertWrapper h4 {background: "+this.args.titleBackgroundColor+"; color: "+this.args.titleColor+"; margin: 0; padding: 5px; font-size:16px;}",t+=".modernAlertWrapper p {margin: 0;padding: 5px 10px;}",t+=".maInputWrapper input {width: 100%; max-width: 300px;}"},extract_vars:function(t,e){e="undefined"!=typeof e?e:"confirm";var n=new Object;return n.msg=t[0]||"",n.title=t[1]||"Message","alert"===e?(n.extra_var="undefined"!=typeof t[2]?t[2]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof t[3]?t[3]:this.args.defaultButtonsText):(n.callback="function"==typeof t[2]?t[2]:function(){console.warn("Callback function is missing!")},n.extra_var="undefined"!=typeof t[3]?t[3]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof t[4]?t[4]:this.args.defaultButtonsText),n},alert:function(){var e,n;e=t.extract_vars(arguments,"alert"),n="

"+e.title+"

"+e.msg+'

',t.createInsertHtml("div","modernAlertWrapper",n)},confirm:function(){var e,n,a,r,o;e=t.extract_vars(arguments),n="

"+e.title+"

"+e.msg+'

\n \n ',a=t.createInsertHtml("div","modernAlertWrapper",n),r=a.getElementsByClassName("maYes"),o=a.getElementsByClassName("maNo"),r[0].onclick=function(){e.callback(!0,e.extra_var),this.parentNode.remove()},o[0].onclick=function(){e.callback(!1,e.extra_var),this.parentNode.remove()}},prompt:function(){var e,n,a,r,o,s;e=t.extract_vars(arguments),n="

"+e.title+"

"+e.msg+'

\n

\n \n ',a=t.createInsertHtml("div","modernAlertWrapper",n),r=a.getElementsByClassName("maYes"),o=a.getElementsByClassName("maNo"),s=a.getElementsByClassName("maInput"),r[0].onclick=function(){e.callback(s[0].value,e.extra_var),this.parentNode.remove()},o[0].onclick=function(){e.callback(!1,e.extra_var),this.parentNode.remove()}},createInsertHtml:function(t,e,n){var a=document.createElement(t);return a.className=e,a.innerHTML=n,document.body.appendChild(a),a.style.cssText="margin-left: -"+a.offsetWidth/2+"px; margin-top: -"+a.offsetHeight/2+"px;",a}};return t.init(arguments[0])}}(); \ No newline at end of file +!function(){this.modernAlert=function(){var e={init:function(){if("object"==typeof arguments[0])for(var e in arguments[0])this.args.hasOwnProperty(e)&&(this.args[e]=arguments[0][e]);return this.head.insertBefore(this.getStyleTag(),this.head.firstChild),window.alert=this.alert,window.confirm=this.confirm,window.prompt=this.prompt,this},args:{backgroundColor:"#fff",color:"#555",borderColor:"#ccc",titleBackgroundColor:"#e8a033",titleColor:"#fff",defaultButtonsText:{ok:"Ok",cancel:"Cancel"},overlayColor:"rgba(0, 0, 0, 0.5)",overlayBlur:2},head:document.head||document.getElementsByTagName("head")[0],getStyleTag:function(){var e=document.createElement("style");return e.type="text/css",e.appendChild(document.createTextNode(this.getCSS())),e},getCSS:function(){var e=".modernAlertWrapper {background: "+this.args.backgroundColor+"; color: "+this.args.color+"; border: 1px solid "+this.args.borderColor+"; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); left: 50%; min-height: 120px; min-width: 240px; position: fixed; text-align: center; top: 50%; z-index: 999;font-size:14px;padding-bottom: 15px;}";return e+=".modernAlertWrapper h4 {background: "+this.args.titleBackgroundColor+"; color: "+this.args.titleColor+"; margin: 0; padding: 5px; font-size:16px;}",e+=".modernAlertWrapper p {margin: 0;padding: 5px 10px;}",e+=".maInputWrapper input {width: 100%; max-width: 300px;}",e+=".modernAlertOverlay {background: "+this.args.overlayColor+"; cursor: wait;height: 100%;left: 0;position: fixed;top: 0;width: 100%;z-index: 998;}",this.args.overlayBlur!==!1&&(e+="body.maActive > *:not(script):not(link):not(.modernAlertOverlay):not(.modernAlertWrapper) {-webkit-filter: blur("+this.args.overlayBlur+"px); filter: blur("+this.args.overlayBlur+"px);}"),e},extract_vars:function(e,t){t="undefined"!=typeof t?t:"confirm";var n=new Object;return n.msg=e[0]||"",n.title=e[1]||"Message","alert"===t?(n.extra_var="undefined"!=typeof e[2]?e[2]:"You can use this var by passing value as fourth parameter in confirm function.",n.buttons="object"==typeof e[3]?e[3]:this.args.defaultButtonsText):(n.callback="function"==typeof e[2]?e[2]:function(){console.warn("Callback function is missing!")},n.extra_var="undefined"!=typeof e[3]?e[3]:"You can use this var by passing value as fourth parameter in confirm and prompt function.",n.buttons="object"==typeof e[4]?e[4]:this.args.defaultButtonsText),n},generateId:function(){var e=(new Date).getTime();return"modernAlert"+e},alert:function(){var t,n,r;r=e.generateId(),t=e.extract_vars(arguments,"alert"),n="

"+t.title+"

"+t.msg+'

',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),e.createInsertHtml("div","modernAlertWrapper",n,r)},confirm:function(){var t,n,r,a,o,l;l=e.generateId(),t=e.extract_vars(arguments),n="

"+t.title+"

"+t.msg+'

\n \n ',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),r=e.createInsertHtml("div","modernAlertWrapper",n,l),a=r.getElementsByClassName("maYes"),o=r.getElementsByClassName("maNo"),a[0].onclick=function(){window.modernAlert.close(l),t.callback(!0,t.extra_var)},o[0].onclick=function(){window.modernAlert.close(l),t.callback(!1,t.extra_var)}},prompt:function(){var t,n,r,a,o,l,s;s=e.generateId(),t=e.extract_vars(arguments),n="

"+t.title+"

"+t.msg+'

\n

\n \n ',window.modernAlert.addRemoveClass("maActive"),e.createInsertHtml("div","modernAlertOverlay","",!1,!0),r=e.createInsertHtml("div","modernAlertWrapper",n,s),a=r.getElementsByClassName("maYes"),o=r.getElementsByClassName("maNo"),l=r.getElementsByClassName("maInput"),a[0].onclick=function(){window.modernAlert.close(s),t.callback(l[0].value,t.extra_var)},o[0].onclick=function(){window.modernAlert.close(s),t.callback(!1,t.extra_var)}},createInsertHtml:function(e,t,n,r,a){a="undefined"!=typeof a?a:!1,r="undefined"!=typeof r?r:!1;var o=document.createElement(e);return o.className=t,r!==!1&&(o.id=r),o.innerHTML=n,document.body.appendChild(o),a===!1&&(o.style.cssText="margin-left: -"+o.offsetWidth/2+"px; margin-top: -"+o.offsetHeight/2+"px;"),o}};return e.init(arguments[0])},this.modernAlert.close=function(e){var t=document.getElementsByClassName("modernAlertOverlay"),n=!1;window.modernAlert.addRemoveClass("maActive",!0),e&&(n=document.getElementById(e))&&n.remove(),"object"==typeof t[0]&&t[0].remove()},this.modernAlert.addRemoveClass=function(e,t,n){return"undefined"==typeof e?!1:(t="undefined"!=typeof t?t:!1,n="undefined"!=typeof n?n:document.body||document.getElementsByTagName("body")[0],void(t===!0?n.classList.remove(e):n.classList.add(e)))}}(); \ No newline at end of file