Sha256: 9d2d1624698ba06efb3a58a1c278de0dd77eec17c21f25e824e26770c2bbc89a

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

require 'nitro/control/attribute'

module Nitro

# Controls a Float attribute.

class FloatControl < AttributeControl
  setting :style, :default => 'width: 100px', :doc => 'The default style'

  def render
    style = @anno.control_style || self.class.style 
    %{
      #{emit_label}
      <input type="text" id="#{@attribute}_ctl" name="#{@attribute}" value="#{value}"#{emit_style}#{emit_disabled} />
      <a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)+#{step}; return false;">+</a>
      <a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)-#{step}; return false;">-</a>
    }
  end
  
  def step
    0.5
  end
  
end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.41.0 lib/nitro/control/attribute/float.rb
nitro-0.40.0 lib/nitro/control/attribute/float.rb