From bc8cd529ceb8971fb6be26997294c8b530489147 Mon Sep 17 00:00:00 2001 From: Fabien Doiron Date: Sat, 12 Jan 2013 16:01:44 -0500 Subject: [PATCH] resolving dialog blocking elements, issue #92 --- lib/alertify.js | 99 +++++++++++++++++++------------------ lib/alertify.min.js | 2 +- src/alertify.js | 99 +++++++++++++++++++------------------ themes/alertify.core.css | 8 ++- themes/alertify.default.css | 2 +- 5 files changed, 113 insertions(+), 97 deletions(-) diff --git a/lib/alertify.js b/lib/alertify.js index d302449f..413faca4 100644 --- a/lib/alertify.js +++ b/lib/alertify.js @@ -24,7 +24,7 @@ isopen = false, keys = { ENTER: 13, ESC: 27, SPACE: 32 }, queue = [], - $, elCallee, elCover, elDialog, elLog, getTransitionEvent; + $, btnCancel, btnOK, btnReset, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent; /** * Markup pieces @@ -50,11 +50,10 @@ var t, el = document.createElement("fakeelement"), transitions = { - "transition" : "transitionend", - "OTransition" : "otransitionend", - "MSTransition" : "msTransitionEnd", + "WebkitTransition" : "webkitTransitionEnd", "MozTransition" : "transitionend", - "WebkitTransition" : "webkitTransitionEnd" + "OTransition" : "otransitionend", + "transition" : "transitionend" }; for (t in transitions) { @@ -113,12 +112,7 @@ * @return {undefined} */ addListeners : function (fn) { - var btnReset = $("alertify-resetFocus"), - btnOK = $("alertify-ok") || undefined, - btnCancel = $("alertify-cancel") || undefined, - input = $("alertify-text") || undefined, - form = $("alertify-form") || undefined, - hasOK = (typeof btnOK !== "undefined"), + var hasOK = (typeof btnOK !== "undefined"), hasCancel = (typeof btnCancel !== "undefined"), hasInput = (typeof input !== "undefined"), val = "", @@ -185,11 +179,7 @@ // bind form submit if (hasInput) this.bind(form, "submit", ok); if (typeof this.transition === "undefined") { - if (input) { - input.focus(); - input.select(); - } - else btnOK.focus(); + this.setFocus(); } }, @@ -376,13 +366,28 @@ * @return {undefined} */ hide : function () { + var transitionDone, + self = this; // remove reference from queue queue.splice(0,1); // if items remaining in the queue if (queue.length > 0) this.setup(); else { isopen = false; - elDialog.className = "alertify alertify-hide alertify-hidden"; + // Hide the dialog box after transition + // This ensure it doens't block any element from being clicked + transitionDone = function (event) { + elDialog.className += " alertify-isHidden"; + // unbind event so function only gets called once + self.unbind(elDialog, self.transition, transitionDone); + }; + // whether CSS transition exists + if (typeof this.transition !== "undefined") { + this.bind(elDialog, this.transition, transitionDone); + elDialog.className = "alertify alertify-hide alertify-hidden"; + } else { + elDialog.className = "alertify alertify-hide alertify-hidden alertify-isHidden"; + } elCover.className = "alertify-cover alertify-cover-hidden"; // set focus to the last element or body // after the dialog is closed @@ -492,51 +497,53 @@ } }, + /** + * Common place to set focus to proper element + * + * @return {undefined} + */ + setFocus : function () { + if (input) { + input.focus(); + input.select(); + } + else btnOK.focus(); + }, + /** * Initiate all the required pieces for the dialog box * * @return {undefined} */ setup : function () { - var item = queue[0], - first = true, - self = this, + var item = queue[0], + self = this, transitionDone; + // dialog is open isopen = true; - - /** - * Set button focus after transition - * - * @param {Event} event transition event - * - * @return {undefined} - */ + // Set button focus after transition transitionDone = function (event) { - var input = $("alertify-text") || undefined, - btnOK = $("alertify-ok") || undefined; - event.stopPropagation(); // transitionend event gets fired for every property (using `all`) // this ensures it only tries to remove the element once - if (first) { - first = false; - if (input) { - input.focus(); - input.select(); - } - else btnOK.focus(); - self.unbind(elDialog, self.transition, transitionDone); - } + self.setFocus(); + self.unbind(elDialog, self.transition, transitionDone); }; - // whether CSS transition exists if (typeof this.transition !== "undefined") { this.bind(elDialog, this.transition, transitionDone); } - + // build the proper dialog HTML elDialog.innerHTML = this.build(item); - if (typeof item.placeholder === "string" && item.placeholder !== "") $("alertify-text").value = item.placeholder; + // assign all the common elements + btnReset = $("alertify-resetFocus"); + btnOK = $("alertify-ok") || undefined; + btnCancel = $("alertify-cancel") || undefined; + input = $("alertify-text") || undefined; + form = $("alertify-form") || undefined; + // add placeholder value to the input field + if (typeof item.placeholder === "string" && item.placeholder !== "") input.value = item.placeholder; this.addListeners(item.callback); }, @@ -575,10 +582,8 @@ // AMD and window support if (typeof define === "function") { define([], function () { return new Alertify(); }); - } else { - if (typeof global.alertify === "undefined") { - global.alertify = new Alertify(); - } + } else if (typeof global.alertify === "undefined") { + global.alertify = new Alertify(); } }(this)); \ No newline at end of file diff --git a/lib/alertify.min.js b/lib/alertify.min.js index b48902ae..74f4f9d4 100644 --- a/lib/alertify.min.js +++ b/lib/alertify.min.js @@ -9,4 +9,4 @@ * @module alertify * @version 0.3.3 */ -(function(e,t){"use strict";var n=e.document,r;r=function(){var e={},r={},i=!1,s={ENTER:13,ESC:27,SPACE:32},o=[],u,a,f,l,c,h;return r={buttons:{holder:'',submit:'',ok:'{{ok}}',cancel:'{{cancel}}'},input:'
',message:'

