ember-big_project 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +208 -0
- data/Rakefile +1 -0
- data/ember-big_project.gemspec +25 -0
- data/lib/ember/big_project.rb +7 -0
- data/lib/ember/big_project/version.rb +5 -0
- data/lib/generators/ember_proj/bootstrap_generator.rb +291 -0
- data/lib/generators/ember_proj/gem_helper.rb +48 -0
- data/lib/generators/ember_proj/templates/app/app_loader.js.coffee +16 -0
- data/lib/generators/ember_proj/templates/app/authentication.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/config.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/config/app.js.coffee +0 -0
- data/lib/generators/ember_proj/templates/app/config/display.js.coffee +0 -0
- data/lib/generators/ember_proj/templates/app/config/logging.js.coffee +0 -0
- data/lib/generators/ember_proj/templates/app/controllers.js.coffee +3 -0
- data/lib/generators/ember_proj/templates/app/helpers.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/lib.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/mixins.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/models.js.coffee +3 -0
- data/lib/generators/ember_proj/templates/app/routes.js.coffee +4 -0
- data/lib/generators/ember_proj/templates/app/state_managers.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/stores.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/templates.js.coffee +1 -0
- data/lib/generators/ember_proj/templates/app/views.js.coffee +3 -0
- data/lib/generators/ember_proj/templates/application.js.coffee +20 -0
- data/vendor/assets/javascripts/ember-data-validations.js +68 -0
- data/vendor/assets/javascripts/ember-easyForm.js +290 -0
- data/vendor/assets/javascripts/ember-formBuilder.js +32 -0
- data/vendor/assets/javascripts/ember-validations.js +581 -0
- metadata +118 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
(function(exports) {
|
2
|
+
(function() {
|
3
|
+
var Bootstrap;
|
4
|
+
|
5
|
+
Bootstrap = Ember.Mixin.create({
|
6
|
+
wrapperTag: 'div',
|
7
|
+
wrapperClass: 'control-group',
|
8
|
+
inputWrapperTag: 'div',
|
9
|
+
inputWrapperClass: 'controls',
|
10
|
+
labelClass: 'control-label',
|
11
|
+
helpTag: 'p',
|
12
|
+
helpClass: 'help-block',
|
13
|
+
errorTag: 'span',
|
14
|
+
errorClass: 'help-inline',
|
15
|
+
formClass: '',
|
16
|
+
submitClass: 'btn btn-success',
|
17
|
+
cancelClass: 'btn btn-danger',
|
18
|
+
submitTag: 'button',
|
19
|
+
cancelTag: 'a'
|
20
|
+
});
|
21
|
+
|
22
|
+
Ember.FormBuilder = Ember.Namespace.create({
|
23
|
+
mixins: {
|
24
|
+
'bootstrap': Bootstrap
|
25
|
+
},
|
26
|
+
pushMixin: function(mixin, mixinName) {
|
27
|
+
return this.mixins[mixinName] = mixin;
|
28
|
+
},
|
29
|
+
getMixin: function(mixinName) {
|
30
|
+
return this.mixins[mixinName];
|
31
|
+
}
|
32
|
+
});
|
@@ -0,0 +1,581 @@
|
|
1
|
+
// Last commit: f16740a (2013-02-27 16:14:05 -0500)
|
2
|
+
|
3
|
+
|
4
|
+
(function() {
|
5
|
+
Ember.Validations = Ember.Namespace.create({
|
6
|
+
VERSION: '0.2.1'
|
7
|
+
});
|
8
|
+
|
9
|
+
})();
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
(function() {
|
14
|
+
Ember.Application.reopen({
|
15
|
+
bootstrapValidations: function(validations) {
|
16
|
+
var objectName, property, validator, option, value, tmp,
|
17
|
+
normalizedValidations = {}, existingValidations;
|
18
|
+
function normalizeObject(object) {
|
19
|
+
var key, value, normalizedObject = {};
|
20
|
+
|
21
|
+
for (key in object) {
|
22
|
+
if (typeof(object[key]) === 'object') {
|
23
|
+
value = normalizeObject(object[key]);
|
24
|
+
} else {
|
25
|
+
value = object[key];
|
26
|
+
}
|
27
|
+
normalizedObject[key.camelize()] = value;
|
28
|
+
}
|
29
|
+
return normalizedObject;
|
30
|
+
}
|
31
|
+
|
32
|
+
for (objectName in validations) {
|
33
|
+
existingValidations = (new this[objectName.camelize().capitalize()]()).get('validations');
|
34
|
+
normalizedValidations = normalizeObject(validations[objectName]);
|
35
|
+
this[objectName.camelize().capitalize()].reopen({
|
36
|
+
validations: Ember.$.extend(true, {}, normalizedValidations, existingValidations)
|
37
|
+
});
|
38
|
+
|
39
|
+
}
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
})();
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
(function() {
|
48
|
+
Ember.Validations.messages = {
|
49
|
+
render: function(attribute, context) {
|
50
|
+
return Handlebars.compile(Ember.Validations.messages.defaults[attribute])(context);
|
51
|
+
},
|
52
|
+
defaults: {
|
53
|
+
inclusion: "is not included in the list",
|
54
|
+
exclusion: "is reserved",
|
55
|
+
invalid: "is invalid",
|
56
|
+
confirmation: "doesn't match {{attribute}}",
|
57
|
+
accepted: "must be accepted",
|
58
|
+
empty: "can't be empty",
|
59
|
+
blank: "can't be blank",
|
60
|
+
present: "must be blank",
|
61
|
+
tooLong: "is too long (maximum is {{count}} characters)",
|
62
|
+
tooShort: "is too short (minimum is {{count}} characters)",
|
63
|
+
wrongLength: "is the wrong length (should be {{count}} characters)",
|
64
|
+
notANumber: "is not a number",
|
65
|
+
notAnInteger: "must be an integer",
|
66
|
+
greaterThan: "must be greater than {{count}}",
|
67
|
+
greaterThanOrEqualTo: "must be greater than or equal to {{count}}",
|
68
|
+
equalTo: "must be equal to {{count}}",
|
69
|
+
lessThan: "must be less than {{count}}",
|
70
|
+
lessThanOrEqualTo: "must be less than or equal to {{count}}",
|
71
|
+
otherThan: "must be other than {{count}}",
|
72
|
+
odd: "must be odd",
|
73
|
+
even: "must be even"
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
})();
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
(function() {
|
82
|
+
Ember.Validations.Errors = Ember.Object.extend({
|
83
|
+
add: function(property, value) {
|
84
|
+
this.set(property, (this.get(property) || []).concat(value));
|
85
|
+
},
|
86
|
+
clear: function() {
|
87
|
+
var keys = Object.keys(this);
|
88
|
+
for(var i = 0; i < keys.length; i++) {
|
89
|
+
this.set(keys[i], undefined);
|
90
|
+
delete this[keys[i]];
|
91
|
+
}
|
92
|
+
}
|
93
|
+
});
|
94
|
+
|
95
|
+
})();
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
(function() {
|
100
|
+
Ember.Validations.Mixin = Ember.Mixin.create({
|
101
|
+
init: function() {
|
102
|
+
this._super();
|
103
|
+
this.set('errors', Ember.Validations.Errors.create());
|
104
|
+
if (this.get('validations') === undefined) {
|
105
|
+
this.set('validations', {});
|
106
|
+
}
|
107
|
+
},
|
108
|
+
validate: function(filter) {
|
109
|
+
var options, message, property, validator, toRun, value, index1, index2, valid = true, deferreds = [];
|
110
|
+
var object = this;
|
111
|
+
if (filter !== undefined) {
|
112
|
+
toRun = [filter];
|
113
|
+
} else {
|
114
|
+
toRun = Object.keys(object.validations);
|
115
|
+
}
|
116
|
+
for(index1 = 0; index1 < toRun.length; index1++) {
|
117
|
+
property = toRun[index1];
|
118
|
+
this.errors.set(property, undefined);
|
119
|
+
delete this.errors[property];
|
120
|
+
|
121
|
+
for(validator in this.validations[property]) {
|
122
|
+
value = object.validations[property][validator];
|
123
|
+
if (typeof(value) !== 'object' || (typeof(value) === 'object' && value.constructor !== Array)) {
|
124
|
+
value = [value];
|
125
|
+
}
|
126
|
+
|
127
|
+
for(index2 = 0; index2 < value.length; index2++) {
|
128
|
+
var deferredObject = new Ember.Deferred();
|
129
|
+
deferreds = deferreds.concat(deferredObject);
|
130
|
+
message = Ember.Validations.validators.local[validator](object, property, value[index2], deferredObject);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
return Ember.RSVP.all(deferreds).then(function() {
|
136
|
+
object.set('isValid', Object.keys(object.errors).length === 0);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
});
|
140
|
+
|
141
|
+
})();
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
(function() {
|
146
|
+
Ember.Validations.patterns = Ember.Namespace.create({
|
147
|
+
numericality: /^(-|\+)?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d*)?$/,
|
148
|
+
blank: /^\s*$/
|
149
|
+
});
|
150
|
+
|
151
|
+
})();
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
(function() {
|
156
|
+
Ember.Validations.validators = Ember.Namespace.create();
|
157
|
+
Ember.Validations.validators.local = Ember.Namespace.create();
|
158
|
+
Ember.Validations.validators.remote = Ember.Namespace.create();
|
159
|
+
|
160
|
+
})();
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
(function() {
|
165
|
+
Ember.Validations.validators.local.reopen({
|
166
|
+
absence: function(model, property, options, deferredObject) {
|
167
|
+
/*jshint expr:true*/
|
168
|
+
if (options === true) {
|
169
|
+
options = {};
|
170
|
+
}
|
171
|
+
|
172
|
+
if (options.message === undefined) {
|
173
|
+
options.message = Ember.Validations.messages.render('present', options);
|
174
|
+
}
|
175
|
+
|
176
|
+
if (!Ember.Validations.Utilities.isBlank(model.get(property))) {
|
177
|
+
model.errors.add(property, options.message);
|
178
|
+
}
|
179
|
+
|
180
|
+
deferredObject && deferredObject.resolve();
|
181
|
+
}
|
182
|
+
});
|
183
|
+
|
184
|
+
})();
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
(function() {
|
189
|
+
Ember.Validations.validators.local.reopen({
|
190
|
+
acceptance: function(model, property, options, deferredObject) {
|
191
|
+
/*jshint expr:true*/
|
192
|
+
if (options === true) {
|
193
|
+
options = {};
|
194
|
+
}
|
195
|
+
|
196
|
+
if (options.message === undefined) {
|
197
|
+
options.message = Ember.Validations.messages.render('accepted', options);
|
198
|
+
}
|
199
|
+
|
200
|
+
if (options.accept) {
|
201
|
+
if (model.get(property) !== options.accept) {
|
202
|
+
model.errors.add(property, options.message);
|
203
|
+
}
|
204
|
+
} else if (model.get(property) !== '1' && model.get(property) !== 1 && model.get(property) !== true) {
|
205
|
+
model.errors.add(property, options.message);
|
206
|
+
}
|
207
|
+
deferredObject && deferredObject.resolve();
|
208
|
+
}
|
209
|
+
});
|
210
|
+
|
211
|
+
})();
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
(function() {
|
216
|
+
Ember.Validations.validators.local.reopen({
|
217
|
+
confirmation: function(model, property, options, deferredObject) {
|
218
|
+
/*jshint expr:true*/
|
219
|
+
if (options === true) {
|
220
|
+
options = { attribute: property };
|
221
|
+
options = { message: Ember.Validations.messages.render('confirmation', options) };
|
222
|
+
}
|
223
|
+
|
224
|
+
if (model.get(property) !== model.get('' + property + 'Confirmation')) {
|
225
|
+
model.errors.add(property, options.message);
|
226
|
+
}
|
227
|
+
deferredObject && deferredObject.resolve();
|
228
|
+
}
|
229
|
+
});
|
230
|
+
|
231
|
+
})();
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
(function() {
|
236
|
+
Ember.Validations.validators.local.reopen({
|
237
|
+
exclusion: function(model, property, options, deferredObject) {
|
238
|
+
/*jshint expr:true*/
|
239
|
+
var message, lower, upper;
|
240
|
+
|
241
|
+
if (options.constructor === Array) {
|
242
|
+
options = { 'in': options };
|
243
|
+
}
|
244
|
+
|
245
|
+
if (options.message === undefined) {
|
246
|
+
options.message = Ember.Validations.messages.render('exclusion', options);
|
247
|
+
}
|
248
|
+
|
249
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
250
|
+
if (options.allowBlank === undefined) {
|
251
|
+
model.errors.add(property, options.message);
|
252
|
+
}
|
253
|
+
} else if (options['in']) {
|
254
|
+
if (Ember.$.inArray(model.get(property), options['in']) !== -1) {
|
255
|
+
model.errors.add(property, options.message);
|
256
|
+
}
|
257
|
+
} else if (options.range) {
|
258
|
+
lower = options.range[0];
|
259
|
+
upper = options.range[1];
|
260
|
+
|
261
|
+
if (model.get(property) >= lower && model.get(property) <= upper) {
|
262
|
+
model.errors.add(property, options.message);
|
263
|
+
}
|
264
|
+
}
|
265
|
+
deferredObject && deferredObject.resolve();
|
266
|
+
}
|
267
|
+
});
|
268
|
+
|
269
|
+
})();
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
(function() {
|
274
|
+
Ember.Validations.validators.local.reopen({
|
275
|
+
format: function(model, property, options, deferredObject) {
|
276
|
+
/*jshint expr:true*/
|
277
|
+
var message;
|
278
|
+
|
279
|
+
if (options.constructor === RegExp) {
|
280
|
+
options = { 'with': options };
|
281
|
+
}
|
282
|
+
|
283
|
+
if (options.message === undefined) {
|
284
|
+
options.message = Ember.Validations.messages.render('invalid', options);
|
285
|
+
}
|
286
|
+
|
287
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
288
|
+
if (options.allowBlank === undefined) {
|
289
|
+
model.errors.add(property, options.message);
|
290
|
+
}
|
291
|
+
} else if (options['with'] && !options['with'].test(model.get(property))) {
|
292
|
+
model.errors.add(property, options.message);
|
293
|
+
} else if (options.without && options.without.test(model.get(property))) {
|
294
|
+
model.errors.add(property, options.message);
|
295
|
+
}
|
296
|
+
|
297
|
+
deferredObject && deferredObject.resolve();
|
298
|
+
}
|
299
|
+
});
|
300
|
+
|
301
|
+
})();
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
(function() {
|
306
|
+
Ember.Validations.validators.local.reopen({
|
307
|
+
inclusion: function(model, property, options, deferredObject) {
|
308
|
+
/*jshint expr:true*/
|
309
|
+
var message, lower, upper;
|
310
|
+
|
311
|
+
if (options.constructor === Array) {
|
312
|
+
options = { 'in': options };
|
313
|
+
}
|
314
|
+
|
315
|
+
if (options.message === undefined) {
|
316
|
+
options.message = Ember.Validations.messages.render('inclusion', options);
|
317
|
+
}
|
318
|
+
|
319
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
320
|
+
if (options.allowBlank === undefined) {
|
321
|
+
model.errors.add(property, options.message);
|
322
|
+
}
|
323
|
+
} else if (options['in']) {
|
324
|
+
if (Ember.$.inArray(model.get(property), options['in']) === -1) {
|
325
|
+
model.errors.add(property, options.message);
|
326
|
+
}
|
327
|
+
} else if (options.range) {
|
328
|
+
lower = options.range[0];
|
329
|
+
upper = options.range[1];
|
330
|
+
|
331
|
+
if (model.get(property) < lower || model.get(property) > upper) {
|
332
|
+
model.errors.add(property, options.message);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
deferredObject && deferredObject.resolve();
|
336
|
+
}
|
337
|
+
});
|
338
|
+
|
339
|
+
})();
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
(function() {
|
344
|
+
Ember.Validations.validators.local.reopen({
|
345
|
+
length: function(model, property, options, deferredObject) {
|
346
|
+
/*jshint expr:true*/
|
347
|
+
var CHECKS, MESSAGES, allowBlankOptions, check, fn, message, operator, tokenizedLength, tokenizer, index, keys, key;
|
348
|
+
|
349
|
+
CHECKS = {
|
350
|
+
'is' : '==',
|
351
|
+
'minimum' : '>=',
|
352
|
+
'maximum' : '<='
|
353
|
+
};
|
354
|
+
|
355
|
+
MESSAGES = {
|
356
|
+
'is' : 'wrongLength',
|
357
|
+
'minimum' : 'tooShort',
|
358
|
+
'maximum' : 'tooLong'
|
359
|
+
};
|
360
|
+
|
361
|
+
if (typeof(options) === 'number') {
|
362
|
+
options = { 'is': options };
|
363
|
+
}
|
364
|
+
|
365
|
+
if (options.messages === undefined) {
|
366
|
+
options.messages = {};
|
367
|
+
}
|
368
|
+
|
369
|
+
keys = Object.keys(MESSAGES);
|
370
|
+
for (index = 0; index < keys.length; index++) {
|
371
|
+
key = keys[index];
|
372
|
+
if (options[key] !== undefined && options.messages[key] === undefined) {
|
373
|
+
if (Ember.$.inArray(key, Object.keys(CHECKS)) !== -1) {
|
374
|
+
options.count = options[key];
|
375
|
+
}
|
376
|
+
options.messages[key] = Ember.Validations.messages.render(MESSAGES[key], options);
|
377
|
+
if (options.count !== undefined) {
|
378
|
+
delete options.count;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
|
383
|
+
tokenizer = options.tokenizer || 'split("")';
|
384
|
+
tokenizedLength = new Function('value', 'return value.' + tokenizer + '.length')(model.get(property) || '');
|
385
|
+
|
386
|
+
allowBlankOptions = {};
|
387
|
+
if (options.is) {
|
388
|
+
allowBlankOptions.message = options.messages.is;
|
389
|
+
} else if (options.minimum) {
|
390
|
+
allowBlankOptions.message = options.messages.minimum;
|
391
|
+
}
|
392
|
+
|
393
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
394
|
+
if (options.allowBlank === undefined) {
|
395
|
+
model.errors.add(property, allowBlankOptions.message);
|
396
|
+
}
|
397
|
+
} else {
|
398
|
+
for (check in CHECKS) {
|
399
|
+
operator = CHECKS[check];
|
400
|
+
if (!options[check]) {
|
401
|
+
continue;
|
402
|
+
}
|
403
|
+
|
404
|
+
fn = new Function("return " + tokenizedLength + " " + operator + " " + options[check]);
|
405
|
+
if (!fn()) {
|
406
|
+
model.errors.add(property, options.messages[check]);
|
407
|
+
}
|
408
|
+
}
|
409
|
+
}
|
410
|
+
deferredObject && deferredObject.resolve();
|
411
|
+
}
|
412
|
+
});
|
413
|
+
|
414
|
+
})();
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
(function() {
|
419
|
+
Ember.Validations.validators.local.reopen({
|
420
|
+
numericality: function(model, property, options, deferredObject) {
|
421
|
+
/*jshint expr:true*/
|
422
|
+
var CHECKS, check, checkValue, fn, form, operator, val, index, keys, key;
|
423
|
+
|
424
|
+
CHECKS = {
|
425
|
+
equalTo :'===',
|
426
|
+
greaterThan : '>',
|
427
|
+
greaterThanOrEqualTo : '>=',
|
428
|
+
lessThan : '<',
|
429
|
+
lessThanOrEqualTo : '<='
|
430
|
+
};
|
431
|
+
|
432
|
+
if (options === true) {
|
433
|
+
options = {};
|
434
|
+
}
|
435
|
+
|
436
|
+
if (options.messages === undefined) {
|
437
|
+
options.messages = { numericality: Ember.Validations.messages.render('notANumber', options) };
|
438
|
+
}
|
439
|
+
|
440
|
+
if (options.onlyInteger !== undefined && options.messages.onlyInteger === undefined) {
|
441
|
+
options.messages.onlyInteger = Ember.Validations.messages.render('notAnInteger', options);
|
442
|
+
}
|
443
|
+
|
444
|
+
keys = Object.keys(CHECKS).concat(['odd', 'even']);
|
445
|
+
for(index = 0; index < keys.length; index++) {
|
446
|
+
key = keys[index];
|
447
|
+
if (options[key] !== undefined && options.messages[key] === undefined) {
|
448
|
+
if (Ember.$.inArray(key, Object.keys(CHECKS)) !== -1) {
|
449
|
+
options.count = options[key];
|
450
|
+
}
|
451
|
+
options.messages[key] = Ember.Validations.messages.render(key, options);
|
452
|
+
if (options.count !== undefined) {
|
453
|
+
delete options.count;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
459
|
+
if (options.allowBlank === undefined) {
|
460
|
+
model.errors.add(property, options.messages.numericality);
|
461
|
+
}
|
462
|
+
} else if (!Ember.Validations.patterns.numericality.test(model.get(property))) {
|
463
|
+
model.errors.add(property, options.messages.numericality);
|
464
|
+
} else if (options.onlyInteger === true && !(/^[+\-]?\d+$/.test(model.get(property)))) {
|
465
|
+
model.errors.add(property, options.messages.onlyInteger);
|
466
|
+
} else if (options.odd && parseInt(model.get(property), 10) % 2 === 0) {
|
467
|
+
model.errors.add(property, options.messages.odd);
|
468
|
+
} else if (options.even && parseInt(model.get(property), 10) % 2 !== 0) {
|
469
|
+
model.errors.add(property, options.messages.even);
|
470
|
+
} else {
|
471
|
+
|
472
|
+
for (check in CHECKS) {
|
473
|
+
operator = CHECKS[check];
|
474
|
+
|
475
|
+
if (options[check] === undefined) {
|
476
|
+
continue;
|
477
|
+
}
|
478
|
+
|
479
|
+
if (!isNaN(parseFloat(options[check])) && isFinite(options[check])) {
|
480
|
+
checkValue = options[check];
|
481
|
+
} else if (model.get(options[check]) !== undefined) {
|
482
|
+
checkValue = model.get(options[check]);
|
483
|
+
} else {
|
484
|
+
deferredObject && deferredObject.resolve();
|
485
|
+
return;
|
486
|
+
}
|
487
|
+
|
488
|
+
fn = new Function('return ' + model.get(property) + ' ' + operator + ' ' + checkValue);
|
489
|
+
|
490
|
+
if (!fn()) {
|
491
|
+
model.errors.add(property, options.messages[check]);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
}
|
495
|
+
deferredObject && deferredObject.resolve();
|
496
|
+
}
|
497
|
+
});
|
498
|
+
|
499
|
+
})();
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
(function() {
|
504
|
+
Ember.Validations.validators.local.reopen({
|
505
|
+
presence: function(model, property, options, deferredObject) {
|
506
|
+
/*jshint expr:true*/
|
507
|
+
if (options === true) {
|
508
|
+
options = {};
|
509
|
+
}
|
510
|
+
|
511
|
+
if (options.message === undefined) {
|
512
|
+
options.message = Ember.Validations.messages.render('blank', options);
|
513
|
+
}
|
514
|
+
|
515
|
+
if (Ember.Validations.Utilities.isBlank(model.get(property))) {
|
516
|
+
model.errors.add(property, options.message);
|
517
|
+
}
|
518
|
+
|
519
|
+
deferredObject && deferredObject.resolve();
|
520
|
+
}
|
521
|
+
});
|
522
|
+
|
523
|
+
})();
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
(function() {
|
528
|
+
Ember.Validations.validators.local.reopen({
|
529
|
+
uniqueness: function(model, property, options) {
|
530
|
+
}
|
531
|
+
});
|
532
|
+
|
533
|
+
})();
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
(function() {
|
538
|
+
|
539
|
+
})();
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
(function() {
|
544
|
+
// this is fugly, I know but no other way to get these from what I can see
|
545
|
+
// var states = (new DS.StateManager).states;
|
546
|
+
// var validating = DS.State.extend({
|
547
|
+
// enter: function(manager) {
|
548
|
+
|
549
|
+
// }
|
550
|
+
// });
|
551
|
+
|
552
|
+
// states.rootState.get('loaded.created').reopen({
|
553
|
+
// validating: validating
|
554
|
+
// });
|
555
|
+
|
556
|
+
// states.rootState.get('loaded.updated').reopen({
|
557
|
+
// validating: validating
|
558
|
+
// });
|
559
|
+
|
560
|
+
// DS.StateManager.reopen({
|
561
|
+
// states: states
|
562
|
+
// });
|
563
|
+
|
564
|
+
})();
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
(function() {
|
569
|
+
Ember.Validations.Utilities = {
|
570
|
+
isBlank: function(value) {
|
571
|
+
return value !== 0 && (!value || /^\s*$/.test(''+value));
|
572
|
+
}
|
573
|
+
};
|
574
|
+
|
575
|
+
})();
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
(function() {
|
580
|
+
|
581
|
+
})();
|