├── .document ├── .gitignore ├── MIT-LICENSE ├── README.md ├── Rakefile ├── VERSION.yml ├── config └── locale │ └── en.yml ├── generators └── jintastic │ ├── USAGE │ ├── jintastic_generator.rb │ └── templates │ ├── _in_place_editor.html.erb │ └── jintastic.js ├── init.rb ├── jintastic.gemspec ├── lib └── jintastic.rb ├── test ├── jintastic_test.rb └── test_helper.rb └── vendor └── plugins └── formtastic ├── .gitignore ├── MIT-LICENSE ├── README.textile ├── RELEASE_PROCESS ├── Rakefile ├── VERSION.yml ├── formtastic.gemspec ├── generators ├── form │ ├── USAGE │ ├── form_generator.rb │ └── templates │ │ ├── view__form.html.erb │ │ └── view__form.html.haml ├── formtastic │ ├── formtastic_generator.rb │ └── templates │ │ ├── formtastic.css │ │ ├── formtastic_changes.css │ │ └── formtastic_config.rb └── formtastic_stylesheets │ └── formtastic_stylesheets_generator.rb ├── install.rb ├── lib ├── formtastic.rb ├── formtastic │ └── i18n.rb └── locale │ └── en.yml ├── rails └── init.rb ├── spec ├── buttons_spec.rb ├── commit_button_spec.rb ├── custom_builder_spec.rb ├── custom_macros.rb ├── defaults_spec.rb ├── error_proc_spec.rb ├── errors_spec.rb ├── form_helper_spec.rb ├── i18n_spec.rb ├── include_blank_spec.rb ├── input_spec.rb ├── inputs │ ├── boolean_input_spec.rb │ ├── check_boxes_input_spec.rb │ ├── country_input_spec.rb │ ├── date_input_spec.rb │ ├── datetime_input_spec.rb │ ├── file_input_spec.rb │ ├── hidden_input_spec.rb │ ├── numeric_input_spec.rb │ ├── password_input_spec.rb │ ├── radio_input_spec.rb │ ├── select_input_spec.rb │ ├── string_input_spec.rb │ ├── text_input_spec.rb │ ├── time_input_spec.rb │ └── time_zone_input_spec.rb ├── inputs_spec.rb ├── label_spec.rb ├── semantic_errors_spec.rb ├── semantic_fields_for_spec.rb ├── spec.opts └── spec_helper.rb └── uninstall.rb /.document: -------------------------------------------------------------------------------- 1 | README.rdoc 2 | lib/**/*.rb 3 | bin/* 4 | features/**/*.feature 5 | LICENSE 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.sw? 2 | .DS_Store 3 | coverage 4 | rdoc 5 | pkg 6 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 Nandor Komzak 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Jintastic 2 | 3 | Jintastic is a **j**Query based **in**-place editor generated by [Form**tastic**](http://github.com/justinfrench/formtastic/tree/master). 4 | 5 | ## Features 6 | 7 | * easy usage 8 | * you can reuse your partials and controller actions 9 | * you can edit more than one attribute at once 10 | * you can use nested resources 11 | 12 | ## Install 13 | 14 | **Gem** 15 | 16 | It’s hosted on Gemcutter, so you’ll need to set that up first, if you haven’t already: gem sources -a http://gemcutter.org/ 17 | 18 | sudo gem install jintastic 19 | 20 | Add Jintastic as a dependency in your environment.rb file: 21 | 22 | config.gem 'jintastic' 23 | 24 | **Plugin** 25 | 26 | script/plugin install git://github.com/rubymood/jintastic.git 27 | 28 | **After Jintastic gem or plugin installed generate jintastic assets** 29 | 30 | script/generate jintastic 31 | 32 | ## Usage 33 | 34 | Having downloaded jQuery(>=1.3.2) include jintastic in your template: 35 | 36 | <%= javascripts_include_tag 'jquery', 'jintastic' %> 37 | 38 | **Example** 39 | 40 | Let's say you have a bookmark resource and you have this haml files: 41 | 42 | # bookmarks/index.html.haml 43 | %ul 44 | = render @bookmarks 45 | 46 | # bookmarks/_bookmark.html.haml 47 | %li 48 | = bookmark.name 49 | 50 | # bookmarks/edit.html.haml 51 | -# with formtastic 52 | - semantic_form_for @bookmark do |f| 53 | -f.inputs 54 | = render :partial=>'form', :locals=>{:f=>f} 55 | = f.commit_button 56 | -# or with default form_for helper 57 | - form_for @bookmark do |f| 58 | = render :partial=>'form' 59 | = f.submit_tag 'Save' 60 | 61 | # bookmarks/_form.html.haml 62 | -# with formtastic 63 | = f.input :name 64 | = f.input :url 65 | -# or with default form_for helper 66 | = error_messages_for :bookmark 67 | = f.text_field :name 68 | = f.text_field :url 69 | 70 | This is simple. If you organize your views in this way you just follows the rails conventions. Now if you want to in-place editing a bookmark inside your index page just simply do one of the below: 71 | 72 | # bookmarks/_bookmark.html.haml 73 | %li{:id=>dom_id(bookmark)} # we are referencing the id later in a js file (see below) 74 | -# this shows name attribute, and if you click on it, you can edit it 75 | = in_place_editor_for bookmark, :name 76 | -# this shows name attribute, and if you click on it, it will show your bookmark form partial 77 | = in_place_editor_for bookmark, :name=>:form 78 | -# this shows name attribute, and if you click on it, it will show your custom form partial 79 | = in_place_editor_for bookmark, :name=>'bookmarks/custom_form' 80 | -# this shows name attribute, and if you click on it, you can edit both the name and url attributes 81 | = in_place_editor_for bookmark, :name=>[:name, :bookmark] 82 | -# so you can edit something else (this shows name attribute, but when you click on it, you will edit the url attribute) 83 | = in_place_editor_for bookmark, :name=>:url 84 | -# and finally, you can add nested resource 85 | = in_place_editor_for [:admin, bookmark], :name 86 | 87 | Inside your bookmark controller you have to make nothing new. The only thing you have to do is some javascript magic: 88 | 89 | # bookmarks/update.js.erb 90 | $('#<%= dom_id @bookmark %>').replaceWith('<%= escape_javascript render @bookmark %>') 91 | 92 | ## And finally, what happens at validation error? 93 | 94 | With formtastic input helper the validation errors will be displayed automatic. If you use rails default input helpers you could display the errors in your form partial (see above in the example). 95 | 96 | ## TODO 97 | 98 | * some options to customize in place editor form 99 | * make some tests 100 | 101 | Copyright (c) 2009 Nandor Komzak, released under the MIT license 102 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake' 3 | 4 | begin 5 | require 'jeweler' 6 | Jeweler::Tasks.new do |gem| 7 | gem.name = "jintastic" 8 | gem.summary = %Q{jQuery based in-place editor generated by Formtastic} 9 | gem.email = "nandor.komzak@gmail.com" 10 | gem.homepage = "http://github.com/rubymood/jintastic" 11 | gem.authors = ["Nandor Komzak"] 12 | gem.description = gem.summary 13 | gem.files.include FileList["{assets}/**/*"] 14 | gem.add_dependency("formtastic") 15 | gem.has_rdoc = false 16 | end 17 | Jeweler::GemcutterTasks.new 18 | rescue LoadError 19 | puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" 20 | end 21 | 22 | require 'rake/testtask' 23 | Rake::TestTask.new(:test) do |test| 24 | test.libs << 'lib' << 'test' 25 | test.pattern = 'test/**/*_test.rb' 26 | test.verbose = true 27 | end 28 | 29 | begin 30 | require 'rcov/rcovtask' 31 | Rcov::RcovTask.new do |test| 32 | test.libs << 'test' 33 | test.pattern = 'test/**/*_test.rb' 34 | test.verbose = true 35 | end 36 | rescue LoadError 37 | task :rcov do 38 | abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" 39 | end 40 | end 41 | 42 | 43 | task :default => :test 44 | 45 | require 'rake/rdoctask' 46 | Rake::RDocTask.new do |rdoc| 47 | if File.exist?('VERSION.yml') 48 | config = YAML.load(File.read('VERSION.yml')) 49 | version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}" 50 | else 51 | version = "" 52 | end 53 | 54 | rdoc.rdoc_dir = 'rdoc' 55 | rdoc.title = "jintastic #{version}" 56 | rdoc.rdoc_files.include('README*') 57 | rdoc.rdoc_files.include('lib/**/*.rb') 58 | end 59 | 60 | -------------------------------------------------------------------------------- /VERSION.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :build: 3 | :major: 1 4 | :minor: 1 5 | :patch: 0 6 | -------------------------------------------------------------------------------- /config/locale/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | formtastic: 3 | actions: 4 | cancel: Cancel 5 | -------------------------------------------------------------------------------- /generators/jintastic/USAGE: -------------------------------------------------------------------------------- 1 | NAME 2 | jintastic - Jintastic asset generator. 3 | 4 | DESCRIPTION 5 | Generates javascript and partial template files for Jintastic in your Rails project. 6 | 7 | EXAMPLE 8 | ./script/generate jintastic 9 | -------------------------------------------------------------------------------- /generators/jintastic/jintastic_generator.rb: -------------------------------------------------------------------------------- 1 | class JintasticGenerator < Rails::Generator::Base 2 | def manifest 3 | record do |m| 4 | m.directory File.join(%w[app views jintastic]) 5 | m.file "_in_place_editor.html.erb", File.join(%w[app views jintastic _in_place_editor.html.erb]) 6 | m.file "jintastic.js", File.join(%w[public javascripts jintastic.js]) 7 | end 8 | end 9 | 10 | protected 11 | 12 | def banner 13 | %{Usage: #{$0} #{spec.name}\nCopies jintastic.js to public/javascripts/ and a partial to app/views/jintastic/_in_place_editor.html.erb} 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /generators/jintastic/templates/_in_place_editor.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= content_tag container_tag, h(html_text), content_tag_options %> 3 | <% semantic_form_for path_spec_or_object, form_tag_options do |f| %> 4 | <% f.inputs do %> 5 | <% if input_attributes %> 6 | <% input_attributes.each do |attr| %> 7 | <%= f.input attr %> 8 | <% end %> 9 | <% else %> 10 | <%= render :partial=>form_partial, :locals=>{:f=>f} %> 11 | <% end %> 12 | <% end %> 13 | <%= f.commit_button :button_html => {:class => 'in_place_save', :style=>"float:left"} %> 14 | 'Cancel') %>' class='in_place_cancel' /> 15 | <% end %> 16 |
17 | -------------------------------------------------------------------------------- /generators/jintastic/templates/jintastic.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | $(function(){ 3 | $.inPlaceEditor = { 4 | toggle: function() { 5 | $([this.attribute, this.form]).toggle() 6 | 7 | if (this.form.is(':visible')) 8 | $.inPlaceEditor.form.find('fieldset li:nth-child(1)') 9 | } 10 | } 11 | 12 | $('.in_place_attribute').live('click', function() { 13 | $.inPlaceEditor.attribute = $(this) 14 | $.inPlaceEditor.form = $.inPlaceEditor.attribute.next() 15 | $.inPlaceEditor.toggle() 16 | }) 17 | 18 | $('.in_place_save').live('click', function() { 19 | form = $(this).parents('form') // return size always must be eql 1 20 | $.ajax({ 21 | url: form.attr('action'), 22 | type: "POST", 23 | dataType: "script", 24 | data: form.serializeArray() 25 | }) 26 | return false 27 | }) 28 | 29 | $('.in_place_cancel').live('click', function() { 30 | $.inPlaceEditor.form = $(this).parent('form') 31 | $.inPlaceEditor.attribute = $.inPlaceEditor.form.prev() 32 | $.inPlaceEditor.toggle() 33 | }) 34 | }) 35 | })(jQuery) 36 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | require File.join File.dirname(__FILE__), *%w{vendor plugins formtastic rails init} 2 | require 'jintastic' 3 | I18n.load_path.unshift File.join File.dirname(__FILE__), 'config', 'locale', 'en.yml' 4 | -------------------------------------------------------------------------------- /jintastic.gemspec: -------------------------------------------------------------------------------- 1 | # Generated by jeweler 2 | # DO NOT EDIT THIS FILE DIRECTLY 3 | # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command 4 | # -*- encoding: utf-8 -*- 5 | 6 | Gem::Specification.new do |s| 7 | s.name = %q{jintastic} 8 | s.version = "1.1.0" 9 | 10 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 11 | s.authors = ["Nandor Komzak"] 12 | s.date = %q{2010-02-19} 13 | s.description = %q{jQuery based in-place editor generated by Formtastic} 14 | s.email = %q{nandor.komzak@gmail.com} 15 | s.extra_rdoc_files = [ 16 | "README.md" 17 | ] 18 | s.files = [ 19 | ".document", 20 | ".gitignore", 21 | "MIT-LICENSE", 22 | "README.md", 23 | "Rakefile", 24 | "VERSION.yml", 25 | "config/locale/en.yml", 26 | "generators/jintastic/USAGE", 27 | "generators/jintastic/jintastic_generator.rb", 28 | "generators/jintastic/templates/_in_place_editor.html.erb", 29 | "generators/jintastic/templates/jintastic.js", 30 | "init.rb", 31 | "jintastic.gemspec", 32 | "lib/jintastic.rb", 33 | "test/jintastic_test.rb", 34 | "test/test_helper.rb", 35 | "vendor/plugins/formtastic/.gitignore", 36 | "vendor/plugins/formtastic/MIT-LICENSE", 37 | "vendor/plugins/formtastic/README.textile", 38 | "vendor/plugins/formtastic/RELEASE_PROCESS", 39 | "vendor/plugins/formtastic/Rakefile", 40 | "vendor/plugins/formtastic/VERSION.yml", 41 | "vendor/plugins/formtastic/formtastic.gemspec", 42 | "vendor/plugins/formtastic/generators/form/USAGE", 43 | "vendor/plugins/formtastic/generators/form/form_generator.rb", 44 | "vendor/plugins/formtastic/generators/form/templates/view__form.html.erb", 45 | "vendor/plugins/formtastic/generators/form/templates/view__form.html.haml", 46 | "vendor/plugins/formtastic/generators/formtastic/formtastic_generator.rb", 47 | "vendor/plugins/formtastic/generators/formtastic/templates/formtastic.css", 48 | "vendor/plugins/formtastic/generators/formtastic/templates/formtastic_changes.css", 49 | "vendor/plugins/formtastic/generators/formtastic/templates/formtastic_config.rb", 50 | "vendor/plugins/formtastic/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb", 51 | "vendor/plugins/formtastic/install.rb", 52 | "vendor/plugins/formtastic/lib/formtastic.rb", 53 | "vendor/plugins/formtastic/lib/formtastic/i18n.rb", 54 | "vendor/plugins/formtastic/lib/locale/en.yml", 55 | "vendor/plugins/formtastic/rails/init.rb", 56 | "vendor/plugins/formtastic/spec/buttons_spec.rb", 57 | "vendor/plugins/formtastic/spec/commit_button_spec.rb", 58 | "vendor/plugins/formtastic/spec/custom_builder_spec.rb", 59 | "vendor/plugins/formtastic/spec/custom_macros.rb", 60 | "vendor/plugins/formtastic/spec/defaults_spec.rb", 61 | "vendor/plugins/formtastic/spec/error_proc_spec.rb", 62 | "vendor/plugins/formtastic/spec/errors_spec.rb", 63 | "vendor/plugins/formtastic/spec/form_helper_spec.rb", 64 | "vendor/plugins/formtastic/spec/i18n_spec.rb", 65 | "vendor/plugins/formtastic/spec/include_blank_spec.rb", 66 | "vendor/plugins/formtastic/spec/input_spec.rb", 67 | "vendor/plugins/formtastic/spec/inputs/boolean_input_spec.rb", 68 | "vendor/plugins/formtastic/spec/inputs/check_boxes_input_spec.rb", 69 | "vendor/plugins/formtastic/spec/inputs/country_input_spec.rb", 70 | "vendor/plugins/formtastic/spec/inputs/date_input_spec.rb", 71 | "vendor/plugins/formtastic/spec/inputs/datetime_input_spec.rb", 72 | "vendor/plugins/formtastic/spec/inputs/file_input_spec.rb", 73 | "vendor/plugins/formtastic/spec/inputs/hidden_input_spec.rb", 74 | "vendor/plugins/formtastic/spec/inputs/numeric_input_spec.rb", 75 | "vendor/plugins/formtastic/spec/inputs/password_input_spec.rb", 76 | "vendor/plugins/formtastic/spec/inputs/radio_input_spec.rb", 77 | "vendor/plugins/formtastic/spec/inputs/select_input_spec.rb", 78 | "vendor/plugins/formtastic/spec/inputs/string_input_spec.rb", 79 | "vendor/plugins/formtastic/spec/inputs/text_input_spec.rb", 80 | "vendor/plugins/formtastic/spec/inputs/time_input_spec.rb", 81 | "vendor/plugins/formtastic/spec/inputs/time_zone_input_spec.rb", 82 | "vendor/plugins/formtastic/spec/inputs_spec.rb", 83 | "vendor/plugins/formtastic/spec/label_spec.rb", 84 | "vendor/plugins/formtastic/spec/semantic_errors_spec.rb", 85 | "vendor/plugins/formtastic/spec/semantic_fields_for_spec.rb", 86 | "vendor/plugins/formtastic/spec/spec.opts", 87 | "vendor/plugins/formtastic/spec/spec_helper.rb", 88 | "vendor/plugins/formtastic/uninstall.rb" 89 | ] 90 | s.homepage = %q{http://github.com/rubymood/jintastic} 91 | s.rdoc_options = ["--charset=UTF-8"] 92 | s.require_paths = ["lib"] 93 | s.rubygems_version = %q{1.3.5} 94 | s.summary = %q{jQuery based in-place editor generated by Formtastic} 95 | s.test_files = [ 96 | "test/test_helper.rb", 97 | "test/jintastic_test.rb" 98 | ] 99 | 100 | if s.respond_to? :specification_version then 101 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION 102 | s.specification_version = 3 103 | 104 | if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then 105 | s.add_runtime_dependency(%q, [">= 0"]) 106 | else 107 | s.add_dependency(%q, [">= 0"]) 108 | end 109 | else 110 | s.add_dependency(%q, [">= 0"]) 111 | end 112 | end 113 | 114 | -------------------------------------------------------------------------------- /lib/jintastic.rb: -------------------------------------------------------------------------------- 1 | require 'formtastic' 2 | 3 | class ActionView::Base 4 | def in_place_editor_for(path_spec_or_object, attributes, html_text = nil) 5 | instance = path_spec_or_object.kind_of?(Array) ? path_spec_or_object.last : path_spec_or_object 6 | 7 | if attributes.class==Symbol 8 | #simple one attribute in place editor 9 | #in_place_editor_for @user, :name 10 | attribute = attributes 11 | input_attributes = Array(attribute) 12 | 13 | elsif attributes.values.first==:form 14 | #render default form partial 15 | #in_place_editor_for @user, :name=>:form 16 | attribute = attributes.keys.first 17 | 18 | elsif attributes.values.first.class==String 19 | #render custom form partial 20 | #in_place_editor_for @user, :name=>'users/custom_form' 21 | attribute = attributes.keys.first 22 | form_partial = attributes[attribute] 23 | 24 | else 25 | #attribute is an array 26 | #in_place_editor_for @user, :name=>[:name,:address] 27 | attribute = attributes.keys.first 28 | input_attributes = attributes[attribute] 29 | end 30 | 31 | container_tag = instance.respond_to?(:column_for_attribute) ? 32 | instance.column_for_attribute(attribute).type == :text ? :pre : :span : :span 33 | 34 | form_tag_options = {} 35 | content_tag_options = {:class=>'in_place_attribute'} 36 | 37 | form_partial ||= "#{instance.class.to_s.downcase.pluralize}/form" unless input_attributes 38 | 39 | html_text ||= instance[attribute] 40 | 41 | if instance.valid? 42 | form_tag_options.merge!({:html=>{:style=>"display: none"}}) 43 | else 44 | content_tag_options.merge!({:style=>"display: none"}) 45 | end 46 | 47 | render :partial => 'jintastic/in_place_editor', 48 | :locals => {:container_tag=>container_tag, 49 | :input_attributes=>input_attributes, 50 | :path_spec_or_object=>path_spec_or_object, 51 | :html_text=>html_text, 52 | :content_tag_options=>content_tag_options, 53 | :form_tag_options=>form_tag_options, 54 | :form_partial=>form_partial} 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /test/jintastic_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class JintasticTest < Test::Unit::TestCase 4 | should "probably rename this file and start testing for real" do 5 | flunk "hey buddy, you should probably rename this file and start testing for real" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | 5 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) 6 | $LOAD_PATH.unshift(File.dirname(__FILE__)) 7 | require 'jintastic' 8 | 9 | class Test::Unit::TestCase 10 | end 11 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | coverage 3 | pkg 4 | *~ 5 | *watchr.rb 6 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 Justin French 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/README.textile: -------------------------------------------------------------------------------- 1 | h1. Formtastic 2 | 3 | Formtastic is a Rails FormBuilder DSL (with some other goodies) to make it far easier to create beautiful, semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications. 4 | 5 | h2. The Story 6 | 7 | One day, I finally had enough, so I opened up my text editor, and wrote a DSL for how I'd like to author forms: 8 | 9 |
 10 |   <% semantic_form_for @article do |form| %>
 11 | 
 12 |     <% form.inputs :name => "Basic" do %>
 13 |       <%= form.input :title %>
 14 |       <%= form.input :body %>
 15 |       <%= form.input :section %>
 16 |       <%= form.input :publication_state, :as => :radio %>
 17 |       <%= form.input :category %>
 18 |       <%= form.input :allow_comments, :label => "Allow commenting on this article" %>
 19 |     <% end %>
 20 | 
 21 |     <% form.inputs :name => "Advanced" do %>
 22 |       <%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
 23 |       <%= form.input :extract, :required => false %>
 24 |       <%= form.input :description, :required => false %>
 25 |       <%= form.input :url_title, :required => false %>
 26 |     <% end %>
 27 | 
 28 |     <% form.inputs :name => "Author", :for => :author do |author_form| %>
 29 |       <%= author_form.input :first_name %>
 30 |       <%= author_form.input :last_name %>
 31 |     <% end %>
 32 | 
 33 |     <% form.buttons do %>
 34 |       <%= form.commit_button %>
 35 |     <% end %>
 36 | 
 37 |   <% end %>
 38 | 
39 | 40 | I also wrote the accompanying HTML output I expected, favoring something very similar to the fieldsets, lists and other semantic elements Aaron Gustafson presented in "Learning to Love Forms":http://www.slideshare.net/AaronGustafson/learning-to-love-forms-web-directions-south-07, hacking together enough Ruby to prove it could be done. 41 | 42 | 43 | h2. It's better than _SomeOtherFormBuilder_ because... 44 | 45 | * it can handle @belongs_to@ associations (like Post belongs_to :author), rendering a select or set of radio inputs with choices from the parent model. 46 | * it can handle @has_many@ and @has_and_belongs_to_many@ associations (like: Post has_many :tags), rendering a multi-select with choices from the child models. 47 | * it's Rails 2.3-ready (including nested forms). 48 | * it has internationalization (I18n)! 49 | * it's _really_ quick to get started with a basic form in place (4 lines), then go back to add in more detail if you need it. 50 | * there's heaps of elements, id and class attributes for you to hook in your CSS and JS. 51 | * it handles real world stuff like inline hints, inline error messages & help text. 52 | * it doesn't hijack or change any of the standard Rails form inputs, so you can still use them as expected (even mix and match). 53 | * it's got absolutely awesome spec coverage. 54 | * there's a bunch of people using and working on it (it's not just one developer building half a solution). 55 | 56 | 57 | h2. Why? 58 | 59 | * web apps = lots of forms. 60 | * forms are so friggin' boring to code. 61 | * semantically rich & accessible forms really are possible. 62 | * the "V" is way behind the "M" and "C" in Rails' MVC – it's the ugly sibling. 63 | * best practices and common patterns have to start somewhere. 64 | * i need a challenge. 65 | 66 | 67 | h2. Opinions 68 | 69 | * it should be easier to do things the right way than the wrong way. 70 | * sometimes _more mark-up_ is better. 71 | * elements and attribute hooks are _gold_ for stylesheet authors. 72 | * make the common things we do easy, yet still ensure uncommon things are still possible. 73 | 74 | 75 | h2. Documentation 76 | 77 | RDoc documentation _should_ be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic. 78 | 79 | 80 | h2. Installation 81 | 82 | The gem is hosted on gemcutter, so *if you haven't already*, add it as a gem source: 83 | 84 |
 85 |   sudo gem sources -a http://gemcutter.org/
 86 | 
87 | 88 | Then install the Formtastic gem: 89 | 90 |
 91 |   sudo gem install formtastic
 92 | 
93 | 94 | And add it to your environment.rb configuration as a gem dependency: 95 | 96 |
 97 |   config.gem 'formtastic'
 98 | 
99 | 100 | Optionally, run @./script/generate formtastic@ to copy the following files into your app: 101 | 102 | * @config/initializers/formtastic_config.rb@ - a commented out Formtastic config initializer 103 | * @public/stylesheets/formtastic.css@ 104 | * @public/stylesheets/formtastic_changes.css@ 105 | 106 | A proof-of-concept stylesheet is provided which you can include in your layout. Customization is best achieved by overriding these styles in an additional stylesheet so that the Formtastic styles can be updated without clobbering your changes. If you want to use these stylesheets, add both to your layout: 107 | 108 |
109 |   <%= stylesheet_link_tag "formtastic" %>
110 |   <%= stylesheet_link_tag "formtastic_changes" %>
111 | 
112 | 113 | h2. Usage 114 | 115 | Forms are really boring to code... you want to get onto the good stuff as fast as possible. 116 | 117 | This renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord @belongs_to@-association), followed by a submit button: 118 | 119 |
120 |   <% semantic_form_for @user do |form| %>
121 |     <%= form.inputs %>
122 |     <%= form.buttons %>
123 |   <% end %>
124 | 
125 | 126 | If you want to specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't detect, you can pass in a list of field names to @inputs@ and list of button names to @buttons@: 127 | 128 |
129 |   <% semantic_form_for @user do |form| %>
130 |     <%= form.inputs :title, :body, :section, :categories, :created_at %>
131 |     <%= form.buttons :commit %>
132 |   <% end %>
133 | 
134 | 135 | If you want control over the input type Formtastic uses for each field, you can expand the @inputs@ and @buttons@ blocks. This specifies the @:section@ input should be a set of radio buttons (rather than the default select box), and that the @:created_at@ field should be a string (rather than the default datetime selects): 136 | 137 |
138 |   <% semantic_form_for @post do |form| %>
139 |     <% form.inputs do %>
140 |       <%= form.input :title %>
141 |       <%= form.input :body %>
142 |       <%= form.input :section, :as => :radio %>
143 |       <%= form.input :categories %>
144 |       <%= form.input :created_at, :as => :string %>
145 |     <% end %>
146 |     <% form.buttons do %>
147 |       <%= form.commit_button %>
148 |     <% end %>
149 |   <% end %>
150 | 
151 | 152 | If you want to customize the label text, or render some hint text below the field, specify which fields are required/optional, or break the form into two fieldsets, the DSL is pretty comprehensive: 153 | 154 |
155 |   <% semantic_form_for @post do |form| %>
156 |     <% form.inputs "Basic", :id => "basic" do %>
157 |       <%= form.input :title %>
158 |       <%= form.input :body %>
159 |     <% end %>
160 |     <% form.inputs :name => "Advanced Options", :id => "advanced" do %>
161 |       <%= form.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
162 |       <%= form.input :section, :as => :radio %>
163 |       <%= form.input :user, :label => "Author", :label_method => :full_name,  %>
164 |       <%= form.input :categories, :required => false %>
165 |       <%= form.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
166 |     <% end %>
167 |     <% form.buttons do %>
168 |       <%= form.commit_button %>
169 |     <% end %>
170 |   <% end %>
171 | 
172 | 173 | Nested forms (Rails 2.3) are also supported. You can do it in the Rails way: 174 | 175 |
176 |   <% semantic_form_for @post do |form| %>
177 |     <%= form.inputs :title, :body, :created_at %>
178 |     <% form.semantic_fields_for :author do |author| %>
179 |       <%= author.inputs :first_name, :last_name, :name => "Author" %>
180 |     <% end %>
181 |     <%= form.buttons %>
182 |   <% end %>
183 | 
184 | 185 | Or the Formtastic way with the @:for@ option: 186 | 187 |
188 |   <% semantic_form_for @post do |form| %>
189 |     <%= form.inputs :title, :body, :created_at %>
190 |     <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
191 |     <%= form.buttons %>
192 |   <% end %>
193 | 
194 | 195 | When working in has many association, you can even supply @"%i"@ in your fieldset name that it will be properly interpolated with the child index. For example: 196 | 197 |
198 |   <% semantic_form_for @post do |form| %>
199 |     <%= form.inputs %>
200 |     <%= form.inputs :name => 'Category #%i', :for => :categories %>
201 |     <%= form.buttons %>
202 |   <% end %>
203 | 
204 | 205 | 206 | Customize HTML attributes for any input using the @:input_html@ option. Typically his is used to disable the input, change the size of a text field, change the rows in a textarea, or even to add a special class to an input to attach special behavior like "autogrow":http://plugins.jquery.com/project/autogrow textareas: 207 | 208 |
209 |   <% semantic_form_for @post do |form| %>
210 |     <%= form.input :title,      :input_html => { :size => 60 } %>
211 |     <%= form.input :body,       :input_html => { :class => 'autogrow' } %>
212 |     <%= form.input :created_at, :input_html => { :disabled => true } %>
213 |     <%= form.buttons %>
214 |   <% end %>
215 | 
216 | 217 | The same can be done for buttons with the @:button_html@ option: 218 | 219 |
220 |   <% semantic_form_for @post do |form| %>
221 |     ...
222 |     <% form.buttons do %>
223 |       <%= form.commit_button :button_html => { :class => "primary" } %>
224 |     <% end %>
225 |   <% end %>
226 | 
227 | 228 | Customize the HTML attributes for the @
  • @ wrapper around every input with the @:wrapper_html@ option hash. There's one special key in the hash (@:class@), which will actually _append_ your string of classes to the existing classes provided by Formtastic (like @"required string error"@) 229 | 230 |
    231 |   <% semantic_form_for @post do |form| %>
    232 |     <%= form.input :title, :wrapper_html => { :class => "important" } %>
    233 |     <%= form.input :body %>
    234 |     <%= form.input :description, :wrapper_html => { :style => "display:none;" } %>
    235 |     ...
    236 |   <% end %>
    237 | 
    238 | 239 | 240 | h2. The Available Inputs 241 | 242 | The Formtastic input types: 243 | 244 | * @:select@ - a select menu. Default for ActiveRecord associations: @belongs_to@, @has_many@, and @has_and_belongs_to_many@. 245 | * @:check_boxes@ - a set of check_box inputs. Alternative to @:select@ for ActiveRecord-associations: @has_many@, and @has_and_belongs_to_many@. 246 | * @:radio@ - a set of radio inputs. Alternative to @:select@ for ActiveRecord-associations: @belongs_to@. 247 | * @:time_zone@ - a select input. Default for column types: @:string@ with name matching @"time_zone"@. 248 | * @:password@ - a password input. Default for column types: @:string@ with name matching @"password"@. 249 | * @:text@ - a textarea. Default for column types: @:text@. 250 | * @:date@ - a date select. Default for column types: @:date@. 251 | * @:datetime@ - a date and time select. Default for column types: @:datetime@ and @:timestamp@. 252 | * @:time@ - a time select. Default for column types: @:time@. 253 | * @:boolean@ - a checkbox. Default for column types: @:boolean@. 254 | * @:string@ - a text field. Default for column types: @:string@. 255 | * @:numeric@ - a text field (just like string). Default for column types: @:integer@, @:float@, and @:decimal@. 256 | * @:file@ - a file field. Default for file-attachment attributes matching: "paperclip":http://github.com/thoughtbot/paperclip or "attachment_fu":http://github.com/technoweenie/attachment_fu. 257 | * @:country@ - a select menu of country names. Default for column types: :string with name @"country"@ - requires a *country_select* plugin to be installed. 258 | * @:hidden@ - a hidden field. Creates a hidden field (added for compatibility). 259 | 260 | The documentation is pretty good for each of these (what it does, what the output is, what the options are, etc.) so go check it out. 261 | 262 | h2. Delegation for label lookups 263 | 264 | Formtastic decides which label to use in the following order: 265 | 266 |
    267 |   1. :label             # :label => "Choose Title"
    268 |   2. Formtastic i18n    # if either :label => true || i18n_lookups_by_default = true (see Internationalization)
    269 |   3. Activerecord i18n  # if localization file found for the given attribute
    270 |   4. label_str_method   # if nothing provided this defaults to :humanize but can be set to a custom method 
    271 | 
    272 | 273 | h2. Internationalization (I18n) 274 | 275 | h3. Basic Localization 276 | 277 | Formtastic got some neat I18n-features. ActiveRecord object names and attributes are, by default, taken from calling @@object.human_name@ and @@object.human_attribute_name(attr)@ respectively. There are a few words specific to Formtastic that can be translated. See @lib/locale/en.yml@ for more information. 278 | 279 | Basic localization (labels only, with ActiveRecord): 280 | 281 |
    282 |   <% semantic_form_for @post do |form| %>
    283 |     <%= form.input :title %>        # => :label => I18n.t('activerecord.attributes.user.title')    or 'Title'
    284 |     <%= form.input :body %>         # => :label => I18n.t('activerecord.attributes.user.body')     or 'Body'
    285 |     <%= form.input :section %>      # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
    286 |   <% end %>
    287 | 
    288 | 289 | *Note:* This is perfectly fine if you just want your labels/attributes and/or models to be translated using *ActiveRecord I18n attribute translations*, and you don't use input hints and legends. But what if you do? And what if you don't want same labels in all forms? 290 | 291 | h3. Enhanced Localization (Formtastic I18n API) 292 | 293 | Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the I18n API for more advanced usage. Your forms can now be DRYer and more flexible than ever, and still fully localized. This is how: 294 | 295 | *1. Enable I18n lookups by default (@config/initializers/formtastic.rb@):* 296 | 297 |
    298 |   Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
    299 | 
    300 | 301 | *2. Add some cool label-translations/variants (@config/locale/en.yml@):* 302 | 303 |
    304 |   en:
    305 |     formtastic:
    306 |       titles:
    307 |         post_details: "Post details"
    308 |       labels:
    309 |         post:
    310 |           title: "Choose a title..."
    311 |           body: "Write something..."
    312 |           edit:
    313 |             title: "Edit title"
    314 |       hints:
    315 |         post:
    316 |           title: "Choose a good title for you post."
    317 |           body: "Write something inspiring here."
    318 |       actions:
    319 |         create: "Create my {{model}}"
    320 |         update: "Save changes"
    321 |         dummie: "Launch!"
    322 | 
    323 | 324 | *Note:* We are using English here still, but you get the point. 325 | 326 | *3. ...and now you'll get:* 327 | 328 |
    329 |   <% semantic_form_for Post.new do |form| %>
    330 |     <% form.inputs do %>
    331 |       <%= form.input :title %>      # => :label => "Choose a title...", :hint => "Choose a good title for you post."
    332 |       <%= form.input :body %>       # => :label => "Write something...", :hint => "Write something inspiring here."
    333 |       <%= form.input :section %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
    334 |     <% end %>
    335 |     <% form.buttons do %>
    336 |       <%= form.commit_button %>     # => "Create my {{model}}"
    337 |     <% end %>
    338 |   <% end %>
    339 | 
    340 | 341 | *4. Localized titles (a.k.a. legends):* 342 | 343 | _Note: Slightly different because Formtastic can't guess how you group fields in a form. Legend text can be set with first (as in the sample below) specified value, or :name/:title options - depending on what flavor is preferred._ 344 | 345 |
    346 |   <% semantic_form_for @post do |form| %>
    347 |     <% form.inputs :post_details do %>   # => :title => "Post details"
    348 |       # ...
    349 |     <% end %>
    350 |     # ...
    351 | <% end %>
    352 | 
    353 | 354 | *5. Override I18n settings:* 355 | 356 |
    357 |   <% semantic_form_for @post do |form| %>
    358 |     <% form.inputs do %>
    359 |       <%= form.input :title %>      # => :label => "Choose a title...", :hint => "Choose a good title for you post."
    360 |       <%= form.input :body, :hint => false %>                 # => :label => "Write something..."
    361 |       <%= form.input :section, :label => 'Some section' %>    # => :label => 'Some section'
    362 |     <% end %>
    363 |     <% form.buttons do %>
    364 |       <%= form.commit_button :dummie %>     # => "Launch!"
    365 |     <% end %>
    366 |   <% end %>
    367 | 
    368 | 369 | If I18n-lookups is disabled, i.e.: 370 | 371 |
    372 |   Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
    373 | 
    374 | 375 | ...then you can enable I18n within the forms instead: 376 | 377 |
    378 |   <% semantic_form_for @post do |form| %>
    379 |     <% form.inputs do %>
    380 |       <%= form.input :title, :label => true %>      # => :label => "Choose a title..."
    381 |       <%= form.input :body, :label => true %>       # => :label => "Write something..."
    382 |       <%= form.input :section, :label => true %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
    383 |     <% end %>
    384 |     <% form.buttons do %>
    385 |       <%= form.commit_button true %>                # => "Save changes" (if we are in edit that is...)
    386 |     <% end %>
    387 |   <% end %>
    388 | 
    389 | 390 | *6. Advanced I18n lookups* 391 | 392 | For more flexible forms; Formtastic find translations using a bottom-up approach taking the following variables in account: 393 | 394 | * @MODEL@, e.g. "post" 395 | * @ACTION@, e.g. "edit" 396 | * @KEY/ATTRIBUTE@, e.g. "title", :my_custom_key, ... 397 | 398 | ...in the following order: 399 | 400 | 1. @formtastic.{titles,labels,hints,actions}.MODEL.ACTION.ATTRIBUTE@ - by model and action 401 | 2. @formtastic.{titles,labels,hints,actions}.MODEL.ATTRIBUTE@ - by model 402 | 3. @formtastic.{titles,labels,hints,actions}.ATTRIBUTE@ - global default 403 | 404 | ...which means that you can define translations like this: 405 | 406 |
    407 |   en:
    408 |     formtastic:
    409 |       labels:
    410 |         title: "Title"  # Default global value
    411 |         article:
    412 |           body: "Article content"
    413 |         post:
    414 |           new:
    415 |             title: "Choose a title..."
    416 |             body: "Write something..."
    417 |           edit:
    418 |             title: "Edit title"
    419 |             body: "Edit body"
    420 | 
    421 | 422 | Values for @labels@/@hints@/@actions@ are can take values: @String@ (explicit value), @Symbol@ (i18n-lookup-key relative to the current "type", e.g. actions:), @true@ (force I18n lookup), @false@ (force no I18n lookup). Titles (legends) can only take: @String@ and @Symbol@ - true/false have no meaning. 423 | 424 | 425 | h2. Semantic errors 426 | 427 | You can show errors on base (by default) and any other attribute just passing it name to semantic_errors method: 428 | 429 |
    430 |   <% semantic_form_for @post do |form| %>
    431 |     <%= form.semantic_errors :state %>
    432 |   <% end %>
    433 | 
    434 | 435 | 436 | h2. ValidationReflection plugin 437 | 438 | If you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin installed, you won't have to specify the @:required@ option (it checks the validations on the model instead). 439 | 440 | 441 | h2. Configuration 442 | 443 | Run @./script/generate formtastic@ to copy a commented out config file into @config/initializers/formtastic.rb@. You can "view the configuration file on GitHub":http://github.com/justinfrench/formtastic/blob/master/generators/formtastic/templates/formtastic.rb 444 | 445 | 446 | h2. Form Generator 447 | 448 | There's a Formtastic form code generator to make your transition to Formtastic easier. All you have to do is to *specify an existing model name*, and optionally specify view template framework (ERB/HAML), and you are good to go. *Note:* This won't overwrite any of you stuff. This is how you use it: 449 | 450 | *Alt. 1: Generate in terminal:* 451 | 452 |
    453 | $ ./script/generate form Post
    454 | # ---------------------------------------------------------
    455 | #  GENERATED FORMTASTIC CODE
    456 | # ---------------------------------------------------------
    457 | 
    458 | <% f.inputs do %>
    459 |   <%= f.input :title, :label => 'Title' %>
    460 |   <%= f.input :body, :label => 'Body' %>
    461 |   <%= f.input :published, :label => 'Published' %>
    462 | <% end %>
    463 | 
    464 | # ---------------------------------------------------------
    465 |  Copied to clipboard - just paste it!
    466 | 
    467 | 468 | *Alt. 2: Generate partial:* 469 | 470 |
    471 | $ ./script/generate form Post --partial
    472 |       exists  app/views/posts
    473 |       create  app/views/posts/_form.html.erb
    474 | 
    475 | 476 | To generate *HAML* markup, just add the @--haml@ as argument: 477 | 478 |
    479 | $ ./script/generate form Post --haml
    480 |       exists  app/views/admin/posts
    481 |       create  app/views/admin/posts/_form.html.haml
    482 | 
    483 | 484 | To specify the controller in a namespace (eg admin/posts instead of posts), use the --controller argument: 485 | 486 |
    487 | $ ./script/generate form Post --partial --controller admin/posts
    488 |       exists  app/views/admin/posts
    489 |       create  app/views/admin/posts/_form.html.erb
    490 | 
    491 | 492 | 493 | h2. Custom Inputs 494 | 495 | If you want to add your own input types to encapsulate your own logic or interface patterns, you can do so by subclassing SemanticFormBuilder and configuring Formtastic to use your custom builder class. 496 | 497 | @Formtastic::SemanticFormHelper.builder = MyCustomBuilder@ 498 | 499 | 500 | 501 | 502 | h2. Status 503 | 504 | Formtastic has been in active development for about a year. We've just recently jumped to an 0.9 version number, signaling that we consider this a 1.0 release candidate, and that the API won't change significantly for the 1.x series. 505 | 506 | 507 | h2. Dependencies 508 | 509 | There are none, but... 510 | 511 | * if you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin is installed, you won't have to specify the @:required@ option (it checks the validations on the model instead). 512 | * if you want to use the @:country@ input, you'll need to install the "iso-3166-country-select plugin":http://github.com/rails/iso-3166-country-select (or any other country_select plugin with the same API). 513 | * "rspec":http://github.com/dchelimsky/rspec/, "rspec_hpricot_matchers":http://rubyforge.org/projects/rspec-hpricot/ and "rcov":http://github.com/relevance/rcov gems (plus any of their own dependencies) are required for the test suite. 514 | 515 | 516 | h2. Compatibility 517 | 518 | I'm only testing Formtastic with the latest Rails 2.4.x stable release, and it should be fine under Rails 2.3.x as well (including nested forms). Patches are welcome to allow backwards compatibility, but I don't have the energy! 519 | 520 | h2. Got TextMate? 521 | 522 | Well...there's a TextMate-bundle in town, dedicated to make usage of Formtastic in the "TextMate":http://macromates.com/ editor even more of a breeze: 523 | 524 | "Formtastic.tmbundle":http://github.com/grimen/formtastic_tmbundle 525 | 526 | 527 | h2. How to contribute 528 | 529 | *Before you send a pull request*, please ensure that you provide appropriate spec/test coverage and ensure the documentation is up-to-date. Bonus points if you perform your changes in a clean topic branch rather than master. 530 | 531 | Please also keep your commits *atomic* so that they are more likely to apply cleanly. That means that each commit should contain the smallest possible logical change. Don't commit two features at once, don't update the gemspec at the same time you add a feature, don't fix a whole bunch of whitespace in a file at the same time you change a few lines, etc, etc. 532 | 533 | For significant changes, you may wish to discuss your idea on the Formtastic Google group before coding to ensure that your change is likely to be accepted. Formtastic relies heavily on i18n, so if you're unsure of the impact this has on your changes, please discuss them with the group. 534 | 535 | 536 | h2. Maintainers & Contributors 537 | 538 | Formtastic is maintained by "Justin French":http://justinfrench.com, "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen, but it wouldn't be as awesome as it is today without help from over 40 contributors. 539 | 540 | @git shortlog -n -s --no-merges@ 541 | 542 | 543 | h2. Google Group 544 | 545 | Please join the "Formtastic Google Group":http://groups.google.com.au/group/formtastic, especially if you'd like to talk about a new feature, or report a bug. 546 | 547 | 548 | h2. Project Info 549 | 550 | Formtastic is hosted on Github: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic, where your contributions, forkings, comments and feedback are greatly welcomed. 551 | 552 | 553 | Copyright (c) 2007-2008 Justin French, released under the MIT license. 554 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/RELEASE_PROCESS: -------------------------------------------------------------------------------- 1 | git status # check you have a clean working directory 2 | rake version:bump:minor # or patch or major, commits the change 3 | rake gemspec # to generate the new gemspec file 4 | git add formtastic.gemspec # stage changes 5 | git commit -am "new gemspec" # commit and describe the reason for the new gem 6 | git tag -am "0.2.3" 0.2.3 # tag the new version in the code base too 7 | git log 0.2.2..0.2.3 # check the log since last tag 8 | gem build formtastic.gemspec # build the gem 9 | gem push formtastic-0.2.3.gem # publish the gem 10 | git push # push to github 11 | git push --tags # push the tags up to remote too 12 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/Rakefile: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | require 'rake' 3 | require 'rake/rdoctask' 4 | 5 | begin 6 | require 'spec/rake/spectask' 7 | rescue LoadError 8 | begin 9 | gem 'rspec-rails', '>= 1.0.0' 10 | require 'spec/rake/spectask' 11 | rescue LoadError 12 | puts "[formtastic:] RSpec - or one of it's dependencies - is not available. Install it with: sudo gem install rspec-rails" 13 | end 14 | end 15 | 16 | begin 17 | GEM = "formtastic" 18 | AUTHOR = "Justin French" 19 | EMAIL = "justin@indent.com.au" 20 | SUMMARY = "A Rails form builder plugin/gem with semantically rich and accessible markup" 21 | HOMEPAGE = "http://github.com/justinfrench/formtastic/tree/master" 22 | INSTALL_MESSAGE = %q{ 23 | ======================================================================== 24 | Thanks for installing Formtastic! 25 | ------------------------------------------------------------------------ 26 | You can now (optionally) run the generator to copy some stylesheets and 27 | a config initializer into your application: 28 | ./script/generate formtastic 29 | 30 | To generate some semantic form markup for your exisiting models, just run: 31 | ./script/generate form MODEL_NAME 32 | 33 | Find out more and get involved: 34 | http://github.com/justinfrench/formtastic 35 | http://groups.google.com.au/group/formtastic 36 | ======================================================================== 37 | } 38 | 39 | gem 'jeweler', '>= 1.0.0' 40 | require 'jeweler' 41 | 42 | Jeweler::Tasks.new do |s| 43 | s.name = GEM 44 | s.summary = SUMMARY 45 | s.email = EMAIL 46 | s.homepage = HOMEPAGE 47 | s.description = SUMMARY 48 | s.author = AUTHOR 49 | s.post_install_message = INSTALL_MESSAGE 50 | 51 | s.require_path = 'lib' 52 | s.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob("{rails,lib,generators,spec}/**/*") 53 | 54 | # Runtime dependencies: When installing Formtastic these will be checked if they are installed. 55 | # Will be offered to install these if they are not already installed. 56 | s.add_dependency 'activesupport', '>= 2.3.0' 57 | s.add_dependency 'actionpack', '>= 2.3.0' 58 | 59 | # Development dependencies. Not installed by default. 60 | # Install with: sudo gem install formtastic --development 61 | s.add_development_dependency 'rspec-rails', '>= 1.2.6' 62 | s.add_development_dependency 'rspec_tag_matchers', '>= 1.0.0' 63 | end 64 | 65 | Jeweler::GemcutterTasks.new 66 | rescue LoadError 67 | puts "[formtastic:] Jeweler - or one of its dependencies - is not available. Install it with: sudo gem install jeweler -s http://gemcutter.org" 68 | end 69 | 70 | desc 'Default: run unit specs.' 71 | task :default => :spec 72 | 73 | desc 'Generate documentation for the formtastic plugin.' 74 | Rake::RDocTask.new(:rdoc) do |rdoc| 75 | rdoc.rdoc_dir = 'rdoc' 76 | rdoc.title = 'Formtastic' 77 | rdoc.options << '--line-numbers' << '--inline-source' 78 | rdoc.rdoc_files.include('README.textile') 79 | rdoc.rdoc_files.include('lib/**/*.rb') 80 | end 81 | 82 | if defined?(Spec) 83 | desc 'Test the formtastic plugin.' 84 | Spec::Rake::SpecTask.new('spec') do |t| 85 | t.spec_files = FileList['spec/**/*_spec.rb'] 86 | t.spec_opts = ["-c"] 87 | end 88 | 89 | desc 'Test the formtastic plugin with specdoc formatting and colors' 90 | Spec::Rake::SpecTask.new('specdoc') do |t| 91 | t.spec_files = FileList['spec/**/*_spec.rb'] 92 | t.spec_opts = ["--format specdoc", "-c"] 93 | end 94 | 95 | desc "Run all examples with RCov" 96 | Spec::Rake::SpecTask.new('examples_with_rcov') do |t| 97 | t.spec_files = FileList['spec/**/*_spec.rb'] 98 | t.rcov = true 99 | t.rcov_opts = ['--exclude', 'spec,Library'] 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/VERSION.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :minor: 9 3 | :patch: 7 4 | :major: 0 5 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/formtastic.gemspec: -------------------------------------------------------------------------------- 1 | # Generated by jeweler 2 | # DO NOT EDIT THIS FILE 3 | # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` 4 | # -*- encoding: utf-8 -*- 5 | 6 | Gem::Specification.new do |s| 7 | s.name = %q{formtastic} 8 | s.version = "0.9.7" 9 | 10 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 11 | s.authors = ["Justin French"] 12 | s.date = %q{2009-12-04} 13 | s.description = %q{A Rails form builder plugin/gem with semantically rich and accessible markup} 14 | s.email = %q{justin@indent.com.au} 15 | s.extra_rdoc_files = [ 16 | "README.textile" 17 | ] 18 | s.files = [ 19 | "MIT-LICENSE", 20 | "README.textile", 21 | "Rakefile", 22 | "generators/form/USAGE", 23 | "generators/form/form_generator.rb", 24 | "generators/form/templates/view__form.html.erb", 25 | "generators/form/templates/view__form.html.haml", 26 | "generators/formtastic/formtastic_generator.rb", 27 | "generators/formtastic/templates/formtastic.css", 28 | "generators/formtastic/templates/formtastic.rb", 29 | "generators/formtastic/templates/formtastic_changes.css", 30 | "generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb", 31 | "lib/formtastic.rb", 32 | "lib/formtastic/i18n.rb", 33 | "lib/locale/en.yml", 34 | "rails/init.rb", 35 | "spec/buttons_spec.rb", 36 | "spec/commit_button_spec.rb", 37 | "spec/custom_builder_spec.rb", 38 | "spec/custom_macros.rb", 39 | "spec/defaults_spec.rb", 40 | "spec/error_proc_spec.rb", 41 | "spec/errors_spec.rb", 42 | "spec/form_helper_spec.rb", 43 | "spec/i18n_spec.rb", 44 | "spec/include_blank_spec.rb", 45 | "spec/input_spec.rb", 46 | "spec/inputs/boolean_input_spec.rb", 47 | "spec/inputs/check_boxes_input_spec.rb", 48 | "spec/inputs/country_input_spec.rb", 49 | "spec/inputs/date_input_spec.rb", 50 | "spec/inputs/datetime_input_spec.rb", 51 | "spec/inputs/file_input_spec.rb", 52 | "spec/inputs/hidden_input_spec.rb", 53 | "spec/inputs/numeric_input_spec.rb", 54 | "spec/inputs/password_input_spec.rb", 55 | "spec/inputs/radio_input_spec.rb", 56 | "spec/inputs/select_input_spec.rb", 57 | "spec/inputs/string_input_spec.rb", 58 | "spec/inputs/text_input_spec.rb", 59 | "spec/inputs/time_input_spec.rb", 60 | "spec/inputs/time_zone_input_spec.rb", 61 | "spec/inputs_spec.rb", 62 | "spec/label_spec.rb", 63 | "spec/semantic_fields_for_spec.rb", 64 | "spec/spec.opts", 65 | "spec/spec_helper.rb" 66 | ] 67 | s.homepage = %q{http://github.com/justinfrench/formtastic/tree/master} 68 | s.post_install_message = %q{ 69 | ======================================================================== 70 | Thanks for installing Formtastic! 71 | ------------------------------------------------------------------------ 72 | You can now (optionally) run the generator to copy some stylesheets and 73 | a config initializer into your application: 74 | ./script/generate formtastic 75 | 76 | To generate some semantic form markup for your exisiting models, just run: 77 | ./script/generate form MODEL_NAME 78 | 79 | Find out more and get involved: 80 | http://github.com/justinfrench/formtastic 81 | http://groups.google.com.au/group/formtastic 82 | ======================================================================== 83 | } 84 | s.rdoc_options = ["--charset=UTF-8"] 85 | s.require_paths = ["lib"] 86 | s.rubygems_version = %q{1.3.5} 87 | s.summary = %q{A Rails form builder plugin/gem with semantically rich and accessible markup} 88 | s.test_files = [ 89 | "spec/buttons_spec.rb", 90 | "spec/commit_button_spec.rb", 91 | "spec/custom_builder_spec.rb", 92 | "spec/custom_macros.rb", 93 | "spec/defaults_spec.rb", 94 | "spec/error_proc_spec.rb", 95 | "spec/errors_spec.rb", 96 | "spec/form_helper_spec.rb", 97 | "spec/i18n_spec.rb", 98 | "spec/include_blank_spec.rb", 99 | "spec/input_spec.rb", 100 | "spec/inputs/boolean_input_spec.rb", 101 | "spec/inputs/check_boxes_input_spec.rb", 102 | "spec/inputs/country_input_spec.rb", 103 | "spec/inputs/date_input_spec.rb", 104 | "spec/inputs/datetime_input_spec.rb", 105 | "spec/inputs/file_input_spec.rb", 106 | "spec/inputs/hidden_input_spec.rb", 107 | "spec/inputs/numeric_input_spec.rb", 108 | "spec/inputs/password_input_spec.rb", 109 | "spec/inputs/radio_input_spec.rb", 110 | "spec/inputs/select_input_spec.rb", 111 | "spec/inputs/string_input_spec.rb", 112 | "spec/inputs/text_input_spec.rb", 113 | "spec/inputs/time_input_spec.rb", 114 | "spec/inputs/time_zone_input_spec.rb", 115 | "spec/inputs_spec.rb", 116 | "spec/label_spec.rb", 117 | "spec/semantic_fields_for_spec.rb", 118 | "spec/spec_helper.rb" 119 | ] 120 | 121 | if s.respond_to? :specification_version then 122 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION 123 | s.specification_version = 3 124 | 125 | if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then 126 | s.add_runtime_dependency(%q, [">= 2.3.0"]) 127 | s.add_runtime_dependency(%q, [">= 2.3.0"]) 128 | s.add_development_dependency(%q, [">= 1.2.6"]) 129 | s.add_development_dependency(%q, [">= 1.0.0"]) 130 | else 131 | s.add_dependency(%q, [">= 2.3.0"]) 132 | s.add_dependency(%q, [">= 2.3.0"]) 133 | s.add_dependency(%q, [">= 1.2.6"]) 134 | s.add_dependency(%q, [">= 1.0.0"]) 135 | end 136 | else 137 | s.add_dependency(%q, [">= 2.3.0"]) 138 | s.add_dependency(%q, [">= 2.3.0"]) 139 | s.add_dependency(%q, [">= 1.2.6"]) 140 | s.add_dependency(%q, [">= 1.0.0"]) 141 | end 142 | end 143 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/form/USAGE: -------------------------------------------------------------------------------- 1 | NAME 2 | form - Formtastic form generator. 3 | 4 | DESCRIPTION 5 | Generates formtastic form code based on an existing model. By default the generated code will be printed out directly in the terminal, and also copied to clipboard. Can optionally be saved into partial directly. 6 | 7 | Required: 8 | ExistingModelName - The name of an existing model for which the generator should generate form code. 9 | 10 | Options: 11 | --haml Generate HAML instead of ERB. 12 | --partial Generate a form partial in the model views path, i.e. "_form.html.erb" or _form.html.haml". 13 | --controller PATH Generate for custom controller/view path - in case model and controller namespace is different, i.e. "admin/posts". 14 | 15 | EXAMPLE 16 | ./script/generate form ExistingModelName [--haml] [--partial] -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/form/form_generator.rb: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | # Get current OS - needed for clipboard functionality 3 | case RUBY_PLATFORM 4 | when /darwin/ then 5 | CURRENT_OS = :osx 6 | when /win32/ 7 | CURRENT_OS = :win 8 | begin 9 | require 'win32/clipboard' 10 | rescue LoadError 11 | # Do nothing 12 | end 13 | else 14 | CURRENT_OS = :x 15 | end 16 | 17 | class FormGenerator < Rails::Generator::NamedBase 18 | 19 | default_options :haml => false, 20 | :partial => false 21 | 22 | VIEWS_PATH = File.join('app', 'views').freeze 23 | IGNORED_COLUMNS = [:updated_at, :created_at].freeze 24 | 25 | attr_reader :controller_file_name, 26 | :controller_class_path, 27 | :controller_class_nesting, 28 | :controller_class_nesting_depth, 29 | :controller_class_name, 30 | :template_type 31 | 32 | def initialize(runtime_args, runtime_options = {}) 33 | super 34 | base_name, @controller_class_path = extract_modules(@name.pluralize) 35 | controller_class_name_without_nesting, @controller_file_name = inflect_names(base_name) 36 | @template_type = options[:haml] ? :haml : :erb 37 | end 38 | 39 | def manifest 40 | record do |m| 41 | if options[:partial] 42 | controller_and_view_path = options[:controller] || File.join(controller_class_path, controller_file_name) 43 | # Ensure directory exists. 44 | m.directory File.join(VIEWS_PATH, controller_and_view_path) 45 | # Create a form partial for the model as "_form" in it's views path. 46 | m.template "view__form.html.#{template_type}", File.join(VIEWS_PATH, controller_and_view_path, "_form.html.#{template_type}") 47 | else 48 | # Load template file, and render without saving to file 49 | template = File.read(File.join(source_root, "view__form.html.#{template_type}")) 50 | erb = ERB.new(template, nil, '-') 51 | generated_code = erb.result(binding).strip rescue nil 52 | 53 | # Print the result, and copy to clipboard 54 | puts "# ---------------------------------------------------------" 55 | puts "# GENERATED FORMTASTIC CODE" 56 | puts "# ---------------------------------------------------------" 57 | puts 58 | puts generated_code || " Nothing could be generated - model exists?" 59 | puts 60 | puts "# ---------------------------------------------------------" 61 | puts " Copied to clipboard - just paste it!" if save_to_clipboard(generated_code) 62 | end 63 | end 64 | end 65 | 66 | protected 67 | 68 | # Save to lipboard with multiple OS support. 69 | def save_to_clipboard(data) 70 | return unless data 71 | begin 72 | case CURRENT_OS 73 | when :osx 74 | `echo "#{data}" | pbcopy` 75 | when :win 76 | ::Win32::Clipboard.data = data 77 | else # :linux/:unix 78 | `echo "#{data}" | xsel --clipboard` || `echo "#{data}" | xclip` 79 | end 80 | rescue 81 | false 82 | else 83 | true 84 | end 85 | end 86 | 87 | # Add additional model attributes if specified in args - probably not that common scenario. 88 | def attributes 89 | # Get columns for the requested model. 90 | existing_attributes = @class_name.constantize.content_columns.reject { |column| IGNORED_COLUMNS.include?(column.name.to_sym) } 91 | @args = super + existing_attributes 92 | end 93 | 94 | def add_options!(opt) 95 | opt.separator '' 96 | opt.separator 'Options:' 97 | 98 | # Allow option to generate HAML views instead of ERB. 99 | opt.on('--haml', 100 | "Generate HAML output instead of the default ERB.") do |v| 101 | options[:haml] = v 102 | end 103 | 104 | # Allow option to generate to partial in model's views path, instead of printing out in terminal. 105 | opt.on('--partial', 106 | "Save generated output directly to a form partial (app/views/{resource}/_form.html.*).") do |v| 107 | options[:partial] = v 108 | end 109 | 110 | opt.on('--controller CONTROLLER_PATH', 111 | "Specify a non-standard controller for the specified model (e.g. admin/posts).") do |v| 112 | options[:controller] = v if v.present? 113 | end 114 | end 115 | 116 | def banner 117 | "Usage: #{$0} form ExistingModelName [--haml] [--partial]" 118 | end 119 | 120 | end -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/form/templates/view__form.html.erb: -------------------------------------------------------------------------------- 1 | <%% f.inputs do %> 2 | <% attributes.each do |attribute| -%> 3 | <%%= f.input :<%= attribute.name %>, :label => '<%= attribute.name.humanize %>' %> 4 | <% end -%> 5 | <%% end %> -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/form/templates/view__form.html.haml: -------------------------------------------------------------------------------- 1 | - f.inputs do 2 | <% attributes.each do |attribute| -%> 3 | = f.input :<%= attribute.name %>, :label => '<%= attribute.name.humanize %>' 4 | <% end -%> -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/formtastic/formtastic_generator.rb: -------------------------------------------------------------------------------- 1 | class FormtasticGenerator < Rails::Generator::Base 2 | 3 | def initialize(*runtime_args) 4 | super 5 | end 6 | 7 | def manifest 8 | record do |m| 9 | m.directory File.join('config', 'initializers') 10 | m.template 'formtastic_config.rb', File.join('config', 'initializers', 'formtastic_config.rb') 11 | 12 | m.directory File.join('public', 'stylesheets') 13 | m.template 'formtastic.css', File.join('public', 'stylesheets', 'formtastic.css') 14 | m.template 'formtastic_changes.css', File.join('public', 'stylesheets', 'formtastic_changes.css') 15 | end 16 | end 17 | 18 | protected 19 | 20 | def banner 21 | %{Usage: #{$0} #{spec.name}\nCopies formtastic.css and formtastic_changes.css to public/stylesheets/ and a config initializer to config/initializers/formtastic_config.rb} 22 | end 23 | 24 | end -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/formtastic/templates/formtastic.css: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------------------------------------- 2 | 3 | It's *strongly* suggested that you don't modify this file. Instead, load a new stylesheet after 4 | this one in your layouts (eg formtastic_changes.css) and override the styles to suit your needs. 5 | This will allow you to update formtastic.css with new releases without clobbering your own changes. 6 | 7 | This stylesheet forms part of the Formtastic Rails Plugin 8 | (c) 2008 Justin French 9 | 10 | --------------------------------------------------------------------------------------------------*/ 11 | 12 | 13 | /* NORMALIZE AND RESET - obviously inspired by Yahoo's reset.css, but scoped to just form.formtastic 14 | --------------------------------------------------------------------------------------------------*/ 15 | form.formtastic, form.formtastic ul, form.formtastic ol, form.formtastic li, form.formtastic fieldset, form.formtastic legend, form.formtastic input, form.formtastic textarea, form.formtastic select, form.formtastic p { margin:0; padding:0; } 16 | form.formtastic fieldset { border:0; } 17 | form.formtastic em, form.formtastic strong { font-style:normal; font-weight:normal; } 18 | form.formtastic ol, form.formtastic ul { list-style:none; } 19 | form.formtastic abbr, form.formtastic acronym { border:0; font-variant:normal; } 20 | form.formtastic input, form.formtastic textarea, form.formtastic select { font-family:inherit; font-size:inherit; font-weight:inherit; } 21 | form.formtastic input, form.formtastic textarea, form.formtastic select { font-size:100%; } 22 | form.formtastic legend { color:#000; } 23 | 24 | 25 | /* SEMANTIC ERRORS 26 | --------------------------------------------------------------------------------------------------*/ 27 | form.formtastic ul.errors { color:#cc0000; margin:0.5em 0 1.5em 25%; list-style:square; } 28 | form.formtastic ul.errors li { padding:0; border:none; display:list-item; } 29 | 30 | 31 | /* FIELDSETS & LISTS 32 | --------------------------------------------------------------------------------------------------*/ 33 | form.formtastic fieldset { } 34 | form.formtastic fieldset.inputs { } 35 | form.formtastic fieldset.buttons { padding-left:25%; } 36 | form.formtastic fieldset ol { } 37 | form.formtastic fieldset.buttons li { float:left; padding-right:0.5em; } 38 | 39 | /* clearfixing the fieldsets */ 40 | form.formtastic fieldset { display: inline-block; } 41 | form.formtastic fieldset:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } 42 | html[xmlns] form.formtastic fieldset { display: block; } 43 | * html form.formtastic fieldset { height: 1%; } 44 | 45 | 46 | /* INPUT LIs 47 | --------------------------------------------------------------------------------------------------*/ 48 | form.formtastic fieldset ol li { margin-bottom:1.5em; } 49 | 50 | /* clearfixing the li's */ 51 | form.formtastic fieldset ol li { display: inline-block; } 52 | form.formtastic fieldset ol li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } 53 | html[xmlns] form.formtastic fieldset ol li { display: block; } 54 | * html form.formtastic fieldset ol li { height: 1%; } 55 | 56 | form.formtastic fieldset ol li.required { } 57 | form.formtastic fieldset ol li.optional { } 58 | form.formtastic fieldset ol li.error { } 59 | 60 | 61 | /* LABELS 62 | --------------------------------------------------------------------------------------------------*/ 63 | form.formtastic fieldset ol li label { display:block; width:25%; float:left; padding-top:.2em; } 64 | form.formtastic fieldset ol li li label { line-height:100%; padding-top:0; } 65 | form.formtastic fieldset ol li li label input { line-height:100%; vertical-align:middle; margin-top:-0.1em;} 66 | 67 | 68 | /* NESTED FIELDSETS AND LEGENDS (radio, check boxes and date/time inputs use nested fieldsets) 69 | --------------------------------------------------------------------------------------------------*/ 70 | form.formtastic fieldset ol li fieldset { position:relative; } 71 | form.formtastic fieldset ol li fieldset legend { position:absolute; width:25%; padding-top:0.1em; } 72 | form.formtastic fieldset ol li fieldset legend span { position:absolute; } 73 | form.formtastic fieldset ol li fieldset legend.label label { position:absolute; } 74 | form.formtastic fieldset ol li fieldset ol { float:left; width:74%; margin:0; padding:0 0 0 25%; } 75 | form.formtastic fieldset ol li fieldset ol li { padding:0; border:0; } 76 | 77 | 78 | /* INLINE HINTS 79 | --------------------------------------------------------------------------------------------------*/ 80 | form.formtastic fieldset ol li p.inline-hints { color:#666; margin:0.5em 0 0 25%; } 81 | 82 | 83 | /* INLINE ERRORS 84 | --------------------------------------------------------------------------------------------------*/ 85 | form.formtastic fieldset ol li p.inline-errors { color:#cc0000; margin:0.5em 0 0 25%; } 86 | form.formtastic fieldset ol li ul.errors { color:#cc0000; margin:0.5em 0 0 25%; list-style:square; } 87 | form.formtastic fieldset ol li ul.errors li { padding:0; border:none; display:list-item; } 88 | 89 | 90 | /* STRING & NUMERIC OVERRIDES 91 | --------------------------------------------------------------------------------------------------*/ 92 | form.formtastic fieldset ol li.string input { width:74%; } 93 | form.formtastic fieldset ol li.password input { width:74%; } 94 | form.formtastic fieldset ol li.numeric input { width:74%; } 95 | 96 | 97 | /* TEXTAREA OVERRIDES 98 | --------------------------------------------------------------------------------------------------*/ 99 | form.formtastic fieldset ol li.text textarea { width:74%; } 100 | 101 | 102 | /* HIDDEN OVERRIDES 103 | --------------------------------------------------------------------------------------------------*/ 104 | form.formtastic fieldset ol li.hidden { display:none; } 105 | 106 | 107 | /* BOOLEAN OVERRIDES 108 | --------------------------------------------------------------------------------------------------*/ 109 | form.formtastic fieldset ol li.boolean label { padding-left:25%; width:auto; } 110 | form.formtastic fieldset ol li.boolean label input { margin:0 0.5em 0 0.2em; } 111 | 112 | 113 | /* RADIO OVERRIDES 114 | --------------------------------------------------------------------------------------------------*/ 115 | form.formtastic fieldset ol li.radio { } 116 | form.formtastic fieldset ol li.radio fieldset ol { margin-bottom:-0.6em; } 117 | form.formtastic fieldset ol li.radio fieldset ol li { margin:0.1em 0 0.5em 0; } 118 | form.formtastic fieldset ol li.radio fieldset ol li label { float:none; width:100%; } 119 | form.formtastic fieldset ol li.radio fieldset ol li label input { margin-right:0.2em; } 120 | 121 | 122 | /* CHECK BOXES (COLLECTION) OVERRIDES 123 | --------------------------------------------------------------------------------------------------*/ 124 | form.formtastic fieldset ol li.check_boxes { } 125 | form.formtastic fieldset ol li.check_boxes fieldset ol { margin-bottom:-0.6em; } 126 | form.formtastic fieldset ol li.check_boxes fieldset ol li { margin:0.1em 0 0.5em 0; } 127 | form.formtastic fieldset ol li.check_boxes fieldset ol li label { float:none; width:100%; } 128 | form.formtastic fieldset ol li.check_boxes fieldset ol li label input { margin-right:0.2em; } 129 | 130 | 131 | 132 | /* DATE & TIME OVERRIDES 133 | --------------------------------------------------------------------------------------------------*/ 134 | form.formtastic fieldset ol li.date fieldset ol li, 135 | form.formtastic fieldset ol li.time fieldset ol li, 136 | form.formtastic fieldset ol li.datetime fieldset ol li { float:left; width:auto; margin:0 .3em 0 0; } 137 | 138 | form.formtastic fieldset ol li.date fieldset ol li label, 139 | form.formtastic fieldset ol li.time fieldset ol li label, 140 | form.formtastic fieldset ol li.datetime fieldset ol li label { display:none; } 141 | 142 | form.formtastic fieldset ol li.date fieldset ol li label input, 143 | form.formtastic fieldset ol li.time fieldset ol li label input, 144 | form.formtastic fieldset ol li.datetime fieldset ol li label input { display:inline; margin:0; padding:0; } 145 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/formtastic/templates/formtastic_changes.css: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------------------------------------- 2 | 3 | Load this stylesheet after formtastic.css in your layouts to override the CSS to suit your needs. 4 | This will allow you to update formtastic.css with new releases without clobbering your own changes. 5 | 6 | For example, to make the inline hint paragraphs a little darker in color than the standard #666: 7 | 8 | form.formtastic fieldset ol li p.inline-hints { color:#333; } 9 | 10 | --------------------------------------------------------------------------------------------------*/ 11 | -------------------------------------------------------------------------------- /vendor/plugins/formtastic/generators/formtastic/templates/formtastic_config.rb: -------------------------------------------------------------------------------- 1 | # Set the default text field size when input is a string. Default is 50. 2 | # Formtastic::SemanticFormBuilder.default_text_field_size = 50 3 | 4 | # Set the default text area height when input is a text. Default is 20. 5 | # Formtastic::SemanticFormBuilder.default_text_area_height = 5 6 | 7 | # Should all fields be considered "required" by default? 8 | # Defaults to true, see ValidationReflection notes below. 9 | # Formtastic::SemanticFormBuilder.all_fields_required_by_default = true 10 | 11 | # Should select fields have a blank option/prompt by default? 12 | # Defaults to true. 13 | # Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true 14 | 15 | # Set the string that will be appended to the labels/fieldsets which are required 16 | # It accepts string or procs and the default is a localized version of 17 | # '*'. In other words, if you configure formtastic.required 18 | # in your locale, it will replace the abbr title properly. But if you don't want to use 19 | # abbr tag, you can simply give a string as below 20 | # Formtastic::SemanticFormBuilder.required_string = "(required)" 21 | 22 | # Set the string that will be appended to the labels/fieldsets which are optional 23 | # Defaults to an empty string ("") and also accepts procs (see required_string above) 24 | # Formtastic::SemanticFormBuilder.optional_string = "(optional)" 25 | 26 | # Set the way inline errors will be displayed. 27 | # Defaults to :sentence, valid options are :sentence, :list and :none 28 | # Formtastic::SemanticFormBuilder.inline_errors = :sentence 29 | 30 | # Set the method to call on label text to transform or format it for human-friendly 31 | # reading when formtastic is user without object. Defaults to :humanize. 32 | # Formtastic::SemanticFormBuilder.label_str_method = :humanize 33 | 34 | # Set the array of methods to try calling on parent objects in :select and :radio inputs 35 | # for the text inside each @