Sha256: c4fe4bd6203acf2978775d72600f49daf1101826b8cd1d6ea1a12075550430cd

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

module JquerySortableTreeHelper
  module RenderIndentedOptionsHelper
    class Render
      attr_accessor :h, :options

      def initialize(h, options)
        @h, @options = h, options
      end

      def render_node
        h.content_tag(:option, title, tag_options) + children
      end

      def title
        "\u202f" * (@options[:spacing] || 3).to_i * (@options[:level]-1) + node.send(@options[:title])
      end

      def tag_options
        html_options = { value: node.id }

        if options[:selected] == node
          html_options[:selected] = 'selected'
          html_options[:class] = 'selected'
        end
        html_options
      end

      def node
        @options[:node]
      end

      def children
        @options[:children].html_safe
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jquery_sortable_tree-3.0.0 app/helpers/jquery_sortable_tree_helper/render_indented_options_helper.rb