default_classes_for_form_inputs 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
 - data/README.rdoc +26 -0
 - data/Rakefile +23 -0
 - data/VERSION +1 -0
 - data/lib/default_classes_for_form_inputs.rb +2 -0
 - data/lib/default_classes_for_form_inputs/form_helpers.rb +32 -0
 - data/lib/default_classes_for_form_inputs/form_tag_helpers.rb +34 -0
 - data/test/default_classes_for_form_inputs_test.rb +8 -0
 - data/test/test_helper.rb +3 -0
 - metadata +76 -0
 
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2009 [Brent Greeff]
         
     | 
| 
      
 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.
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = Default Classes for Form Inputs
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Just use the rails form helpers
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  <%= f.text_field :something, :class => 'text' %>
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            * But leave out the class
         
     | 
| 
      
 8 
     | 
    
         
            +
                  
         
     | 
| 
      
 9 
     | 
    
         
            +
                  <%= f.text_field :something %>
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  <%= text_field_tag :something %>    (works too.)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            You get default classes for different inputs.
         
     | 
| 
      
 15 
     | 
    
         
            +
                  
         
     | 
| 
      
 16 
     | 
    
         
            +
                  'text' for type="text"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  
         
     | 
| 
      
 18 
     | 
    
         
            +
                  'password text' for type="password"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  
         
     | 
| 
      
 20 
     | 
    
         
            +
                  'submit' for type="submit"
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            More coming...
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Copyright (c) 2009 [Brent Greeff], released under the MIT license
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rake/rdoctask'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            desc 'Default: run unit tests.'
         
     | 
| 
      
 6 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            desc 'Test the default_classes_for_form_inputs plugin.'
         
     | 
| 
      
 9 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 10 
     | 
    
         
            +
              t.libs << 'lib'
         
     | 
| 
      
 11 
     | 
    
         
            +
              t.libs << 'test'
         
     | 
| 
      
 12 
     | 
    
         
            +
              t.pattern = 'test/**/*_test.rb'
         
     | 
| 
      
 13 
     | 
    
         
            +
              t.verbose = true
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            desc 'Generate documentation for the default_classes_for_form_inputs plugin.'
         
     | 
| 
      
 17 
     | 
    
         
            +
            Rake::RDocTask.new(:rdoc) do |rdoc|
         
     | 
| 
      
 18 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 19 
     | 
    
         
            +
              rdoc.title    = 'DefaultClassesForFormInputs'
         
     | 
| 
      
 20 
     | 
    
         
            +
              rdoc.options << '--line-numbers' << '--inline-source'
         
     | 
| 
      
 21 
     | 
    
         
            +
              rdoc.rdoc_files.include('README')
         
     | 
| 
      
 22 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            2.0.0
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActionView
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Helpers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module FormHelper
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def text_field_with_default_class(object_name, method, options = {}) 
         
     | 
