sferik/rails_admin — pull request #1231 by rovermicrover (2012-07-01 04:10:35+00:00)
Title: Added in tinymce support

Added in TinyMCE support. Tested with the tinymce-rails gem.

The set up is very simliar to how code-mirror works.

The only major difference is the defaults have to be set like bellow.

```coffee
window.tinyMCEPreInit = {
base: options['base'],
theme: options['theme'],
suffix: '',
mode: "specific_textareas"
}
```

Also because the jquery version is loaded, two different scripts must be loaded, with the second as a call back, and then the load events as yet another call back for the second script load.

```coffee
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
$.getScript options['jqpath'], (script, textStatus, jqXHR) =>
gotinyMCE(@arraytmc)
```

The options are as follows

```ruby
register_instance_option(:tinymce) do
false
end

register_instance_option(:tinymce_js_location) do
"/assets/tinymce/tiny_mce_jquery_src.js"
end

register_instance_option(:tinymce_jquery_location) do
"/assets/tinymce/jquery.tinymce.js"
end

register_instance_option(:tinymce_theme_options) do
"advanced"
end

register_instance_option(:tinymce_options) do
{}
end

register_instance_option(:tinymce_base_location) do
'/assets/tinymce'
end
```
The theme option is really just the default theme option, and once again because the jquery version is being used two scripts must be loaded, so there are two options for script location.

From what I have been able to test everything seems to work fine, but about every 10th load or so TinyMCE will just refuse to load. I tried forcing a wait to make sure it wasn't an issue with TinyMCE getting called before all the corresponding files where loaded, even with the nested callbacks. But I wasn't able to find the root cause of the issue.

I hope this helps, and let me know if anything is explained poorly or you have any questions.

PS: I also changed the array variable name for each of the editor setups in the coffee script, just to make things clearer.