Sha256: d2cd0d8d072c965b5eaf9b2e000d3206ba25cf643ec6c10bd8bb2a3286fb8af0

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

#
# Slider Class will serve as a wrapper for the JQuery UI Slider widget,
# allowing the user to interact with the slider, setting it to a specific
# position within the length of the slider, between 0% and 100%.
#
# The user will pass in the variable they wish to set with the addition
# of the % symbol.
#
# NOTE: The code for the Slider widget will be kept as basic as
# possible in order to allow the user to tailor the class to suit
# their own needs in case customization of the slider has been
# exercised.
#

class JQueryUIWidgets::Slider < PageObject::Elements::Div

  #
  #  Generates two methods.
  #
  # The {NAME} method picks up the current position of the
  # slider, grabbing the % and returning it.
  #
  # The {NAME}= method will allow the user to set the
  # position of the slider by passing in a percentage.
  #
  #   @example
  #     the_slider=('15%')
  #     Will set the slider to 15%.
  #
  def self.accessor_methods(accessor, name)
    accessor.send :define_method, "#{name}" do
      slider = self.send "#{name}_element"
      the_slider = slider.link_element(:class => 'ui-slider-handle ui-state-default ui-corner-all')
      the_slider.html[/\d+%/]
    end

    accessor.send :define_method, "#{name}=" do |value|
      browser.execute_script("document.getElementsByClassName('ui-slider-handle')[0].style.left=\"#{value}\";")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jqueryui_widgets-1.0 lib/jqueryui_widgets/slider.rb
jqueryui_widgets-0.7.1 lib/jqueryui_widgets/slider.rb
jqueryui_widgets-0.6 lib/jqueryui_widgets/slider.rb