Module: TextileToolbar

Defined in:
lib/textile_toolbar.rb,
lib/textile_toolbar/version.rb

Defined Under Namespace

Modules: FormBuilder

Constant Summary collapse

VERSION =
"0.5.5"

Instance Method Summary collapse

Instance Method Details

#textile_area(object_name, method, options = {}) ⇒ Object



4
5
6
7
8
# File 'lib/textile_toolbar.rb', line 4

def textile_area(object_name, method, options={})
  disable = options.delete(:disable) || {}
  toolbar = textile_toolbar(options[:id] || "#{object_name}_#{method}", disable)
  raw("<div class=\"textile_toolbar\">#{toolbar}</div><div class=\"textile_area\">#{text_area(object_name, method, options)}</div>").html_safe
end

#textile_toolbar(id, disable) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/textile_toolbar.rb', line 10

def textile_toolbar(id, disable)
  html = javascript_include_tag("textile_toolbar")
  html << link_to_function(image_tag("textile_toolbar/bold.png", :size => "23x22", :alt => "Make selection bold"), "surround_selection('#{id}', '*', '*')")
  html << raw("&nbsp;")
  html << link_to_function(image_tag("textile_toolbar/italic.png", :size => "23x22", :alt => "Make selection italic"), "surround_selection('#{id}', '_', '_')")
  html << raw("&nbsp;")
  html << link_to_function(image_tag("textile_toolbar/underline.png", :size => "23x22", :alt => "Make selection underlined"), "surround_selection('#{id}', '+', '+')")
  html << raw("&nbsp;")
  html << link_to_function(image_tag("textile_toolbar/hyperlink.png", :size => "23x22", :alt => "Make hyperlink"), "insert_hyperlink('#{id}')")
  html << raw("&nbsp;")
  unless disable == :image
    html << link_to_function(image_tag("textile_toolbar/image.png", :size => "23x22", :alt => "Insert image"), "insert_image('#{id}')")
    html << raw("&nbsp;")
  end
  html << raw("<small>") << link_to("Textile", "http://hobix.com/textile/", :target => "_blank") << raw(" enabled</small>")
  html.html_safe
end