Dialog class

The Dialog class is an abstract of the Jquery dialog and can be used to quickly prepare a dialog from the PHP side for quickly use in javascript.

To create a dialog, to the following:

$dialog = new Dialog('mydialog', 'Hello World', 'This is my hello world dialog', ['ok_event' => 'Ok', 'cancel_event' => 'Cancel']);
 
$dialog->render();

This will create a (closed) jquery dialog ready for use. The first parameter is the ID of the dialog object, the next is the dialog title and the third is the dialog content. The dialog buttons are passed as an array of button texts hashed by event keywords. When the button is pressed, the associated event will fire on the dialog itself. The dialog above can be utilised in javascript like this:

$('#mydialog').dialog('open');
 
$('#mydialog').on('ok_event', function() { /* Actions to take when OK is pressed */});
$('#mydialog').on('cancel_event', function() { /* Actions to take when cancel is pressed */});

Javascript quick dialogs

Two functions are available directly in javascript to create easy dialoges. warningDialog() which displays a dialog with a single OK-button, and confirmDialog() which displays a dialog with both an OK and a Cancel-button.