Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Button code creates a generic, styled input button.
<pre class='prettyprint' language='ruby'>def button(title, values) # title: Accepts a string that will appear on the button # values: accepts the possible optional parameters. # category: Accepts one of the following: # - primary: Standard "green" button with white text # - primary_secure: Standard "green" button with "lock" icon # - primary_mini: Yes / No small "green" buttons # - secondary: Standard "blue" button with white text # - secondary_secure: # - secondary_prev: Standard "blue" button with left arrow # - secondary_next: Standard "blue" button with right arrow # - purchase: Standard "gold" purchase button # - purchase_tight: Like purchase but half the padding # type: Accepts "button", "submit" or "reset" -- Defaults to "button" if not passed. # onclick: Will accept an onclick event. # url: Will accept a URL or path to another page. # class: Will accept an additional class to assign to the button. # id: Will accept an ID to attach to the button. #Checks the category for certain keywords so the proper icon can be inlined in to the button. if values[:category] then button_icon = "buttons_secure" if values[:category].match("secure") button_icon = "buttons_prev" if values[:category].match("prev") button_icon = "buttons_next" if values[:category].match("next") img_tag = content_tag(:img, '', :src => "../images/" + button_icon + ".gif") else img_tag = "" # if no button category is given, it defaults to primary. values[:category] = "primary" end # The input type defaults to "button" if not given. if !values[:type] then values[:type] = "button" end if values[:onclick] then onclick_event = values[:onclick] elsif values[:url] then onclick_event = "window.location=" + values[:url] end # The tag is created to accomplish the sliding door technique. div_tag = content_tag(:div, '&nbsp', :class => 'endcap') content_tag(:div, content_tag( :input, img_tag + div_tag, :value => title, :type => values[:type], :onclick => onclick_event, :class => values[:class], :id => values[:id] ), :class => "button button_" + values[:category]) end</pre> <a href="http://www.refactormycode.com/codes/1029-button-code-creates-a-generic-styled-input-button" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>