Module: Card::Set::All::Alert::HtmlFormat

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

Instance Method Summary collapse

Instance Method Details

#alert(alert_type, dismissable = false, disappear = false, args = {}) ⇒ Object

alert_types: ‘success’, ‘info’, ‘warning’, ‘danger’



10
11
12
13
14
15
# File 'card/tmpsets/set/mod030-card-mod-layout/all/alert.rb', line 10

def alert alert_type, dismissable=false, disappear=false, args={}
  add_class args, alert_classes(alert_type, dismissable, disappear)
  wrap_with :div, args.merge(role: "alert") do
    [(alert_close_button if dismissable), output(yield)]
  end
end

#alert_classes(alert_type, dismissable, disappear) ⇒ Object



17
18
19
20
21
22
# File 'card/tmpsets/set/mod030-card-mod-layout/all/alert.rb', line 17

def alert_classes alert_type, dismissable, disappear
  classes = ["alert", "alert-#{alert_type}"]
  classes << "alert-dismissible " if dismissable
  classes << "_disappear" if disappear
  classy classes
end

#alert_close_buttonObject



24
25
26
27
28
29
# File 'card/tmpsets/set/mod030-card-mod-layout/all/alert.rb', line 24

def alert_close_button
  wrap_with :button, type: "button", "data-dismiss": "alert",
                     class: "close", "aria-label": "Close" do
    wrap_with :span, "&times;", "aria-hidden" => true
  end
end