Class: Scarpe::Webview::Para

Inherits:
Drawable show all
Defined in:
lib/scarpe/wv/para.rb

Constant Summary

Constants included from Shoes::Log

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

Instance Attribute Summary

Attributes inherited from Drawable

#children, #parent, #shoes_linkable_id

Attributes inherited from Shoes::Linkable

#linkable_id

Instance Method Summary collapse

Methods inherited from Drawable

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles

Methods included from Shoes::Log

configure_logger, #log_init, logger

Methods inherited from Shoes::Linkable

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

Constructor Details

This class inherits a constructor from Scarpe::Webview::Drawable

Instance Method Details

#element(&block) ⇒ Object



49
50
51
# File 'lib/scarpe/wv/para.rb', line 49

def element(&block)
  render("para", &block)
end

#items_to_display_children(items) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/scarpe/wv/para.rb', line 37

def items_to_display_children(items)
  return [] if items.nil?

  items.map do |item|
    if item.is_a?(String)
      item
    else
      Scarpe::Webview::DisplayService.instance.query_display_drawable_for(item)
    end
  end
end

#properties_changed(changes) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/scarpe/wv/para.rb', line 22

def properties_changed(changes)
  items = changes.delete("text_items")
  if items
    html_element.inner_html = to_html
    return
  end

  # Not deleting, so this will re-render
  if changes["size"] && SIZES[@size.to_sym]
    @size = @size.to_sym
  end

  super
end

#to_htmlObject

Because para's to_html takes a block, and it needs to convert IDs into display drawables, it needs to also override to_html



55
56
57
58
59
# File 'lib/scarpe/wv/para.rb', line 55

def to_html
  @children ||= []

  element { child_markup }
end