Skip to content

0.3.* API Documentation

Fabien Doiron edited this page Mar 22, 2014 · 2 revisions

Methods

Alert

@since 0.0.1
Create an alert dialog box

Parameters

@param  {String}   message     The message passed from the callee
@param  {Function} fn          [Optional] Callback function
@param  {String}   cssClass    [Optional] Class(es) to append to dialog box
@return {Object}

Examples

alertify.alert("message");

Confirm

@since 0.0.1
Create a confirm dialog box

Parameters

@param  {String}   message     The message passed from the callee
@param  {Function} fn          [Optional] Callback function
@param  {String}   cssClass    [Optional] Class(es) to append to dialog box
@return {Object}

Examples

alertify.confirm("message", fn);

Extend

@since 0.0.1
Extend the log method to create custom methods

Parameters

@param  {String} type    Custom method name
@return {Function}

Examples

alertify.custom = alertify.extend( "custom" );
alertify.custom( message ); // same as alertify.log( message, "custom" );

Init

@since 0.0.1
Initialize Alertify and create the 2 main elements. Initialization will happen automatically on the first use of alert, confirm, prompt or log.

Examples

alertify.init();
// or
alertify.alert("message") // also initiates on confirm, prompt or log

Log

@since 0.0.1
Show a new log message box

Parameters

@param  {String} message    The message passed from the callee
@param  {String} type       [Optional] Optional type of log message
@param  {Number} wait       [Optional] Time (in ms) to wait before auto-hiding

Examples

alertify.log("message", type);

Prompt

@since 0.0.1
Create a prompt dialog box

Parameters

@param  {String}   message        The message passed from the callee
@param  {Function} fn             [Optional] Callback function
@param  {String}   placeholder    [Optional] Default value for prompt input field
@param  {String}   cssClass       [Optional] Class(es) to append to dialog box
@return {Object}

Examples

alertify.prompt("message", fn, "default input value");

Set

@since 0.2.11
Used to set alertify properties

Parameters

@param {Object} args     Passing parameters

Success / Error

@since 0.0.1
Shorthand for log messages.

Examples

alertify.success( message ); // same as alertify.log( message, "success" );
alertify.error( message );   // same as alertify.log( message, "error" );

Debug

@since 0.3.8
Attaches alertify.error to window.onerror method.

Usage

alertify.debug();

Properties
Properties are set using the set method.

Delay

@since 0.0.1
Time in milliseconds for log messages to stay open

Examples

alertify.set({ delay : 10000 }); // 10s

Labels

@since 0.0.1
Object for "OK" and "Cancel" button labels

Examples

alertify.set({ labels : { ok: "OK", cancel: "Cancel" } });

Focus Buttons

@since 0.3.6
Set which button gets focus by default

Examples

// "ok" default
alertify.set({ buttonFocus: "ok" }); // "none", "cancel", "ok"

Reverse Buttons

@since 0.3.1
Reverse the order of the "OK" and "Cancel" button

Examples

alertify.set({ buttonReverse: true });