Sha256: fcb046bd6a5cc9ce5073669037ffa1551a37a4ba426516f693495ed8777f31a1

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

module RulesView
  module Alerts
    
    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    
    
    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  

    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rules_view-0.0.3 lib/rules_view/alerts.rb
rules_view-0.0.2 lib/rules_view/alerts.rb
rules_view-0.0.1 lib/rules_view/alerts.rb