From 3a54464f7556a9600044b80fd032d20c80f42582 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 26 Sep 2007 21:42:42 +0000 Subject: [PATCH] ActionItem64: finishing with fckeditor. --- app/helpers/application_helper.rb | 19 +++++++++++++++++-- app/views/cms/_form.rhtml | 4 ++-- public/javascripts/fck-custom-styles.xml | 17 +++++++++++++++++ public/javascripts/fckcustom.js | 13 +++++++------ 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 public/javascripts/fck-custom-styles.xml diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a316749..2014723 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -195,8 +195,23 @@ module ApplicationHelper end end - def rich_text_editor(object, method, options = {}) - fckeditor_textarea(object, method, options.merge({:toolbarSet => 'Simple', :height => '300px'})) + def text_editor(object, method, filter_type_method, options = {}) + filter_type = instance_variable_get("@#{object}").send(filter_type_method) + if filter_type == '[No Filter]' || filter_type.blank? + fckeditor_textarea(object, method, options.merge({:toolbarSet => 'Simple', :height => '300px'})) + else + text_area(object, method, { :rows => 12, :columns => 72 }.merge(options)) + end + end + + def select_filter_type(object, method, html_options) + options = [ + [ _('No Filter at all'), '[No Filter]' ], + [ _('RDoc filter'), 'RDoc' ], + [ _('Simple'), 'Simple' ], + [ _('Textile'), 'Textile' ] + ] + select_tag "#{object}[#{method}]", options_for_select(options, @page.filter_type || Comatose.config.default_filter), { :id=> "#{object}_#{method}" }.merge(html_options) end end diff --git a/app/views/cms/_form.rhtml b/app/views/cms/_form.rhtml index 54fbe91..e287008 100644 --- a/app/views/cms/_form.rhtml +++ b/app/views/cms/_form.rhtml @@ -32,13 +32,13 @@
- <%= f.text_area :body, :rows => 14, :tabindex => 2 %> + <%= text_editor('page', 'body', 'filter_type', :tabindex => 2) %>
<% if show_field? 'filter' %> - <%= select_tag 'page[filter_type]', options_for_select(TextFilters.all_titles.sort, @page.filter_type || Comatose.config.default_filter), :tabindex=>3, :id=>'page_filter_type' %> + <%= select_filter_type('page', 'filter_type', :tabindex => 3 ) %> <%= _('Converts plain text into HTML') %> <% end %>
diff --git a/public/javascripts/fck-custom-styles.xml b/public/javascripts/fck-custom-styles.xml new file mode 100644 index 0000000..f9d9663 --- /dev/null +++ b/public/javascripts/fck-custom-styles.xml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/public/javascripts/fckcustom.js b/public/javascripts/fckcustom.js index 2c6e0ee..03ec1a8 100644 --- a/public/javascripts/fckcustom.js +++ b/public/javascripts/fckcustom.js @@ -16,15 +16,16 @@ FCKConfig.SpellChecker = 'SpellerPages'; FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/'; FCKConfig.ToolbarSets["Simple"] = [ - ['Source','-','-','Templates'], - ['Cut','Copy','Paste','PasteWord','-','Print','SpellCheck'], - ['Undo','Redo','-','Find','Replace','-','SelectAll'], + ['Source','-','Templates'], + ['Cut','Copy','Paste','PasteWord','-','Print'], + ['Undo','Redo','-','Find','Replace', 'Style'], '/', - ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], - ['OrderedList','UnorderedList','-','Outdent','Indent'], + ['Bold','Italic','Underline','StrikeThrough'], + ['OrderedList','UnorderedList'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink'], - '/', ['Image','Table','Rule','Smiley'], ['-','About'] ] ; + +FCKConfig.StylesXmlPath = FCKConfig.EditorPath + '../fck-custom-styles.xml' ; -- libgit2 0.21.2