Module: TinymceFm::ApplicationHelper

Defined in:
app/helpers/tinymce_fm/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#append_class_name(options, class_name) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/tinymce_fm/application_helper.rb', line 19

def append_class_name options, class_name
  key = options.has_key?('class') ? 'class' : :class
  unless options[key].to_s =~ /(^|\s+)#{class_name}(\s+|$)/
    options[key] = "#{options[key]} #{class_name}".strip
  end
  options
end

#tinymce_javascript_tag(controller = nil, theme = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/tinymce_fm/application_helper.rb', line 3

def tinymce_javascript_tag( controller = nil, theme = nil )
  opts = {:manager => "#{controller.to_s if controller.present?}", :theme => theme}
  # As using javascript_include_tag will malform js path
  tinymce_js = "<script type='text/javascript' src='#{tinymce_fm_engine.tinymce_combine_js_path(opts)}'></script>"
  scripts = [ javascript_include_tag('tinymce_fm/application.js'), 
              tinymce_js,
              stylesheet_link_tag('tinymce_fm/application.css')
            ].join("\n")
  raw scripts
end

#tinymce_tag(name, content = '', options = {}) ⇒ Object



14
15
16
17
# File 'app/helpers/tinymce_fm/application_helper.rb', line 14

def tinymce_tag name, content = '', options = {}
  append_class_name(options, 'tinymce_managed')
  text_area_tag(name, content, options)
end