Sha256: eafaacf09ac83da73812310ab46149f224134f7c81f3a64d4905ac1cab4643c3

Contents?: true

Size: 1.03 KB

Versions: 39

Compression:

Stored size: 1.03 KB

Contents

module Formtastic
  module Inputs
    class SelectableCheckBoxesInput < CheckBoxesInput
      def to_html
        input_wrapping do
          choices_wrapping do
            legend_html <<
            hidden_field_for_all <<
            choices_group_wrapping do
              select_all_html +
              collection.map { |choice|
                choice_wrapping(choice_wrapping_html_options(choice)) do
                  choice_html(choice)
                end
              }.join("\n").html_safe
            end
          end
        end
      end

      def select_all_html
        choice_wrapping({}) do
          check_box = template.check_box_tag(nil, nil, false, 
            :onclick => <<-JS
              selector  = $(this);
              condition = selector.is(':checked');

              selector.closest('.choices-group').find('[type=checkbox]').attr('checked', condition);
            JS
          )

          template.content_tag(:label,
            check_box << I18n.t('select_all')
          )
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
smartkiosk-server-0.13.1 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.13 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.12.1 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.12 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.11 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.10 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.9 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.8 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.7 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.6 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.5 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.4 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.3 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.2 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11.1 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.11 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.10.19 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.10.18 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.10.17 lib/formtastic/inputs/selectable_check_boxes.rb
smartkiosk-server-0.10.16 lib/formtastic/inputs/selectable_check_boxes.rb