bengourley / modal.js

An async modal window for the browser
12 stars 13 forks source link

Modal

A modal window for the browser.

This module provides generic modal dialog functionality for blocking the UI and obtaining user input.

Note:

You need to 'require' this module in a commonJS style environment, and you need to be able to require the things with the .jade extension. I use browserify to do this.

Usage

modal([options])[.on('event')]

Options

Events will be fired on the modal according to which button is clicked. Defaults are confirm/cancel, but these can be overriden in your options.

Example

modal(
  { title: 'Delete object'
  , content: 'Are you sure you want to delete this object?'
  , buttons:
    [ { text: 'Don’t delete', event: 'cancel', keyCodes: [ 27 ] }
    , { text: 'Delete', event: 'confirm', className: 'button-danger', iconClassName: 'icon-delete' }
    ]
  })
  .on('confirm', deleteItem)