Class: OMF::Web::Theme::TextRenderer

Inherits:
Erector::Widget
  • Object
show all
Defined in:
lib/omf-web/theme/bright/text_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(text_widget, content, opts) ⇒ TextRenderer

Returns a new instance of TextRenderer.



8
9
10
11
12
# File 'lib/omf-web/theme/bright/text_renderer.rb', line 8

def initialize(text_widget, content, opts)
  super opts
  @widget = text_widget
  @content = content
end

Instance Method Details

#contentObject



15
16
17
18
19
20
21
22
# File 'lib/omf-web/theme/bright/text_renderer.rb', line 15

def content
  wid = "w#{@widget.object_id}"
  div :class => "text" do
    rawtext @content.to_html
    render_content_observer(wid)
  end
  
end

#render_content_observer(wid) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/omf-web/theme/bright/text_renderer.rb', line 24

def render_content_observer(wid)
  javascript(%{
    OHUB.bind("content.changed.#{@widget.content_id}", function(evt) {
      
      $.ajax({
        url: '/widget/#{@widget.widget_id}?embedded&body_only',
        type: 'GET'
      }).done(function(data) { 
        $('\##{wid}_b').replaceWith(data);
        var i = 0;
      });
    });
  })
end