Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added in tinymce support

  • Loading branch information...
commit 5a34643b9732cb8c2232a3dec4fdaf07bc209508 1 parent db6b852
@rovermicrover rovermicrover authored
View
53 app/assets/javascripts/rails_admin/ra.widgets.coffee
@@ -134,16 +134,45 @@ $(document).live 'rails_admin.dom_ready', ->
window.CKEDITOR.replace(this, options['options'])
$(this).addClass('ckeditored')
- array = $('form [data-richtext=ckeditor]').not('.ckeditored')
- if array.length
- @array = array
+ arrayck = $('form [data-richtext=ckeditor]').not('.ckeditored')
+ if arrayck.length
+ @arrayck = arrayck
if not window.CKEDITOR
- options = $(array[0]).data('options')
+ options = $(arrayck[0]).data('options')
window.CKEDITOR_BASEPATH = options['base_location']
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
- goCkeditors(@array)
+ goCkeditors(@arrayck)
else
- goCkeditors(@array)
+ goCkeditors(@arrayck)
+
+ #tinymce
+
+ gotinyMCE = (array) =>
+ array.each (index, domEle) ->
+ options = $(this).data('options')
+ tinyMCE.init(jQuery.extend({
+ mode : "exact",
+ elements : $(this).attr("id")
+ }, options))
+ $(this).addClass('tinymced')
+
+
+ arraytmc = $('form [data-richtext=tinymce]').not('.tinymced')
+ if arraytmc.length
+ @arraytmc = arraytmc
+ if not window.tinyMCE
+ options = $(arraytmc[0]).data('options')
+ window.tinyMCEPreInit = {
+ base: options['base'],
+ theme: options['theme'],
+ suffix: '',
+ mode: "specific_textareas"
+ }
+ $.getScript options['jspath'], (script, textStatus, jqXHR) =>
+ $.getScript options['jqpath'], (script, textStatus, jqXHR) =>
+ gotinyMCE(@arraytmc)
+ else
+ gotinyMCE(@arraytmc)
#codemirror
@@ -156,14 +185,14 @@ $(document).live 'rails_admin.dom_ready', ->
CodeMirror.fromTextArea(textarea,{mode:options['options']['mode'],theme:options['options']['theme']})
$(textarea).addClass('codemirrored')
- array = $('form [data-richtext=codemirror]').not('.codemirrored')
- if array.length
- @array = array
+ arraycm = $('form [data-richtext=codemirror]').not('.codemirrored')
+ if arraycm.length
+ @arraycm = arraycm
if not window.CodeMirror
- options = $(array[0]).data('options')
+ options = $(arraycm[0]).data('options')
$('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">')
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
- goCodeMirrors(@array)
+ goCodeMirrors(@arraycm)
else
- goCodeMirrors(@array)
+ goCodeMirrors(@arraycm)
View
9 app/views/rails_admin/main/_form_text.html.haml
@@ -16,6 +16,15 @@
:options => field.codemirror_config,
:locations => field.codemirror_assets
}
+ elsif field.tinymce
+ richtext = 'tinymce'
+ js_data = {
+ :jspath => field.tinymce_js_location,
+ :jqpath => field.tinymce_jquery_location,
+ :theme => field.tinymce_theme_options,
+ :base => field.tinymce_base_location,
+ :options => field.tinymce_options
+ }
else
richtext = false
js_data = {}
View
25 lib/rails_admin/config/fields/types/text.rb
@@ -67,6 +67,31 @@ class Text < RailsAdmin::Config::Fields::Base
}
end
+ # TinyMCE is disabled by default
+ 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
+
register_instance_option(:partial) do
:form_text
end
Please sign in to comment.
Something went wrong with that request. Please try again.