Class: ODDB::View::Drugs::DDDPriceComposite

Inherits:
HtmlGrid::Composite show all
Includes:
Facebook, PartSize
Defined in:
src/view/drugs/ddd_price.rb

Constant Summary

COMPONENTS =
{
  [0,0] => :ddd_price,
  [0,1] => DDDPriceTable,
}
CSS_CLASS =
'composite'
CSS_MAP =
{
  [0,0] => 'th',
}
LEGACY_INTERFACE =
false

Instance Method Summary (collapse)

Methods included from Facebook

#facebook_fan, #facebook_share

Methods included from PartSize

#comparable_size, #part_size

Methods inherited from HtmlGrid::Composite

event_link, #hash_insert_col, #hash_insert_row

Instance Method Details

- (Object) ddd_chart(model)



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

def ddd_chart(model)
  link = HtmlGrid::Link.new(:ddd_chart, model, @session, self)
  img = HtmlGrid::Image.new(:ddd_chart, model, @session, self)
  file = sprintf "%s_%s_%s.png", model.ikskey, model.name_base,
                                 @lookandfeel.lookup(:ddd_price_comparison)
  args = [
    :for, file.gsub(/\s+/, '_')
  ]
  url = @lookandfeel._event_url(:ddd_chart, args)
  img.set_attribute('src', url)
  link.href = url
  link.value = img
  link
end

- (Object) ddd_price(model)



127
128
129
# File 'src/view/drugs/ddd_price.rb', line 127

def ddd_price(model)
  @lookandfeel.lookup(:ddd_price_for, model.name_base)
end

- (Object) init



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'src/view/drugs/ddd_price.rb', line 98

def init
  if @lookandfeel.enabled?(:ddd_chart)
    components.store [0,2], :ddd_chart
    css_map.store [0,2], 'ddd-chart'
    if @lookandfeel.enabled?(:twitter_share)
      components.store [0,3,0], :twitter_share
      css_map.store [0,3], 'list'
    end
    if @lookandfeel.enabled?(:facebook_share)
      components.store [0,3,1], :facebook_share
      css_map.store [0,3], 'list spaced'
    end
  end
  super
end

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



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'src/view/drugs/ddd_price.rb', line 130

def (model, session=@session)
  link = HtmlGrid::Link.new(:twitter_share_short, model, @session, self)
  link.value = HtmlGrid::Image.new(:icon_twitter, model, @session, self)
  base = model.name_base
  size = comparable_size(model)
  fullname = u sprintf("%s, %s", base, size)
  title = @lookandfeel.lookup(:ddd_chart_title, fullname)
  url = @lookandfeel._event_url(:ddd_price, :pointer => model.pointer)
  tweet = "http://twitter.com/home?status=#{title} - "
  if ind = model.indication
    tweet << ind.send(@session.language) << " - "
  end
  link.href = "#" #tweet + url
  link.onclick = "bitly_for_twitter('#{url}', '#{tweet}');"
  link.set_attribute("title", @lookandfeel.lookup(:twitter_share))
  link.css_class = "twitter"
  link
end