Module: Card::Set::All::RichHtml::Modal::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- tmpsets/set/mod021-standard/all/rich_html/modal.rb
Constant Summary collapse
- MODAL_SIZE =
{ small: "sm", medium: nil, large: "lg", full: "full" }.freeze
- MODAL_CLOSE_OPTS =
{ class: "_close-modal", "data-dismiss": "modal", "data-cy": "close-modal" }.freeze
Instance Method Summary collapse
- #add_modal_size_class(classes, size) ⇒ Object
- #cast_model_option(val) ⇒ Object
- #cast_model_option_symbol(val) ⇒ Object
- #close_modal_window ⇒ Object
- #modal_close_button(link_text = "Close", opts = {}) ⇒ Object
- #modal_dialog_classes(opts) ⇒ Object
- #modal_link(text = nil, opts = {}) ⇒ Object
- #modal_link_opts(opts) ⇒ Object
- #modal_submit_button(opts = {}) ⇒ Object
- #normalize_modal_option(key, opts) ⇒ Object
- #normalize_modal_size_class(size) ⇒ Object
- #pop_out_modal_window ⇒ Object
- #show_in_modal_link(link_text, body) ⇒ Object
Instance Method Details
#add_modal_size_class(classes, size) ⇒ Object
106 107 108 109 110 111 |
# File 'tmpsets/set/mod021-standard/all/rich_html/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 'tmpsets/set/mod021-standard/all/rich_html/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 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 38 def cast_model_option_symbol val respond_to?(val) ? send(val) : val end |
#close_modal_window ⇒ Object
117 118 119 120 121 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 117 def close_modal_window link_to icon_tag(:close), path: "", class: "_close-modal close", "data-dismiss": "modal" end |
#modal_close_button(link_text = "Close", opts = {}) ⇒ Object
50 51 52 53 54 55 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 50 def link_text="Close", opts={} classes = opts.delete(:class) = opts.merge(MODAL_CLOSE_OPTS) add_class , classes if classes link_text, end |
#modal_dialog_classes(opts) ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 97 def modal_dialog_classes opts classes = [classy("modal-dialog")] return classes unless opts.present? add_modal_size_class classes, opts.delete(:size) classes << "modal-dialog-centered" if opts.delete(:vertically_centered) classes.join " " end |
#modal_link(text = nil, opts = {}) ⇒ Object
82 83 84 85 86 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 82 def modal_link text=nil, opts={} opts = modal_link_opts(opts) opts[:path][:layout] ||= :modal link_to text, opts end |
#modal_link_opts(opts) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'tmpsets/set/mod021-standard/all/rich_html/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 |
#modal_submit_button(opts = {}) ⇒ Object
57 58 59 60 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 57 def opts={} add_class opts, "submit-button _close-modal" opts end |
#normalize_modal_option(key, opts) ⇒ Object
21 22 23 24 25 |
# File 'tmpsets/set/mod021-standard/all/rich_html/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 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 113 def normalize_modal_size_class size size.in?(MODAL_SIZE.keys) ? size : cast_model_option(size) end |
#pop_out_modal_window ⇒ Object
123 124 125 |
# File 'tmpsets/set/mod021-standard/all/rich_html/modal.rb', line 123 def pop_out_modal_window link_to icon_tag(:new_window), path: {}, class: "pop-out-modal close" end |
#show_in_modal_link(link_text, body) ⇒ Object
46 47 48 |
# File 'tmpsets/set/mod021-standard/all/rich_html/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 |