Module: Famfamfam
- Defined in:
- lib/famfamfam.rb,
lib/famfamfam/version.rb,
lib/famfamfam/rails/engine.rb
Defined Under Namespace
Modules: Rails
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
- #default_icon_set ⇒ Object
- #default_icon_set=(set) ⇒ Object
- #default_icon_size ⇒ Object
- #default_icon_size=(size) ⇒ Object
-
#icon(name, alt = nil, opts = {}) ⇒ Object
Insert an image tag with an icon with name equal to “name” param and extension .png, with alt attribute and options.
-
#icon_preview(opts = {}) ⇒ Object
offer up the preview of all icons for the current set.
-
#icon_submit_tag(name, alt = nil, opts = {}) ⇒ Object
Insert a image for submit the form.
Instance Method Details
#default_icon_set ⇒ Object
12 13 14 |
# File 'lib/famfamfam.rb', line 12 def default_icon_set @default_icon_set ||= 'fam-fam' # :aesthetica # :'fam-fam' end |
#default_icon_set=(set) ⇒ Object
4 5 6 |
# File 'lib/famfamfam.rb', line 4 def default_icon_set=( set ) @default_icon_set = set end |
#default_icon_size ⇒ Object
16 17 18 |
# File 'lib/famfamfam.rb', line 16 def default_icon_size @default_icon_size ||= 16 # 24 #16 end |
#default_icon_size=(size) ⇒ Object
8 9 10 |
# File 'lib/famfamfam.rb', line 8 def default_icon_size=( size ) @default_icon_size = size end |
#icon(name, alt = nil, opts = {}) ⇒ Object
Insert an image tag with an icon with name equal to “name” param and extension .png, with alt attribute and options. Example:
<%= icon :information, "Information icon", :border => 0 %>
will generate:
<img src="../icons/information.png" alt="Information icon" border="0" />
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/famfamfam.rb', line 26 def icon(name, alt = nil, opts = {}) opts[:border] = 0 unless opts[:border] opts[:align] = "bottom" unless opts[:align] opts[:alt] = alt opts[:class] = ["icon", opts[:class]].join(" ") set = opts.delete(:set) || default_icon_set size = opts.delete(:size) || default_icon_size path = "icons/#{set}/#{size}/#{name}.png" image_tag path, opts end |
#icon_preview(opts = {}) ⇒ Object
offer up the preview of all icons for the current set
47 48 49 50 |
# File 'lib/famfamfam.rb', line 47 def icon_preview(opts = {}) set = opts.delete(:set) || default_icon_set image_tag "icons/#{set}/preview_icons.png", opts end |
#icon_submit_tag(name, alt = nil, opts = {}) ⇒ Object
Insert a image for submit the form. Uses the same syntax of icon
39 40 41 42 43 44 |
# File 'lib/famfamfam.rb', line 39 def icon_submit_tag(name, alt = nil, opts = {}) opts[:alt] = alt set = opts.delete(:set) || default_icon_set size = opts.delete(:size) || default_icon_size image_submit_tag "../icons/#{set}/#{size}/#{name}.png", opts end |