From 6204a0df1aa8be60e0133f7128e488ec4884900f Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 1 Mar 2014 21:44:17 +0300 Subject: [PATCH] Update alertify.js --- lib/alertify.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/alertify.js b/lib/alertify.js index 373d32d7..8a35079e 100644 --- a/lib/alertify.js +++ b/lib/alertify.js @@ -306,7 +306,7 @@ * * @return {undefined} */ - close : function (elem, wait) { + close : function (elem, wait, callback) { // Unary Plus: +"2" === 2 var timer = (wait && !isNaN(wait)) ? +wait : this.delay, self = this, @@ -314,7 +314,7 @@ // set click event on log messages this.bind(elem, "click", function () { - hideElement(elem); + hideElement(elem, callback); }); // Hide the dialog box after transition // This ensure it doens't block any element from being clicked @@ -328,7 +328,7 @@ }; // this sets the hide class to transition out // or removes the child if css transitions aren't supported - hideElement = function (el) { + hideElement = function (el, callback) { // ensure element exists if (typeof el !== "undefined" && el.parentNode === elLog) { // whether CSS transition exists @@ -339,6 +339,9 @@ elLog.removeChild(el); if (!elLog.hasChildNodes()) elLog.className += " alertify-logs-hidden"; } + if (typeof(callback) == "function") { + callback(); + } } }; // never close (until click) if wait is set to 0 @@ -484,7 +487,7 @@ * * @return {Object} */ - log : function (message, type, wait) { + log : function (message, type, wait, callback) { // check to ensure the alertify dialog element // has been successfully created var check = function () { @@ -496,7 +499,7 @@ check(); elLog.className = "alertify-logs"; - this.notify(message, type, wait); + this.notify(message, type, wait, callback); return this; }, @@ -511,7 +514,7 @@ * * @return {undefined} */ - notify : function (message, type, wait) { + notify : function (message, type, wait, callback) { var log = document.createElement("article"); log.className = "alertify-log" + ((typeof type === "string" && type !== "") ? " alertify-log-" + type : ""); log.innerHTML = message; @@ -519,7 +522,7 @@ elLog.appendChild(log); // triggers the CSS animation setTimeout(function() { log.className = log.className + " alertify-log-show"; }, 50); - this.close(log, wait); + this.close(log, wait, callback); }, /**