Module: ApplicationHelper
Instance Method Summary
collapse
#close_modal_button, #next_button, #next_exercise_button, #next_lesson_button
Instance Method Details
#avatar_image(avatar_url, **options) ⇒ Object
14
15
16
17
|
# File 'app/helpers/application_helper.rb', line 14
def avatar_image(avatar_url, **options)
options.merge!(class: "rounded-circle #{options[:class]}")
image_tag(image_url(avatar_url), options)
end
|
#btn_toggle(hidden_text, active_text, active, **options) ⇒ Object
41
42
43
44
45
46
|
# File 'app/helpers/application_helper.rb', line 41
def btn_toggle(hidden_text, active_text, active, **options)
%Q{
<button class="btn btn-complementary #{'d-none' if active} #{options[:class]}" onclick="#{options[:onclick]}">#{hidden_text}</button>
<button class="btn btn-secondary #{'d-none' unless active} #{options[:class]}" onclick="#{options[:onclick]}">#{active_text}</button>
}.html_safe
end
|
#chapter_finished(chapter) ⇒ Object
37
38
39
|
# File 'app/helpers/application_helper.rb', line 37
def chapter_finished(chapter)
t :chapter_finished_html, chapter: link_to_path_element(chapter) if chapter
end
|
#corollary_box(with_corollary, trailing_boxes = false) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/helpers/application_helper.rb', line 27
def corollary_box(with_corollary, trailing_boxes = false)
if with_corollary.corollary.present?
%Q{
<div class="#{last_box_class trailing_boxes}">
<p>#{with_corollary.corollary_html}</p>
</div>
}.html_safe
end
end
|
#html_rescape(html) ⇒ Object
html-escapes an string even if it is html-safe
5
6
7
|
# File 'app/helpers/application_helper.rb', line 5
def html_rescape(html)
html_escape html.to_str
end
|
#last_box_class(trailing_boxes) ⇒ Object
23
24
25
|
# File 'app/helpers/application_helper.rb', line 23
def last_box_class(trailing_boxes)
trailing_boxes ? '' : 'mu-last-box'
end
|
#notification_preview_for(target) ⇒ Object
48
49
50
|
# File 'app/helpers/application_helper.rb', line 48
def notification_preview_for(target)
render "notifications/#{target.class.name.underscore}", { target: target }
end
|
#paginate(object, options = {}) ⇒ Object
19
20
21
|
# File 'app/helpers/application_helper.rb', line 19
def paginate(object, options = {})
super(object, {theme: 'bootstrap-5', pagination_class: 'flex-wrap justify-content-center'}.merge(options))
end
|
#profile_picture_for(user, **options) ⇒ Object
9
10
11
12
|
# File 'app/helpers/application_helper.rb', line 9
def profile_picture_for(user, **options)
default_options = { height: 40, onError: "this.onerror = null; this.src = '#{image_url(user.placeholder_image_url)}'" }
avatar_image(user.profile_picture, default_options.merge(options))
end
|