Class: Scarpe::WebviewCheck

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

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, #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) ⇒ WebviewCheck



7
8
9
10
11
12
13
# File 'lib/scarpe/wv/check.rb', line 7

def initialize(properties)
  super

  bind("click") do
    send_self_event(event_name: "click", target: shoes_linkable_id)
  end
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/scarpe/wv/check.rb', line 5

def text
  @text
end

Instance Method Details

#elementObject



23
24
25
26
27
# File 'lib/scarpe/wv/check.rb', line 23

def element
  HTML.render do |h|
    h.input(type: :checkbox, id: html_id, onclick: handler_js_code("click"), value: "hmm #{text}", checked: @checked, style:)
  end
end

#properties_changed(changes) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/scarpe/wv/check.rb', line 15

def properties_changed(changes)
  checked = changes.delete("checked")

  html_element.toggle_input_button(checked)

  super
end