Skip to content

Instantly share code, notes, and snippets.

@tmking
Created October 27, 2009 02:44
Show Gist options
  • Save tmking/219255 to your computer and use it in GitHub Desktop.
Save tmking/219255 to your computer and use it in GitHub Desktop.
#see global.css around line 1300 for all available CSS button options
def graphic_button(params)
className = (!params[:class].nil?) ? params[:class] : "" # if no classname, default to ??
if className == ""
className = (!params[:buttonStyle].nil?) ? params[:buttonStyle] : "graphicBtnSmall"
className = (!params[:buttonColor].nil?) ? className + " " + params[:buttonColor] + className.classify : className
className = (!params[:extraClass].nil?) ? className + " " + params[:extraClass] : className
end
text = (!params[:text].nil?) ? params[:text] : "Submit" # if text is set use it, otherwise use 'Submit
title = (!params[:title].nil?) ? params[:title] : text # if title is set use that, otherwise default to text
href = (!params[:href].nil?) ? params[:href] : "javascript:;" # default to JS if blank
type = (!params[:type].nil?) ? ' type="' + params[:type] + '"' : '' # default to blank
name = (!params[:name].nil?) ? ' name="' + params[:name] + '"' : '' # default to blank
id = (!params[:id].nil?) ? ' id="' + params[:id] + '"' : '' # default to blank
aId = (!params[:id].nil?) ? ' id="' + params[:id] + '_button"' : '' # default to blank
style = (!params[:style].nil?) ? ' style="' + params[:style] + '"' : '' # default to blank
hrefOnclick = (!params[:hrefOnclick].nil?) ? ' onclick="' + params[:hrefOnclick] + '"' : "" # default to blank
onclick = (!params[:onclick].nil?) ? ' onclick="' + params[:onclick] + '"' : "" # default to blank
disabled = (!params[:disabled].nil?) ? ' disabled="' + params[:disabled] + '"' : "" # default to blank
button = (onclick != '' || type != '') ? '<button' + onclick + type + name + id + disabled +'>&nbsp;</button>' : "" # default to blank if not set
rel = (!params[:rel].nil?) ? ' rel="' + params[:rel] + '"' : 'rel="nofollow"' # default to no follow if blank
button_html = '<a href="' + href + '" class="' + className + '" ' + aId + rel + style + hrefOnclick + ' title="'+ title + '">
<span><span>' + text + '</span></span>' + button + '</a>'
return button_html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment