Permalink
Browse files

Strip whitespaces

  • Loading branch information...
1 parent 1e41762 commit 4347a852a52cf6b51c8e16555a10786a6b822412 @sobrinho sobrinho committed Feb 25, 2011
Showing with 385 additions and 385 deletions.
  1. +7 −7 CHANGELOG
  2. +8 −8 lib/formtastic/form_builder.rb
  3. +25 −25 lib/formtastic/helpers/buttons_helper.rb
  4. +13 −13 lib/formtastic/helpers/errors_helper.rb
  5. +8 −8 lib/formtastic/helpers/fieldset_wrapper.rb
  6. +2 −2 lib/formtastic/helpers/file_column_detection.rb
  7. +21 −21 lib/formtastic/helpers/form_helper.rb
  8. +68 −68 lib/formtastic/helpers/inputs_helper.rb
  9. +14 −14 lib/formtastic/helpers/label_helper.rb
  10. +5 −5 lib/formtastic/html_attributes.rb
  11. +15 −15 lib/formtastic/inputs/base.rb
  12. +11 −11 lib/formtastic/inputs/basic.rb
  13. +7 −7 lib/formtastic/inputs/boolean_input.rb
  14. +22 −22 lib/formtastic/inputs/check_boxes_input.rb
  15. +10 −10 lib/formtastic/inputs/country_input.rb
  16. +4 −4 lib/formtastic/inputs/email_input.rb
  17. +4 −4 lib/formtastic/inputs/file_input.rb
  18. +5 −5 lib/formtastic/inputs/hidden_input.rb
  19. +4 −4 lib/formtastic/inputs/numeric_input.rb
  20. +4 −4 lib/formtastic/inputs/password_input.rb
  21. +3 −3 lib/formtastic/inputs/phone_input.rb
  22. +26 −26 lib/formtastic/inputs/radio_input.rb
  23. +4 −4 lib/formtastic/inputs/search_input.rb
  24. +35 −35 lib/formtastic/inputs/select_input.rb
  25. +2 −2 lib/formtastic/inputs/string_input.rb
  26. +3 −3 lib/formtastic/inputs/text_input.rb
  27. +5 −5 lib/formtastic/inputs/time_zone_input.rb
  28. +21 −21 lib/formtastic/inputs/timeish.rb
  29. +4 −4 lib/formtastic/inputs/url_input.rb
  30. +10 −10 lib/formtastic/localized_string.rb
  31. +1 −1 lib/formtastic/util.rb
  32. +3 −3 lib/generators/formtastic/form/form_generator.rb
  33. +7 −7 lib/generators/templates/formtastic.css
  34. +4 −4 lib/generators/templates/formtastic.rb
