Module: Card::Set::All::ReferenceEditor::NestEditor::NestEditorOptions::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb

Instance Method Summary collapse

Instance Method Details

#image_size_selectObject



61
62
63
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 61

def image_size_select
  select_tag :size, size_select_options(:medium), class: "_image-size-select"
end

#image_view_select(selected) ⇒ Object



55
56
57
58
59
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 55

def image_view_select selected
  select_tag :view, options_for_select(view_list.unshift(nil), selected: selected),
             class: "tags _image-view-select",
             "data-placeholder": "Select view"
end

#nest_option_classesObject



9
10
11
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 9

def nest_option_classes
  "form-control"
end

#nest_option_name_disabled(selected, level) ⇒ Object



34
35
36
37
38
39
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 34

def nest_option_name_disabled selected, level
  disabled = nest_option_name_disabled_options level
  disabled = disabled&.map(&:first)
  disabled&.delete selected if selected
  disabled
end

#nest_option_name_disabled_options(level) ⇒ Object



41
42
43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 41

def nest_option_name_disabled_options level
  if level.zero?
    nest_snippet.options
  else
    nest_snippet.item_options[level - 1] || default_nest_editor_item_options
  end
end

#nest_option_name_select(selected = nil, level = 0, include_view_option = true, template = false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 13

def nest_option_name_select selected=nil, level=0,
                            include_view_option=true, template=false
  classes = "#{nest_option_classes} _nest-option-name"
  classes += " _new-row" unless selected
  classes += " _no-select2" if template
  select_tag "nest_option_name_#{unique_id}",
             nest_option_name_select_options(selected, level, include_view_option),
             class: classes, id: nil, "data-placeholder": "Select option"
  # id: nil ensures that select2 generates its own unique identifier
  # that ensures that we can clone this tag without breaking select2
end

#nest_option_name_select_options(selected, level, include_view_option = true) ⇒ Object



25
26
27
28
29
30
31
32
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 25

def nest_option_name_select_options selected, level, include_view_option=true
  options = [""] + Card::Reference::NestParser::NEST_OPTIONS.dup
  options.delete :view unless include_view_option
  options_for_select(
    options, disabled: nest_option_name_disabled(selected, level),
             selected: selected
  )
end

#nest_option_value_default_templateObject



71
72
73
74
75
76
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 71

def nest_option_value_default_template
  text_field_tag "value", nil,
                 class: "_nest-option-template-default _nest-option-value "\
                        "#{nest_option_classes}",
                 id: nil
end

#nest_option_value_select(value = nil) ⇒ Object



65
66
67
68
69
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 65

def nest_option_value_select value=nil
  text_field_tag "value", value,
                 class: "_nest-option-value #{nest_option_classes}",
                 disabled: !value, id: nil
end

#nest_option_value_select_tag(option_names, options) ⇒ Object



94
95
96
97
98
99
100
101
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 94

def nest_option_value_select_tag option_names, options
  wrap_classes =
    Array.wrap(option_names).map  { |name| "_nest-option-template-#{name}" }.join " "
  wrap_with :div, class: wrap_classes do
    select_tag :size, options,
               class: "_no-select2 _nest-option-value #{nest_option_classes}"
  end
end

#nest_show_and_hide_select_templateObject



90
91
92
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 90

def nest_show_and_hide_select_template
  nest_option_value_select_tag %i[show hide], options_for_select(all_views)
end

#nest_size_select_templateObject



82
83
84
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 82

def nest_size_select_template
  nest_option_value_select_tag :size, size_select_options
end

#nest_view_select(selected) ⇒ Object



49
50
51
52
53
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 49

def nest_view_select selected
  select_tag :view, options_for_select(view_list.unshift(nil), selected: selected),
             class: "tags _view-select _nest-option-value",
             "data-placeholder": "Select view"
end

#nest_view_select_templateObject



86
87
88
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 86

def nest_view_select_template
  nest_option_value_select_tag :view, options_for_select(view_list)
end

#size_select_options(selected = :medium) ⇒ Object



78
79
80
# File 'platypus/tmp/set/gem-defaults/mod033-tinymce_editor/all/reference_editor/nest_editor/nest_editor_options.rb', line 78

def size_select_options selected=:medium
  options_for_select(%w[icon small medium large original], selected: selected)
end