| 
      
 6 
     | 
    
         
            +
                    add_class_to_options_if_missing(options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                		options[:class] << 'text'
         
     | 
| 
      
 8 
     | 
    
         
            +
                		text_field_without_default_class(object_name, method, options)
         
     | 
| 
      
 9 
     | 
    
         
            +
                	end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  alias_method_chain :text_field, :default_class
         
     | 
| 
      
 12 
     | 
    
         
            +
                  
         
     | 
| 
      
 13 
     | 
    
         
            +
                  def password_field_with_default_class(object_name, method, options = {})
         
     | 
| 
      
 14 
     | 
    
         
            +
                    add_class_to_options_if_missing(options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                		options[:class] << 'text password'
         
     | 
| 
      
 16 
     | 
    
         
            +
                		password_field_without_default_class(object_name, method, options)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  alias_method_chain :password_field, :default_class
         
     | 
| 
      
 20 
     | 
    
         
            +
                  
         
     | 
| 
      
 21 
     | 
    
         
            +
                  private
         
     | 
| 
      
 22 
     | 
    
         
            +
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                	def add_class_to_options_if_missing(options)
         
     | 
| 
      
 24 
     | 
    
         
            +
                	  if options[:class].blank?
         
     | 
| 
      
 25 
     | 
    
         
            +
                  		options[:class] = ''
         
     | 
| 
      
 26 
     | 
    
         
            +
                		else
         
     | 
| 
      
 27 
     | 
    
         
            +
                  	  options[:class] += ' '
         
     | 
| 
      
 28 
     | 
    
         
            +
                  	end
         
     | 
| 
      
 29 
     | 
    
         
            +
                	end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActionView
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Helpers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module FormTagHelper
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def submit_tag_with_default_class(value = "Save changes", options = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    add_class_to_options_if_missing(options)
         
     | 
| 
      
 6 
     | 
    
         
            +
                		options[:class] << 'submit'
         
     | 
| 
      
 7 
     | 
    
         
            +
                		submit_tag_without_default_class(value, options)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  
         
     | 
| 
      
 10 
     | 
    
         
            +
                  alias_method_chain :submit_tag, :default_class
         
     | 
| 
      
 11 
     | 
    
         
            +
                  
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def text_field_tag_with_default_class(name, value = nil, options = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                    unless options['type'].eql? 'hidden'
         
     | 
| 
      
 14 
     | 
    
         
            +
                      add_class_to_options_if_missing(options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                		  options[:class] << 'text'
         
     | 
| 
      
 16 
     | 
    
         
            +
                		end
         
     | 
| 
      
 17 
     | 
    
         
            +
                		
         
     | 
| 
      
 18 
     | 
    
         
            +
                		text_field_tag_without_default_class(name, value, options)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  
         
     | 
| 
      
 21 
     | 
    
         
            +
                  alias_method_chain :text_field_tag, :default_class
         
     | 
| 
      
 22 
     | 
    
         
            +
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                  private
         
     | 
| 
      
 24 
     | 
    
         
            +
                  
         
     | 
| 
      
 25 
     | 
    
         
            +
                	def add_class_to_options_if_missing(options)
         
     | 
| 
      
 26 
     | 
    
         
            +
                	  if options[:class].blank?
         
     | 
| 
      
 27 
     | 
    
         
            +
                  		options[:class] = ''
         
     | 
| 
      
 28 
     | 
    
         
            +
                		else
         
     | 
| 
      
 29 
     | 
    
         
            +
                  	  options[:class] += ' '
         
     | 
| 
      
 30 
     | 
    
         
            +
                  	end
         
     | 
| 
      
 31 
     | 
    
         
            +
                	end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: default_classes_for_form_inputs
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 15
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 2.0.0
         
     | 
| 
      
 11 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Brent Greeff
         
     | 
| 
      
 14 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 16 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-10-30 00:00:00 +01:00
         
     | 
| 
      
 19 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            description: Adds classes to html form input elements so they are can be targeted with css.
         
     | 
| 
      
 23 
     | 
    
         
            +
            email: email@brentgreeff.com
         
     | 
| 
      
 24 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 29 
     | 
    
         
            +
            - MIT-LICENSE
         
     | 
| 
      
 30 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 31 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 32 
     | 
    
         
            +
            - MIT-LICENSE
         
     | 
| 
      
 33 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 34 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 35 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/default_classes_for_form_inputs.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/default_classes_for_form_inputs/form_helpers.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/default_classes_for_form_inputs/form_tag_helpers.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - test/default_classes_for_form_inputs_test.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - test/test_helper.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 42 
     | 
    
         
            +
            homepage: http://github.com/brentgreeff/default_classes_for_form_inputs
         
     | 
| 
      
 43 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 46 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 47 
     | 
    
         
            +
            - --charset=UTF-8
         
     | 
| 
      
 48 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 50 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 51 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 52 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 53 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 54 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 55 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 56 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 57 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 58 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 59 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 60 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 61 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 62 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 63 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 64 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 65 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 66 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 67 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 68 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 71 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 72 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 73 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 74 
     | 
    
         
            +
            summary: Adds classes to html form input elements so they are can be targeted with css.
         
     | 
| 
      
 75 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     |