Module: Pageflow::PagesHelper
- Included in:
- SocialShareHelper
- Defined in:
- app/helpers/pageflow/pages_helper.rb
Instance Method Summary collapse
- #page_css_class(page) ⇒ Object
- #page_default_content(page) ⇒ Object
- #page_has_content(page) ⇒ Object private
- #page_header(page) ⇒ Object
- #page_media_breakpoints ⇒ Object
- #page_navigation_css_class(page) ⇒ Object
- #page_print_image(page) ⇒ Object
- #page_text(page) ⇒ Object
- #page_thumbnail_file(page) ⇒ Object
- #page_thumbnail_image_class(page, hero) ⇒ Object
- #page_thumbnail_url(page, *args) ⇒ Object
- #render_page_template(page, locals = {}) ⇒ Object
- #shadow_div(options = {}) ⇒ Object
Instance Method Details
#page_css_class(page) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/pageflow/pages_helper.rb', line 11 def page_css_class(page) classes = ['page'] classes << 'invert' if page.configuration['invert'] classes << 'hide_title' if page.configuration['hide_title'] classes << "text_position_#{page.configuration['text_position']}" if page.configuration['text_position'].present? classes << "scroll_indicator_mode_#{page.configuration['scroll_indicator_mode']}" if page.configuration['scroll_indicator_mode'].present? classes << "scroll_indicator_orientation_#{page.configuration['scroll_indicator_orientation']}" if page.configuration['scroll_indicator_orientation'].present? classes << "delayed_text_fade_in_#{page.configuration['delayed_text_fade_in']}" if page.configuration['delayed_text_fade_in'].present? classes << 'chapter_beginning' if page.position == 0 classes << 'first_page' if page.is_first classes << 'no_text_content' if !page_has_content(page) classes << 'hide_logo' if page.configuration['hide_logo'] classes.join(' ') end |
#page_default_content(page) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/helpers/pageflow/pages_helper.rb', line 26 def page_default_content(page) safe_join([ page_header(page), page_print_image(page), page_text(page) ]) end |
#page_has_content(page) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/pageflow/pages_helper.rb', line 58 def page_has_content(page) has_title = ['title','subtitle','tagline'].any? do |attribute| page.configuration[attribute].present? end has_text = (page.configuration['text']).present? (has_title && !page.configuration['hide_title']) || has_text end |
#page_header(page) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/pageflow/pages_helper.rb', line 34 def page_header(page) content_tag(:h3, class: 'page_header') do safe_join([ content_tag(:span, page.configuration['tagline'], class: 'page_header-tagline'), content_tag(:span, page.configuration['title'], class: 'page_header-title'), content_tag(:span, page.configuration['subtitle'], class: 'page_header-subtitle') ]) end end |
#page_media_breakpoints ⇒ Object
84 85 86 87 88 89 |
# File 'app/helpers/pageflow/pages_helper.rb', line 84 def page_media_breakpoints { desktop: :default, mobile: 'max-width: 900px' } end |
#page_navigation_css_class(page) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/helpers/pageflow/pages_helper.rb', line 68 def (page) classes = [page.template] classes << 'chapter_beginning' if page.position == 0 classes << 'emphasized' if page.configuration['emphasize_in_navigation'] classes << "chapter_#{page.chapter.position}" page.chapter.position % 2 == 0 ? classes << 'chapter_even' : classes << 'chapter_odd' classes.join(' ') end |
#page_print_image(page) ⇒ Object
47 48 49 |
# File 'app/helpers/pageflow/pages_helper.rb', line 47 def page_print_image(page) background_image_tag(page.configuration['background_image_id'], 'class' => 'print_image') end |
#page_text(page) ⇒ Object
51 52 53 54 55 |
# File 'app/helpers/pageflow/pages_helper.rb', line 51 def page_text(page) content_tag(:div, class: 'page_text') do content_tag(:div, raw(page.configuration['text']), class: 'paragraph') end end |
#page_thumbnail_file(page) ⇒ Object
99 100 101 102 |
# File 'app/helpers/pageflow/pages_helper.rb', line 99 def page_thumbnail_file(page) ThumbnailFileResolver.new(@entry, page.page_type.thumbnail_candidates, page.configuration) .find_thumbnail end |
#page_thumbnail_image_class(page, hero) ⇒ Object
91 92 93 |
# File 'app/helpers/pageflow/pages_helper.rb', line 91 def page_thumbnail_image_class(page, hero) file_thumbnail_css_class(page_thumbnail_file(page), hero ? :link_thumbnail_large : :link_thumbnail) end |
#page_thumbnail_url(page, *args) ⇒ Object
95 96 97 |
# File 'app/helpers/pageflow/pages_helper.rb', line 95 def page_thumbnail_url(page, *args) page_thumbnail_file(page).thumbnail_url(*args) end |
#render_page_template(page, locals = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/pageflow/pages_helper.rb', line 3 def render_page_template(page, locals = {}) page_type = Pageflow.config.page_types.find_by_name!(page.template) render(template: page_type.template_path, locals: locals.merge(page: page, configuration: page.configuration)) end |
#shadow_div(options = {}) ⇒ Object
77 78 79 80 81 82 |
# File 'app/helpers/pageflow/pages_helper.rb', line 77 def shadow_div( = {}) style = [:opacity] ? "opacity: #{[:opacity] / 100.0};" : nil content_tag(:div, '', :class => 'shadow_wrapper') do content_tag(:div, '', :class => 'shadow', :style => style) end end |