Class: ODDB::Html::View::Drugs::Pager

Inherits:
HtmlGrid::Div
  • Object
show all
Defined in:
lib/oddb/html/view/drugs/result.rb

Constant Summary collapse

CSS_CLASS =
'pager'

Instance Method Summary collapse

Instance Method Details

#initObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/oddb/html/view/drugs/result.rb', line 48

def init
  super
  @value = [@lookandfeel.lookup(:pager, @model.page + 1, 
                                @model.page_count)]
  @value.push(' ', link('<<', @model.page))
  1.upto(@model.page_count) { |page|
    @value.push(' ', link(page.to_s, page))
  }
  @value.push(' ', link('>>', @model.page + 2))
end


58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/oddb/html/view/drugs/result.rb', line 58

def link(text, pos)
  link = HtmlGrid::Link.new(:pager, @model, @session, self)
  link.value = text
  unless([0, @model.page.next, @model.page_count.next].include?(pos))
    args = @session.state.direct_event
    event = args.shift
    args.push(:page, pos)
    link.href = @lookandfeel._event_url(event, args)
  else
    link.css_class = 'current_page'
  end
  link
end