Method: XHTML#start_button

Defined in:
lib/xhtml.rb

#start_button(options = {}) ⇒ Object



1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
# File 'lib/xhtml.rb', line 1844

def start_button(options = {})
    out = ''
    opts = ['name', 'type', 'value', 'accessley', 'disabled', 'onblur',
            'onfocus', 'tabindex', 'class', 'id', 'title', 'onclick',
            'ondblclick', 'onkeyup', 'onkeydown', 'onkeypress',
            'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove',
            'onmouseout', 'style']
    if options.nil?
        out << "<button>\n"
    else
        out << "<button"
        options.each do |x,y|
            x = x.to_s
            if opts.include?("#{x}")
                if ( "#{x}" == 'class' or "#{x}" == 'id' and y.kind_of?(Array))
                    z = y.join(' ')
                    out << " #{x}='#{z}'"
                else
                    out << " #{x}='#{y}'"
                end
            end
        end
        out << ">\n"
    end
    return out
end