Class: Spree::PageSections::Video

Inherits:
Spree::PageSection show all
Includes:
MemoizedData
Defined in:
app/models/spree/page_sections/video.rb

Constant Summary collapse

MEMOIZED_METHODS =
%w(video_embed)

Constants inherited from Spree::PageSection

Spree::PageSection::BACKGROUND_COLOR_DEFAULT, Spree::PageSection::BORDER_COLOR_DEFAULT, Spree::PageSection::BOTTOM_BORDER_WIDTH_DEFAULT, Spree::PageSection::BOTTOM_PADDING_DEFAULT, Spree::PageSection::TEXT_COLOR_DEFAULT, Spree::PageSection::TOP_BORDER_WIDTH_DEFAULT, Spree::PageSection::TOP_PADDING_DEFAULT

Instance Method Summary collapse

Methods inherited from Spree::PageSection

#can_be_deleted?, #can_be_sorted?, #copy_rich_text_fields_from, #deep_clone, #deep_clone_links, #display_name, #dup, #lazy?, #lazy_path, #restore_design_settings_to_defaults, #rich_text_fields, role, #role, #theme, #to_partial_path

Instance Method Details

#available_blocks_to_addObject



47
48
49
# File 'app/models/spree/page_sections/video.rb', line 47

def available_blocks_to_add
  [Spree::PageBlocks::Heading]
end

#blocks_available?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/spree/page_sections/video.rb', line 55

def blocks_available?
  true
end

#can_sort_blocks?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/spree/page_sections/video.rb', line 59

def can_sort_blocks?
  true
end

#default_blocksObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/spree/page_sections/video.rb', line 18

def default_blocks
  @default_blocks.presence || [
    Spree::PageBlocks::Heading.new(
      text: Spree.t('page_sections.video.heading_1_default'),
      preferred_text_alignment: nil,
      preferred_container_alignment: nil,
      preferred_bottom_padding: 8,
      preferred_top_padding: 24,
      preferred_size: 'small'
    ),
    Spree::PageBlocks::Heading.new(
      text: Spree.t('page_sections.video.heading_2_default'),
      preferred_text_alignment: nil,
      preferred_container_alignment: nil,
      preferred_bottom_padding: 8,
      preferred_top_padding: 24,
      preferred_size: 'large'
    ),
    Spree::PageBlocks::Heading.new(
      text: store.name,
      preferred_text_alignment: nil,
      preferred_container_alignment: nil,
      preferred_bottom_padding: 8,
      preferred_top_padding: 24,
      preferred_size: 'small'
    )
  ]
end

#icon_nameObject



51
52
53
# File 'app/models/spree/page_sections/video.rb', line 51

def icon_name
  'movie'
end

#video_embedObject



63
64
65
# File 'app/models/spree/page_sections/video.rb', line 63

def video_embed
  @video_embed ||= ::ActionText::VideoEmbed.find_by(id: preferred_youtube_video_embed_id) if preferred_youtube_video_embed_id.present?
end