lib/opal/bootbox.rb in opal-bootbox-0.1.1 vs lib/opal/bootbox.rb in opal-bootbox-0.1.2
- old
+ new
@@ -5,16 +5,24 @@
if RUBY_ENGINE == 'opal'
require 'native'
+# see http://bootboxjs.com/documentation.html
+
module Opal
module Bootbox
module_function
def bootbox_call(method, *args, &block)
- Native.call(`bootbox`, 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
# Creates an alert window.
# The given block is optional.
# Method executes asynchronously.
@@ -32,9 +40,17 @@
# Creates a prompt window.
# Method executes asynchronously.
# The result passed to given block is a String or nil.
def prompt(*args, &block)
+ bootbox_call(__method__, *args, &block)
+ end
+
+ # Creates a custom dialog window.
+ # Method executes asynchronously.
+ # The result passed to given block is a String or nil.
+ # see http://bootboxjs.com/examples.html
+ def dialog(*args, &block)
bootbox_call(__method__, *args, &block)
end
end
end