### Dialogs

The most frequent dialogs are alert, confirm and prompt. In the case of an alert you just need to display a message to the user and require no feedback besides user acknowledgement. Confirm dialog has similar purpose, but expects from the user a response by accepting or declining the message. Prompt waits for user input. The w2ui library includes these dialogs for your convenience.

#### w2alert (msg, [title], [callBack])

The alert dialog can be called in the following way: w2alert('This is an alert'); First argument, msg, is a message to display. Second optional argument, title, is the title for the dialog. The third optional argument, callBack, is a call back function when dialog is closed.
w2alert('This is an alert').done(function () { // call back when alert closed });

#### w2confirm (msg, [title], [callBack])

The confirm dialog can be called in the following way: w2confirm('Are you sure?', function btn(answer) { console.log(answer); // Yes or No -- case-sensitive }); The method takes up to three arguments w2confirm(msg, [title], [callBack]), where msg is the message to display. You can optionally supply title for the message and a call back function.

#### w2confirm(options)

You can optionally call w2confirm passing an object with options. This options object has following structure: options = { msg : '', title : 'Confirmation', width : 450, // width of the dialog height : 220, // height of the dialog btn_yes : { text : 'Yes', // text for yes button (or yes_text) class : '', // class for yes button (or yes_class) style : '', // style for yes button (or yes_style) callBack : null // callBack for yes button (or yes_callBack) }, btn_no : { text : 'No', // text for no button (or no_text) class : '', // class for no button (or no_class) style : '', // style for no button (or no_style) callBack : null // callBack for no button (or no_callBack) }, callBack : null // common callBack }; For convenience, w2confirm will return to you an object with yes() and no() methods that you can use in the following way: w2confirm('Are you sure?') .yes(function () { console.log('user clicked YES'); }) .no(function () { console.log("user clicked NO") });

#### w2prompt(label, [title], [callBack])

Prompts user to enter value. Instead of passing label, title, and callBack, you can call w2prompt in the following way: w2prompt({ label : 'Enter value', value : '0', attrs : 'size=6' }) .change(function () { console.log('Input value changed.'); }) .ok(function () { console.log("User clicked ok.") });

#### w2prompt(options)

Following properties are supported: options = { label : '', // label for the input control value : '', // initial value of input attrs : '', // attributes for input control title : 'Notification', // title of dialog ok_text : 'Ok', // text of Ok button cancel_text : 'Cancel', // text of Cancel button width : 400, // width of the dialog height : 220, // height of dialog callBack : null // callBack function, if any }