realtime-validations 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -60,7 +60,7 @@ Include the core javascript of the application:
60
60
  # app/assets/javascripts/application.js
61
61
  //= require realtime_validations
62
62
 
63
- For now it is necessary to include the stylesheet too, but it will be optional in next versions:
63
+ If you want to use the default error messages, you need to include the stylesheet too:
64
64
 
65
65
  # app/assets/stylesheets/application.css
66
66
  *= require realtime_validations
@@ -73,3 +73,18 @@ Usage is very transparent from your project:
73
73
 
74
74
  You should use +form_validated_for+ instead of +form_for+ on your forms in order for them to
75
75
  automatically validate.
76
+
77
+ === Error messages
78
+
79
+ You can write your own error messages handlers. There are two hooks in JQuery that will be executed
80
+ in order to show and hide errors, and that can be found commented out on the JS file installed by
81
+ the generator.
82
+
83
+ RealtimeValidations.showErrors = function(field, errors) {
84
+ }
85
+
86
+ RealtimeValidations.hideErrors = function(field) {
87
+ }
88
+
89
+ There is a default implementation for both, and you can use that one if you want. If you need a more
90
+ personalized error reporting or more sophisticated you will have to code your own. :)
@@ -1,3 +1,9 @@
1
- RealtimeValidations.customFields = function() {
2
- return { };
3
- }
1
+ // RealtimeValidations.customFields = function() {
2
+ // return { };
3
+ // }
4
+
5
+ // RealtimeValidations.showErrors = function(field, errors) {
6
+ // }
7
+
8
+ // RealtimeValidations.hideErrors = function(field) {
9
+ // }
@@ -60,7 +60,7 @@
60
60
  # # app/assets/javascripts/application.js
61
61
  # //= require realtime_validations
62
62
  #
63
- # For now it is necessary to include the stylesheet too, but it will be optional in next versions:
63
+ # If you want to use the default error messages, you need to include the stylesheet too:
64
64
  #
65
65
  # # app/assets/stylesheets/application.css
66
66
  # *= require realtime_validations
@@ -73,6 +73,21 @@
73
73
  #
74
74
  # You should use +form_validated_for+ instead of +form_for+ on your forms in order for them to
75
75
  # automatically validate.
76
+ #
77
+ # === Error messages
78
+ #
79
+ # You can write your own error messages handlers. There are two hooks in JQuery that will be executed
80
+ # in order to show and hide errors, and that can be found commented out on the JS file installed by
81
+ # the generator.
82
+ #
83
+ # RealtimeValidations.showErrors = function(field, errors) {
84
+ # }
85
+ #
86
+ # RealtimeValidations.hideErrors = function(field) {
87
+ # }
88
+ #
89
+ # There is a default implementation for both, and you can use that one if you want. If you need a more
90
+ # personalized error reporting or more sophisticated you will have to code your own. :)
76
91
  module RealtimeValidations
77
92
 
78
93
  # @private
@@ -1,3 +1,3 @@
1
1
  module RealtimeValidations
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -64,6 +64,22 @@ var RealtimeValidations = {
64
64
  }
65
65
  field.attr('valid', false);
66
66
  field.attr('validation-errors', errors);
67
+ RealtimeValidations.showErrors(field, errors);
68
+ },
69
+
70
+ hide_warning_message : function(field) {
71
+ field.attr('valid', true);
72
+ field.attr('validation-errors', null);
73
+ RealtimeValidations.hideErrors(field);
74
+ },
75
+
76
+ // Public functions (meant to be overriden if necessary):
77
+
78
+ customFields : function() {
79
+ return { };
80
+ },
81
+
82
+ showErrors : function(field, errors) {
67
83
  if ($('#' + field.attr('id') + '_error').length) {
68
84
  $('#' + field.attr('id') + '_error').remove();
69
85
  }
@@ -75,16 +91,10 @@ var RealtimeValidations = {
75
91
  $('#' + field.attr('id') + '_error').fadeIn('slow');
76
92
  },
77
93
 
78
- hide_warning_message : function(field) {
79
- field.attr('valid', true);
80
- field.attr('validation-errors', null);
94
+ hideErrors : function(field) {
81
95
  $('#' + field.attr('id') + '_error').fadeOut('slow', function() {
82
96
  $(this).remove();
83
97
  });
84
- },
85
-
86
- customFields : function() {
87
- return { };
88
98
  }
89
99
 
90
100
  };
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.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &25143660 !ruby/object:Gem::Requirement
16
+ requirement: &20223780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,18 @@ dependencies:
21
21
  version: 3.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25143660
24
+ version_requirements: *20223780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &25143160 !ruby/object:Gem::Requirement
27
+ requirement: &20223280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 1.0.19
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25143160
35
+ version_requirements: *20223280
36
36
  description: Form real time validations for free on Rails applications
37
37
  email:
38
38
  - ereslibre@gmail.com