Class: OMF::Web::Theme::StackedRenderer

Inherits:
LayoutRenderer
  • Object
show all
Defined in:
lib/omf-web/theme/bright/stacked_renderer.rb

Instance Method Summary collapse

Methods inherited from LayoutRenderer

#render?

Constructor Details

#initialize(stacked_widget, widgets, active_index, opts) ⇒ StackedRenderer

Returns a new instance of StackedRenderer.



9
10
11
12
13
14
15
# File 'lib/omf-web/theme/bright/stacked_renderer.rb', line 9

def initialize(stacked_widget, widgets, active_index, opts)
  @stacked_widget = stacked_widget
  @widgets = widgets
  @active_index = active_index
  @helper = StackedRendererHelper.new(widgets, active_index, opts)
  @opts = opts
end

Instance Method Details

#to_htmlObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/omf-web/theme/bright/stacked_renderer.rb', line 17

def to_html()
  wp = "w#{@helper.object_id}"
  @opts[:menu] = @widgets.each_with_index.map do |w, i|
    wc = w.widget_type.split('/').inject([]) do |a, e|
            a << (a.empty? ? e : "#{a[-1]}_#{e}")
          end
    {
      :name => w.name,
      :class => wc.join(' '),
      :is_active => (@active_index == i),
      :id => "#{wp}_l_#{i}",
      :js_function => 'OML.show_widget',
      :inner_class => wp,
      :index => i,
      :widget_id => w.dom_id
    }
  end
  WidgetChrome.new(@stacked_widget, @helper, @opts).to_html
end