app/helpers/casein/casein_helper.rb in casein-5.1.1.1 vs app/helpers/casein/casein_helper.rb in casein-5.1.1.2

- old
+ new

@@ -1,13 +1,13 @@ module Casein module CaseinHelper def casein_get_footer_string include_version = false if include_version - "Running on #{link_to 'Casein', 'http://www.github.com/russellquinn/casein'} #{casein_get_full_version_string}, an open-source project.".html_safe + "Running on #{link_to 'Casein', 'http://www.caseincms.com'} #{casein_get_full_version_string}, an open-source project.".html_safe else - "Running on #{link_to 'Casein', 'http://www.github.com/russellquinn/casein'}, an open-source project.".html_safe + "Running on #{link_to 'Casein', 'http://www.caseincms.com'}, an open-source project.".html_safe end end def casein_get_version_info Casein::VERSION_HASH @@ -210,92 +210,70 @@ def casein_hidden_field form, obj, attribute, options = {} form.hidden_field(attribute, strip_casein_options(options)).html_safe end - def casein_custom_field form, obj, attribute, custom_contents, options = {} - casein_form_tag_wrapper(custom_contents, form, obj, attribute, options).html_safe + def casein_color_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.color_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_color_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :color_field, form, obj, attribute, options + def casein_search_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.search_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_search_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :search_field, form, obj, attribute, options + def casein_telephone_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.telephone_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_telephone_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :telephone_field, form, obj, attribute, options + def casein_url_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.url_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_url_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :url_field, form, obj, attribute, options + def casein_email_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.email_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_email_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :email_field, form, obj, attribute, options + def casein_date_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.date_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_date_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :date_field, form, obj, attribute, options + def casein_datetime_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.datetime_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_datetime_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :datetime_field, form, obj, attribute, options + def casein_datetime_local_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.datetime_local_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_datetime_local_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :datetime_local_field, form, obj, attribute, options + def casein_month_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.month_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_month_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :month_field, form, obj, attribute, options + def casein_week_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.week_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_week_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :week_field, form, obj, attribute, options + def casein_time_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.time_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_time_field form, obj, attribute, options = nil - options ||= {} - casein_wrapped_field :time_field, form, obj, attribute, options + def casein_number_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.number_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_number_field form, obj, attribute, range, step, options = nil - options ||= {} - casein_wrapped_field :number_field, form, obj, attribute, {in: range, step: step}.merge(options) + def casein_range_field form, obj, attribute, options = {} + casein_form_tag_wrapper(form.range_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe end - def casein_range_field form, obj, attribute, range, options = nil - options ||= {} - casein_wrapped_field :range_field, form, obj, attribute, {in: range}.merge(options) + def casein_custom_field form, obj, attribute, custom_contents, options = {} + casein_form_tag_wrapper(custom_contents, form, obj, attribute, options).html_safe end - protected - def casein_wrapped_field field_helper_method, form, obj, attribute, options - clz = "casein-" + field_helper_method.to_s.gsub(/_field$/,'').gsub('_', '-') - contents = content_tag 'div', class: clz do - form.send(field_helper_method, attribute, strip_casein_options(options)) - end - casein_form_tag_wrapper(contents.html_safe, form, obj, attribute, options).html_safe - end - def strip_casein_options options - (options || {}).reject {|key, value| key.to_s.include? "casein_" } + options.reject {|key, value| key.to_s.include? "casein_" } end def merged_class_hash options, new_class if options.key? :class new_class += " #{options[:class]}" @@ -310,11 +288,10 @@ end options[:class] = new_class options end - def casein_form_tag_wrapper form_tag, form, obj, attribute, options = nil - options ||= {} + def casein_form_tag_wrapper form_tag, form, obj, attribute, options = {} unless options.key? :casein_label human_attribute_name = attribute.to_s.humanize else human_attribute_name = options[:casein_label] end