module Marta::Lightning

Marta can highlight or unhighlight elements when her styles are injected.

Private Instance Methods

highlight(element) click to toggle source

We can highlight an element

# File lib/marta/lightning.rb, line 9
def highlight(element)
  if is_here?(element)
    engine.execute_script("arguments[0].setAttribute"\
                        "('martaclass','foundbymarta')", element)
  end
end
is_here?(element) click to toggle source

Method to understand that something shouldn't be highlighted

# File lib/marta/lightning.rb, line 25
def is_here?(element)
  element.exists?
rescue
  false
end
mass_highlight_turn(mass, turn_on = true) click to toggle source

We can highlightunhighlight tons of elements at once

# File lib/marta/lightning.rb, line 32
def mass_highlight_turn(mass, turn_on = true)
  mass.each_with_index do |element, i|
    if turn_on
      highlight element
    else
      unhighlight element
    end
  end
end
unhighlight(element) click to toggle source

We can unhighlight an element

# File lib/marta/lightning.rb, line 17
def unhighlight(element)
  if is_here?(element)
    engine.execute_script("arguments[0].removeAttribute('martaclass')",
                          element)
  end
end