Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
hacked up the fckeditor plugin so I can specify the ID attribute on t…
Browse files Browse the repository at this point in the history
…he textarea if it's bound to a resource
  • Loading branch information
James Cook committed Jan 12, 2009
1 parent 424fda9 commit 2fcd6f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Expand Up @@ -2,7 +2,6 @@ module Ansuz
module JAdams
class ContentSection < ActiveRecord::Base
before_save :set_default_content_section_type

CONTENT_SECTION_TYPES = ["FCKeditor", "Markdown", "Textile"]
has_settings
# Prevent bad things ™ from happening on initial rake db:migrate -james
Expand Down Expand Up @@ -71,6 +70,5 @@ def set_default_content_section_type
end
end
end

end
end
@@ -1,12 +1,12 @@
<% @content_section = plugin_module if local_assigns.include?(:plugin_module) %>
<% remote_form_for :content_section, @content_section, :url => admin_content_section_path(@content_section), :html => { :method => :put }, :before => fckeditor_before_js(:content_section, :contents), :success => "update_dropdown_for(#{@content_section.id})" do |f| -%>
<% remote_form_for :content_section, @content_section, :url => admin_content_section_path(@content_section), :html => { :method => :put }, :before => fckeditor_before_js(:content_section, :contents, :id => "fckeditor-contents"), :success => "update_dropdown_for(#{@content_section.id})" do |f| -%>
<label>Filter:</label>
<%= f.select "content_type", Ansuz::JAdams::ContentSection::CONTENT_SECTION_TYPES.collect{|x| [x,x] }, {}, :class => "selected-content-type" -%>
<br />
<%= f.text_area :contents, :id => "markdown-contents", :style => "display:none" -%><br />

<br />
<%= fckeditor_textarea(:content_section, :contents, :toolbarSet => 'Simple', :width => '100%', :height => '400px', :ajax => true) -%><br />
<%= fckeditor_textarea(:content_section, :contents, :toolbarSet => 'Simple', :width => '100%', :height => '400px', :ajax => true, :id => "fckeditor-contents") -%><br />
<table class='form-table'>
<%= form_row "Revision", rollback_dropdown(@content_section) %>
</table>
Expand Down Expand Up @@ -35,19 +35,29 @@
function handle_selected_content_type( selected_type)
{
var selected_value = selected_type.val();
var markdown_contents = jQuery("#markdown-contents");
var fckeditor_contents = jQuery("#fckeditor-contents");

switch( selected_value )
{
case "Markdown":
jQuery("iframe").hide();
jQuery("#markdown-contents").show();
markdown_contents.show();
// Prevent name overlap.
markdown_contents.attr("name", "content_section[contents]" );
fckeditor_contents.attr("name", "__content_section[contents]");
break;
case "Textile":
jQuery("iframe").hide();
jQuery("#markdown-contents").show();
markdown_contents.show();
markdown_contents.attr("name", "content_section[contents]" );
fckeditor_contents.attr("name", "__content_section[contents]");
break;
case "FCKeditor":
jQuery("iframe").show();
jQuery("#markdown-contents").hide();
markdown_contents.hide();
markdown_contents.attr("name", "__content_section[contents]" );
fckeditor_contents.attr("name", "content_section[contents]");
break;
}
}
Expand Down

0 comments on commit 2fcd6f9

Please sign in to comment.