Class: Flammarion::Writeable::ClickableImage

Inherits:
Object
  • Object
show all
Defined in:
lib/cem/cflame/clickable_img.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, width, height, alt, title, name, owner, block) ⇒ ClickableImage

Returns a new instance of ClickableImage.



14
15
16
17
18
19
20
21
22
23
# File 'lib/cem/cflame/clickable_img.rb', line 14

def initialize(url, width, height, alt, title, name, owner, block)
  @name = name
  @owner = owner
  @block = block
  @url = url
  @width = width
  @height = height
  @alt = alt
  @title = title
end

Instance Method Details

#htmlObject



31
32
33
# File 'lib/cem/cflame/clickable_img.rb', line 31

def html
  %|<img id="#{@name}" width=#{@width.to_s} max-height=#{@height.to_s} src="#{@url.to_s}" alt="#{@alt}" title="#{@title}"/>|
end

#to_sObject



25
26
27
28
29
# File 'lib/cem/cflame/clickable_img.rb', line 25

def to_s
  return @owner.callback_link(html) {
    @block.call(self) if @block
  }
end

#update(url, width, height, alt, title) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/cem/cflame/clickable_img.rb', line 35

def update(url, width, height, alt, title)
  @url = url
  @width = width
  @height = height
  @alt = alt if alt
  @title = title if title
  
  @owner.js("$( '##{@name}' ).replaceWith('#{html}');")

end

#url=(value) ⇒ Object



46
47
48
49
50
# File 'lib/cem/cflame/clickable_img.rb', line 46

def url=(value)
  value = value.to_s
  # puts "urlset on #{@name}"
  @owner.js("$( '##{@name}' ).attr('src', '#{value}');")
end