<commit_before>module UiBibz::Ui::Core::Forms::Choices

  # Create a SurroundField
  #
  # This element is an extend of UiBibz::Ui::Core::Component.
  # Source : http://www.bootstrap-switch.org/documentation-2.html
  # ==== Attributes
  #
  # * +content+ - Content of element
  # * +options+ - Options of element
  # * +html_options+ - Html Options of element
  #
  # ==== Options
  #
  # You can add HTML attributes using the +html_options+.
  # You can pass arguments in options attribute:
  # * +state+ - String
  # * +animate+ - Boolean
  # * +on_color+ - String
  # * +off_color+ - String
  # * +on_text+ - String
  # * +off_text+ - String
  # * +label_text+ - String
  # * +readonly+ - Boolean
  # * +checked+ - Boolean
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::Forms::SwitchField.new(content, options = {}, html_options = {}).render
  #
  #   UiBibz::Ui::Core::Forms::SwitchField.new(options = {}, html_options = {}) do
  #     content
  #   end.render
  #
  # ==== Examples
  #
  #   switch_field 'name', { on_color: :primary }, { readonly: true }
  #
  # ==== Helper
  #
  #   switch_field(options = {}, html_options = {}) do
  #    # content
  #   end
  #
  class SwitchField < UiBibz::Ui::Core::Component

    # See UiBibz::Ui::Core::Component.initialize
    def initialize content = nil, options = nil, html_options = nil, &block
      super
    end

    # Render html tag
    def render
      if options[:builder].nil?
        check_box_tag content, value, html_options[:checked], html_options
      else
        options[:builder].check_box(content, html_options)
      end
    end

    private

    def value
      options[:value]
    end

    def component_html_classes
      "switch-field"
    end

    def component_html_data
      super
      size
      state
      animate
      left_color
      right_color
      left_text
      right_text
      middle_text<commit_msg>fix switch field for simple form<commit_after>module UiBibz::Ui::Core::Forms::Choices

  # Create a SurroundField
  #
  # This element is an extend of UiBibz::Ui::Core::Component.
  # Source : http://www.bootstrap-switch.org/documentation-2.html
  # ==== Attributes
  #
  # * +content+ - Content of element
  # * +options+ - Options of element
  # * +html_options+ - Html Options of element
  #
  # ==== Options
  #
  # You can add HTML attributes using the +html_options+.
  # You can pass arguments in options attribute:
  # * +state+ - String
  # * +animate+ - Boolean
  # * +on_color+ - String
  # * +off_color+ - String
  # * +on_text+ - String
  # * +off_text+ - String
  # * +label_text+ - String
  # * +readonly+ - Boolean
  # * +checked+ - Boolean
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::Forms::SwitchField.new(content, options = {}, html_options = {}).render
  #
  #   UiBibz::Ui::Core::Forms::SwitchField.new(options = {}, html_options = {}) do
  #     content
  #   end.render
  #
  # ==== Examples
  #
  #   switch_field 'name', { on_color: :primary }, { readonly: true }
  #
  # ==== Helper
  #
  #   switch_field(options = {}, html_options = {}) do
  #    # content
  #   end
  #
  class SwitchField < UiBibz::Ui::Core::Component

    # See UiBibz::Ui::Core::Component.initialize
    def initialize content = nil, options = nil, html_options = nil, &block
      super
    end

    # Render html tag
    def render
      check_box_tag content, value, html_options[:checked], html_options
    end

    private

    def value
      options[:value]
    end

    def component_html_classes
      "switch-field"
    end

    def component_html_data
      super
      size
      state
      animate
      left_color
      right_color
      left_text
      right_text
      middle_text
{'fraction_non_alphanumeric': 0.1312449365379422, 'fraction_numerical': 0.0005401026194977045, 'mean_word_length': 2.6171875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556797', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1212, 'n_words': 274}