i18n_rails_helpers 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,147 @@
1
+ module BootstrapHelper
2
+ def boot_page_title(action_or_title = nil, model = nil)
3
+ if action_or_title.is_a? String
4
+ title = action_or_title
5
+ else
6
+ action = action_or_title || action_name
7
+ if action.to_s == 'show' && defined?(resource) && resource.present?
8
+ title = resource.to_s
9
+ else
10
+ title = t_title(action, model)
11
+ end
12
+ end
13
+
14
+ content_for :page_title, title
15
+ content_tag(:div, :class => 'page-header') do
16
+ content_tag(:h1, title)
17
+ end
18
+ end
19
+
20
+ # Icons
21
+ # =====
22
+ def boot_icon(type)
23
+ content_tag(:i, '', :class => "icon-#{type}")
24
+ end
25
+
26
+ # Labels
27
+ # ======
28
+ def boot_label(content, type = nil)
29
+ return "" unless content.present?
30
+
31
+ classes = ['label', "label-#{type}"].compact.join(' ')
32
+ content_tag(:span, content, :class => classes)
33
+ end
34
+
35
+ # Modal
36
+ # =====
37
+ def modal_header(title)
38
+ content_tag(:div, :class => 'modal-header') do
39
+ content_tag(:button, '×'.html_safe, :type => 'button', :class => 'close', 'data-dismiss' => 'modal') +
40
+ content_tag(:h3, title)
41
+ end
42
+ end
43
+
44
+ # Messages
45
+ # ========
46
+ def boot_alert(*args, &block)
47
+ if block_given?
48
+ type = args[0]
49
+ content = capture(&block)
50
+ else
51
+ content = args[0]
52
+ type = args[1]
53
+ end
54
+
55
+ type ||= 'info'
56
+ content_tag(:div, :class => "alert alert-block alert-#{type} fade in") do
57
+ link_to('×'.html_safe, '#', :class => 'close', 'data-dismiss' => 'alert') + content
58
+ end
59
+ end
60
+
61
+ def boot_no_entry_alert
62
+ boot_alert t('alerts.empty')
63
+ end
64
+
65
+ # Navigation
66
+ # ==========
67
+ def boot_nav_header(title, refresh_action = false)
68
+ if title.is_a? Symbol
69
+ title = t("#{title}.title")
70
+ end
71
+
72
+ content_tag(:li, :class => 'nav-header') do
73
+ content = [title]
74
+ if refresh_action
75
+ content << content_tag(:button, :type => "submit", :style => 'border: none; background-color: transparent; float: right') do
76
+ content_tag(:i, "", :class => 'icon-refresh')
77
+ end
78
+ end
79
+
80
+ content.join("\n").html_safe
81
+ end
82
+ end
83
+
84
+ def boot_nav_li_link(filter_name, param_value, title = nil, param_name = filter_name, current_value = params[param_name], classes = [], &content)
85
+ classes << "active" if current_value.to_s == param_value.to_s
86
+ title ||= param_value
87
+ title = t("#{filter_name.to_s}.#{title}", :default => title)
88
+
89
+ if block_given?
90
+ content_tag(:li, :class => classes, &content)
91
+ else
92
+ content_tag(:li, :class => classes) do
93
+ url = url_for(params.merge({param_name => param_value}))
94
+ link_to title, url
95
+ end
96
+ end
97
+ end
98
+
99
+ def boot_nav_li_checkbox(filter_name, param_value, title = nil, param_name = filter_name, current_value = params[param_name], classes = [], &content)
100
+ active = current_value.include? param_value.to_s
101
+ classes << "active" if active
102
+
103
+ title ||= param_value
104
+ title = t("#{filter_name.to_s}.#{title}", :default => title)
105
+
106
+ if block_given?
107
+ content_tag(:li, :class => classes, &content)
108
+ else
109
+ content_tag(:li, :class => classes) do
110
+ content_tag 'label', :class => 'checkbox' do
111
+ content = []
112
+ content << content_tag('input', '', :type => 'checkbox', :checked => active, :name => "#{param_name}[]", :value => param_value)
113
+ content << title
114
+
115
+ content.join("\n").html_safe
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ def boot_nav_filter(name, entries, type = :link)
122
+ refresh_action = (type == :checkbox)
123
+
124
+ content_tag(:ul, :class => ['nav', 'nav-list']) do
125
+ content = []
126
+ content << boot_nav_header(name, refresh_action)
127
+
128
+ entries.each do |entry|
129
+ if entry.is_a? Hash
130
+ title = entry[:title]
131
+ value = entry[:value]
132
+ else
133
+ title = value = entry
134
+ end
135
+
136
+ case type
137
+ when :link
138
+ content << boot_nav_li_link(name, value, title)
139
+ when :checkbox
140
+ content << boot_nav_li_checkbox(name, value, title)
141
+ end
142
+ end
143
+
144
+ content.join("\n").html_safe
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,7 @@
1
+ %table.table.table-striped.table-hover
2
+ %thead
3
+ %tr
4
+ = render 'list_header'
5
+
6
+ %body
7
+ = render collection
@@ -0,0 +1,5 @@
1
+ = contextual_links
2
+
3
+ = boot_page_title
4
+
5
+ = render 'form'
@@ -0,0 +1,6 @@
1
+ = contextual_links
2
+
3
+ = boot_page_title
4
+
5
+ = paginate collection
6
+ = render "list"
@@ -0,0 +1,5 @@
1
+ = contextual_links
2
+
3
+ = boot_page_title
4
+
5
+ = render 'form'
@@ -0,0 +1,5 @@
1
+ = contextual_links
2
+
3
+ = boot_page_title
4
+
5
+ = render "show"
@@ -1,3 +1,3 @@
1
1
  module I18nRailsHelpers
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_rails_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,9 +19,15 @@ extensions: []
19
19
  extra_rdoc_files:
20
20
  - README.markdown
21
21
  files:
22
+ - app/helpers/bootstrap_helper.rb
22
23
  - app/helpers/contextual_link_helpers.rb
23
24
  - app/helpers/i18n_helpers.rb
24
25
  - app/helpers/list_link_helpers.rb
26
+ - app/views/application/_list.html.haml
27
+ - app/views/application/edit.html.haml
28
+ - app/views/application/index.html.haml
29
+ - app/views/application/new.html.haml
30
+ - app/views/application/show.html.haml
25
31
  - config/locales/de.yml
26
32
  - config/locales/en.yml
27
33
  - lib/i18n_rails_helpers.rb