Class: TurboBoost::Elements::ToggleCommand

Inherits:
ApplicationCommand show all
Defined in:
app/commands/turbo_boost/elements/toggle_command.rb

Instance Method Summary collapse

Instance Method Details

#hideObject



18
19
20
21
22
# File 'app/commands/turbo_boost/elements/toggle_command.rb', line 18

def hide
  validate_element!
  state[element.aria.controls] = false
  morph id: element.morphs, html: render(element.render_options)
end

#showObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/commands/turbo_boost/elements/toggle_command.rb', line 6

def show
  validate_element!

  if element.remember?
    state[element.aria.controls] = true
  else
    state.now[element.aria.controls] = true
  end

  morph id: element.morphs, html: render(element.render_options)
end

#toggleObject



24
25
26
# File 'app/commands/turbo_boost/elements/toggle_command.rb', line 24

def toggle
  element.aria.expanded? ? hide : show
end