Module: Tungsten::NoticeHelper

Defined in:
app/helpers/tungsten/notice_helper.rb

Instance Method Summary collapse

Instance Method Details

#card_notice(title = nil, options = {}, &block) ⇒ Object



18
19
20
21
# File 'app/helpers/tungsten/notice_helper.rb', line 18

def card_notice( title=nil, options={}, &block )
  options[:type] = :'card-notice'
  notice( title, options, &block )
end

#card_warning_notice(title = nil, options = {}, &block) ⇒ Object



23
24
25
26
# File 'app/helpers/tungsten/notice_helper.rb', line 23

def card_warning_notice( title=nil, options={}, &block )
  options[:type] = :'card-warning-notice'
  notice( title, options, &block )
end

#inline_notice(title = nil, options = {}, &block) ⇒ Object



8
9
10
11
# File 'app/helpers/tungsten/notice_helper.rb', line 8

def inline_notice( title=nil, options={}, &block )
  options[:type] = :'inline-notice'
  notice( title, options, &block )
end

#inline_warning_notice(title = nil, options = {}, &block) ⇒ Object



13
14
15
16
# File 'app/helpers/tungsten/notice_helper.rb', line 13

def inline_warning_notice( title=nil, options={}, &block )
  options[:type] = :'inline-warning-notice'
  notice( title, options, &block )
end

#notice(title = nil, options = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/tungsten/notice_helper.rb', line 28

def notice( title=nil, options={}, &block )
  if title.is_a? Hash
    options = title 
    title = nil
  end

  options[:class] = "notice #{options[:class]}".strip
  options[:class] << " #{options[:type]}" if options[:type]

  header = ( :h4, class: 'notice-title' ) { title }

  if options.delete(:dismiss)
    options[:id] = "notice-#{SecureRandom.hex(5)}"
    header = ( :header, class: 'notice-header' ) {
      concat header
      concat icon_button 'x-circle', class: 'dismiss-notice', toggle: "##{options[:id]}", clear: true
    }
  end

  ( :div, options ) {
    concat header
    concat ( :div, class: 'notice-content' ) {
      capture(&block).html_safe if block_given?
    }
  }
end

#warning_notice(title = nil, options = {}, &block) ⇒ Object



3
4
5
6
# File 'app/helpers/tungsten/notice_helper.rb', line 3

def warning_notice( title=nil, options={}, &block )
  options[:type] = :warning
  notice( title, options, &block )
end