Sha256: 8dfdc796f19a2331204ef0ae96dec00233774425fce16b9bdd3ec102d6243b90

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'glimmer/opal/element_proxy'

module Glimmer
  module Opal
    class TabFolder < ElementProxy
      attr_reader :tabs
      
      def initialize(parent, args)
        super(parent, args)
        @tabs = []
      end
      
      def add_child(child)
        super(child)
        if @children.size == 1
          child.show
        end
      end
      
      def redraw
        super()
        @children.each do |child|
          add_child(child) # TODO think of impact of this on performance
        end
      end
      
      def hide_all_tab_content
        @children.each(&:hide)
      end
    
      def name
        'div'
      end
      
      def tabs_dom
        tabs_id = id + '-tabs'
        @tabs_dom ||= DOM {
          div(id: tabs_id, class: 'tabs')
        }
      end
      
      def dom
        tab_folder_id = id
        tab_folder_id_style = css
        @dom ||= DOM {
          div(id: tab_folder_id, style: tab_folder_id_style, class: 'tab-folder') {
            
          }
        }.tap {|the_dom| the_dom << tabs_dom }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.0.9 lib/glimmer/opal/tab_folder.rb
glimmer-dsl-opal-0.0.8 lib/glimmer/opal/tab_folder.rb