public/js/lib/alertify.js
function (fn) {
				var hasOK     = (typeof btnOK !== "undefined"),
				    hasCancel = (typeof btnCancel !== "undefined"),
				    hasInput  = (typeof input !== "undefined"),
				    val       = "",
				    self      = this,
				    ok, cancel, common, key, reset;

				// ok event handler
				ok = function (event) {
					if (typeof event.preventDefault !== "undefined") event.preventDefault();
					common(event);
					if (typeof input !== "undefined") val = input.value;
					if (typeof fn === "function") {
						if (typeof input !== "undefined") {
							fn(true, val);
						}
						else fn(true);
					}
					return false;
				};

				// cancel event handler
				cancel = function (event) {
					if (typeof event.preventDefault !== "undefined") event.preventDefault();
					common(event);
					if (typeof fn === "function") fn(false);
					return false;
				};

				// common event handler (keyup, ok and cancel)
				common = function (event) {
					self.hide();
					self.unbind(document.body, "keyup", key);
					self.unbind(btnReset, "focus", reset);
					if (hasInput) self.unbind(form, "submit", ok);
					if (hasOK) self.unbind(btnOK, "click", ok);
					if (hasCancel) self.unbind(btnCancel, "click", cancel);
				};

				// keyup handler
				key = function (event) {
					var keyCode = event.keyCode;
					if (keyCode === keys.SPACE && !hasInput) ok(event);
					if (keyCode === keys.ESC && hasCancel) cancel(event);
				};

				// reset focus to first item in the dialog
				reset = function (event) {
					if (hasInput) input.focus();
					else if (!hasCancel || self.buttonReverse) btnOK.focus();
					else btnCancel.focus();
				};

				// handle reset focus link
				// this ensures that the keyboard focus does not
				// ever leave the dialog box until an action has
				// been taken
				this.bind(btnReset, "focus", reset);
				// handle OK click
				if (hasOK) this.bind(btnOK, "click", ok);
				// handle Cancel click
				if (hasCancel) this.bind(btnCancel, "click", cancel);
				// listen for keys, Cancel => ESC
				this.bind(document.body, "keyup", key);
				// bind form submit
				if (hasInput) this.bind(form, "submit", ok);
				if (!this.transition.supported) {
					this.setFocus();
				}
			}
function (fn) {
				var hasOK     = (typeof btnOK !== "undefined"),
				    hasCancel = (typeof btnCancel !== "undefined"),
				    hasInput  = (typeof input !== "undefined"),
				    val       = "",
				    self      = this,
				    ok, cancel, common, key, reset;

				// ok event handler
				ok = function (event) {
					if (typeof event.preventDefault !== "undefined") event.preventDefault();
					common(event);
					if (typeof input !== "undefined") val = input.value;
					if (typeof fn === "function") {
						if (typeof input !== "undefined") {
							fn(true, val);
						}
						else fn(true);
					}
					return false;
				};

				// cancel event handler
				cancel = function (event) {
					if (typeof event.preventDefault !== "undefined") event.preventDefault();
					common(event);
					if (typeof fn === "function") fn(false);
					return false;
				};

				// common event handler (keyup, ok and cancel)
				common = function (event) {
					self.hide();
					self.unbind(document.body, "keyup", key);
					self.unbind(btnReset, "focus", reset);
					if (hasInput) self.unbind(form, "submit", ok);
					if (hasOK) self.unbind(btnOK, "click", ok);
					if (hasCancel) self.unbind(btnCancel, "click", cancel);
				};

				// keyup handler
				key = function (event) {
					var keyCode = event.keyCode;
					if (keyCode === keys.SPACE && !hasInput) ok(event);
					if (keyCode === keys.ESC && hasCancel) cancel(event);
				};

				// reset focus to first item in the dialog
				reset = function (event) {
					if (hasInput) input.focus();
					else if (!hasCancel || self.buttonReverse) btnOK.focus();
					else btnCancel.focus();
				};

				// handle reset focus link
				// this ensures that the keyboard focus does not
				// ever leave the dialog box until an action has
				// been taken
				this.bind(btnReset, "focus", reset);
				// handle OK click
				if (hasOK) this.bind(btnOK, "click", ok);
				// handle Cancel click
				if (hasCancel) this.bind(btnCancel, "click", cancel);
				// listen for keys, Cancel => ESC
				this.bind(document.body, "keyup", key);
				// bind form submit
				if (hasInput) this.bind(form, "submit", ok);
				if (!this.transition.supported) {
					this.setFocus();
				}
			}
function ( fn ) { var hasOK = ( typeof btnOK !== "undefined" ) , hasCancel = ( typeof btnCancel !== "undefined" ) , hasInput = ( typeof input !== "undefined" ) , val = "" , self = this , ok , cancel , common , key , reset ; // ok event handler ok = function ( event ) { if ( typeof event . preventDefault !== "undefined" ) event . preventDefault ( ) ; common ( event ) ; if ( typeof input !== "undefined" ) val = input . value ; if ( typeof fn === "function" ) { if ( typeof input !== "undefined" ) { fn ( true , val ) ; } else fn ( true ) ; } return false ; } ; // cancel event handler cancel = function ( event ) { if ( typeof event . preventDefault !== "undefined" ) event . preventDefault ( ) ; common ( event ) ; if ( typeof fn === "function" ) fn ( false ) ; return false ; } ; // common event handler (keyup, ok and cancel) common = function ( event ) { self . hide ( ) ; self . unbind ( document . body , "keyup" , key ) ; self . unbind ( btnReset , "focus" , reset ) ; if ( hasInput ) self . unbind ( form , "submit" , ok ) ; if ( hasOK ) self . unbind ( btnOK , "click" , ok ) ; if ( hasCancel ) self . unbind ( btnCancel , "click" , cancel ) ; } ; // keyup handler key = function ( event ) { var keyCode = event . keyCode ; if ( keyCode === keys . SPACE && ! hasInput ) ok ( event ) ; if ( keyCode === keys . ESC && hasCancel ) cancel ( event ) ; } ; // reset focus to first item in the dialog reset = function ( event ) { if ( hasInput ) input . focus ( ) ; else if ( ! hasCancel || self . buttonReverse ) btnOK . focus ( ) ; else btnCancel . focus ( ) ; } ; // handle reset focus link // this ensures that the keyboard focus does not // ever leave the dialog box until an action has // been taken this . bind ( btnReset , "focus" , reset ) ; // handle OK click if ( hasOK ) this . bind ( btnOK , "click" , ok ) ; // handle Cancel click if ( hasCancel ) this . bind ( btnCancel , "click" , cancel ) ; // listen for keys, Cancel => ESC this . bind ( document . body , "keyup" , key ) ; // bind form submit if ( hasInput ) this . bind ( form , "submit" , ok ) ; if ( ! this . transition . supported ) { this . setFocus ( ) ; } }
Set the proper button click events

@param {Function} fn    [Optional] Callback function

@return {undefined}
Set the proper button click events