View
@@ -16,8 +16,8 @@
* Changed :boolean inputs to use Rails' check_box_checked? instead of our own logic
* Changed developer instructions in README
* Fixed :boolean inputs to disable the included hidden input when disabling the actual checkbox
-* Fixed that Formtastic was making changes to the options hash directly instead of on a duplicate, causing problems for those trying to reuse options on multiple inputs in the view
-* Fixed that tiny scroll bars were appearing on legends in date/time/radio/cbheckboxes fielsets (GH-477)
+* Fixed that Formtastic was making changes to the options hash directly instead of on a duplicate, causing problems for those trying to reuse options on multiple inputs in the view
+* Fixed that tiny scroll bars were appearing on legends in date/time/radio/cbheckboxes fielsets (GH-477)
* Fixed an issue when formtastic fails to determine if a checkbox is checked with custom checked and unchecked values (thanks to Eugene Bolshakov)
* Fixed that the hidden input rendered with a boolean checkbox did nt use the custom :name from :input_html options hash
@@ -41,7 +41,7 @@
* Removed deprecated aliased method names (input_field_set, button_field_set)
* Removed deprecated :class => 'whatever' on commit_button
* Fixed that classes in :button_html were being merged into :wrapper_html
-* Fixed that :include_blank was being ignored (always false) for multi selects
+* Fixed that :include_blank was being ignored (always false) for multi selects
* Fixed that we should reflect on allow_blank option to determine required status with validates_inclusion_of
* Added the ability to pass :input_html options be passed to the checkbox on a boolean input
* Developers: Added bundler support to for developer/contribution
@@ -87,7 +87,7 @@
* Added a fallback to Rails' helpers.label key if Formtastic label translation are not found
* Added support for default_text_area_width
* Added support for #persisted? over #new_record? (ActiveModel)
- * Added the 'required' logic to attributes with validates_inclusion_of validation, in addition to validates_presence_of
+ * Added the 'required' logic to attributes with validates_inclusion_of validation, in addition to validates_presence_of
* Added new HTML5 :as => :email input (Rails 3)
* Added new HTML5 :as => :phone input (Rails 3)
* Added new HTML5 :as => :search input (Rails 3)
@@ -101,15 +101,15 @@
* Added custom_inline_order to allow inline ordering per input type
* Added the ability to override the generator templates in Rails 3
-* Fixes
+* Fixes
* Fixed invalid HTML generated by Rails' hidden inputs on checkboxes (by rendering our own hidden tag in a more deliberate place)
* Fixed a bunch of invalid i18n key defaults
* Fixed that 'required' classes and logic were not being applied to :check_boxes and :radio inputs
* Fixed CSS bugs around Firefox's quirks with form elements that resulted in overflow/scroll bar issues
* Fixed that errors on fields with association were not marking the wrapping tag with the error class
* Fixed CSS where FF was displaying extra scroll bars on .check_boxes and .radio inputs (and the choices within them)
-
+
* Changes
* Changed that we were defaulting to a :select input for columns ending in _id, instead of columns with an appropriate associations
@@ -159,7 +159,7 @@
1.0.0.rc
-* Fixed that :checked_value and :unchecked_value options were being passed down into the HTML tags as attributes
+* Fixed that :checked_value and :unchecked_value options were being passed down into the HTML tags as attributes
1.0.0.beta4
@@ -29,12 +29,12 @@
module Formtastic
class FormBuilder < ActionView::Helpers::FormBuilder
-
+
def self.configure(name, value = nil)
class_attribute(name)
- self.send(:"#{name}=", value)
+ self.send(:"#{name}=", value)
end
-
+
configure :custom_namespace
configure :default_text_field_size
configure :default_text_area_height, 20
@@ -58,11 +58,11 @@ def self.configure(name, value = nil)
configure :default_inline_error_class, 'inline-errors'
configure :default_error_list_class, 'errors'
configure :default_hint_class, 'inline-hints'
-
+
attr_accessor :template
-
+
include Formtastic::HtmlAttributes
-
+
include Formtastic::Helpers::InputsHelper
include Formtastic::Helpers::ButtonsHelper
include Formtastic::Helpers::LabelHelper
@@ -87,7 +87,7 @@ def self.configure(name, value = nil)
include Formtastic::Inputs::TimeInput
include Formtastic::Inputs::TimeZoneInput
include Formtastic::Inputs::UrlInput
-
+
end
-
+
end
@@ -3,11 +3,11 @@
module Formtastic
module Helpers
-
- # ButtonsHelper encapsulates the responsibilties of the {#buttons} and {#commit_button} helpers
+
+ # ButtonsHelper encapsulates the responsibilties of the {#buttons} and {#commit_button} helpers
# for submitting forms.
#
- # {#buttons} is used to wrap the form's button(s) and actions in a `<fieldset>` and `<ol>`,
+ # {#buttons} is used to wrap the form's button(s) and actions in a `<fieldset>` and `<ol>`,
# with each item in the list containing the markup representing a single button.
#
# {#buttons} is usually called with a block containing a single {#commit_button} call:
@@ -34,12 +34,12 @@ module Helpers
#
# While this may seem slightly over-engineered, it is consistent with the way form inputs are
# handled, and makes room for other types of buttons and actions in future versions (such as
- # cancel buttons or links, reset buttons and even alternate actions like 'save and continue
+ # cancel buttons or links, reset buttons and even alternate actions like 'save and continue
# editing').
#
# It's important to note that the `semantic_form_for` and {#buttons} blocks wrap the
# standard Rails `form_for` helper and form builder, so you have full access to every standard
- # Rails form helper, with any HTML markup and ERB syntax, allowing you to "break free" from
+ # Rails form helper, with any HTML markup and ERB syntax, allowing you to "break free" from
# Formtastic when it doesn't suit to create your own buttons, links and actions:
#
# <%= semantic_form_for @post do |f| %>
@@ -59,7 +59,7 @@ module Helpers
module ButtonsHelper
include Formtastic::Helpers::FieldsetWrapper
include Formtastic::LocalizedString
-
+
# Creates a fieldset and ol tag wrapping for use around a set of buttons. It can be
# called either with a block (in which you can do the usual Rails form stuff, HTML, ERB, etc),
# or with a list of named buttons. These two examples are functionally equivalent:
@@ -71,12 +71,12 @@ module ButtonsHelper
# <%= f.commit_button %>
# <% end %>
# <% end %>
- #
+ #
# # With a list of fields:
# <% semantic_form_for @post do |f| %>
# <%= f.buttons :commit %>
# <% end %>
- #
+ #
# # Output:
# <form ...>
# <fieldset class="inputs">
@@ -88,7 +88,7 @@ module ButtonsHelper
# </fieldset>
# </form>
#
- # Only one type of named button is supported at this time (:commit), and it's assumed to be
+ # Only one type of named button is supported at this time (:commit), and it's assumed to be
# the default choice, so this is also functionally equivalent, but may change in the future:
#
# # With no args:
@@ -99,11 +99,11 @@ module ButtonsHelper
#
# While this may seem slightly over-engineered, it is consistent with the way form inputs are
# handled, and makes room for other types of buttons and actions in future versions (such as
- # cancel buttons or links, reset buttons and even alternate actions like 'save and continue
+ # cancel buttons or links, reset buttons and even alternate actions like 'save and continue
# editing').
#
# All options except `:name` and `:title` are passed down to the fieldset as HTML
- # attributes (`id`, `class`, `style`...). If provided, the `:name` or `:title` option is
+ # attributes (`id`, `class`, `style`...). If provided, the `:name` or `:title` option is
# passed into a `<legend>` inside the `<fieldset>` to name the set of buttons.
#
# @example Quickly add button(s) to the form, accepting all default values, options and behaviors
@@ -170,7 +170,7 @@ module ButtonsHelper
def buttons(*args, &block)
html_options = args.extract_options!
html_options[:class] ||= "buttons"
-
+
if block_given?
field_set_and_list_wrapping(html_options, &block)
else
@@ -179,18 +179,18 @@ def buttons(*args, &block)
field_set_and_list_wrapping(html_options, contents)
end
end
-
+
# Creates a submit input tag with the value "Save [model name]" (for existing records) or
- # "Create [model name]" (for new records) by default. The output is an `<input>` tag with the
+ # "Create [model name]" (for new records) by default. The output is an `<input>` tag with the
# `type` of `submit` and a class of either `create` or `update` (if Formtastic can determin if)
# the record is new or not) with `submit` as a fallback class. The submit button is wrapped in
# an `<li>` tag with a class of `commit`, and is intended to be rendered inside a {#buttons}
# block which wraps the button in a `fieldset` and `ol`.
#
- # The textual value of the label can be changed from this default through the `:label`
+ # The textual value of the label can be changed from this default through the `:label`
# argument or through i18n.
#
- # You can pass HTML attributes down to the `<input>` tag with the `:button_html` option, and
+ # You can pass HTML attributes down to the `<input>` tag with the `:button_html` option, and
# pass HTML attributes to the wrapping `<li>` tag with the `:wrapper_html` option.
#
# @example Basic usage
@@ -226,24 +226,24 @@ def buttons(*args, &block)
# <%= f.commit_button :label => "Go", :button_html => { :class => 'special', :id => 'whatever' } %>
# <%= f.commit_button "Go", :button_html => { :class => 'special', :id => 'whatever' } %>
#
- # @option *args :label [String, Symbol]
+ # @option *args :label [String, Symbol]
# Override the label text with a String or a symbold for an i18n translation key
#
- # @option *args :button_html [Hash]
+ # @option *args :button_html [Hash]
# Override or add to the HTML attributes to be passed down to the `<input>` tag
#
- # @option *args :wrapper_html [Hash]
+ # @option *args :wrapper_html [Hash]
# Override or add to the HTML attributes to be passed down to the wrapping `<li>` tag
#
# @todo document i18n keys
# @todo strange that `:accesskey` seems to be supported in the top level args as well as `:button_html`
def commit_button(*args)
options = args.extract_options!
text = options.delete(:label) || args.shift
-
+
if @object && (@object.respond_to?(:persisted?) || @object.respond_to?(:new_record?))
key = @object.persisted? ? :update : :create
-
+
# Deal with some complications with ActiveRecord::Base.human_name and two name models (eg UserPost)
# ActiveRecord::Base.human_name falls back to ActiveRecord::Base.name.humanize ("Userpost")
# if there's no i18n, which is pretty crappy. In this circumstance we want to detect this
@@ -260,17 +260,17 @@ def commit_button(*args)
key = :submit
object_name = @object_name.to_s.send(label_str_method)
end
-
+
text = (localized_string(key, text, :action, :model => object_name) ||
Formtastic::I18n.t(key, :model => object_name)) unless text.is_a?(::String)
-
+
button_html = options.delete(:button_html) || {}
button_html.merge!(:class => [button_html[:class], key].compact.join(' '))
-
+
wrapper_html_class = ['commit'] # TODO: Add class reflecting on form action.
wrapper_html = options.delete(:wrapper_html) || {}
wrapper_html[:class] = (wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')
-
+
accesskey = (options.delete(:accesskey) || default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
button_html = button_html.merge(:accesskey => accesskey) if accesskey
template.content_tag(:li, Formtastic::Util.html_safe(submit(text, button_html)), wrapper_html)
@@ -8,15 +8,15 @@ module ErrorsHelper
include Formtastic::Helpers::FileColumnDetection
include Formtastic::Reflection
include Formtastic::LocalizedString
-
+
INLINE_ERROR_TYPES = [:sentence, :list, :first]
-
- # Generates an unordered list of error messages on the base object and optionally for a given
- # set of named attribute. This is idea for rendering a block of error messages at the top of
- # the form for hidden/special/virtual attributes (the Paperclip Rails plugin does this), or
+
+ # Generates an unordered list of error messages on the base object and optionally for a given
+ # set of named attribute. This is idea for rendering a block of error messages at the top of
+ # the form for hidden/special/virtual attributes (the Paperclip Rails plugin does this), or
# errors on the base model.
#
- # A hash can be used as the last set of arguments to pass HTML attributes to the `<ul>`
+ # A hash can be used as the last set of arguments to pass HTML attributes to the `<ul>`
# wrapper.
#
# @example A list of errors on the base model
@@ -58,9 +58,9 @@ def semantic_errors(*args)
Formtastic::Util.html_safe(full_errors.map { |error| template.content_tag(:li, Formtastic::Util.html_safe(error)) }.join)
end
end
-
+
protected
-
+
def error_keys(method, options)
@methods_for_error ||= {}
@methods_for_error[method] ||= begin
@@ -70,27 +70,27 @@ def error_keys(method, options)
methods_for_error.flatten.compact.uniq
end
end
-
+
def has_errors?(method, options)
methods_for_error = error_keys(method,options)
@object && @object.respond_to?(:errors) && methods_for_error.any?{|error| !@object.errors[error].blank?}
end
-
+
def render_inline_errors?
@object && @object.respond_to?(:errors) && Formtastic::FormBuilder::INLINE_ERROR_TYPES.include?(inline_errors)
end
-
+
def association_macro_for_method(method) #:nodoc:
reflection = reflection_for(method)
reflection.macro if reflection
end
-
+
def association_primary_key(method)
reflection = reflection_for(method)
reflection.options[:foreign_key] if reflection && !reflection.options[:foreign_key].blank?
:"#{method}_id"
end
-
+
end
end
end
@@ -2,9 +2,9 @@ module Formtastic
module Helpers
# @private
module FieldsetWrapper
-
+
protected
-
+
# Generates a fieldset and wraps the content in an ordered list. When working
# with nested attributes, it allows %i as interpolation option in :name. So you can do:
#
@@ -24,34 +24,34 @@ module FieldsetWrapper
def field_set_and_list_wrapping(*args, &block) #:nodoc:
contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten
html_options = args.extract_options!
-
+
legend = html_options.dup.delete(:name).to_s
legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
legend = template.content_tag(:legend, template.content_tag(:span, Formtastic::Util.html_safe(legend))) unless legend.blank?
-
+
if block_given?
contents = if template.respond_to?(:is_haml?) && template.is_haml?
template.capture_haml(&block)
else
template.capture(&block)
end
end
-
+
# Ruby 1.9: String#to_s behavior changed, need to make an explicit join.
contents = contents.join if contents.respond_to?(:join)
fieldset = template.content_tag(:fieldset,
Formtastic::Util.html_safe(legend) << template.content_tag(:ol, Formtastic::Util.html_safe(contents)),
html_options.except(:builder, :parent)
)
-
+
fieldset
end
-
+
# Gets the nested_child_index value from the parent builder. It returns a hash with each
# association that the parent builds.
def parent_child_index(parent) #:nodoc:
duck = parent[:builder].instance_variable_get('@nested_child_index')
-
+
child = parent[:for]
child = child.first if child.respond_to?(:first)
duck[child].to_i + 1
@@ -2,15 +2,15 @@ module Formtastic
module Helpers
# @private
module FileColumnDetection
-
+
def is_file?(method, options = {})
@files ||= {}
@files[method] ||= (options[:as].present? && options[:as] == :file) || begin
file = @object.send(method) if @object && @object.respond_to?(method)
file && file_methods.any?{|m| file.respond_to?(m)}
end
end
-
+
end
end
end
Oops, something went wrong.

0 comments on commit 4347a85

Please sign in to comment.