Module: Card::Set::All::Modal::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod030-card-mod-layout/all/modal.rb,
card/tmpsets/set/mod031-card-mod-layout/all/modal.rb

Constant Summary collapse

{ small: "sm", medium: nil, large: "lg", full: "full" }.freeze
{ "data-dismiss": "modal",
"data-cy": "close-modal" }.freeze

Instance Method Summary collapse

Instance Method Details

#add_modal_size_class(classes, size) ⇒ Object



106
107
108
109
110
111
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 106

def add_modal_size_class classes, size
  size = normalize_modal_size_class size
  return if size == :medium || size.blank?

  classes << "modal-#{MODAL_SIZE[size]}"
end

#cast_model_option(val) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 27

def cast_model_option val
  case val
  when Symbol
    cast_model_option_symbol val
  when Proc
    val.call(self)
  else
    val
  end
end

#cast_model_option_symbol(val) ⇒ Object



38
39
40
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 38

def cast_model_option_symbol val
  respond_to?(val) ? send(val) : val
end

#close_modal_windowObject



117
118
119
120
121
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 117

def close_modal_window
  link_to icon_tag(:close), path: "",
                            class: "_close-modal close",
                            "data-dismiss": "modal"
end


50
51
52
53
54
55
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 50

def modal_close_button link_text="Close", opts={}
  classes = opts.delete(:class)
  button_opts = opts.merge(MODAL_CLOSE_OPTS)
  add_class button_opts, classes if classes
  button_tag link_text, button_opts
end


97
98
99
100
101
102
103
104
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 97

def modal_dialog_classes opts
  classes = [classy("modal-dialog")]
  return classes unless opts.present?

  add_modal_size_class classes, opts[:size]
  classes << "modal-dialog-centered" if opts[:vertically_centered]
  classes.join " "
end


82
83
84
85
86
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 82

def modal_link text=nil, opts={}
  opts = modal_link_opts(opts)
  opts[:path][:layout] ||= :modal
  link_to text, opts
end


88
89
90
91
92
93
94
95
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 88

def modal_link_opts opts
  add_class opts, "slotter"
  opts.reverse_merge! path: {},
                      "data-slotter-mode": "modal",
                      "data-modal-class": modal_dialog_classes(opts),
                      remote: true
  opts
end


57
58
59
60
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 57

def modal_submit_button opts={}
  add_class opts, "submit-button _close-modal"
  submit_button opts
end

#normalize_modal_option(key, opts) ⇒ Object



21
22
23
24
25
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 21

def normalize_modal_option key, opts
  val = opts[key]
  return render("modal_#{key}") unless val
  cast_model_option val
end

#normalize_modal_size_class(size) ⇒ Object



113
114
115
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 113

def normalize_modal_size_class size
  size.in?(MODAL_SIZE.keys) ? size : cast_model_option(size)
end

#pop_out_modal_windowObject



123
124
125
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 123

def pop_out_modal_window
  link_to icon_tag(:new_window), path: {}, class: "pop-out-modal close"
end


46
47
48
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 46

def show_in_modal_link link_text, body
  link_to_view :modal, link_text, "data-modal-body": body, "data-slotter-mode": "modal"
end


42
43
44
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 42

view :modal, wrap: :modal do
  ""
end


72
73
74
75
76
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 72

view :modal_footer, unknown: true do
  button_tag "Close",
             class: "btn-xs _close-modal float-right",
             "data-dismiss" => "modal"
end


78
79
80
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 78

view :modal_link do
  modal_link _render_title, size: voo.size
end


62
63
64
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 62

view :modal_menu, unknown: true, wrap: :modal_menu do
  [close_modal_window, pop_out_modal_window]
end


68
69
70
# File 'card/tmpsets/set/mod030-card-mod-layout/all/modal.rb', line 68

view :modal_title, unknown: true do
  ""
end