Module: Pageflow::PagesHelper

Defined in:
app/helpers/pageflow/pages_helper.rb

Constant Summary collapse

CSS_RENDERED_THUMBNAIL_STYLES =
[:thumbnail_large, :navigation_thumbnail_large, :link_thumbnail, :link_thumbnail_large]

Instance Method Summary collapse

Instance Method Details

#page_css_class(page) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# 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 << 'no_text_content' if !page_has_content(page)
  classes.join(' ')
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.



25
26
27
28
29
30
31
32
33
# File 'app/helpers/pageflow/pages_helper.rb', line 25

def page_has_content(page)
  has_title = ['title','subtitle','tagline'].any? do |attribute|
    page.configuration[attribute].present?
  end

  has_text = strip_tags(page.configuration['text']).present?

  (has_title && !page.configuration['hide_title']) || has_text
end

#page_media_breakpointsObject



51
52
53
54
55
56
# File 'app/helpers/pageflow/pages_helper.rb', line 51

def page_media_breakpoints
  {
    :large => :default,
    :medium => 'max-width: 900px'
  }
end


35
36
37
38
39
40
41
42
# File 'app/helpers/pageflow/pages_helper.rb', line 35

def page_navigation_css_class(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_thumbnail_image_class(page, hero) ⇒ Object



58
59
60
# File 'app/helpers/pageflow/pages_helper.rb', line 58

def page_thumbnail_image_class(page, hero)
  file_thumbnail_css_class(page.thumbnail_file, hero ? :link_thumbnail_large : :link_thumbnail)
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



44
45
46
47
48
49
# File 'app/helpers/pageflow/pages_helper.rb', line 44

def shadow_div(options = {})
  style = options[:opacity] ? "opacity: #{options[:opacity] / 100.0};" : nil
  (:div, '', :class => 'shadow_wrapper') do
    (:div, '', :class => 'shadow', :style => style)
  end
end