Module: BootstrapNotifyHelper

Extended by:
ActiveSupport::Concern
Includes:
BootstrapHelper
Defined in:
app/helpers/bootstrap_notify_helper.rb

Instance Method Summary collapse

Methods included from BootstrapHelper

#div, #javascript_include_tag_with_p, #merge_predef_class

Instance Method Details

#notify(title, message, options = {}) ⇒ Object

Generate the script tag that shows the pnotify immediately

title - title of notify message - message of notify options - all options that can be accepted by pnotify



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/bootstrap_notify_helper.rb', line 35

def notify(title, message, options={})
  default_options = {
      type: 'warning'
  }

  options.reverse_merge!(default_options)

  javascript_tag do
    js = '$(function(){'
    js << notify_js(title, message, options)
    js << '});'
    js.html_safe
  end
end

#notify_js(title, message, options = {}) ⇒ Object

A fragment of javascript that shows the pnotify

title - title of notify message - message of notify options - all options that can be accepted by pnotify



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/bootstrap_notify_helper.rb', line 11

def notify_js(title, message, options={})
  default_options = {
      type: 'warning'
  }

  options.reverse_merge!(default_options)

  js = <<-JS
$.pnotify({
  title: '#{title}',
  text: '#{message}',
  #{options.map {|k, v| k.to_s + ': \'' + v + '\'' }.join(',')},
  styling: 'bootstrap'
});
  JS

  js.html_safe
end