From 6204a0df1aa8be60e0133f7128e488ec4884900f Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 1 Mar 2014 21:44:17 +0300 Subject: [PATCH 1/2] 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); }, /** From e995bb2d27ae43a14305fa8ec21825986559dcc0 Mon Sep 17 00:00:00 2001 From: AS3Boyan Date: Fri, 27 Jun 2014 20:10:29 +0300 Subject: [PATCH 2/2] Adjust log, success, error API for callback. Update extend function. --- lib/alertify.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/alertify.js b/lib/alertify.js index 8a35079e..caaac3ec 100644 --- a/lib/alertify.js +++ b/lib/alertify.js @@ -339,7 +339,7 @@ elLog.removeChild(el); if (!elLog.hasChildNodes()) elLog.className += " alertify-logs-hidden"; } - if (typeof(callback) == "function") { + if (typeof callback === "function") { callback(); } } @@ -395,8 +395,8 @@ */ extend : function (type) { if (typeof type !== "string") throw new Error("extend method must have exactly one paramter"); - return function (message, wait) { - this.log(message, type, wait); + return function (message, wait, callback) { + this.log(message, type, wait, callback); return this; }; }, @@ -619,10 +619,10 @@ confirm : function (message, fn, cssClass) { _alertify.dialog(message, "confirm", fn, "", cssClass); return this; }, extend : _alertify.extend, init : _alertify.init, - log : function (message, type, wait) { _alertify.log(message, type, wait); return this; }, + log : function (message, type, wait, callback) { _alertify.log(message, type, wait); return this; }, prompt : function (message, fn, placeholder, cssClass) { _alertify.dialog(message, "prompt", fn, placeholder, cssClass); return this; }, - success : function (message, wait) { _alertify.log(message, "success", wait); return this; }, - error : function (message, wait) { _alertify.log(message, "error", wait); return this; }, + success : function (message, wait, callback) { _alertify.log(message, "success", wait); return this; }, + error : function (message, wait, callback) { _alertify.log(message, "error", wait); return this; }, set : function (args) { _alertify.set(args); }, labels : _alertify.labels, debug : _alertify.handleErrors