realtime-validations 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module RealtimeValidations
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -73,6 +73,22 @@ var RealtimeValidations = {
73
73
  RealtimeValidations.hideErrors(field);
74
74
  },
75
75
 
76
+ showErrorsSmoothly : function(field, errors) {
77
+ field.parent().append('<div style="display: none;" id="' + field.attr('id') + '_error" class="field-error">'
78
+ + errors.join(', ') +
79
+ '<div class="field-error-arrow-border"></div> \
80
+ <div class="field-error-arrow"></div> \
81
+ </div>');
82
+ $('#' + field.attr('id') + '_error').fadeIn('slow');
83
+ },
84
+
85
+ showValidSmoothly : function(field) {
86
+ field.parent().append('<div style="display: none;" id="' + field.attr('id') + '_valid" class="field-valid"> \
87
+ <img src="/assets/valid_field.png"> \
88
+ </div>');
89
+ $('#' + field.attr('id') + '_valid').fadeIn('slow');
90
+ },
91
+
76
92
  // Public functions (meant to be overriden if necessary):
77
93
 
78
94
  customFields : function() {
@@ -81,20 +97,31 @@ var RealtimeValidations = {
81
97
 
82
98
  showErrors : function(field, errors) {
83
99
  if ($('#' + field.attr('id') + '_error').length) {
84
- $('#' + field.attr('id') + '_error').remove();
100
+ $('#' + field.attr('id') + '_error').fadeOut('slow', function() {
101
+ $(this).remove();
102
+ RealtimeValidations.showErrorsSmoothly(field, errors);
103
+ });
104
+ } else if ($('#' + field.attr('id') + '_valid').length) {
105
+ $('#' + field.attr('id') + '_valid').fadeOut('slow', function() {
106
+ $(this).remove();
107
+ RealtimeValidations.showErrorsSmoothly(field, errors);
108
+ });
109
+ } else {
110
+ RealtimeValidations.showErrorsSmoothly(field, errors);
85
111
  }
86
- field.parent().append('<div style="display: none;" id="' + field.attr('id') + '_error" class="field-error">'
87
- + errors.join(', ') +
88
- '<div class="field-error-arrow-border"></div> \
89
- <div class="field-error-arrow"></div> \
90
- </div>');
91
- $('#' + field.attr('id') + '_error').fadeIn('slow');
92
112
  },
93
113
 
94
114
  hideErrors : function(field) {
95
- $('#' + field.attr('id') + '_error').fadeOut('slow', function() {
96
- $(this).remove();
97
- });
115
+ if ($('#' + field.attr('id') + '_error').length) {
116
+ $('#' + field.attr('id') + '_error').fadeOut('slow', function() {
117
+ $(this).remove();
118
+ RealtimeValidations.showValidSmoothly(field);
119
+ });
120
+ } else if ($('#' + field.attr('id') + '_valid').length) {
121
+ return;
122
+ } else {
123
+ RealtimeValidations.showValidSmoothly(field);
124
+ }
98
125
  }
99
126
 
100
127
  };
@@ -37,4 +37,12 @@ div.field-error-arrow {
37
37
  position: absolute;
38
38
  top: 10px;
39
39
  left: -17px;
40
+ }
41
+
42
+ div.field-valid {
43
+ display: inline-block;
44
+ position: absolute;
45
+ padding: 0;
46
+ margin: 0;
47
+ margin-top: 5px;
40
48
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realtime-validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-02 00:00:00.000000000 Z
12
+ date: 2012-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &20223780 !ruby/object:Gem::Requirement
16
+ requirement: &13177960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20223780
24
+ version_requirements: *13177960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &20223280 !ruby/object:Gem::Requirement
27
+ requirement: &13177340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.0.19
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20223280
35
+ version_requirements: *13177340
36
36
  description: Form real time validations for free on Rails applications
37
37
  email:
38
38
  - ereslibre@gmail.com
@@ -43,46 +43,47 @@ files:
43
43
  - app/controllers/realtime_validations/validations_controller.rb
44
44
  - config/routes.rb
45
45
  - config/initializers/form_validated_for.rb
46
- - lib/realtime-validations.rb
47
- - lib/realtime-validations/version.rb
48
46
  - lib/generators/realtime_validations/install_generator.rb
49
47
  - lib/generators/realtime_validations/templates/initializer.rb
50
48
  - lib/generators/realtime_validations/templates/realtime_validations.custom.js
49
+ - lib/realtime-validations.rb
50
+ - lib/realtime-validations/version.rb
51
51
  - lib/tasks/realtime-validations_tasks.rake
52
52
  - vendor/assets/stylesheets/realtime_validations.css
53
+ - vendor/assets/images/valid_field.png
53
54
  - vendor/assets/javascripts/realtime_validations.js
54
55
  - MIT-LICENSE
55
56
  - Rakefile
56
57
  - README.rdoc
57
58
  - test/test_helper.rb
59
+ - test/dummy/public/500.html
58
60
  - test/dummy/public/404.html
59
61
  - test/dummy/public/favicon.ico
60
62
  - test/dummy/public/422.html
61
- - test/dummy/public/500.html
62
- - test/dummy/config/application.rb
63
- - test/dummy/config/database.yml
63
+ - test/dummy/README.rdoc
64
+ - test/dummy/script/rails
65
+ - test/dummy/config.ru
66
+ - test/dummy/Rakefile
64
67
  - test/dummy/config/environment.rb
65
- - test/dummy/config/routes.rb
66
- - test/dummy/config/environments/production.rb
67
68
  - test/dummy/config/environments/development.rb
68
69
  - test/dummy/config/environments/test.rb
69
- - test/dummy/config/locales/en.yml
70
+ - test/dummy/config/environments/production.rb
70
71
  - test/dummy/config/boot.rb
72
+ - test/dummy/config/application.rb
73
+ - test/dummy/config/database.yml
74
+ - test/dummy/config/locales/en.yml
75
+ - test/dummy/config/routes.rb
71
76
  - test/dummy/config/initializers/mime_types.rb
72
- - test/dummy/config/initializers/wrap_parameters.rb
73
- - test/dummy/config/initializers/session_store.rb
74
- - test/dummy/config/initializers/inflections.rb
75
77
  - test/dummy/config/initializers/secret_token.rb
78
+ - test/dummy/config/initializers/inflections.rb
76
79
  - test/dummy/config/initializers/backtrace_silencers.rb
77
- - test/dummy/script/rails
78
- - test/dummy/config.ru
79
- - test/dummy/README.rdoc
80
+ - test/dummy/config/initializers/wrap_parameters.rb
81
+ - test/dummy/config/initializers/session_store.rb
82
+ - test/dummy/app/helpers/application_helper.rb
80
83
  - test/dummy/app/assets/stylesheets/application.css
81
84
  - test/dummy/app/assets/javascripts/application.js
82
85
  - test/dummy/app/controllers/application_controller.rb
83
86
  - test/dummy/app/views/layouts/application.html.erb
84
- - test/dummy/app/helpers/application_helper.rb
85
- - test/dummy/Rakefile
86
87
  - test/realtime-validations_test.rb
87
88
  homepage: https://github.com/ereslibre/realtime-validations/wiki
88
89
  licenses: []
@@ -110,32 +111,32 @@ specification_version: 3
110
111
  summary: Provides real time validations for free
111
112
  test_files:
112
113
  - test/test_helper.rb
114
+ - test/dummy/public/500.html
113
115
  - test/dummy/public/404.html
114
116
  - test/dummy/public/favicon.ico
115
117
  - test/dummy/public/422.html
116
- - test/dummy/public/500.html
117
- - test/dummy/config/application.rb
118
- - test/dummy/config/database.yml
118
+ - test/dummy/README.rdoc
119
+ - test/dummy/script/rails
120
+ - test/dummy/config.ru
121
+ - test/dummy/Rakefile
119
122
  - test/dummy/config/environment.rb
120
- - test/dummy/config/routes.rb
121
- - test/dummy/config/environments/production.rb
122
123
  - test/dummy/config/environments/development.rb
123
124
  - test/dummy/config/environments/test.rb
124
- - test/dummy/config/locales/en.yml
125
+ - test/dummy/config/environments/production.rb
125
126
  - test/dummy/config/boot.rb
127
+ - test/dummy/config/application.rb
128
+ - test/dummy/config/database.yml
129
+ - test/dummy/config/locales/en.yml
130
+ - test/dummy/config/routes.rb
126
131
  - test/dummy/config/initializers/mime_types.rb
127
- - test/dummy/config/initializers/wrap_parameters.rb
128
- - test/dummy/config/initializers/session_store.rb
129
- - test/dummy/config/initializers/inflections.rb
130
132
  - test/dummy/config/initializers/secret_token.rb
133
+ - test/dummy/config/initializers/inflections.rb
131
134
  - test/dummy/config/initializers/backtrace_silencers.rb
132
- - test/dummy/script/rails
133
- - test/dummy/config.ru
134
- - test/dummy/README.rdoc
135
+ - test/dummy/config/initializers/wrap_parameters.rb
136
+ - test/dummy/config/initializers/session_store.rb
137
+ - test/dummy/app/helpers/application_helper.rb
135
138
  - test/dummy/app/assets/stylesheets/application.css
136
139
  - test/dummy/app/assets/javascripts/application.js
137
140
  - test/dummy/app/controllers/application_controller.rb
138
141
  - test/dummy/app/views/layouts/application.html.erb
139
- - test/dummy/app/helpers/application_helper.rb
140
- - test/dummy/Rakefile
141
142
  - test/realtime-validations_test.rb