Class: ODDB::Html::View::ChapterNames

Inherits:
HtmlGrid::DivList
  • Object
show all
Defined in:
lib/oddb/html/view/document.rb

Constant Summary collapse

COMPONENTS =
{
  [0,0] => :link,
}

Instance Method Summary collapse

Constructor Details

#initialize(type, *args) ⇒ ChapterNames

Returns a new instance of ChapterNames.



14
15
16
17
# File 'lib/oddb/html/view/document.rb', line 14

def initialize(type, *args)
  @document_type = type
  super(*args)
end

Instance Method Details

#initObject



18
19
20
21
22
23
24
25
# File 'lib/oddb/html/view/document.rb', line 18

def init
  @current = @session.user_input(:chapter)
  @model = @model.chapter_names.unshift(nil)
  super
  @css_grid = @model.collect { |name| 
    { "id" => "chapter_%s" % name || @document_type } 
  }
end


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/oddb/html/view/document.rb', line 26

def link(model)
  link = HtmlGrid::Link.new("chapter_#{model || @document_type}", 
                            model, @session, self)
  if(@current != model)
    event, args = @session.direct_event
    args.push :chapter, model if(model)
    link.href = @lookandfeel._event_url(event, args)
  end
  link.value ||= model
  link
end