midas-g_form_submit_protector 1.0.1

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/History.txt ADDED
@@ -0,0 +1,8 @@
1
+ == 1.0.0 2009-03-21
2
+
3
+ * Fixed bug with not including view_helpers file
4
+
5
+
6
+ == 1.0.0 2009-03-17
7
+
8
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,20 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ g_form_submit_protector.gemspec
7
+ lib/g_form_submit_protector.rb
8
+ lib/g_form_submit_protector/view_helpers.rb
9
+ rails_generators/form_submit_protector_assets/form_submit_protector_assets_generator.rb
10
+ rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.js
11
+ rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.min.js
12
+ rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.js
13
+ rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.min.js
14
+ script/console
15
+ script/destroy
16
+ script/generate
17
+ spec/g_form_submit_protector_spec.rb
18
+ spec/spec.opts
19
+ spec/spec_helper.rb
20
+ tasks/rspec.rake
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on g_form_submit_protector, see http://g_form_submit_protector.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,61 @@
1
+ = g_form_submit_protector
2
+
3
+ http://github.com/midas/g_form_submit_protector/tree/master
4
+
5
+
6
+ == DESCRIPTION:
7
+
8
+ A Rails Guilded (http://github.com/midas/guilded/tree/master) component that will disable form elements once the
9
+ submit button has been used.
10
+
11
+
12
+ == FEATURES:
13
+
14
+ * Disables the form submission button once the form is submitted
15
+ * Can implement callback to determine if the disabling should occur (this will help integrate with other form plugins, etc)
16
+
17
+
18
+ == USAGE:
19
+
20
+ <% g_form_submit_protector :form_class => 'itemForm' %>
21
+
22
+
23
+ == REQUIREMENTS:
24
+
25
+ * Rails >= 2.2.0
26
+ * Guilded >= 0.1.4 (http://github.com/midas/guilded/tree/master)
27
+
28
+
29
+ == INSTALL:
30
+
31
+ sudo gem install midas-g_form_submit_protector
32
+
33
+ In rails environment.rb file:
34
+
35
+ config.gem 'midas-g_form_submit_protector', :version => "1.0.1", :lib => 'g_form_submit_protector', :source => 'http://gems.github.com'
36
+
37
+
38
+ == LICENSE:
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2009 C. Jason Harrelson (midas)
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/g_form_submit_protector'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('g_form_submit_protector', GFormSubmitProtector::VERSION) do |p|
7
+ p.developer('C. Jason Harrelson (midas)', 'jason@lookforwardenterprises.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
+ p.rubyforge_name = p.name # TODO this is default value
11
+ # p.extra_deps = [
12
+ # ['activesupport','>= 2.0.2'],
13
+ # ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"],
16
+ ['rails', ">= 2.2.0"],
17
+ ['midas-guilded', ">=0.1.4"]
18
+ ]
19
+
20
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
21
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
22
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
23
+ p.rsync_args = '-av --delete --ignore-errors'
24
+ end
25
+
26
+ require 'newgem/tasks' # load /tasks/*.rake
27
+ Dir['tasks/**/*.rake'].each { |t| load t }
28
+
29
+ # TODO - want other tests/tasks run by default? Add them to the list
30
+ # task :default => [:spec, :features]
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{g_form_submit_protector}
5
+ s.version = "1.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["C. Jason Harrelson (midas)"]
9
+ s.date = %q{2009-03-21}
10
+ s.description = %q{A Rails Guilded (http://github.com/midas/guilded/tree/master) component that will disable form elements once the submit button has been used.}
11
+ s.email = ["jason@lookforwardenterprises.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
13
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "g_form_submit_protector.gemspec", "lib/g_form_submit_protector.rb", "lib/g_form_submit_protector/view_helpers.rb", "rails_generators/form_submit_protector_assets/form_submit_protector_assets_generator.rb", "rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.js", "rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.min.js", "rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.js", "rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.min.js", "script/console", "script/destroy", "script/generate", "spec/g_form_submit_protector_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/midas/g_form_submit_protector/tree/master}
16
+ s.post_install_message = %q{PostInstall.txt}
17
+ s.rdoc_options = ["--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{g_form_submit_protector}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{A Rails Guilded (http://github.com/midas/guilded/tree/master) component that will disable form elements once the submit button has been used.}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
29
+ s.add_development_dependency(%q<rails>, [">= 2.2.0"])
30
+ s.add_development_dependency(%q<midas-guilded>, [">= 0.1.4"])
31
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
32
+ else
33
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
34
+ s.add_dependency(%q<rails>, [">= 2.2.0"])
35
+ s.add_dependency(%q<midas-guilded>, [">= 0.1.4"])
36
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
40
+ s.add_dependency(%q<rails>, [">= 2.2.0"])
41
+ s.add_dependency(%q<midas-guilded>, [">= 0.1.4"])
42
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'g_form_submit_protector/view_helpers'
5
+
6
+ module GFormSubmitProtector
7
+ VERSION = '1.0.1'
8
+ end
9
+
10
+ if defined?( ActionView::Base )
11
+ ActionView::Base.send( :include, GFormSubmitProtector::ViewHelpers ) unless ActionView::Base.include?( GFormSubmitProtector::ViewHelpers )
12
+ end
@@ -0,0 +1,15 @@
1
+ module GFormSubmitProtector
2
+ module ViewHelpers
3
+
4
+ def g_form_submit_protector( *args )
5
+ return if Guilded::Guilder.instance.include_component?( :form_submit_protector ) # We only need one field highligher per page
6
+ options = args.extract_options!
7
+ throw Guilded::Exception::GuildedException.new( "'form_class' is a required option" ) unless options.has_key?( :form_class )
8
+ options.merge! :id => "form-submit-protector"
9
+ options.merge! :exclude_css => true
10
+ Guilded::Guilder.instance.add( :form_submit_protector, options, [ 'jquery/jquery-disable_on_submit-1.0.min.js' ] )
11
+ ''
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class FormSubmitProtectorAssetsGenerator < Rails::Generator::Base
2
+ def initialize(runtime_args, runtime_options = {})
3
+ super
4
+ end
5
+
6
+ def manifest
7
+ record do |m|
8
+ m.file "guilded.form_submit_protector.js", "public/javascripts/guilded.form_submit_protector.js"
9
+ m.file "guilded.form_submit_protector.min.js", "public/javascripts/guilded.form_submit_protector.min.js"
10
+ m.directory "public/javascripts/jquery"
11
+ m.file "jquery-disable_on_submit-1.0.js", "public/javascripts/jquery/jquery-disable_on_submit-1.0.js"
12
+ m.file "jquery-disable_on_submit-1.0.min.js", "public/javascripts/jquery/jquery-disable_on_submit-1.0.min.js"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ /* Guilded Form Submit Protector 1.0.0
2
+ * Copyright (c) 2009 C. Jason Harrelson (midas)
3
+ * Guilded Form Submit Protector is licensed under the terms of the MIT License */
4
+
5
+ g.formSubmitProtectorInit = function( options )
6
+ {
7
+ if( !options )
8
+ options = {};
9
+
10
+ if( g.beforeFormSubmitProtectorInit )
11
+ {
12
+ g.beforeFormSubmitProtectorInit( options );
13
+ }
14
+
15
+ if( g.doFormSubmitProtector )
16
+ options['should_inactivate'] = g.doFormSubmitProtector
17
+
18
+ $jc( options.form_class ).disableOnSubmit( options );
19
+
20
+ if( g.afterFormSubmitProtectorInit )
21
+ {
22
+ g.afterFormSubmitProtectorInit( options );
23
+ }
24
+ };
@@ -0,0 +1,4 @@
1
+ /* Guilded Form Submit Protector 1.0.0
2
+ * Copyright (c) 2009 C. Jason Harrelson (midas)
3
+ * Guilded Form Submit Protector is licensed under the terms of the MIT License */
4
+ g.formSubmitProtectorInit=function(options){if(!options)options={};if(g.beforeFormSubmitProtectorInit){g.beforeFormSubmitProtectorInit(options);}if(options.disable_list){$jc( options.form_class ).disableOnSubmit(options);else{$jc(options.form_class).disableOnSubmit();}if(g.afterFormSubmitProtectorInit){g.afterFormSubmitProtectorInit(options);}};
@@ -0,0 +1,45 @@
1
+ /*
2
+ * jQuery Disable On Submit Plugin
3
+ * http://www.evanbot.com/article/jquery-disable-on-submit-plugin/13
4
+ *
5
+ * Copyright (c) 2009 Evan Byrne (http://www.evanbot.com)
6
+ */
7
+ (function($){
8
+
9
+ jQuery.fn.disableOnSubmit = function( /* Object literal */ options )
10
+ {
11
+ opts = jQuery.extend( jQuery.fn.disableOnSubmit.defaults, options );
12
+
13
+ if(opts.disable_list == null)
14
+ {
15
+ $list = 'input[type=submit],input[type=button],input[type=reset],button';
16
+ }
17
+ else
18
+ {
19
+ $list = opts.disable_list;
20
+ }
21
+
22
+ // Makes sure button is enabled at start
23
+ jQuery(this).find($list).removeAttr('disabled');
24
+
25
+ jQuery(this).submit(inactivateForm);
26
+ return this;
27
+ };
28
+
29
+ /* *************** public *************** */
30
+
31
+ jQuery.fn.disableOnSubmit.defaults =
32
+ {
33
+ disable_list: 'input[type=submit],input[type=button],input[type=reset],button', /* selector list of elements to disable */
34
+ should_inactivate: function(){ return true; } /* a callback function that returns true or false deciding if the form should be inactivated */
35
+ };
36
+
37
+ /* *************** private *************** */
38
+
39
+ inactivateForm = function( /* jquery Event */ e )
40
+ {
41
+ if( opts.should_inactivate() )
42
+ jQuery(this).find($list).attr('disabled','disabled');
43
+ };
44
+
45
+ })(jQuery);
@@ -0,0 +1,7 @@
1
+ /*
2
+ * jQuery Disable On Submit Plugin
3
+ * http://www.evanbot.com/article/jquery-disable-on-submit-plugin/13
4
+ *
5
+ * Copyright (c) 2009 Evan Byrne (http://www.evanbot.com)
6
+ */
7
+ (function($){jQuery.fn.disableOnSubmit=function(options){opts = jQuery.extend( jQuery.fn.disableOnSubmit.defaults, options );if(opts.disable_list==null){$list='input[type=submit],input[type=button],input[type=reset],button';}else{$list=opts.disable_list;}jQuery(this).find($list).removeAttr('disabled');jQuery(this).submit(inactivateForm);return this;};jQuery.fn.disableOnSubmit.defaults={disable_list:'input[type=submit],input[type=button],input[type=reset],button',should_inactivate:function(){return true;}};inactivateForm=function(e){if(opts.should_inactivate())jQuery(this).find($list).attr('disabled','disabled');};})(jQuery);
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/g_form_submit_protector.rb'}"
9
+ puts "Loading g_form_submit_protector gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'g_form_submit_protector'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: midas-g_form_submit_protector
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - C. Jason Harrelson (midas)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-21 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: midas-guilded
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.4
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.0
54
+ version:
55
+ description: A Rails Guilded (http://github.com/midas/guilded/tree/master) component that will disable form elements once the submit button has been used.
56
+ email:
57
+ - jason@lookforwardenterprises.com
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - History.txt
64
+ - Manifest.txt
65
+ - PostInstall.txt
66
+ - README.rdoc
67
+ files:
68
+ - History.txt
69
+ - Manifest.txt
70
+ - PostInstall.txt
71
+ - README.rdoc
72
+ - Rakefile
73
+ - g_form_submit_protector.gemspec
74
+ - lib/g_form_submit_protector.rb
75
+ - lib/g_form_submit_protector/view_helpers.rb
76
+ - rails_generators/form_submit_protector_assets/form_submit_protector_assets_generator.rb
77
+ - rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.js
78
+ - rails_generators/form_submit_protector_assets/templates/guilded.form_submit_protector.min.js
79
+ - rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.js
80
+ - rails_generators/form_submit_protector_assets/templates/jquery-disable_on_submit-1.0.min.js
81
+ - script/console
82
+ - script/destroy
83
+ - script/generate
84
+ - spec/g_form_submit_protector_spec.rb
85
+ - spec/spec.opts
86
+ - spec/spec_helper.rb
87
+ - tasks/rspec.rake
88
+ has_rdoc: true
89
+ homepage: http://github.com/midas/g_form_submit_protector/tree/master
90
+ post_install_message: PostInstall.txt
91
+ rdoc_options:
92
+ - --main
93
+ - README.rdoc
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ version:
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: "0"
107
+ version:
108
+ requirements: []
109
+
110
+ rubyforge_project: g_form_submit_protector
111
+ rubygems_version: 1.2.0
112
+ signing_key:
113
+ specification_version: 2
114
+ summary: A Rails Guilded (http://github.com/midas/guilded/tree/master) component that will disable form elements once the submit button has been used.
115
+ test_files: []
116
+