Module: TinyMCE::Helpers
- Defined in:
- lib/tiny_mce/helpers.rb
Overview
The helper module we include into ActionController::Base
Instance Method Summary collapse
-
#include_tiny_mce_if_needed(options = {}, raw_options = nil) ⇒ Object
Form a JS include tag for the TinyMCE JS src, and form the raw JS and wrap in in a <script> tag for inclusion in the <head> for inclusion in the <head> (only if tiny mce is actually being used).
-
#include_tiny_mce_js ⇒ Object
Form a JS include tag for the TinyMCE JS src for inclusion in the <head>.
-
#include_tiny_mce_js_if_needed ⇒ Object
Form a JS include tag for the TinyMCE JS src for inclusion in the <head> (only if tiny mce is actually being used).
-
#raw_tiny_mce_init(options = {}, raw_options = nil) ⇒ Object
Parse @tiny_mce_options and @raw_tiny_mce_options to create a raw JS string used by TinyMCE.
-
#tiny_mce_init(options = {}, raw_options = nil) ⇒ Object
Form the raw JS and wrap in in a <script> tag for inclusion in the <head>.
-
#tiny_mce_init_if_needed(options = {}, raw_options = nil) ⇒ Object
Form the raw JS and wrap in in a <script> tag for inclusion in the <head> (only if tiny mce is actually being used).
-
#using_tiny_mce? ⇒ Boolean
Has uses_tiny_mce method been declared in the controller for this page?.
Instance Method Details
#include_tiny_mce_if_needed(options = {}, raw_options = nil) ⇒ Object
Form a JS include tag for the TinyMCE JS src, and form the raw JS and wrap in in a <script> tag for inclusion in the <head> for inclusion in the <head> (only if tiny mce is actually being used)
49 50 51 52 53 |
# File 'lib/tiny_mce/helpers.rb', line 49 def include_tiny_mce_if_needed( = {}, = nil) if using_tiny_mce? include_tiny_mce_js + tiny_mce_init(, ) end end |
#include_tiny_mce_js ⇒ Object
Form a JS include tag for the TinyMCE JS src for inclusion in the <head>
37 38 39 |
# File 'lib/tiny_mce/helpers.rb', line 37 def include_tiny_mce_js javascript_include_tag (Rails.env.to_s == 'development' ? "tiny_mce/tiny_mce_src" : "tiny_mce/tiny_mce") end |
#include_tiny_mce_js_if_needed ⇒ Object
Form a JS include tag for the TinyMCE JS src for inclusion in the <head> (only if tiny mce is actually being used)
42 43 44 |
# File 'lib/tiny_mce/helpers.rb', line 42 def include_tiny_mce_js_if_needed include_tiny_mce_js if using_tiny_mce? end |
#raw_tiny_mce_init(options = {}, raw_options = nil) ⇒ Object
Parse @tiny_mce_options and @raw_tiny_mce_options to create a raw JS string used by TinyMCE. Returns errors if the option or options type is invalid
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tiny_mce/helpers.rb', line 12 def raw_tiny_mce_init( = {}, = nil) tinymce_js = "" @tiny_mce_configurations ||= [Configuration.new] @tiny_mce_configurations.each do |configuration| configuration.(, ) tinymce_js += "tinyMCE.init(" tinymce_js += configuration.to_json tinymce_js += ");" end tinymce_js end |
#tiny_mce_init(options = {}, raw_options = nil) ⇒ Object
Form the raw JS and wrap in in a <script> tag for inclusion in the <head>
27 28 29 |
# File 'lib/tiny_mce/helpers.rb', line 27 def tiny_mce_init( = {}, = nil) javascript_tag raw_tiny_mce_init(, ) end |
#tiny_mce_init_if_needed(options = {}, raw_options = nil) ⇒ Object
Form the raw JS and wrap in in a <script> tag for inclusion in the <head> (only if tiny mce is actually being used)
32 33 34 |
# File 'lib/tiny_mce/helpers.rb', line 32 def tiny_mce_init_if_needed( = {}, = nil) tiny_mce_init(, ) if using_tiny_mce? end |
#using_tiny_mce? ⇒ Boolean
Has uses_tiny_mce method been declared in the controller for this page?
6 7 8 |
# File 'lib/tiny_mce/helpers.rb', line 6 def using_tiny_mce? !@uses_tiny_mce.blank? end |