Sha256: df22e3747dc6c1cbd339fef297b3c9e887b1520b2bdc92fff09daff26ee25c7a

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

require 'nitro/control/attribute'

module Nitro

# Controls a Fixnum attribute.

class FixnumControl < 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
    1
  end
  
end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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