Class: Scarpe::WebviewImage
- Inherits:
-
WebviewWidget
- Object
- Shoes::Linkable
- WebviewWidget
- Scarpe::WebviewImage
- Includes:
- Components::Base64
- Defined in:
- lib/scarpe/wv/image.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
Instance Method Summary collapse
- #element ⇒ Object
-
#initialize(properties) ⇒ WebviewImage
constructor
A new instance of WebviewImage.
- #style ⇒ Object protected
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, #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) ⇒ WebviewImage
Returns a new instance of WebviewImage.
8 9 10 11 12 |
# File 'lib/scarpe/wv/image.rb', line 8 def initialize(properties) super @url = valid_url?(@url) ? @url : "data:image/png;base64,#{encode_file_to_base64(@url)}" end |
Instance Method Details
#element ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/scarpe/wv/image.rb', line 14 def element if @click HTML.render do |h| h.a(id: html_id, href: @click) { h.img(id: html_id, src: @url, style:) } end else HTML.render do |h| h.img(id: html_id, src: @url, style:) end end end |
#style ⇒ Object (protected)
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scarpe/wv/image.rb', line 28 def style styles = super styles[:width] = Dimensions.length(@width) if @width styles[:height] = Dimensions.length(@height) if @height styles[:top] = Dimensions.length(@top) if @top styles[:left] = Dimensions.length(@left) if @left styles[:position] = "absolute" if @top || @left styles end |