ende 0.4.3 → 0.4.4

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.
@@ -1,224 +1,212 @@
1
- var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
2
-
3
- require('./translationable');
4
-
5
- root = typeof exports !== "undefined" && exports !== null ? exports : this;
6
-
7
- stampit = require('../../vendor/stampit');
8
-
9
- observable = require('observable').mixin;
10
-
11
- type = require('type');
12
-
13
- messages = {
14
- blank: function(attribute_name) {
15
- attribute_name = this.human_attribute_name(attribute_name);
16
- return "O campo " + attribute_name + " não pode ficar em branco.";
17
- },
18
- cpf: function(attribute_name) {
19
- attribute_name = this.human_attribute_name(attribute_name);
20
- return "O campo " + attribute_name + " não está válido.";
21
- },
22
- confirmation: function(attribute_name) {
23
- var confirmation_attribute_name;
24
-
25
- confirmation_attribute_name = this.human_attribute_name(attribute_name);
26
- attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
27
- return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
28
- },
29
- associated: function(attribute_name) {
30
- attribute_name = this.human_attribute_name(attribute_name);
31
- return "O registro associado " + attribute_name + " não é válido.";
32
- },
33
- server: function(attribute_name, options) {
34
- if (attribute_name === 'base') {
35
- return options.server_message;
36
- } else {
37
- attribute_name = this.human_attribute_name(attribute_name);
38
- return "" + attribute_name + " " + options.server_message + ".";
39
- }
40
- },
41
- type: function(attribute_name, options) {
42
- attribute_name = this.human_attribute_name(attribute_name);
43
- return "O campo " + attribute_name + " não está válido.";
44
- }
45
- };
46
-
47
- errorsable = stampit({
48
- add: function(attribute_name, message_key, options) {
49
- var translator;
50
-
51
- this.push([attribute_name, message_key, options]);
52
- this.messages[attribute_name] = '';
53
- translator = messages[message_key];
54
- if (translator != null) {
55
- return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
56
- } else {
57
- return this.messages[attribute_name] += message_key;
58
- }
59
- },
60
- clear: function() {
61
- var attribute_name, _results;
1
+ (function() {
2
+ var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
62
3
 
63
- if (this.length) {
64
- this.length = 0;
65
- _results = [];
66
- for (attribute_name in this.messages) {
67
- _results.push(this.messages[attribute_name] = null);
4
+ require('./translationable');
5
+
6
+ root = typeof exports !== "undefined" && exports !== null ? exports : this;
7
+
8
+ stampit = require('../../vendor/stampit');
9
+
10
+ observable = require('observable').mixin;
11
+
12
+ type = require('type');
13
+
14
+ messages = {
15
+ blank: function(attribute_name) {
16
+ attribute_name = this.human_attribute_name(attribute_name);
17
+ return "O campo " + attribute_name + " não pode ficar em branco.";
18
+ },
19
+ cpf: function(attribute_name) {
20
+ attribute_name = this.human_attribute_name(attribute_name);
21
+ return "O campo " + attribute_name + " não está válido.";
22
+ },
23
+ confirmation: function(attribute_name) {
24
+ var confirmation_attribute_name;
25
+ confirmation_attribute_name = this.human_attribute_name(attribute_name);
26
+ attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
27
+ return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
28
+ },
29
+ associated: function(attribute_name) {
30
+ attribute_name = this.human_attribute_name(attribute_name);
31
+ return "O registro associado " + attribute_name + " não é válido.";
32
+ },
33
+ server: function(attribute_name, options) {
34
+ if (attribute_name === 'base') {
35
+ return options.server_message;
36
+ } else {
37
+ attribute_name = this.human_attribute_name(attribute_name);
38
+ return "" + attribute_name + " " + options.server_message + ".";
68
39
  }
69
- return _results;
40
+ },
41
+ type: function(attribute_name, options) {
42
+ attribute_name = this.human_attribute_name(attribute_name);
43
+ return "O campo " + attribute_name + " não está válido.";
70
44
  }
71
- },
72
- push: Array.prototype.push,
73
- splice: Array.prototype.splice,
74
- indexOf: Array.prototype.indexOf
75
- }, {
76
- model: null,
77
- messages: null,
78
- length: 0
79
- }, function() {
80
- this.messages = {};
81
- return this;
82
- });
83
-
84
- initializers = {
85
- define_triggers: function() {
86
- this.errors = errorsable({
87
- model: model[this.resource]
88
- });
89
- this.before('save', function() {
90
- if (this.save) {
91
- return this.validate();
45
+ };
46
+
47
+ errorsable = stampit({
48
+ add: function(attribute_name, message_key, options) {
49
+ var translator;
50
+ this.push([attribute_name, message_key, options]);
51
+ this.messages[attribute_name] = '';
52
+ translator = messages[message_key];
53
+ if (translator != null) {
54
+ return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
55
+ } else {
56
+ return this.messages[attribute_name] += message_key;
92
57
  }
93
- });
94
- this.validated = false;
95
- this.subscribe('dirty', function(value) {
96
- return value && (this.validated = false);
97
- });
98
- return Object.defineProperty(this, 'valid', {
99
- get: function() {
100
- this.validate();
101
- if (this.validation.state() === 'resolved') {
102
- return !this.errors.length;
103
- } else {
104
- return null;
105
- }
106
- },
107
- set: function() {
108
- throw new TypeError("You can't set the value for the valid property.");
109
- },
110
- enumerable: false
111
- });
112
- },
113
- create_validators: function(definitions) {
114
- var definition, name, validator, validator_options, _ref, _results;
115
-
116
- this.validators = [];
117
- _ref = manager.validators;
118
- _results = [];
119
- for (name in _ref) {
120
- validator = _ref[name];
121
- definition = definitions[validator.definition_key];
122
- if (definition) {
123
- if (type(definition) !== 'array') {
124
- definition = [definition];
58
+ },
59
+ clear: function() {
60
+ var attribute_name, _results;
61
+ if (this.length) {
62
+ this.length = 0;
63
+ _results = [];
64
+ for (attribute_name in this.messages) {
65
+ _results.push(this.messages[attribute_name] = null);
125
66
  }
126
- _results.push((function() {
127
- var _i, _len, _results1;
128
-
129
- _results1 = [];
130
- for (_i = 0, _len = definition.length; _i < _len; _i++) {
131
- validator_options = definition[_i];
132
- if (type(validator_options) !== 'object') {
133
- validator_options = {
134
- attribute_name: validator_options
135
- };
136
- }
137
- validator_options.model = this;
138
- this.validators.push(validator(validator_options));
139
- _results1.push(delete definitions[validator.definition_key]);
67
+ return _results;
68
+ }
69
+ },
70
+ push: Array.prototype.push,
71
+ splice: Array.prototype.splice,
72
+ indexOf: Array.prototype.indexOf
73
+ }, {
74
+ model: null,
75
+ messages: null,
76
+ length: 0
77
+ }, function() {
78
+ this.messages = {};
79
+ return this;
80
+ });
81
+
82
+ initializers = {
83
+ define_triggers: function() {
84
+ this.errors = errorsable({
85
+ model: model[this.resource]
86
+ });
87
+ this.before('save', function() {
88
+ if (this.save) return this.validate();
89
+ });
90
+ this.validated = false;
91
+ this.subscribe('dirty', function(value) {
92
+ return value && (this.validated = false);
93
+ });
94
+ return Object.defineProperty(this, 'valid', {
95
+ get: function() {
96
+ this.validate();
97
+ if (this.validation.state() === 'resolved') {
98
+ return !this.errors.length;
99
+ } else {
100
+ return null;
140
101
  }
141
- return _results1;
142
- }).call(this));
143
- } else {
144
- _results.push(void 0);
102
+ },
103
+ set: function() {
104
+ throw new TypeError("You can't set the value for the valid property.");
105
+ },
106
+ enumerable: false
107
+ });
108
+ },
109
+ create_validators: function(definitions) {
110
+ var definition, name, validator, validator_options, _ref, _results;
111
+ this.validators = [];
112
+ _ref = manager.validators;
113
+ _results = [];
114
+ for (name in _ref) {
115
+ validator = _ref[name];
116
+ definition = definitions[validator.definition_key];
117
+ if (definition) {
118
+ if (type(definition) !== 'array') definition = [definition];
119
+ _results.push((function() {
120
+ var _i, _len, _results2;
121
+ _results2 = [];
122
+ for (_i = 0, _len = definition.length; _i < _len; _i++) {
123
+ validator_options = definition[_i];
124
+ if (type(validator_options) !== 'object') {
125
+ validator_options = {
126
+ attribute_name: validator_options
127
+ };
128
+ }
129
+ validator_options.model = this;
130
+ this.validators.push(validator(validator_options));
131
+ _results2.push(delete definitions[validator.definition_key]);
132
+ }
133
+ return _results2;
134
+ }).call(this));
135
+ } else {
136
+ _results.push(void 0);
137
+ }
145
138
  }
139
+ return _results;
146
140
  }
147
- return _results;
148
- }
149
- };
150
-
151
- extensions = {
152
- model: {
153
- validators: null
154
- },
155
- record: {
156
- validate_attribute: function(attribute, doned, failed) {
157
- var results, validation, validator, _i, _len, _ref;
158
-
159
- this.errors.messages[attribute] = null;
160
- results = [this, attribute];
161
- _ref = model[this.resource.toString()].validators;
162
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
163
- validator = _ref[_i];
164
- if (validator.attribute_name === attribute) {
141
+ };
142
+
143
+ extensions = {
144
+ model: {
145
+ validators: null
146
+ },
147
+ record: {
148
+ validate_attribute: function(attribute, doned, failed) {
149
+ var results, validation, validator, _i, _len, _ref;
150
+ this.errors.messages[attribute] = null;
151
+ results = [this, attribute];
152
+ _ref = model[this.resource.toString()].validators;
153
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
154
+ validator = _ref[_i];
155
+ if (validator.attribute_name === attribute) {
156
+ results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
157
+ }
158
+ }
159
+ validation = jQuery.when.apply(jQuery, results);
160
+ validation.done(doned);
161
+ validation.fail(failed);
162
+ return validation;
163
+ },
164
+ validate: function(doned, failed) {
165
+ var results, validator, _i, _len, _ref;
166
+ if (this.validated && !this.dirty) return this.validation;
167
+ this.errors.clear();
168
+ results = [this];
169
+ _ref = model[this.resource.toString()].validators;
170
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
171
+ validator = _ref[_i];
165
172
  results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
166
173
  }
174
+ this.validation = jQuery.when.apply(jQuery, results);
175
+ this.validation.done(doned);
176
+ this.validation.fail(failed);
177
+ return this.validation.then(function(record) {
178
+ var old_dirty;
179
+ old_dirty = record.dirty;
180
+ record.dirty = null;
181
+ record.validated || (record.validated = true);
182
+ return record.dirty = old_dirty;
183
+ });
167
184
  }
168
- validation = jQuery.when.apply(jQuery, results);
169
- validation.done(doned);
170
- validation.fail(failed);
171
- return validation;
172
- },
173
- validate: function(doned, failed) {
174
- var results, validator, _i, _len, _ref;
175
-
176
- if (this.validated && !this.dirty) {
177
- return this.validation;
178
- }
179
- this.errors.clear();
180
- results = [this];
181
- _ref = model[this.resource.toString()].validators;
182
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
183
- validator = _ref[_i];
184
- results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
185
- }
186
- this.validation = jQuery.when.apply(jQuery, results);
187
- this.validation.done(doned);
188
- this.validation.fail(failed);
189
- this.validation.then(function(record) {
190
- var old_dirty;
191
-
192
- old_dirty = record.dirty;
193
- record.dirty = null;
194
- record.validated || (record.validated = true);
195
- return record.dirty = old_dirty;
196
- });
197
- return this.validation;
198
185
  }
199
- }
200
- };
186
+ };
187
+
188
+ manager = {
189
+ validators: {}
190
+ };
201
191
 
202
- manager = {
203
- validators: {}
204
- };
192
+ model.mix(function(modelable) {
193
+ jQuery.extend(modelable, extensions.model);
194
+ jQuery.extend(modelable.record, extensions.record);
195
+ modelable.after_mix.unshift(initializers.create_validators);
196
+ modelable.record.after_initialize.push(initializers.define_triggers);
197
+ return model.validators = manager.validators;
198
+ });
205
199
 
206
- model.mix(function(modelable) {
207
- jQuery.extend(modelable, extensions.model);
208
- jQuery.extend(modelable.record, extensions.record);
209
- modelable.after_mix.unshift(initializers.create_validators);
210
- modelable.record.after_initialize.push(initializers.define_triggers);
211
- return model.validators = manager.validators;
212
- });
200
+ manager.validators.confirmation = require('./validations/confirmation');
213
201
 
214
- manager.validators.confirmation = require('./validations/confirmation');
202
+ manager.validators.associated = require('./validations/associated');
215
203
 
216
- manager.validators.associated = require('./validations/associated');
204
+ manager.validators.presence = require('./validations/presence');
217
205
 
218
- manager.validators.presence = require('./validations/presence');
206
+ manager.validators.remote = require('./validations/remote');
219
207
 
220
- manager.validators.remote = require('./validations/remote');
208
+ manager.validators.type = require('./validations/type');
221
209
 
222
- manager.validators.type = require('./validations/type');
210
+ manager.validators.cpf = require('./validations/cpf');
223
211
 
224
- manager.validators.cpf = require('./validations/cpf');
212
+ }).call(this);
@@ -184,8 +184,6 @@ extensions =
184
184
  # Restore dirty state
185
185
  record.dirty = old_dirty
186
186
 
187
- @validation
188
-
189
187
 
190
188
  # Validators management
191
189
  manager =
@@ -2,7 +2,7 @@
2
2
  "name": "observable",
3
3
  "repo": "indefinido/observable",
4
4
  "description": "Observable capabilities built upon observable shim.",
5
- "version": "0.1.3",
5
+ "version": "0.1.4",
6
6
  "keywords": [],
7
7
  "dependencies": {
8
8
  "component/jquery": "*"
@@ -1,4 +1,5 @@
1
1
  // TODO Better keypath support
2
+ // TODO Convert to coffeescript
2
3
 
3
4
  // Shim older browsers
4
5
  if (!Object.create ) require('../vendor/shims/object.create');
@@ -183,8 +184,8 @@ observable.unobserve = function (object) {
183
184
  check = function (keypath, value) {
184
185
  this.observed[keypath] = value;
185
186
 
186
- // TODO implement subscription
187
- (this.dirty === false) && (this.dirty = true);
187
+ // TODO implement subscription to any change, using Object.observe
188
+ (this.dirty === false && keypath != 'dirty') && (this.dirty = true);
188
189
  return true;
189
190
  };
190
191
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ende
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heitor Salazar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-28 00:00:00.000000000 Z
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,7 +139,6 @@ files:
139
139
  - lib/ende/csrf_extensions.rb
140
140
  - lib/ende/version.rb
141
141
  - lib/tasks/.gitkeep
142
- - vendor/assets/components/build.css
143
142
  - vendor/assets/components/ende_build.css
144
143
  - vendor/assets/components/ende_build.js
145
144
  - vendor/assets/components/indemma_with_none.js
@@ -204,7 +203,6 @@ files:
204
203
  - vendor/components/indefinido-advisable/index.js
205
204
  - vendor/components/indefinido-advisable/lib/advisable.js
206
205
  - vendor/components/indefinido-indemma/.gitignore
207
- - vendor/components/indefinido-indemma/.gitignore~
208
206
  - vendor/components/indefinido-indemma/.ruby-gemset
209
207
  - vendor/components/indefinido-indemma/.ruby-version
210
208
  - vendor/components/indefinido-indemma/Gemfile
@@ -1,111 +0,0 @@
1
- .overlay {
2
- position: absolute;
3
- top: 0;
4
- left: 0;
5
- opacity: 1;
6
- width: 100%;
7
- height: 100%;
8
- background: rgba(0,0,0,.75);
9
- -webkit-transition: opacity 300ms;
10
- -moz-transition: opacity 300ms;
11
- transition: opacity 300ms;
12
- z-index: 500;
13
- }
14
-
15
- .overlay.hide {
16
- pointer-events: none;
17
- opacity: 0;
18
- }
19
-
20
- #dialog {
21
- position: fixed;
22
- left: 50%;
23
- top: 150px;
24
- max-width: 600px;
25
- min-width: 250px;
26
- border: 1px solid #eee;
27
- background: white;
28
- z-index: 1000;
29
- }
30
-
31
- #dialog .content {
32
- padding: 15px 20px;
33
- }
34
-
35
- #dialog h1 {
36
- margin: 0 0 5px 0;
37
- font-size: 16px;
38
- font-weight: normal;
39
- }
40
-
41
- #dialog p {
42
- margin: 0;
43
- padding: 0;
44
- font-size: .9em;
45
- }
46
-
47
- /* close */
48
-
49
- #dialog .close {
50
- position: absolute;
51
- top: 3px;
52
- right: 10px;
53
- text-decoration: none;
54
- color: #888;
55
- font-size: 16px;
56
- font-weight: bold;
57
- display: none;
58
- }
59
-
60
- #dialog .close em {
61
- display: none;
62
- }
63
-
64
- #dialog.closable .close {
65
- display: block;
66
- }
67
-
68
- #dialog .close:hover {
69
- color: black;
70
- }
71
-
72
- #dialog .close:active {
73
- margin-top: 1px;
74
- }
75
-
76
- /* slide */
77
-
78
- #dialog.slide {
79
- -webkit-transition: opacity 300ms, top 300ms;
80
- -moz-transition: opacity 300ms, top 300ms;
81
- }
82
-
83
- #dialog.slide.hide {
84
- opacity: 0;
85
- top: -500px;
86
- }
87
-
88
- /* fade */
89
-
90
- #dialog.fade {
91
- -webkit-transition: opacity 300ms;
92
- -moz-transition: opacity 300ms;
93
- }
94
-
95
- #dialog.fade.hide {
96
- opacity: 0;
97
- }
98
-
99
- /* scale */
100
-
101
- #dialog.scale {
102
- -webkit-transition: -webkit-transform 300ms;
103
- -moz-transition: -moz-transform 300ms;
104
- -webkit-transform: scale(1);
105
- -moz-transform: scale(1);
106
- }
107
-
108
- #dialog.scale.hide {
109
- -webkit-transform: scale(0);
110
- -moz-transform: scale(0);
111
- }
@@ -1,2 +0,0 @@
1
- components
2
- build