Class: Scarpe::WebviewLink

Inherits:
WebviewWidget show all
Defined in:
lib/scarpe/wv/link.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 WebviewWidget

#children, #parent, #shoes_linkable_id

Attributes inherited from Shoes::Linkable

#linkable_id

Instance Method Summary collapse

Methods inherited from WebviewWidget

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

Methods included from Shoes::Log

configure_logger, #log_init, logger

Methods inherited from Shoes::Linkable

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

Constructor Details

#initialize(properties) ⇒ WebviewLink

Returns a new instance of WebviewLink.



5
6
7
8
9
10
11
# File 'lib/scarpe/wv/link.rb', line 5

def initialize(properties)
  super

  bind("click") do
    send_self_event(event_name: "click")
  end
end

Instance Method Details

#attributesObject



21
22
23
24
25
26
27
28
# File 'lib/scarpe/wv/link.rb', line 21

def attributes
  {
    id: html_id,
    href: @click,
    onclick: (handler_js_code("click") if @has_block),
    style: style,
  }.compact
end

#elementObject



13
14
15
16
17
18
19
# File 'lib/scarpe/wv/link.rb', line 13

def element
  HTML.render do |h|
    h.a(**attributes) do
      @text
    end
  end
end