ndr_ui 4.1.2 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,87 +0,0 @@
1
- module NdrUi
2
- module Bootstrap
3
- # This provides accordion
4
- module PanelHelper
5
- PANEL_SUBCLASSES = %w(
6
- panel-default
7
- panel-primary
8
- panel-success
9
- panel-info
10
- panel-warning
11
- panel-danger
12
- ).freeze
13
-
14
- # Creates an accordion wrapper and creates a new NdrUi::Bootstrap::Accordion instance
15
- # Creates an plain or nested bootstrap accordion along with bootstrap_accordion_group
16
- # method at NdrUi::Bootstrap::Accordion class.
17
- #
18
- # ==== Signatures
19
- #
20
- # bootstrap_accordion_tag(dom_id) do |accordion|
21
- # #content for accordion items
22
- # end
23
- #
24
- # ==== Examples
25
- #
26
- # <%= bootstrap_accordion_group :fruit do |fruit_accordion| %>
27
- # <% end %>
28
- # # => <div id="fruit" class="accordion"></div>
29
- def bootstrap_accordion_tag(dom_id, &block)
30
- return unless block_given?
31
- accordion = ::NdrUi::Bootstrap::Accordion.new(dom_id, self)
32
- '<div id="'.html_safe + accordion.dom_id.to_s + '" class="panel-group">'.html_safe +
33
- capture { yield(accordion) } +
34
- '</div>'.html_safe
35
- end
36
-
37
- # Creates a bootstrap panel wrapper. the heading is wrapped in a panel-heading.
38
- # The content is not wrapped in a panel-body to enable seamless tables and lists.
39
- #
40
- # ==== Signatures
41
- #
42
- # bootstrap_panel_tag(heading, options = {}) do
43
- # #content for panel
44
- # end
45
- #
46
- # ==== Examples
47
- #
48
- # <%= bootstrap_panel_tag 'Apples', class: 'panel-warning', id: 'fruit' do %>
49
- # Check it out!!
50
- # <% end %>
51
- # # => <div id="fruit" class="panel panel-warning"><div class="panel-heading">Apples</div>
52
- # Check it out!!</div>
53
- def bootstrap_panel_tag(heading, options = {}, &block)
54
- return unless block_given?
55
- options.stringify_keys!
56
- classes = %w(panel)
57
- classes += options['class'].to_s.split(' ') if options.include?('class')
58
- classes << 'panel-default' if (classes & PANEL_SUBCLASSES).empty?
59
- options['class'] = classes.uniq.join(' ')
60
-
61
- content_tag(:div,
62
- content_tag(:div, heading, class: 'panel-heading') +
63
- capture(&block),
64
- options)
65
- end
66
-
67
- # Creates a simple bootstrap panel body.
68
- #
69
- # ==== Signatures
70
- #
71
- # bootstrap_panel_body_tag do
72
- # #content for panel body
73
- # end
74
- #
75
- # ==== Examples
76
- #
77
- # <%= bootstrap_panel_body_tag do %>
78
- # Check it out!!
79
- # <% end %>
80
- # # => <div class="panel-body">Check it out!!</div>
81
- def bootstrap_panel_body_tag(&block)
82
- return unless block_given?
83
- content_tag(:div, capture(&block), class: 'panel-body')
84
- end
85
- end
86
- end
87
- end