{{message}}

',log:'
{{message}}
'},h=function(){var e,r=n.createElement("fakeelement"),i={transition:"transitionend",OTransition:"otransitionend",MSTransition:"msTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in i)if(r.style[e]!==t)return i[e]},u=function(e){return n.getElementById(e)},e={labels:{ok:"OK",cancel:"Cancel"},delay:5e3,buttonReverse:!1,transition:t,addListeners:function(e){var r=u("alertify-resetFocus"),i=u("alertify-ok")||t,o=u("alertify-cancel")||t,a=u("alertify-text")||t,f=u("alertify-form")||t,l=typeof i!="undefined",c=typeof o!="undefined",h=typeof a!="undefined",p="",d=this,v,m,g,y,b;v=function(t){return typeof t.preventDefault!="undefined"&&t.preventDefault(),g(t),typeof a!="undefined"&&(p=a.value),typeof e=="function"&&(typeof a!="undefined"?e(!0,p):e(!0)),!1},m=function(t){return typeof t.preventDefault!="undefined"&&t.preventDefault(),g(t),typeof e=="function"&&e(!1),!1},g=function(e){d.hide(),d.unbind(n.body,"keyup",y),d.unbind(r,"focus",b),h&&d.unbind(f,"submit",v),l&&d.unbind(i,"click",v),c&&d.unbind(o,"click",m)},y=function(e){var t=e.keyCode;t===s.SPACE&&!h&&v(e),t===s.ESC&&c&&m(e)},b=function(e){h?a.focus():c?o.focus():i.focus()},this.bind(r,"focus",b),l&&this.bind(i,"click",v),c&&this.bind(o,"click",m),this.bind(n.body,"keyup",y),h&&this.bind(f,"submit",v),typeof this.transition=="undefined"&&(a?(a.focus(),a.select()):i.focus())},bind:function(e,t,n){typeof e.addEventListener=="function"?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},appendButtons:function(e,t){return this.buttonReverse?t+e:e+t},build:function(e){var t="",n=e.type,i=e.message,s=e.cssClass||"";t+='
',n==="prompt"&&(t+='
'),t+='
',t+=r.message.replace("{{message}}",i),n==="prompt"&&(t+=r.input),t+=r.buttons.holder,t+="
",n==="prompt"&&(t+="
"),t+='Reset Focus',t+="
";switch(n){case"confirm":t=t.replace("{{buttons}}",this.appendButtons(r.buttons.cancel,r.buttons.ok)),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"prompt":t=t.replace("{{buttons}}",this.appendButtons(r.buttons.cancel,r.buttons.submit)),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"alert":t=t.replace("{{buttons}}",r.buttons.ok),t=t.replace("{{ok}}",this.labels.ok);break;default:}return l.className="alertify alertify-show alertify-"+n+" "+s,f.className="alertify-cover",t},close:function(e,t){var n=t&&!isNaN(t)?+t:this.delay,r=this,i;this.bind(e,"click",function(){c.removeChild(e)}),i=function(e){e.stopPropagation(),e.propertyName==="opacity"&&c.removeChild(this)};if(t===0)return;setTimeout(function(){typeof e!="undefined"&&e.parentNode===c&&(typeof r.transition!="undefined"?(r.bind(e,r.transition,i),e.className+=" alertify-log-hide"):c.removeChild(e))},n)},dialog:function(e,t,r,s,u){a=n.activeElement;var f=function(){if(l&&l.scrollTop!==null)return;f()};if(typeof e!="string")throw new Error("message must be a string");if(typeof t!="string")throw new Error("type must be a string");if(typeof r!="undefined"&&typeof r!="function")throw new Error("fn must be a function");return typeof this.init=="function"&&(this.init(),f()),o.push({type:t,message:e,callback:r,placeholder:s,cssClass:u}),i||this.setup(),this},extend:function(e){if(typeof e!="string")throw new Error("extend method must have exactly one paramter");return function(t,n){return this.log(t,e,n),this}},hide:function(){o.splice(0,1),o.length>0?this.setup():(i=!1,l.className="alertify alertify-hide alertify-hidden",f.className="alertify-cover alertify-cover-hidden",a.focus())},init:function(){n.createElement("nav"),n.createElement("article"),n.createElement("section"),f=n.createElement("div"),f.setAttribute("id","alertify-cover"),f.className="alertify-cover alertify-cover-hidden",n.body.appendChild(f),l=n.createElement("section"),l.setAttribute("id","alertify"),l.className="alertify alertify-hidden",n.body.appendChild(l),c=n.createElement("section"),c.setAttribute("id","alertify-logs"),c.className="alertify-logs",n.body.appendChild(c),n.body.setAttribute("tabindex","0"),this.transition=h(),delete this.init},log:function(e,t,n){var r=function(){if(c&&c.scrollTop!==null)return;r()};return typeof this.init=="function"&&(this.init(),r()),this.notify(e,t,n),this},notify:function(e,t,r){var i=n.createElement("article");i.className="alertify-log"+(typeof t=="string"&&t!==""?" alertify-log-"+t:""),i.innerHTML=e,c.insertBefore(i,c.firstChild),setTimeout(function(){i.className=i.className+" alertify-log-show"},50),this.close(i,r)},set:function(e){var t;if(typeof e!="object"&&e instanceof Array)throw new Error("args must be an object");for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},setup:function(){var e=o[0],n=!0,r=this,s;i=!0,s=function(e){var i=u("alertify-text")||t,o=u("alertify-ok")||t;e.stopPropagation(),n&&(n=!1,i?(i.focus(),i.select()):o.focus(),r.unbind(l,r.transition,s))},typeof this.transition!="undefined"&&this.bind(l,this.transition,s),l.innerHTML=this.build(e),typeof e.placeholder=="string"&&e.placeholder!==""&&(u("alertify-text").value=e.placeholder),this.addListeners(e.callback)},unbind:function(e,t,n){typeof e.removeEventListener=="function"?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}},{alert:function(t,n,r){return e.dialog(t,"alert",n,"",r),this},confirm:function(t,n,r){return e.dialog(t,"confirm",n,"",r),this},extend:e.extend,init:e.init,log:function(t,n,r){return e.log(t,n,r),this},prompt:function(t,n,r,i){return e.dialog(t,"prompt",n,r,i),this},success:function(t,n){return e.log(t,"success",n),this},error:function(t,n){return e.log(t,"error",n),this},set:function(t){e.set(t)},labels:e.labels}},typeof define=="function"?define([],function(){return new r}):typeof e.alertify=="undefined"&&(e.alertify=new r)})(this); \ No newline at end of file +(function(e,t){"use strict";var n=e.document,r;r=function(){var e={},r={},i=!1,s={ENTER:13,ESC:27,SPACE:32},o=[],u,a,f,l,c,h,p,d,v,m,g;return r={buttons:{holder:'',submit:'',ok:'{{ok}}',cancel:'{{cancel}}'},input:'
',message:'

