Module: RulesEngineView::Alerts

Defined in:
lib/rules_engine_view/alerts.rb

Instance Method Summary collapse

Instance Method Details

#re_alertObject



4
5
6
7
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
# File 'lib/rules_engine_view/alerts.rb', line 4

def re_alert
  result = '<div id="re_alert">'.html_safe
  
  unless flash[:error].blank?
    result << '<div class="error"><strong>Error : </strong><span>'.html_safe
    result << flash.delete(:error)
    result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe

    flash.delete(:success)
    flash.delete(:notice)
  end

  unless flash[:success].blank?
    result << '<div class="success"><strong>Success : </strong><span>'.html_safe
    result << flash.delete(:success)
    result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe

    flash.delete(:notice)
  end      

  unless flash[:notice].blank?
    result << '<div class="notice"><strong>Warning : </strong><span>'.html_safe
    result << flash.delete(:notice)
    result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe
  end      
  result << '</div>'.html_safe
  
  return result
end

#re_alert_jsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rules_engine_view/alerts.rb', line 34

def re_alert_js
  unless flash[:error].blank?  
    flash.delete(:success)
    flash.delete(:notice)
    return "$.re_error_message('".html_safe + escape_javascript(flash.delete(:error)) + "');".html_safe
  end
  unless flash[:success].blank?
    flash.delete(:notice)
    return "$.re_success_message('".html_safe + escape_javascript(flash.delete(:success)) + "');".html_safe
  end      
  unless flash[:notice].blank?
    return "$.re_notice_message('".html_safe + escape_javascript(flash.delete(:notice)) + "');".html_safe
  end    
end