Skip to content

JamesKyburz/dialogs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dialogs

js-standard-style Greenkeeper badge

non blocking confirm, alert and prompt dialogs.

Theses native counterparts block the UI thread, are are not allowed in electron and some chrome extention contexts.

Try it out! view on requirebin

use with browserify:

methods

var Dialogs = require('dialogs')

var dialogs = Dialogs(opts={})

opts.ok default OK

opts.cancel default Cancel

opts.hostname default location.hostname

opts.icon optional url for icon

dialogs.alert([text], cb)

dialogs.prompt([text], [default], cb)

dialogs.confirm([text], cb)

dialogs.cancel()

Shortcut to cancel the open dialog if exists.

example

const Dialogs = require('dialogs')
const dialogs = Dialogs()
dialogs.alert('okidoki', ok => {
  console.log('alert', ok)
  dialogs.confirm('ok?', ok => {
    console.log('confirm', ok)
    dialogs.prompt('username', '[email protected]', ok => {
      console.log('prompt with default', ok)
      dialogs.prompt('username', ok => {
        console.log('prompt', ok)
      })
    })
  })
})

install

With npm do:

npm install dialogs

license

MIT