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

Commit

Permalink
did some work on the form builder page plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Jan 18, 2009
1 parent 0209659 commit 436d193
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
29 changes: 29 additions & 0 deletions config/initializers/fckeditor_text_area_tag.rb
@@ -0,0 +1,29 @@
module Fckeditor
module Helper
def fckeditor_textarea_tag(name, value='', options={})
options[:id] ||= name
cols = options[:cols].nil? ? '' : "cols='"+options[:cols]+"'"
rows = options[:rows].nil? ? '' : "rows='"+options[:rows]+"'"

width = options[:width].nil? ? '100%' : options[:width]
height = options[:height].nil? ? '100%' : options[:height]

toolbarSet = options[:toolbarSet].nil? ? 'Default' : options[:toolbarSet]

if options[:ajax]
inputs = "<input type='hidden' id='#{options[:id]}_hidden' name='#{name}'>\n" <<
"<textarea class='#{options[:className]}' id='#{options[:id]}' #{cols} #{rows} name='#{options[:id]}'>#{value}</textarea>\n"
else
inputs = "<textarea class='#{options[:className]}' id='#{options[:id]}' #{cols} #{rows} name='#{name}'>#{value}</textarea>\n"
end

js_path = "#{ActionController::Base.relative_url_root}/javascripts"
base_path = "#{js_path}/fckeditor/"
return inputs <<
javascript_tag("jQuery(document).ready(function(){ var oFCKeditor = new FCKeditor('#{options[:id]}', '#{width}', '#{height}', '#{toolbarSet}');\n" <<
"oFCKeditor.BasePath = \"#{base_path}\"\n" <<
"oFCKeditor.Config['CustomConfigurationsPath'] = '#{js_path}/fckcustom.js';\n" <<
"oFCKeditor.ReplaceTextarea(); });\n")
end
end
end
Expand Up @@ -21,19 +21,20 @@ def new
end

def create
options = {:label => params[:label]}
# create the appropriate stuff...
case params[:type]
# TODO: Split this up and provide an API for other plugins to add form field types to the builder
when "Text Field"
@field = Ansuz::JAdams::FormFieldTextField.new
@field = Ansuz::JAdams::FormFieldTextField.new(options)
@form_field.form_builder_id = @form_builder.id
@form_field.field = @field
when "Text Area"
@field = Ansuz::JAdams::FormFieldTextArea.new
@field = Ansuz::JAdams::FormFieldTextArea.new(options)
@form_field.form_builder_id = @form_builder.id
@form_field.field = @field
when "Rich Text Area"
@field = Ansuz::JAdams::FormFieldTextArea.new
@field = Ansuz::JAdams::FormFieldTextArea.new(options)
@form_field.form_builder_id = @form_builder.id
@form_field.field = @field
@field.settings["has_rich_content_editor"] = true
Expand Down
@@ -1,3 +1,4 @@
# FIXME: The whole form builder should be built with inheritance, what the heck happened here?
module Ansuz
module JAdams
class FormFieldTextField < ActiveRecord::Base
Expand Down
@@ -1,6 +1,3 @@
<%= link_to famfamfam_icon("add") + " Add a field", new_admin_form_builder_form_field_path(plugin_module) %>
<br />

<table class='form-table'>
<% plugin_module.form_fields.each do |form_field| %>
<%
Expand All @@ -11,3 +8,5 @@
<%= render_form_field_builder_view(form_field, :locals => { :field => form_field, :admin_links => admin_links.join(" ") }) %>
<% end %>
</table>
<br />
<%= link_to "Add a field", new_admin_form_builder_form_field_path(plugin_module), :class => "icon button add" %>
Expand Up @@ -2,6 +2,7 @@
<% form_for :form_builder, :url => admin_form_builder_form_fields_path(@form_builder) do |f| %>
<table class='form-table'>
<%= form_row "Label", text_field_tag(:label) %>
<%= form_row "Type", select_tag(:type, options_for_select(["Text Field", "Text Area", "Rich Text Area"])) %>
<%= form_row "", submit_tag %>
</table>
Expand Down

0 comments on commit 436d193

Please sign in to comment.