{{message}}

',log:'
{{message}}
'},g=function(){var e,r=n.createElement("fakeelement"),i={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"};for(e in i)if(r.style[e]!==t)return i[e]},u=function(e){return n.getElementById(e)},e={labels:{ok:"OK",cancel:"Cancel"},delay:5e3,buttonReverse:!1,transition:t,addListeners:function(e){var t=typeof f!="undefined",r=typeof a!="undefined",i=typeof m!="undefined",o="",u=this,c,h,p,d,g;c=function(t){return typeof t.preventDefault!="undefined"&&t.preventDefault(),p(t),typeof m!="undefined"&&(o=m.value),typeof e=="function"&&(typeof m!="undefined"?e(!0,o):e(!0)),!1},h=function(t){return typeof t.preventDefault!="undefined"&&t.preventDefault(),p(t),typeof e=="function"&&e(!1),!1},p=function(e){u.hide(),u.unbind(n.body,"keyup",d),u.unbind(l,"focus",g),i&&u.unbind(v,"submit",c),t&&u.unbind(f,"click",c),r&&u.unbind(a,"click",h)},d=function(e){var t=e.keyCode;t===s.SPACE&&!i&&c(e),t===s.ESC&&r&&h(e)},g=function(e){i?m.focus():r?a.focus():f.focus()},this.bind(l,"focus",g),t&&this.bind(f,"click",c),r&&this.bind(a,"click",h),this.bind(n.body,"keyup",d),i&&this.bind(v,"submit",c),typeof this.transition=="undefined"&&this.setFocus()},bind:function(e,t,n){typeof e.addEventListener=="function"?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},appendButtons:function(e,t){return this.buttonReverse?t+e:e+t},build:function(e){var t="",n=e.type,i=e.message,s=e.cssClass||"";t+='
',n==="prompt"&&(t+='
'),t+='
',t+=r.message.replace("{{message}}",i),n==="prompt"&&(t+=r.input),t+=r.buttons.holder,t+="
",n==="prompt"&&(t+="
"),t+='Reset Focus',t+="
";switch(n){case"confirm":t=t.replace("{{buttons}}",this.appendButtons(r.buttons.cancel,r.buttons.ok)),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"prompt":t=t.replace("{{buttons}}",this.appendButtons(r.buttons.cancel,r.buttons.submit)),t=t.replace("{{ok}}",this.labels.ok).replace("{{cancel}}",this.labels.cancel);break;case"alert":t=t.replace("{{buttons}}",r.buttons.ok),t=t.replace("{{ok}}",this.labels.ok);break;default:}return p.className="alertify alertify-show alertify-"+n+" "+s,h.className="alertify-cover",t},close:function(e,t){var n=t&&!isNaN(t)?+t:this.delay,r=this,i;this.bind(e,"click",function(){d.removeChild(e)}),i=function(e){e.stopPropagation(),e.propertyName==="opacity"&&d.removeChild(this)};if(t===0)return;setTimeout(function(){typeof e!="undefined"&&e.parentNode===d&&(typeof r.transition!="undefined"?(r.bind(e,r.transition,i),e.className+=" alertify-log-hide"):d.removeChild(e))},n)},dialog:function(e,t,r,s,u){c=n.activeElement;var a=function(){if(p&&p.scrollTop!==null)return;a()};if(typeof e!="string")throw new Error("message must be a string");if(typeof t!="string")throw new Error("type must be a string");if(typeof r!="undefined"&&typeof r!="function")throw new Error("fn must be a function");return typeof this.init=="function"&&(this.init(),a()),o.push({type:t,message:e,callback:r,placeholder:s,cssClass:u}),i||this.setup(),this},extend:function(e){if(typeof e!="string")throw new Error("extend method must have exactly one paramter");return function(t,n){return this.log(t,e,n),this}},hide:function(){var e,t=this;o.splice(0,1),o.length>0?this.setup():(i=!1,e=function(n){p.className+=" alertify-isHidden",t.unbind(p,t.transition,e)},typeof this.transition!="undefined"?(this.bind(p,this.transition,e),p.className="alertify alertify-hide alertify-hidden"):p.className="alertify alertify-hide alertify-hidden alertify-isHidden",h.className="alertify-cover alertify-cover-hidden",c.focus())},init:function(){n.createElement("nav"),n.createElement("article"),n.createElement("section"),h=n.createElement("div"),h.setAttribute("id","alertify-cover"),h.className="alertify-cover alertify-cover-hidden",n.body.appendChild(h),p=n.createElement("section"),p.setAttribute("id","alertify"),p.className="alertify alertify-hidden",n.body.appendChild(p),d=n.createElement("section"),d.setAttribute("id","alertify-logs"),d.className="alertify-logs",n.body.appendChild(d),n.body.setAttribute("tabindex","0"),this.transition=g(),delete this.init},log:function(e,t,n){var r=function(){if(d&&d.scrollTop!==null)return;r()};return typeof this.init=="function"&&(this.init(),r()),this.notify(e,t,n),this},notify:function(e,t,r){var i=n.createElement("article");i.className="alertify-log"+(typeof t=="string"&&t!==""?" alertify-log-"+t:""),i.innerHTML=e,d.insertBefore(i,d.firstChild),setTimeout(function(){i.className=i.className+" alertify-log-show"},50),this.close(i,r)},set:function(e){var t;if(typeof e!="object"&&e instanceof Array)throw new Error("args must be an object");for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},setFocus:function(){m?(m.focus(),m.select()):f.focus()},setup:function(){var e=o[0],n=this,r;i=!0,r=function(e){e.stopPropagation(),n.setFocus(),n.unbind(p,n.transition,r)},typeof this.transition!="undefined"&&this.bind(p,this.transition,r),p.innerHTML=this.build(e),l=u("alertify-resetFocus"),f=u("alertify-ok")||t,a=u("alertify-cancel")||t,m=u("alertify-text")||t,v=u("alertify-form")||t,typeof e.placeholder=="string"&&e.placeholder!==""&&(m.value=e.placeholder),this.addListeners(e.callback)},unbind:function(e,t,n){typeof e.removeEventListener=="function"?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}},{alert:function(t,n,r){return e.dialog(t,"alert",n,"",r),this},confirm:function(t,n,r){return e.dialog(t,"confirm",n,"",r),this},extend:e.extend,init:e.init,log:function(t,n,r){return e.log(t,n,r),this},prompt:function(t,n,r,i){return e.dialog(t,"prompt",n,r,i),this},success:function(t,n){return e.log(t,"success",n),this},error:function(t,n){return e.log(t,"error",n),this},set:function(t){e.set(t)},labels:e.labels}},typeof define=="function"?define([],function(){return new r}):typeof e.alertify=="undefined"&&(e.alertify=new r)})(this); \ No newline at end of file diff --git a/src/alertify.js b/src/alertify.js index b14347b1..151c6275 100644 --- a/src/alertify.js +++ b/src/alertify.js @@ -12,7 +12,7 @@ isopen = false, keys = { ENTER: 13, ESC: 27, SPACE: 32 }, queue = [], - $, elCallee, elCover, elDialog, elLog, getTransitionEvent; + $, btnCancel, btnOK, btnReset, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent; /** * Markup pieces @@ -38,11 +38,10 @@ var t, el = document.createElement("fakeelement"), transitions = { - "transition" : "transitionend", - "OTransition" : "otransitionend", - "MSTransition" : "msTransitionEnd", + "WebkitTransition" : "webkitTransitionEnd", "MozTransition" : "transitionend", - "WebkitTransition" : "webkitTransitionEnd" + "OTransition" : "otransitionend", + "transition" : "transitionend" }; for (t in transitions) { @@ -101,12 +100,7 @@ * @return {undefined} */ addListeners : function (fn) { - var btnReset = $("alertify-resetFocus"), - btnOK = $("alertify-ok") || undefined, - btnCancel = $("alertify-cancel") || undefined, - input = $("alertify-text") || undefined, - form = $("alertify-form") || undefined, - hasOK = (typeof btnOK !== "undefined"), + var hasOK = (typeof btnOK !== "undefined"), hasCancel = (typeof btnCancel !== "undefined"), hasInput = (typeof input !== "undefined"), val = "", @@ -173,11 +167,7 @@ // bind form submit if (hasInput) this.bind(form, "submit", ok); if (typeof this.transition === "undefined") { - if (input) { - input.focus(); - input.select(); - } - else btnOK.focus(); + this.setFocus(); } }, @@ -364,13 +354,28 @@ * @return {undefined} */ hide : function () { + var transitionDone, + self = this; // remove reference from queue queue.splice(0,1); // if items remaining in the queue if (queue.length > 0) this.setup(); else { isopen = false; - elDialog.className = "alertify alertify-hide alertify-hidden"; + // Hide the dialog box after transition + // This ensure it doens't block any element from being clicked + transitionDone = function (event) { + elDialog.className += " alertify-isHidden"; + // unbind event so function only gets called once + self.unbind(elDialog, self.transition, transitionDone); + }; + // whether CSS transition exists + if (typeof this.transition !== "undefined") { + this.bind(elDialog, this.transition, transitionDone); + elDialog.className = "alertify alertify-hide alertify-hidden"; + } else { + elDialog.className = "alertify alertify-hide alertify-hidden alertify-isHidden"; + } elCover.className = "alertify-cover alertify-cover-hidden"; // set focus to the last element or body // after the dialog is closed @@ -480,51 +485,53 @@ } }, + /** + * Common place to set focus to proper element + * + * @return {undefined} + */ + setFocus : function () { + if (input) { + input.focus(); + input.select(); + } + else btnOK.focus(); + }, + /** * Initiate all the required pieces for the dialog box * * @return {undefined} */ setup : function () { - var item = queue[0], - first = true, - self = this, + var item = queue[0], + self = this, transitionDone; + // dialog is open isopen = true; - - /** - * Set button focus after transition - * - * @param {Event} event transition event - * - * @return {undefined} - */ + // Set button focus after transition transitionDone = function (event) { - var input = $("alertify-text") || undefined, - btnOK = $("alertify-ok") || undefined; - event.stopPropagation(); // transitionend event gets fired for every property (using `all`) // this ensures it only tries to remove the element once - if (first) { - first = false; - if (input) { - input.focus(); - input.select(); - } - else btnOK.focus(); - self.unbind(elDialog, self.transition, transitionDone); - } + self.setFocus(); + self.unbind(elDialog, self.transition, transitionDone); }; - // whether CSS transition exists if (typeof this.transition !== "undefined") { this.bind(elDialog, this.transition, transitionDone); } - + // build the proper dialog HTML elDialog.innerHTML = this.build(item); - if (typeof item.placeholder === "string" && item.placeholder !== "") $("alertify-text").value = item.placeholder; + // assign all the common elements + btnReset = $("alertify-resetFocus"); + btnOK = $("alertify-ok") || undefined; + btnCancel = $("alertify-cancel") || undefined; + input = $("alertify-text") || undefined; + form = $("alertify-form") || undefined; + // add placeholder value to the input field + if (typeof item.placeholder === "string" && item.placeholder !== "") input.value = item.placeholder; this.addListeners(item.callback); }, @@ -563,10 +570,8 @@ // AMD and window support if (typeof define === "function") { define([], function () { return new Alertify(); }); - } else { - if (typeof global.alertify === "undefined") { - global.alertify = new Alertify(); - } + } else if (typeof global.alertify === "undefined") { + global.alertify = new Alertify(); } }(this)); \ No newline at end of file diff --git a/themes/alertify.core.css b/themes/alertify.core.css index f16f3df7..23a0e15d 100644 --- a/themes/alertify.core.css +++ b/themes/alertify.core.css @@ -44,8 +44,10 @@ -o-transform: translate(0,-150px); transform: translate(0,-150px); opacity: 0; - display: none\9; /* IE8 & IE7 */ + display: none; } + /* overwrite display: none; for everything except IE6-8 */ + :root *> .alertify-hidden { display: block; } .alertify-logs { position: fixed; z-index: 5000; @@ -107,6 +109,10 @@ margin-left: 5px; } +.alertify-isHidden { + visibility: hidden; +} + @media only screen and (max-width: 680px) { .alertify, .alertify-logs { diff --git a/themes/alertify.default.css b/themes/alertify.default.css index d4544c3d..99ccf452 100644 --- a/themes/alertify.default.css +++ b/themes/alertify.default.css @@ -56,7 +56,7 @@ background-color: #5CB811; border: 1px solid #3B7808; } - + .alertify-log { background: #1F1F1F; background: rgba(0,0,0,.9);