Module: Platformx::NotifyHelpers

Defined in:
lib/platformx/notify.rb

Instance Method Summary collapse

Instance Method Details

#x_notify(flash: "", timer: 4000, align: "right", from: "top") ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/platformx/notify.rb', line 8

def x_notify(flash: "", timer: 4000, align: "right", from:"top")

color = "success"
message = ""

if !flash[:success].nil?
  message = flash[:success]
  color = "success"
end

if !flash[:notice].nil?
  message = flash[:notice]
  color = "warning"
end

if !flash[:error].nil?
  message = flash[:error]
  color = "danger"
end

unless message == ""
cb = <<EOS
<script>
    $().ready(function(){$.notify({message: "#{message}"},{type: "#{color}",timer: #{timer}, placement: {from: "#{from}",align: "#{align}"}});});
</script>
EOS
return cb
end
end