client_side_validations-formtastic 2.0.0.beta.1 → 2.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,9 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{Formtastic Plugin for ClientSideValidations}
9
9
  gem.homepage = 'https://github.com/dockyard/client_side_validations-formtastic'
10
10
 
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
11
  gem.files = `git ls-files -- {lib/*,vendor/*,*.gemspec}`.split("\n")
13
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
12
  gem.name = 'client_side_validations-formtastic'
15
13
  gem.require_paths = ['lib']
16
14
  gem.version = ClientSideValidations::Formtastic::VERSION
@@ -19,6 +17,7 @@ Gem::Specification.new do |gem|
19
17
  gem.add_dependency 'formtastic', '~> 2.0.0'
20
18
 
21
19
  gem.add_development_dependency 'actionpack', '~> 3.2.0'
20
+ gem.add_development_dependency 'railties', '~> 3.2.0'
22
21
 
23
22
  # For QUnit testing
24
23
  gem.add_development_dependency 'sinatra', '~> 1.0'
@@ -0,0 +1,2 @@
1
+ class ClientSideValidations::Formtastic::Engine < ::Rails::Engine; end
2
+
@@ -1,5 +1,5 @@
1
1
  module ClientSideValidations
2
2
  module Formtastic
3
- VERSION = "2.0.0.beta.1"
3
+ VERSION = '2.0.0.beta.2'
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
1
  require 'formtastic'
2
2
  require 'client_side_validations/formtastic/form_builder'
3
3
  require 'client_side_validations/formtastic/helpers'
4
+ require 'client_side_validations/formtastic/engine'
@@ -1,4 +1 @@
1
- require 'base_helper'
2
- require 'action_view'
3
1
  require 'client_side_validations/formtastic'
