Module: Opal::Bootbox

Defined in:
lib/opal/bootbox.rb,
lib/opal/bootbox.rb,
lib/opal/bootbox/version.rb

Constant Summary collapse

VERSION =
'0.1.3'

Class Method Summary collapse

Class Method Details

.alert(*args, &block) ⇒ Object

Creates an alert window. The given block is optional. Method executes asynchronously. No result is passed to the given block.



30
31
32
# File 'lib/opal/bootbox.rb', line 30

def alert(*args, &block)
  bootbox_call(__method__, *args, &block)
end

.bootbox_call(method, *args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/opal/bootbox.rb', line 16

def bootbox_call(method, *args, &block)
  arg = args.first
  if arg.is_a?(Hash) && arg[:callback].nil?
    arg[:callback] = block
    Native.call(`bootbox`, method, arg.to_n)
  else
    Native.call(`bootbox`, method, arg.to_n, &block)
  end
end

.confirm(*args, &block) ⇒ Object

Creates a confirm window. Method executes asynchronously. The result passed to given block is true or false.



37
38
39
# File 'lib/opal/bootbox.rb', line 37

def confirm(*args, &block)
  bootbox_call(__method__, *args, &block)
end

.dialog(*args, &block) ⇒ Object

Creates a custom dialog window. Method executes asynchronously. The result passed to given block is a String or nil. see bootboxjs.com/examples.html



52
53
54
# File 'lib/opal/bootbox.rb', line 52

def dialog(*args, &block)
  bootbox_call(__method__, *args, &block)
end

.prompt(*args, &block) ⇒ Object

Creates a prompt window. Method executes asynchronously. The result passed to given block is a String or nil.



44
45
46
# File 'lib/opal/bootbox.rb', line 44

def prompt(*args, &block)
  bootbox_call(__method__, *args, &block)
end