Module: ODDB::View::Drugs::InsertBackbutton

Included in:
Compare, DDDPrice, EmptyCompare, PriceHistory
Defined in:
src/view/drugs/compare.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) back_button(model, session = @session)



127
128
129
130
131
132
133
# File 'src/view/drugs/compare.rb', line 127

def back_button(model, session=@session)
  button = HtmlGrid::Button.new(:compare_backbutton, model, @session, self)
  event, url = snapback
  button.set_attribute("onclick", "document.location.href='#{url}'")
  button.css_class = "button"
  button
end

- (Object) backtracking(model, session = @session)



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'src/view/drugs/compare.rb', line 134

def backtracking(model, session=@session)
  if(@lookandfeel.enabled?(:breadcrumbs))
    breadcrumbs = []
    level = 3
    dv = HtmlGrid::Span.new(model, @session, self)
    dv.css_class = "breadcrumb"
    dv.value = "<"
    if @lookandfeel.enabled?(:home)
      span1 = HtmlGrid::Span.new(model, @session, self)
      span1.css_class = "breadcrumb-#{level} bold"
      level -= 1
      link1 = HtmlGrid::Link.new(:back_to_home, model, @session, self)
      link1.href = @lookandfeel._event_url(:home)
      link1.css_class = "list"
      span1.value = link1
      breadcrumbs.push span1, dv
    end
    span2 = HtmlGrid::Span.new(model, @session, self)
    span2.css_class = "breadcrumb-#{level}"
    level -= 1
    link2 = HtmlGrid::Link.new(:result, model, @session, self)
    link2.css_class = "list"
    query = @session.persistent_user_input(:search_query)
    query = model.name_base if query.is_a?(SBSM::InvalidDataError) || query.nil?
    args = [
      :zone, :drugs, :search_query, query.gsub('/', '%2F'), :search_type,
      @session.persistent_user_input(:search_type) || 'st_oddb',
    ]
    link2.href = @lookandfeel._event_url(:search, args)
    link2.value = @lookandfeel.lookup(:back_to_list_for, query)
    span2.value = link2
    span3 = HtmlGrid::Span.new(model, @session, self)
    span3.css_class = "breadcrumb-#{level}"
    if(respond_to?(:pointer_descr))
      span3.value = self.send(:pointer_descr, model)
    elsif(model.respond_to? :pointer_descr)
      span3.value = model.pointer_descr
    end
    breadcrumbs.push span2, dv, span3
  else
    super
  end
end

- (Object) reorganize_components



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'src/view/drugs/compare.rb', line 113

def reorganize_components
  super
  idx = components.index(:backtracking)
  if(@lookandfeel.enabled?(:breadcrumbs))
    css_map.store(idx, 'breadcrumbs')
  end
  if(@lookandfeel.enabled?(:compare_backbutton, false))
    components.delete(idx)
    x,y = idx
    components.store([x,y,0], :backtracking)
    components.store([x,y,1], :back_button)
    css_map.store(idx, 'snapback')
  end
end