4
-
@@ -1,3 +1,12 @@
1
+ /*!
2
+ * Client Side Validations - Formtastic - v2.0.0.beta.2
3
+ * https://github.com/dockyard/client_side_validations-formtastic
4
+ *
5
+ * Copyright (c) 2012 DockYard, LLC
6
+ * Licensed under the MIT license
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ */
9
+
1
10
  ClientSideValidations.formBuilders['Formtastic::FormBuilder'] = {
2
11
  add: function(element, settings, message) {
3
12
  if (element.data('valid') !== false) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_side_validations-formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta.1
4
+ version: 2.0.0.beta.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: client_side_validations
16
- requirement: &70247173167380 !ruby/object:Gem::Requirement
16
+ requirement: &70155695090780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0.beta.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70247173167380
24
+ version_requirements: *70155695090780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: formtastic
27
- requirement: &70247173166240 !ruby/object:Gem::Requirement
27
+ requirement: &70155695088300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70247173166240
35
+ version_requirements: *70155695088300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: actionpack
38
- requirement: &70247173164940 !ruby/object:Gem::Requirement
38
+ requirement: &70155695086840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,21 @@ dependencies:
43
43
  version: 3.2.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70247173164940
46
+ version_requirements: *70155695086840
47
+ - !ruby/object:Gem::Dependency
48
+ name: railties
49
+ requirement: &70155695084080 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70155695084080
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: sinatra
49
- requirement: &70247173164160 !ruby/object:Gem::Requirement
60
+ requirement: &70155695082100 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '1.0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70247173164160
68
+ version_requirements: *70155695082100
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: shotgun
60
- requirement: &70247173163340 !ruby/object:Gem::Requirement
71
+ requirement: &70155695079220 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *70247173163340
79
+ version_requirements: *70155695079220
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: thin
71
- requirement: &70247173162480 !ruby/object:Gem::Requirement
82
+ requirement: &70155695073920 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *70247173162480
90
+ version_requirements: *70155695073920
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: json
82
- requirement: &70247173155440 !ruby/object:Gem::Requirement
93
+ requirement: &70155695071600 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,7 +98,7 @@ dependencies:
87
98
  version: '0'
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *70247173155440
101
+ version_requirements: *70155695071600
91
102
  description: Formtastic Plugin for ClientSideValidaitons
92
103
  email:
93
104
  - bcardarella@gmail.com
@@ -96,29 +107,14 @@ extensions: []
96
107
  extra_rdoc_files: []
97
108
  files:
98
109
  - client_side_validations-formtastic.gemspec
110
+ - lib/client_side_validations-formtastic.rb
99
111
  - lib/client_side_validations/formtastic.rb
112
+ - lib/client_side_validations/formtastic/engine.rb
100
113
  - lib/client_side_validations/formtastic/form_builder.rb
101
114
  - lib/client_side_validations/formtastic/helpers.rb
102
115
  - lib/client_side_validations/formtastic/helpers/input_helper.rb
103
116
  - lib/client_side_validations/formtastic/version.rb
104
117
  - vendor/assets/javascripts/rails.validations.formtastic.js
105
- - test/action_view/models.rb
106
- - test/action_view/models/post.rb
107
- - test/action_view/test_helper.rb
108
- - test/base_helper.rb
109
- - test/formtastic/cases/helper.rb
110
- - test/formtastic/cases/test_form_builder.rb
111
- - test/formtastic/cases/test_form_helpers.rb
112
- - test/javascript/config.ru
113
- - test/javascript/public/test/form_builders/validateFormtastic.js
114
- - test/javascript/public/test/settings.js
115
- - test/javascript/public/vendor/jquery.metadata.js
116
- - test/javascript/public/vendor/qunit.css
117
- - test/javascript/public/vendor/qunit.js
118
- - test/javascript/server.rb
119
- - test/javascript/views/index.erb
120
- - test/javascript/views/layout.erb
121
- - test/test_loader.rb
122
118
  homepage: https://github.com/dockyard/client_side_validations-formtastic
123
119
  licenses: []
124
120
  post_install_message:
@@ -143,21 +139,4 @@ rubygems_version: 1.8.10
143
139
  signing_key:
144
140
  specification_version: 3
145
141
  summary: Formtastic Plugin for ClientSideValidations
146
- test_files:
147
- - test/action_view/models.rb
148
- - test/action_view/models/post.rb
149
- - test/action_view/test_helper.rb
150
- - test/base_helper.rb
151
- - test/formtastic/cases/helper.rb
152
- - test/formtastic/cases/test_form_builder.rb
153
- - test/formtastic/cases/test_form_helpers.rb
154
- - test/javascript/config.ru
155
- - test/javascript/public/test/form_builders/validateFormtastic.js
156
- - test/javascript/public/test/settings.js
157
- - test/javascript/public/vendor/jquery.metadata.js
158
- - test/javascript/public/vendor/qunit.css
159
- - test/javascript/public/vendor/qunit.js
160
- - test/javascript/server.rb
161
- - test/javascript/views/index.erb
162
- - test/javascript/views/layout.erb
163
- - test/test_loader.rb
142
+ test_files: []
@@ -1,35 +0,0 @@
1
- class Post < Struct.new(:title, :author_name, :body, :secret, :written_on, :cost)
2
- extend ActiveModel::Naming
3
- include ActiveModel::Conversion
4
- extend ActiveModel::Translation
5
-
6
- alias_method :secret?, :secret
7
-
8
- def persisted=(boolean)
9
- @persisted = boolean
10
- end
11
-
12
- def persisted?
13
- @persisted
14
- end
15
-
16
- def client_side_validation_hash
17
- {
18
- :cost => {
19
- :presence => {
20
- :message => "can't be blank"
21
- }
22
- }
23
- }
24
- end
25
-
26
- attr_accessor :author
27
- def author_attributes=(attributes); end
28
-
29
- attr_accessor :comments, :comment_ids
30
- def comments_attributes=(attributes); end
31
-
32
- attr_accessor :tags
33
- def tags_attributes=(attributes); end
34
- end
35
-
@@ -1,2 +0,0 @@
1
- require 'active_model'
2
- require 'action_view/models/post'
@@ -1,42 +0,0 @@
1
- require 'base_helper'
2
- require 'action_view'
3
- require 'action_view/models'
4
- require 'client_side_validations/action_view'
5
-
6
- module ActionController
7
- class Base
8
- include ActionDispatch::Routing::RouteSet.new.url_helpers
9
- end
10
- end
11
-
12
- module ActionViewTestSetup
13
- include ::ClientSideValidations::ActionView::Helpers::FormHelper
14
- include ::ClientSideValidations::ActionView::Helpers::FormTagHelper
15
-
16
- def form_for(*)
17
- @output_buffer = super
18
- end
19
-
20
- Routes = ActionDispatch::Routing::RouteSet.new
21
- Routes.draw do
22
- resources :posts
23
- end
24
-
25
- def _routes
26
- Routes
27
- end
28
-
29
- include Routes.url_helpers
30
-
31
- def setup
32
- super
33
-
34
- @post = Post.new
35
- @post.persisted = true
36
- def @post.id; 123; end
37
- def @post.id_before_type_cast; 123; end
38
- def @post.to_param; '123'; end
39
- end
40
-
41
- end
42
-
data/test/base_helper.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
4
- require 'test/unit'
5
-
6
- module ClientSideValidations; end
@@ -1,11 +0,0 @@
1
- require 'formtastic/cases/helper'
2
-
3
- class ClientSideValidations::Formtastic::FormBuilderTest < Test::Unit::TestCase
4
- def test_client_side_form_js_hash
5
- expected = {
6
- :type => 'Formtastic::FormBuilder',
7
- :inline_error_class => 'inline-errors'
8
- }
9
- assert_equal expected, Formtastic::FormBuilder.client_side_form_settings(nil, nil)
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- require 'action_view/test_helper'
2
- require 'formtastic/cases/helper'
3
-
4
- class ClientSideValidations::Formtastic::FormHelpersTest < ActionView::TestCase
5
- include ActionViewTestSetup
6
- include Formtastic::Helpers::FormHelper
7
-
8
- def client_side_form_settings_helper
9
- ''
10
- end
11
-
12
- def test_semantic_form_for
13
- semantic_form_for(@post, :validate => true) do |f|
14
- concat f.input(:cost)
15
- end
16
-
17
- expected = %{<form accept-charset="UTF-8" action="/posts/123" class="formtastic post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><li class="string input required stringish" id="post_cost_input"><label class=\" label\" for="post_cost">Cost<abbr title="required">*</abbr></label><input data-validate="true" id="post_cost" name="post[cost]" type="text" />\n\n</li></form><script>window.ClientSideValidations.forms['edit_post_123'] = {"type":"Formtastic::FormBuilder","inline_error_class":"inline-errors","validators":{"post[cost]":{"presence":{"message":"can't be blank"}}}};</script>}
18
- assert_equal expected, output_buffer, "\n\n *** If you're running Ruby 1.8 and this test fails is is most likely due to 1.8's lack of insertion order persistence with Hashes ***\n"
19
- end
20
-
21
- def test_input_override
22
- semantic_form_for(@post, :validate => true) do |f|
23
- concat f.input(:cost, :validate => false)
24
- end
25
-
26
- expected = %{<form accept-charset="UTF-8" action="/posts/123" class="formtastic post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><li class="string input required stringish" id="post_cost_input"><label class=\" label\" for="post_cost">Cost<abbr title="required">*</abbr></label><input id="post_cost" name="post[cost]" type="text" />\n\n</li></form><script>window.ClientSideValidations.forms['edit_post_123'] = {"type":"Formtastic::FormBuilder","inline_error_class":"inline-errors","validators":{}};</script>}
27
- assert_equal expected, output_buffer, "\n\n *** If you're running Ruby 1.8 and this test fails is is most likely due to 1.8's lack of insertion order persistence with Hashes ***\n"
28
- end
29
-
30
- end
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
- require 'server'
3
- run Sinatra::Application
@@ -1,54 +0,0 @@
1
- module('Validate Formtastic', {
2
- setup: function() {
3
- window.ClientSideValidations.forms['new_user'] = {
4
- type: 'Formtastic::FormBuilder',
5
- inline_error_class: 'inline-errors',
6
- validators: {
7
- "user[name]":{"presence":{"message": "must be present"}, "format":{"message":"is invalid","with":/\d+/}}
8
- }
9
- }
10
-
11
- $('#qunit-fixture')
12
- .append($('<form />', {
13
- action: '/users',
14
- 'data-validate': true,
15
- method: 'post',
16
- id: 'new_user'
17
- }))
18
- .find('form')
19
- .append('<li />').find('li')
20
- .append($('<input />', {
21
- name: 'user[name]',
22
- id: 'user_name',
23
- 'data-validate': 'true',
24
- type: 'text'
25
- }))
26
- .append($('<label for="user_name">Name</label>'));
27
- $('form#new_user').validate();
28
- }
29
- });
30
-
31
- test('Validate error attaching and detaching', function() {
32
- var form = $('form#new_user'), input = form.find('input#user_name');
33
- var label = $('label[for="user_name"]');
34
-
35
- input.trigger('focusout')
36
- ok(input.parent().hasClass('error'));
37
- ok(label.parent().hasClass('error'));
38
- ok(input.parent().find('p.inline-errors:contains("must be present")')[0]);
39
-
40
- input.val('abc')
41
- input.trigger('change')
42
- input.trigger('focusout')
43
- ok(input.parent().hasClass('error'));
44
- ok(label.parent().hasClass('error'));
45
- ok(input.parent().find('p.inline-errors:contains("is invalid")')[0]);
46
-
47
- input.val('123')
48
- input.trigger('change')
49
- input.trigger('focusout')
50
- ok(!input.parent().hasClass('error'));
51
- ok(!label.parent().hasClass('error'));
52
- ok(!input.parent().find('p.inline-errors')[0]);
53
- });
54
-
@@ -1,15 +0,0 @@
1
- // hijacks normal form submit; lets it submit to an iframe to prevent
2
- // navigating away from the test suite
3
- $(document).bind('submit', function(e) {
4
- if (!e.isDefaultPrevented()) {
5
- var form = $(e.target), action = form.attr('action'),
6
- name = 'form-frame' + jQuery.guid++,
7
- iframe = $('<iframe name="' + name + '" />');
8
-
9
- if (action.indexOf('iframe') < 0) form.attr('action', action + '?iframe=true')
10
- form.attr('target', name);
11
- $('#qunit-fixture').append(iframe);
12
- form.trigger('iframe:loading');
13
- }
14
- });
15
-
@@ -1,122 +0,0 @@
1
- /*
2
- * Metadata - jQuery plugin for parsing metadata from elements
3
- *
4
- * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- *
10
- * Revision: $Id: jquery.metadata.js 4187 2007-12-16 17:15:27Z joern.zaefferer $
11
- *
12
- */
13
-
14
- /**
15
- * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
16
- * in the JSON will become a property of the element itself.
17
- *
18
- * There are three supported types of metadata storage:
19
- *
20
- * attr: Inside an attribute. The name parameter indicates *which* attribute.
21
- *
22
- * class: Inside the class attribute, wrapped in curly braces: { }
23
- *
24
- * elem: Inside a child element (e.g. a script tag). The
25
- * name parameter indicates *which* element.
26
- *
27
- * The metadata for an element is loaded the first time the element is accessed via jQuery.
28
- *
29
- * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
30
- * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
31
- *
32
- * @name $.metadata.setType
33
- *
34
- * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
35
- * @before $.metadata.setType("class")
36
- * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
37
- * @desc Reads metadata from the class attribute
38
- *
39
- * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
40
- * @before $.metadata.setType("attr", "data")
41
- * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
42
- * @desc Reads metadata from a "data" attribute
43
- *
44
- * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
45
- * @before $.metadata.setType("elem", "script")
46
- * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
47
- * @desc Reads metadata from a nested script element
48
- *
49
- * @param String type The encoding type
50
- * @param String name The name of the attribute to be used to get metadata (optional)
51
- * @cat Plugins/Metadata
52
- * @descr Sets the type of encoding to be used when loading metadata for the first time
53
- * @type undefined
54
- * @see metadata()
55
- */
56
-
57
- (function($) {
58
-
59
- $.extend({
60
- metadata : {
61
- defaults : {
62
- type: 'class',
63
- name: 'metadata',
64
- cre: /({.*})/,
65
- single: 'metadata'
66
- },
67
- setType: function( type, name ){
68
- this.defaults.type = type;
69
- this.defaults.name = name;
70
- },
71
- get: function( elem, opts ){
72
- var settings = $.extend({},this.defaults,opts);
73
- // check for empty string in single property
74
- if ( !settings.single.length ) settings.single = 'metadata';
75
-
76
- var data = $.data(elem, settings.single);
77
- // returned cached data if it already exists
78
- if ( data ) return data;
79
-
80
- data = "{}";
81
-
82
- if ( settings.type == "class" ) {
83
- var m = settings.cre.exec( elem.className );
84
- if ( m )
85
- data = m[1];
86
- } else if ( settings.type == "elem" ) {
87
- if( !elem.getElementsByTagName )
88
- return undefined;
89
- var e = elem.getElementsByTagName(settings.name);
90
- if ( e.length )
91
- data = $.trim(e[0].innerHTML);
92
- } else if ( elem.getAttribute != undefined ) {
93
- var attr = elem.getAttribute( settings.name );
94
- if ( attr )
95
- data = attr;
96
- }
97
-
98
- if ( data.indexOf( '{' ) <0 )
99
- data = "{" + data + "}";
100
-
101
- data = eval("(" + data + ")");
102
-
103
- $.data( elem, settings.single, data );
104
- return data;
105
- }
106
- }
107
- });
108
-
109
- /**
110
- * Returns the metadata object for the first member of the jQuery object.
111
- *
112
- * @name metadata
113
- * @descr Returns element's metadata object
114
- * @param Object opts An object contianing settings to override the defaults
115
- * @type jQuery
116
- * @cat Plugins/Metadata
117
- */
118
- $.fn.metadata = function( opts ){
119
- return $.metadata.get( this[0], opts );
120
- };
121
-
122
- })(jQuery);