js_stack 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +5 -5
- data/lib/js_stack/version.rb +1 -1
- data/vendor/assets/javascripts/js_stack/base/marionette/{2.3.1.js → 2.3.2.js} +11 -8
- data/vendor/assets/javascripts/js_stack/base/marionette.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.11.3.js +704 -0
- data/vendor/assets/javascripts/js_stack/plugins/backbone/validation/{0.9.1.js → 0.9.2.js} +3 -9
- data/vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/{0.6.0.js → 0.6.1.js} +13 -5
- data/vendor/assets/javascripts/js_stack/plugins/backbone.validation.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone.virtualcollection.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/cocktail/{0.5.8.js → 0.5.10.js} +6 -7
- data/vendor/assets/javascripts/js_stack/plugins/cocktail.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/underscore/string/{3.0.1.js → 3.0.3.js} +2 -2
- data/vendor/assets/javascripts/js_stack/plugins/underscore.string.js +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72c85f96ee87d9d966db874e1f2b2c2e889c6b3
|
4
|
+
data.tar.gz: 7c36f630ad50d5a53336c4fa8d2703c056434cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd00f069a5ce891eeb5b1a7c12b2973f5481e2ad61580b71d02098421df310705c63b3efc84dc36e11f145a86aa66a2f0bddd0496cba803980c5bde370783560
|
7
|
+
data.tar.gz: f1106d0662a634bf9a533beb4c99a2439d4f57f10764733e8204d47a2ac98d3eef1a3ab3a051d84da3fca78901e3fae12172d8fa656e09a3676ce2c6f6c8c394
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 1.7.0
|
4
|
+
|
5
|
+
* update marionette 2.3.1 -> 2.3.2 [@gvl]
|
6
|
+
* update backbone.validation 0.9.1 -> 0.9.2 -> 0.11.3 [@gvl]
|
7
|
+
* update backbone.virtualcollection 0.6.0 -> 0.6.1 [@gvl]
|
8
|
+
* update cocktail 0.5.8 -> 0.5.10 [@gvl]
|
9
|
+
* update underscore.string 3.0.1 -> 3.0.3 [@gvl]
|
10
|
+
|
3
11
|
# 1.6.0
|
4
12
|
|
5
13
|
* update marionette 2.3.0 -> 2.3.1 [@gvl]
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Examples:
|
|
48
48
|
| Library | Versions | Changelog | Homepage |
|
49
49
|
| :-----: | :------: | :-------: | :------: |
|
50
50
|
| backbone | **1.1.2**, 1.0.0 | [changelog](http://backbonejs.org/#changelog) | [homepage](http://backbonejs.org/) |
|
51
|
-
| marionette | **2.3.
|
51
|
+
| marionette | **2.3.2**, 2.2.2, 2.1.0, 2.0.3, 1.8.8, 1.7.4, 1.6.4, 1.5.1, 1.4.1, 1.1.0 | [changelog](https://github.com/marionettejs/backbone.marionette/blob/master/changelog.md) | [homepage](http://marionettejs.com/) |
|
52
52
|
| underscore | **1.7.0**, 1.6.0, 1.5.2 | [changelog](http://underscorejs.org/#changelog) | [homepage](http://underscorejs.org/) |
|
53
53
|
| hamlcoffee | **1.16** | [changelog](https://github.com/netzpirat/haml_coffee_assets/blob/master/CHANGELOG.md) | [homepage](https://github.com/netzpirat/haml_coffee_assets) |
|
54
54
|
| js-routes | **1.0.0** | [changelog](https://github.com/railsware/js-routes/blob/master/CHANGELOG.md) | [homepage](https://github.com/railsware/js-routes) |
|
@@ -64,12 +64,12 @@ Examples:
|
|
64
64
|
| backbone paginator | **2.0.2** | [changelog](https://github.com/backbone-paginator/backbone.paginator/wiki/Changelog) | [homepage](https://github.com/backbone-paginator/backbone.paginator) |
|
65
65
|
| backbone routefilter | **0.2.1** | [changelog](https://github.com/boazsender/backbone.routefilter#release-history) | [homepage](https://github.com/boazsender/backbone.routefilter) |
|
66
66
|
| backbone stickit | **0.8.0**, 0.7.0, 0.6.3 | [changelog](http://nytimes.github.io/backbone.stickit/#change-log) | [homepage](http://nytimes.github.io/backbone.stickit/) |
|
67
|
-
| backbone validation | **0.
|
68
|
-
| backbone virtualcollection | **0.6.
|
69
|
-
| cocktail | **0.5.
|
67
|
+
| backbone validation | **0.11.3**, 0.9.2, 0.8.1 | [changelog](https://github.com/thedersen/backbone.validation#release-notes) | [homepage](https://github.com/thedersen/backbone.validation) |
|
68
|
+
| backbone virtualcollection | **0.6.1**, 0.5.3, 0.4.15 | [changelog](https://github.com/p3drosola/Backbone.VirtualCollection/wiki/Changelog) | [homepage](https://github.com/p3drosola/Backbone.VirtualCollection) |
|
69
|
+
| cocktail | **0.5.10** | None | [homepage](https://github.com/onsi/cocktail) |
|
70
70
|
| momentjs | **2.9.0** | [changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) | [homepage](https://github.com/derekprior/momentjs-rails) |
|
71
71
|
| underscore inflections | **0.2.1** | None | [homepage](https://github.com/geetarista/underscore.inflections) |
|
72
|
-
| underscore string | **3.0.
|
72
|
+
| underscore string | **3.0.3**, 2.4.0, 2.3.2 | [changelog](https://github.com/epeli/underscore.string/blob/master/CHANGELOG.markdown) | [homepage](http://epeli.github.io/underscore.string/) |
|
73
73
|
|
74
74
|
## Contributing
|
75
75
|
|
data/lib/js_stack/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// MarionetteJS (Backbone.Marionette)
|
2
2
|
// ----------------------------------
|
3
|
-
// v2.3.
|
3
|
+
// v2.3.2
|
4
4
|
//
|
5
5
|
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
|
6
6
|
// Distributed under MIT license
|
@@ -493,7 +493,7 @@
|
|
493
493
|
|
494
494
|
var Marionette = Backbone.Marionette = {};
|
495
495
|
|
496
|
-
Marionette.VERSION = '2.3.
|
496
|
+
Marionette.VERSION = '2.3.2';
|
497
497
|
|
498
498
|
Marionette.noConflict = function() {
|
499
499
|
root.Marionette = previousMarionette;
|
@@ -550,6 +550,10 @@
|
|
550
550
|
// undefined return a default value
|
551
551
|
Marionette._getValue = function(value, context, params) {
|
552
552
|
if (_.isFunction(value)) {
|
553
|
+
// We need to ensure that params is not undefined
|
554
|
+
// to prevent `apply` from failing in ie8
|
555
|
+
params = params || [];
|
556
|
+
|
553
557
|
value = value.apply(context, params);
|
554
558
|
}
|
555
559
|
return value;
|
@@ -753,14 +757,13 @@
|
|
753
757
|
// Bind Entity Events & Unbind Entity Events
|
754
758
|
// -----------------------------------------
|
755
759
|
//
|
756
|
-
// These methods are used to bind/unbind a backbone "entity" (collection/model)
|
760
|
+
// These methods are used to bind/unbind a backbone "entity" (e.g. collection/model)
|
757
761
|
// to methods on a target object.
|
758
762
|
//
|
759
|
-
// The first parameter, `target`, must have
|
760
|
-
// EventBinder object.
|
763
|
+
// The first parameter, `target`, must have the Backbone.Events module mixed in.
|
761
764
|
//
|
762
|
-
// The second parameter is the entity (Backbone.Model
|
763
|
-
// to bind the events from.
|
765
|
+
// The second parameter is the `entity` (Backbone.Model, Backbone.Collection or
|
766
|
+
// any object that has Backbone.Events mixed in) to bind the events from.
|
764
767
|
//
|
765
768
|
// The third parameter is a hash of { "event:name": "eventHandler" }
|
766
769
|
// configuration. Multiple handlers can be separated by a space. A
|
@@ -2244,7 +2247,7 @@
|
|
2244
2247
|
},
|
2245
2248
|
|
2246
2249
|
// Render and show the emptyView. Similar to addChild method
|
2247
|
-
// but "child
|
2250
|
+
// but "add:child" events are not fired, and the event from
|
2248
2251
|
// emptyView are not forwarded
|
2249
2252
|
addEmptyView: function(child, EmptyView) {
|
2250
2253
|
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/base/marionette/2.3.
|
1
|
+
//= require js_stack/base/marionette/2.3.2
|
@@ -0,0 +1,704 @@
|
|
1
|
+
// Backbone.Validation v0.11.3
|
2
|
+
//
|
3
|
+
// Copyright (c) 2011-2015 Thomas Pedersen
|
4
|
+
// Distributed under MIT License
|
5
|
+
//
|
6
|
+
// Documentation and full license available at:
|
7
|
+
// http://thedersen.com/projects/backbone-validation
|
8
|
+
Backbone.Validation = (function(_){
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
// Default options
|
12
|
+
// ---------------
|
13
|
+
|
14
|
+
var defaultOptions = {
|
15
|
+
forceUpdate: false,
|
16
|
+
selector: 'name',
|
17
|
+
labelFormatter: 'sentenceCase',
|
18
|
+
valid: Function.prototype,
|
19
|
+
invalid: Function.prototype
|
20
|
+
};
|
21
|
+
|
22
|
+
|
23
|
+
// Helper functions
|
24
|
+
// ----------------
|
25
|
+
|
26
|
+
// Formatting functions used for formatting error messages
|
27
|
+
var formatFunctions = {
|
28
|
+
// Uses the configured label formatter to format the attribute name
|
29
|
+
// to make it more readable for the user
|
30
|
+
formatLabel: function(attrName, model) {
|
31
|
+
return defaultLabelFormatters[defaultOptions.labelFormatter](attrName, model);
|
32
|
+
},
|
33
|
+
|
34
|
+
// Replaces nummeric placeholders like {0} in a string with arguments
|
35
|
+
// passed to the function
|
36
|
+
format: function() {
|
37
|
+
var args = Array.prototype.slice.call(arguments),
|
38
|
+
text = args.shift();
|
39
|
+
return text.replace(/\{(\d+)\}/g, function(match, number) {
|
40
|
+
return typeof args[number] !== 'undefined' ? args[number] : match;
|
41
|
+
});
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
// Flattens an object
|
46
|
+
// eg:
|
47
|
+
//
|
48
|
+
// var o = {
|
49
|
+
// owner: {
|
50
|
+
// name: 'Backbone',
|
51
|
+
// address: {
|
52
|
+
// street: 'Street',
|
53
|
+
// zip: 1234
|
54
|
+
// }
|
55
|
+
// }
|
56
|
+
// };
|
57
|
+
//
|
58
|
+
// becomes:
|
59
|
+
//
|
60
|
+
// var o = {
|
61
|
+
// 'owner': {
|
62
|
+
// name: 'Backbone',
|
63
|
+
// address: {
|
64
|
+
// street: 'Street',
|
65
|
+
// zip: 1234
|
66
|
+
// }
|
67
|
+
// },
|
68
|
+
// 'owner.name': 'Backbone',
|
69
|
+
// 'owner.address': {
|
70
|
+
// street: 'Street',
|
71
|
+
// zip: 1234
|
72
|
+
// },
|
73
|
+
// 'owner.address.street': 'Street',
|
74
|
+
// 'owner.address.zip': 1234
|
75
|
+
// };
|
76
|
+
// This may seem redundant, but it allows for maximum flexibility
|
77
|
+
// in validation rules.
|
78
|
+
var flatten = function (obj, into, prefix) {
|
79
|
+
into = into || {};
|
80
|
+
prefix = prefix || '';
|
81
|
+
|
82
|
+
_.each(obj, function(val, key) {
|
83
|
+
if(obj.hasOwnProperty(key)) {
|
84
|
+
if (!!val && typeof val === 'object' && val.constructor === Object) {
|
85
|
+
flatten(val, into, prefix + key + '.');
|
86
|
+
}
|
87
|
+
|
88
|
+
// Register the current level object as well
|
89
|
+
into[prefix + key] = val;
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
return into;
|
94
|
+
};
|
95
|
+
|
96
|
+
// Validation
|
97
|
+
// ----------
|
98
|
+
|
99
|
+
var Validation = (function(){
|
100
|
+
|
101
|
+
// Returns an object with undefined properties for all
|
102
|
+
// attributes on the model that has defined one or more
|
103
|
+
// validation rules.
|
104
|
+
var getValidatedAttrs = function(model, attrs) {
|
105
|
+
attrs = attrs || _.keys(_.result(model, 'validation') || {});
|
106
|
+
return _.reduce(attrs, function(memo, key) {
|
107
|
+
memo[key] = void 0;
|
108
|
+
return memo;
|
109
|
+
}, {});
|
110
|
+
};
|
111
|
+
|
112
|
+
// Returns an array with attributes passed through options
|
113
|
+
var getOptionsAttrs = function(options, view) {
|
114
|
+
var attrs = options.attributes;
|
115
|
+
if (_.isFunction(attrs)) {
|
116
|
+
attrs = attrs(view);
|
117
|
+
} else if (_.isString(attrs) && (_.isFunction(defaultAttributeLoaders[attrs]))) {
|
118
|
+
attrs = defaultAttributeLoaders[attrs](view);
|
119
|
+
}
|
120
|
+
if (_.isArray(attrs)) {
|
121
|
+
return attrs;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
|
126
|
+
// Looks on the model for validations for a specified
|
127
|
+
// attribute. Returns an array of any validators defined,
|
128
|
+
// or an empty array if none is defined.
|
129
|
+
var getValidators = function(model, attr) {
|
130
|
+
var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {};
|
131
|
+
|
132
|
+
// If the validator is a function or a string, wrap it in a function validator
|
133
|
+
if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) {
|
134
|
+
attrValidationSet = {
|
135
|
+
fn: attrValidationSet
|
136
|
+
};
|
137
|
+
}
|
138
|
+
|
139
|
+
// Stick the validator object into an array
|
140
|
+
if(!_.isArray(attrValidationSet)) {
|
141
|
+
attrValidationSet = [attrValidationSet];
|
142
|
+
}
|
143
|
+
|
144
|
+
// Reduces the array of validators into a new array with objects
|
145
|
+
// with a validation method to call, the value to validate against
|
146
|
+
// and the specified error message, if any
|
147
|
+
return _.reduce(attrValidationSet, function(memo, attrValidation) {
|
148
|
+
_.each(_.without(_.keys(attrValidation), 'msg'), function(validator) {
|
149
|
+
memo.push({
|
150
|
+
fn: defaultValidators[validator],
|
151
|
+
val: attrValidation[validator],
|
152
|
+
msg: attrValidation.msg
|
153
|
+
});
|
154
|
+
});
|
155
|
+
return memo;
|
156
|
+
}, []);
|
157
|
+
};
|
158
|
+
|
159
|
+
// Validates an attribute against all validators defined
|
160
|
+
// for that attribute. If one or more errors are found,
|
161
|
+
// the first error message is returned.
|
162
|
+
// If the attribute is valid, an empty string is returned.
|
163
|
+
var validateAttr = function(model, attr, value, computed) {
|
164
|
+
// Reduces the array of validators to an error message by
|
165
|
+
// applying all the validators and returning the first error
|
166
|
+
// message, if any.
|
167
|
+
return _.reduce(getValidators(model, attr), function(memo, validator){
|
168
|
+
// Pass the format functions plus the default
|
169
|
+
// validators as the context to the validator
|
170
|
+
var ctx = _.extend({}, formatFunctions, defaultValidators),
|
171
|
+
result = validator.fn.call(ctx, value, attr, validator.val, model, computed);
|
172
|
+
|
173
|
+
if(result === false || memo === false) {
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
if (result && !memo) {
|
177
|
+
return _.result(validator, 'msg') || result;
|
178
|
+
}
|
179
|
+
return memo;
|
180
|
+
}, '');
|
181
|
+
};
|
182
|
+
|
183
|
+
// Loops through the model's attributes and validates the specified attrs.
|
184
|
+
// Returns and object containing names of invalid attributes
|
185
|
+
// as well as error messages.
|
186
|
+
var validateModel = function(model, attrs, validatedAttrs) {
|
187
|
+
var error,
|
188
|
+
invalidAttrs = {},
|
189
|
+
isValid = true,
|
190
|
+
computed = _.clone(attrs);
|
191
|
+
|
192
|
+
_.each(validatedAttrs, function(val, attr) {
|
193
|
+
error = validateAttr(model, attr, val, computed);
|
194
|
+
if (error) {
|
195
|
+
invalidAttrs[attr] = error;
|
196
|
+
isValid = false;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
|
200
|
+
return {
|
201
|
+
invalidAttrs: invalidAttrs,
|
202
|
+
isValid: isValid
|
203
|
+
};
|
204
|
+
};
|
205
|
+
|
206
|
+
// Contains the methods that are mixed in on the model when binding
|
207
|
+
var mixin = function(view, options) {
|
208
|
+
return {
|
209
|
+
|
210
|
+
// Check whether or not a value, or a hash of values
|
211
|
+
// passes validation without updating the model
|
212
|
+
preValidate: function(attr, value) {
|
213
|
+
var self = this,
|
214
|
+
result = {},
|
215
|
+
error;
|
216
|
+
|
217
|
+
if(_.isObject(attr)){
|
218
|
+
_.each(attr, function(value, key) {
|
219
|
+
error = self.preValidate(key, value);
|
220
|
+
if(error){
|
221
|
+
result[key] = error;
|
222
|
+
}
|
223
|
+
});
|
224
|
+
|
225
|
+
return _.isEmpty(result) ? undefined : result;
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
return validateAttr(this, attr, value, _.extend({}, this.attributes));
|
229
|
+
}
|
230
|
+
},
|
231
|
+
|
232
|
+
// Check to see if an attribute, an array of attributes or the
|
233
|
+
// entire model is valid. Passing true will force a validation
|
234
|
+
// of the model.
|
235
|
+
isValid: function(option) {
|
236
|
+
var flattened, attrs, error, invalidAttrs;
|
237
|
+
|
238
|
+
option = option || getOptionsAttrs(options, view);
|
239
|
+
|
240
|
+
if(_.isString(option)){
|
241
|
+
attrs = [option];
|
242
|
+
} else if(_.isArray(option)) {
|
243
|
+
attrs = option;
|
244
|
+
}
|
245
|
+
if (attrs) {
|
246
|
+
flattened = flatten(this.attributes);
|
247
|
+
//Loop through all associated views
|
248
|
+
_.each(this.associatedViews, function(view) {
|
249
|
+
_.each(attrs, function (attr) {
|
250
|
+
error = validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes));
|
251
|
+
if (error) {
|
252
|
+
options.invalid(view, attr, error, options.selector);
|
253
|
+
invalidAttrs = invalidAttrs || {};
|
254
|
+
invalidAttrs[attr] = error;
|
255
|
+
} else {
|
256
|
+
options.valid(view, attr, options.selector);
|
257
|
+
}
|
258
|
+
}, this);
|
259
|
+
}, this);
|
260
|
+
}
|
261
|
+
|
262
|
+
if(option === true) {
|
263
|
+
invalidAttrs = this.validate();
|
264
|
+
}
|
265
|
+
if (invalidAttrs) {
|
266
|
+
this.trigger('invalid', this, invalidAttrs, {validationError: invalidAttrs});
|
267
|
+
}
|
268
|
+
return attrs ? !invalidAttrs : this.validation ? this._isValid : true;
|
269
|
+
},
|
270
|
+
|
271
|
+
// This is called by Backbone when it needs to perform validation.
|
272
|
+
// You can call it manually without any parameters to validate the
|
273
|
+
// entire model.
|
274
|
+
validate: function(attrs, setOptions){
|
275
|
+
var model = this,
|
276
|
+
validateAll = !attrs,
|
277
|
+
opt = _.extend({}, options, setOptions),
|
278
|
+
validatedAttrs = getValidatedAttrs(model, getOptionsAttrs(options, view)),
|
279
|
+
allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs),
|
280
|
+
flattened = flatten(allAttrs),
|
281
|
+
changedAttrs = attrs ? flatten(attrs) : flattened,
|
282
|
+
result = validateModel(model, allAttrs, _.pick(flattened, _.keys(validatedAttrs)));
|
283
|
+
|
284
|
+
model._isValid = result.isValid;
|
285
|
+
|
286
|
+
//After validation is performed, loop through all associated views
|
287
|
+
_.each(model.associatedViews, function(view){
|
288
|
+
|
289
|
+
// After validation is performed, loop through all validated and changed attributes
|
290
|
+
// and call the valid and invalid callbacks so the view is updated.
|
291
|
+
_.each(validatedAttrs, function(val, attr){
|
292
|
+
var invalid = result.invalidAttrs.hasOwnProperty(attr),
|
293
|
+
changed = changedAttrs.hasOwnProperty(attr);
|
294
|
+
|
295
|
+
if(!invalid){
|
296
|
+
opt.valid(view, attr, opt.selector);
|
297
|
+
}
|
298
|
+
if(invalid && (changed || validateAll)){
|
299
|
+
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
|
300
|
+
}
|
301
|
+
});
|
302
|
+
});
|
303
|
+
|
304
|
+
// Trigger validated events.
|
305
|
+
// Need to defer this so the model is actually updated before
|
306
|
+
// the event is triggered.
|
307
|
+
_.defer(function() {
|
308
|
+
model.trigger('validated', model._isValid, model, result.invalidAttrs);
|
309
|
+
model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
|
310
|
+
});
|
311
|
+
|
312
|
+
// Return any error messages to Backbone, unless the forceUpdate flag is set.
|
313
|
+
// Then we do not return anything and fools Backbone to believe the validation was
|
314
|
+
// a success. That way Backbone will update the model regardless.
|
315
|
+
if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
|
316
|
+
return result.invalidAttrs;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
};
|
320
|
+
};
|
321
|
+
|
322
|
+
// Helper to mix in validation on a model. Stores the view in the associated views array.
|
323
|
+
var bindModel = function(view, model, options) {
|
324
|
+
if (model.associatedViews) {
|
325
|
+
model.associatedViews.push(view);
|
326
|
+
} else {
|
327
|
+
model.associatedViews = [view];
|
328
|
+
}
|
329
|
+
_.extend(model, mixin(view, options));
|
330
|
+
};
|
331
|
+
|
332
|
+
// Removes view from associated views of the model or the methods
|
333
|
+
// added to a model if no view or single view provided
|
334
|
+
var unbindModel = function(model, view) {
|
335
|
+
if (view && model.associatedViews.length > 1){
|
336
|
+
model.associatedViews = _.without(model.associatedViews, view);
|
337
|
+
} else {
|
338
|
+
delete model.validate;
|
339
|
+
delete model.preValidate;
|
340
|
+
delete model.isValid;
|
341
|
+
delete model.associatedViews;
|
342
|
+
}
|
343
|
+
};
|
344
|
+
|
345
|
+
// Mix in validation on a model whenever a model is
|
346
|
+
// added to a collection
|
347
|
+
var collectionAdd = function(model) {
|
348
|
+
bindModel(this.view, model, this.options);
|
349
|
+
};
|
350
|
+
|
351
|
+
// Remove validation from a model whenever a model is
|
352
|
+
// removed from a collection
|
353
|
+
var collectionRemove = function(model) {
|
354
|
+
unbindModel(model);
|
355
|
+
};
|
356
|
+
|
357
|
+
// Returns the public methods on Backbone.Validation
|
358
|
+
return {
|
359
|
+
|
360
|
+
// Current version of the library
|
361
|
+
version: '0.11.3',
|
362
|
+
|
363
|
+
// Called to configure the default options
|
364
|
+
configure: function(options) {
|
365
|
+
_.extend(defaultOptions, options);
|
366
|
+
},
|
367
|
+
|
368
|
+
// Hooks up validation on a view with a model
|
369
|
+
// or collection
|
370
|
+
bind: function(view, options) {
|
371
|
+
options = _.extend({}, defaultOptions, defaultCallbacks, options);
|
372
|
+
|
373
|
+
var model = options.model || view.model,
|
374
|
+
collection = options.collection || view.collection;
|
375
|
+
|
376
|
+
if(typeof model === 'undefined' && typeof collection === 'undefined'){
|
377
|
+
throw 'Before you execute the binding your view must have a model or a collection.\n' +
|
378
|
+
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
|
379
|
+
}
|
380
|
+
|
381
|
+
if(model) {
|
382
|
+
bindModel(view, model, options);
|
383
|
+
}
|
384
|
+
else if(collection) {
|
385
|
+
collection.each(function(model){
|
386
|
+
bindModel(view, model, options);
|
387
|
+
});
|
388
|
+
collection.bind('add', collectionAdd, {view: view, options: options});
|
389
|
+
collection.bind('remove', collectionRemove);
|
390
|
+
}
|
391
|
+
},
|
392
|
+
|
393
|
+
// Removes validation from a view with a model
|
394
|
+
// or collection
|
395
|
+
unbind: function(view, options) {
|
396
|
+
options = _.extend({}, options);
|
397
|
+
var model = options.model || view.model,
|
398
|
+
collection = options.collection || view.collection;
|
399
|
+
|
400
|
+
if(model) {
|
401
|
+
unbindModel(model, view);
|
402
|
+
}
|
403
|
+
else if(collection) {
|
404
|
+
collection.each(function(model){
|
405
|
+
unbindModel(model, view);
|
406
|
+
});
|
407
|
+
collection.unbind('add', collectionAdd);
|
408
|
+
collection.unbind('remove', collectionRemove);
|
409
|
+
}
|
410
|
+
},
|
411
|
+
|
412
|
+
// Used to extend the Backbone.Model.prototype
|
413
|
+
// with validation
|
414
|
+
mixin: mixin(null, defaultOptions)
|
415
|
+
};
|
416
|
+
}());
|
417
|
+
|
418
|
+
|
419
|
+
// Callbacks
|
420
|
+
// ---------
|
421
|
+
|
422
|
+
var defaultCallbacks = Validation.callbacks = {
|
423
|
+
|
424
|
+
// Gets called when a previously invalid field in the
|
425
|
+
// view becomes valid. Removes any error message.
|
426
|
+
// Should be overridden with custom functionality.
|
427
|
+
valid: function(view, attr, selector) {
|
428
|
+
view.$('[' + selector + '~="' + attr + '"]')
|
429
|
+
.removeClass('invalid')
|
430
|
+
.removeAttr('data-error');
|
431
|
+
},
|
432
|
+
|
433
|
+
// Gets called when a field in the view becomes invalid.
|
434
|
+
// Adds a error message.
|
435
|
+
// Should be overridden with custom functionality.
|
436
|
+
invalid: function(view, attr, error, selector) {
|
437
|
+
view.$('[' + selector + '~="' + attr + '"]')
|
438
|
+
.addClass('invalid')
|
439
|
+
.attr('data-error', error);
|
440
|
+
}
|
441
|
+
};
|
442
|
+
|
443
|
+
|
444
|
+
// Patterns
|
445
|
+
// --------
|
446
|
+
|
447
|
+
var defaultPatterns = Validation.patterns = {
|
448
|
+
// Matches any digit(s) (i.e. 0-9)
|
449
|
+
digits: /^\d+$/,
|
450
|
+
|
451
|
+
// Matches any number (e.g. 100.000)
|
452
|
+
number: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
|
453
|
+
|
454
|
+
// Matches a valid email address (e.g. mail@example.com)
|
455
|
+
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
|
456
|
+
|
457
|
+
// Mathes any valid url (e.g. http://www.xample.com)
|
458
|
+
url: /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
|
459
|
+
};
|
460
|
+
|
461
|
+
|
462
|
+
// Error messages
|
463
|
+
// --------------
|
464
|
+
|
465
|
+
// Error message for the build in validators.
|
466
|
+
// {x} gets swapped out with arguments form the validator.
|
467
|
+
var defaultMessages = Validation.messages = {
|
468
|
+
required: '{0} is required',
|
469
|
+
acceptance: '{0} must be accepted',
|
470
|
+
min: '{0} must be greater than or equal to {1}',
|
471
|
+
max: '{0} must be less than or equal to {1}',
|
472
|
+
range: '{0} must be between {1} and {2}',
|
473
|
+
length: '{0} must be {1} characters',
|
474
|
+
minLength: '{0} must be at least {1} characters',
|
475
|
+
maxLength: '{0} must be at most {1} characters',
|
476
|
+
rangeLength: '{0} must be between {1} and {2} characters',
|
477
|
+
oneOf: '{0} must be one of: {1}',
|
478
|
+
equalTo: '{0} must be the same as {1}',
|
479
|
+
digits: '{0} must only contain digits',
|
480
|
+
number: '{0} must be a number',
|
481
|
+
email: '{0} must be a valid email',
|
482
|
+
url: '{0} must be a valid url',
|
483
|
+
inlinePattern: '{0} is invalid'
|
484
|
+
};
|
485
|
+
|
486
|
+
// Label formatters
|
487
|
+
// ----------------
|
488
|
+
|
489
|
+
// Label formatters are used to convert the attribute name
|
490
|
+
// to a more human friendly label when using the built in
|
491
|
+
// error messages.
|
492
|
+
// Configure which one to use with a call to
|
493
|
+
//
|
494
|
+
// Backbone.Validation.configure({
|
495
|
+
// labelFormatter: 'label'
|
496
|
+
// });
|
497
|
+
var defaultLabelFormatters = Validation.labelFormatters = {
|
498
|
+
|
499
|
+
// Returns the attribute name with applying any formatting
|
500
|
+
none: function(attrName) {
|
501
|
+
return attrName;
|
502
|
+
},
|
503
|
+
|
504
|
+
// Converts attributeName or attribute_name to Attribute name
|
505
|
+
sentenceCase: function(attrName) {
|
506
|
+
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
|
507
|
+
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
|
508
|
+
}).replace(/_/g, ' ');
|
509
|
+
},
|
510
|
+
|
511
|
+
// Looks for a label configured on the model and returns it
|
512
|
+
//
|
513
|
+
// var Model = Backbone.Model.extend({
|
514
|
+
// validation: {
|
515
|
+
// someAttribute: {
|
516
|
+
// required: true
|
517
|
+
// }
|
518
|
+
// },
|
519
|
+
//
|
520
|
+
// labels: {
|
521
|
+
// someAttribute: 'Custom label'
|
522
|
+
// }
|
523
|
+
// });
|
524
|
+
label: function(attrName, model) {
|
525
|
+
return (model.labels && model.labels[attrName]) || defaultLabelFormatters.sentenceCase(attrName, model);
|
526
|
+
}
|
527
|
+
};
|
528
|
+
|
529
|
+
// AttributeLoaders
|
530
|
+
|
531
|
+
var defaultAttributeLoaders = Validation.attributeLoaders = {
|
532
|
+
inputNames: function (view) {
|
533
|
+
var attrs = [];
|
534
|
+
if (view) {
|
535
|
+
view.$('form [name]').each(function () {
|
536
|
+
if (/^(?:input|select|textarea)$/i.test(this.nodeName) && this.name &&
|
537
|
+
this.type !== 'submit' && attrs.indexOf(this.name) === -1) {
|
538
|
+
attrs.push(this.name);
|
539
|
+
}
|
540
|
+
});
|
541
|
+
}
|
542
|
+
return attrs;
|
543
|
+
}
|
544
|
+
};
|
545
|
+
|
546
|
+
|
547
|
+
// Built in validators
|
548
|
+
// -------------------
|
549
|
+
|
550
|
+
var defaultValidators = Validation.validators = (function(){
|
551
|
+
// Use native trim when defined
|
552
|
+
var trim = String.prototype.trim ?
|
553
|
+
function(text) {
|
554
|
+
return text === null ? '' : String.prototype.trim.call(text);
|
555
|
+
} :
|
556
|
+
function(text) {
|
557
|
+
var trimLeft = /^\s+/,
|
558
|
+
trimRight = /\s+$/;
|
559
|
+
|
560
|
+
return text === null ? '' : text.toString().replace(trimLeft, '').replace(trimRight, '');
|
561
|
+
};
|
562
|
+
|
563
|
+
// Determines whether or not a value is a number
|
564
|
+
var isNumber = function(value){
|
565
|
+
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
|
566
|
+
};
|
567
|
+
|
568
|
+
// Determines whether or not a value is empty
|
569
|
+
var hasValue = function(value) {
|
570
|
+
return !(_.isNull(value) || _.isUndefined(value) || (_.isString(value) && trim(value) === '') || (_.isArray(value) && _.isEmpty(value)));
|
571
|
+
};
|
572
|
+
|
573
|
+
return {
|
574
|
+
// Function validator
|
575
|
+
// Lets you implement a custom function used for validation
|
576
|
+
fn: function(value, attr, fn, model, computed) {
|
577
|
+
if(_.isString(fn)){
|
578
|
+
fn = model[fn];
|
579
|
+
}
|
580
|
+
return fn.call(model, value, attr, computed);
|
581
|
+
},
|
582
|
+
|
583
|
+
// Required validator
|
584
|
+
// Validates if the attribute is required or not
|
585
|
+
// This can be specified as either a boolean value or a function that returns a boolean value
|
586
|
+
required: function(value, attr, required, model, computed) {
|
587
|
+
var isRequired = _.isFunction(required) ? required.call(model, value, attr, computed) : required;
|
588
|
+
if(!isRequired && !hasValue(value)) {
|
589
|
+
return false; // overrides all other validators
|
590
|
+
}
|
591
|
+
if (isRequired && !hasValue(value)) {
|
592
|
+
return this.format(defaultMessages.required, this.formatLabel(attr, model));
|
593
|
+
}
|
594
|
+
},
|
595
|
+
|
596
|
+
// Acceptance validator
|
597
|
+
// Validates that something has to be accepted, e.g. terms of use
|
598
|
+
// `true` or 'true' are valid
|
599
|
+
acceptance: function(value, attr, accept, model) {
|
600
|
+
if(value !== 'true' && (!_.isBoolean(value) || value === false)) {
|
601
|
+
return this.format(defaultMessages.acceptance, this.formatLabel(attr, model));
|
602
|
+
}
|
603
|
+
},
|
604
|
+
|
605
|
+
// Min validator
|
606
|
+
// Validates that the value has to be a number and equal to or greater than
|
607
|
+
// the min value specified
|
608
|
+
min: function(value, attr, minValue, model) {
|
609
|
+
if (!isNumber(value) || value < minValue) {
|
610
|
+
return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
|
611
|
+
}
|
612
|
+
},
|
613
|
+
|
614
|
+
// Max validator
|
615
|
+
// Validates that the value has to be a number and equal to or less than
|
616
|
+
// the max value specified
|
617
|
+
max: function(value, attr, maxValue, model) {
|
618
|
+
if (!isNumber(value) || value > maxValue) {
|
619
|
+
return this.format(defaultMessages.max, this.formatLabel(attr, model), maxValue);
|
620
|
+
}
|
621
|
+
},
|
622
|
+
|
623
|
+
// Range validator
|
624
|
+
// Validates that the value has to be a number and equal to or between
|
625
|
+
// the two numbers specified
|
626
|
+
range: function(value, attr, range, model) {
|
627
|
+
if(!isNumber(value) || value < range[0] || value > range[1]) {
|
628
|
+
return this.format(defaultMessages.range, this.formatLabel(attr, model), range[0], range[1]);
|
629
|
+
}
|
630
|
+
},
|
631
|
+
|
632
|
+
// Length validator
|
633
|
+
// Validates that the value has to be a string with length equal to
|
634
|
+
// the length value specified
|
635
|
+
length: function(value, attr, length, model) {
|
636
|
+
if (!_.isString(value) || value.length !== length) {
|
637
|
+
return this.format(defaultMessages.length, this.formatLabel(attr, model), length);
|
638
|
+
}
|
639
|
+
},
|
640
|
+
|
641
|
+
// Min length validator
|
642
|
+
// Validates that the value has to be a string with length equal to or greater than
|
643
|
+
// the min length value specified
|
644
|
+
minLength: function(value, attr, minLength, model) {
|
645
|
+
if (!_.isString(value) || value.length < minLength) {
|
646
|
+
return this.format(defaultMessages.minLength, this.formatLabel(attr, model), minLength);
|
647
|
+
}
|
648
|
+
},
|
649
|
+
|
650
|
+
// Max length validator
|
651
|
+
// Validates that the value has to be a string with length equal to or less than
|
652
|
+
// the max length value specified
|
653
|
+
maxLength: function(value, attr, maxLength, model) {
|
654
|
+
if (!_.isString(value) || value.length > maxLength) {
|
655
|
+
return this.format(defaultMessages.maxLength, this.formatLabel(attr, model), maxLength);
|
656
|
+
}
|
657
|
+
},
|
658
|
+
|
659
|
+
// Range length validator
|
660
|
+
// Validates that the value has to be a string and equal to or between
|
661
|
+
// the two numbers specified
|
662
|
+
rangeLength: function(value, attr, range, model) {
|
663
|
+
if (!_.isString(value) || value.length < range[0] || value.length > range[1]) {
|
664
|
+
return this.format(defaultMessages.rangeLength, this.formatLabel(attr, model), range[0], range[1]);
|
665
|
+
}
|
666
|
+
},
|
667
|
+
|
668
|
+
// One of validator
|
669
|
+
// Validates that the value has to be equal to one of the elements in
|
670
|
+
// the specified array. Case sensitive matching
|
671
|
+
oneOf: function(value, attr, values, model) {
|
672
|
+
if(!_.include(values, value)){
|
673
|
+
return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', '));
|
674
|
+
}
|
675
|
+
},
|
676
|
+
|
677
|
+
// Equal to validator
|
678
|
+
// Validates that the value has to be equal to the value of the attribute
|
679
|
+
// with the name specified
|
680
|
+
equalTo: function(value, attr, equalTo, model, computed) {
|
681
|
+
if(value !== computed[equalTo]) {
|
682
|
+
return this.format(defaultMessages.equalTo, this.formatLabel(attr, model), this.formatLabel(equalTo, model));
|
683
|
+
}
|
684
|
+
},
|
685
|
+
|
686
|
+
// Pattern validator
|
687
|
+
// Validates that the value has to match the pattern specified.
|
688
|
+
// Can be a regular expression or the name of one of the built in patterns
|
689
|
+
pattern: function(value, attr, pattern, model) {
|
690
|
+
if (!hasValue(value) || !value.toString().match(defaultPatterns[pattern] || pattern)) {
|
691
|
+
return this.format(defaultMessages[pattern] || defaultMessages.inlinePattern, this.formatLabel(attr, model), pattern);
|
692
|
+
}
|
693
|
+
}
|
694
|
+
};
|
695
|
+
}());
|
696
|
+
|
697
|
+
// Set the correct context for all validators
|
698
|
+
// when used from within a method validator
|
699
|
+
_.each(defaultValidators, function(validator, key){
|
700
|
+
defaultValidators[key] = _.bind(defaultValidators[key], _.extend({}, formatFunctions, defaultValidators));
|
701
|
+
});
|
702
|
+
|
703
|
+
return Validation;
|
704
|
+
}(_));
|
@@ -1,6 +1,6 @@
|
|
1
|
-
// Backbone.Validation v0.9.
|
1
|
+
// Backbone.Validation v0.9.2
|
2
2
|
//
|
3
|
-
// Copyright (c) 2011-
|
3
|
+
// Copyright (c) 2011-2015 Thomas Pedersen
|
4
4
|
// Distributed under MIT License
|
5
5
|
//
|
6
6
|
// Documentation and full license available at:
|
@@ -64,13 +64,7 @@ Backbone.Validation = (function(_){
|
|
64
64
|
|
65
65
|
_.each(obj, function(val, key) {
|
66
66
|
if(obj.hasOwnProperty(key)) {
|
67
|
-
if (val && typeof val === 'object' &&
|
68
|
-
val instanceof Array ||
|
69
|
-
val instanceof Date ||
|
70
|
-
val instanceof RegExp ||
|
71
|
-
val instanceof Backbone.Model ||
|
72
|
-
val instanceof Backbone.Collection)
|
73
|
-
) {
|
67
|
+
if (!!val && typeof val === 'object' && val.constructor === Object) {
|
74
68
|
flatten(val, into, prefix + key + '.');
|
75
69
|
}
|
76
70
|
else {
|
data/vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/{0.6.0.js → 0.6.1.js}
RENAMED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
// Available under the MIT License (MIT)
|
2
3
|
|
3
4
|
var VirtualCollection,
|
@@ -41,12 +42,12 @@ VirtualCollection = Backbone.Collection.extend({
|
|
41
42
|
|
42
43
|
_rebuildIndex: function () {
|
43
44
|
for(idx in this.models) {
|
44
|
-
this.models[idx].off('all', this.
|
45
|
+
this.models[idx].off('all', this._onAllEvent, this);
|
45
46
|
}
|
46
47
|
this._reset();
|
47
48
|
this.collection.each(function (model, i) {
|
48
49
|
if (this.accepts(model, i)) {
|
49
|
-
model.on('all', this.
|
50
|
+
model.on('all', this._onAllEvent, this);
|
50
51
|
this.models.push(model);
|
51
52
|
this._byId[model.cid] = model;
|
52
53
|
if (model.id) this._byId[model.id] = model;
|
@@ -73,7 +74,7 @@ VirtualCollection = Backbone.Collection.extend({
|
|
73
74
|
var already_here = this.get(model);
|
74
75
|
if (!already_here && this.accepts(model, options.index)) {
|
75
76
|
this._indexAdd(model);
|
76
|
-
model.on('all', this.
|
77
|
+
model.on('all', this._onAllEvent, this);
|
77
78
|
this.trigger('add', model, this, options);
|
78
79
|
}
|
79
80
|
},
|
@@ -84,7 +85,7 @@ VirtualCollection = Backbone.Collection.extend({
|
|
84
85
|
var i = this._indexRemove(model)
|
85
86
|
, options_clone = _.clone(options);
|
86
87
|
options_clone.index = i;
|
87
|
-
model.off('all', this.
|
88
|
+
model.off('all', this._onAllEvent, this);
|
88
89
|
this.trigger('remove', model, this, options_clone);
|
89
90
|
},
|
90
91
|
|
@@ -147,7 +148,7 @@ VirtualCollection = Backbone.Collection.extend({
|
|
147
148
|
},
|
148
149
|
|
149
150
|
_indexRemove: function (model) {
|
150
|
-
model.off('all', this.
|
151
|
+
model.off('all', this._onAllEvent, this);
|
151
152
|
var i = this.indexOf(model);
|
152
153
|
if (i === -1) return i;
|
153
154
|
this.models.splice(i, 1);
|
@@ -155,6 +156,13 @@ VirtualCollection = Backbone.Collection.extend({
|
|
155
156
|
if (model.id) delete this._byId[model.id];
|
156
157
|
this.length -= 1;
|
157
158
|
return i;
|
159
|
+
},
|
160
|
+
|
161
|
+
_onAllEvent: function (eventName) {
|
162
|
+
var explicitlyHandledEvents = ['add', 'remove', 'change', 'reset', 'sort'];
|
163
|
+
if (!_.contains(explicitlyHandledEvents, eventName)) {
|
164
|
+
this.trigger.apply(this, arguments);
|
165
|
+
}
|
158
166
|
}
|
159
167
|
|
160
168
|
}, { // static props
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/backbone/validation/0.
|
1
|
+
//= require js_stack/plugins/backbone/validation/0.11.3
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/backbone/virtualcollection/0.6.
|
1
|
+
//= require js_stack/plugins/backbone/virtualcollection/0.6.1
|
@@ -1,4 +1,3 @@
|
|
1
|
-
// Cocktail.js 0.5.8
|
2
1
|
// (c) 2012 Onsi Fakhouri
|
3
2
|
// Cocktail.js may be freely distributed under the MIT license.
|
4
3
|
// http://github.com/onsi/cocktail
|
@@ -23,11 +22,11 @@
|
|
23
22
|
|
24
23
|
var collisions = {};
|
25
24
|
|
26
|
-
_
|
25
|
+
_.each(mixins, function(mixin) {
|
27
26
|
if (_.isString(mixin)) {
|
28
27
|
mixin = Cocktail.mixins[mixin];
|
29
28
|
}
|
30
|
-
_
|
29
|
+
_.each(mixin, function(value, key) {
|
31
30
|
if (_.isFunction(value)) {
|
32
31
|
// If the mixer already has that exact function reference
|
33
32
|
// Note: this would occur on an accidental mixin of the same base
|
@@ -49,13 +48,13 @@
|
|
49
48
|
});
|
50
49
|
});
|
51
50
|
|
52
|
-
_
|
51
|
+
_.each(collisions, function(propertyValues, propertyName) {
|
53
52
|
obj[propertyName] = function() {
|
54
53
|
var that = this,
|
55
54
|
args = arguments,
|
56
55
|
returnValue;
|
57
56
|
|
58
|
-
_
|
57
|
+
_.each(propertyValues, function(value) {
|
59
58
|
var returnedValue = _.isFunction(value) ? value.apply(that, args) : value;
|
60
59
|
returnValue = (typeof returnedValue === 'undefined' ? returnValue : returnedValue);
|
61
60
|
});
|
@@ -83,7 +82,7 @@
|
|
83
82
|
return klass;
|
84
83
|
};
|
85
84
|
|
86
|
-
_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]
|
85
|
+
_.each([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View], function(klass) {
|
87
86
|
klass.mixin = function mixin() {
|
88
87
|
Cocktail.mixin(this, _.toArray(arguments));
|
89
88
|
};
|
@@ -93,7 +92,7 @@
|
|
93
92
|
};
|
94
93
|
|
95
94
|
Cocktail.unpatch = function unpatch(Backbone) {
|
96
|
-
_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]
|
95
|
+
_.each([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View], function(klass) {
|
97
96
|
klass.mixin = undefined;
|
98
97
|
klass.extend = originalExtend;
|
99
98
|
});
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/cocktail/0.5.
|
1
|
+
//= require js_stack/plugins/cocktail/0.5.10
|
@@ -169,7 +169,7 @@ module.exports = function() {
|
|
169
169
|
// Underscore.string is freely distributable under the terms of the MIT license.
|
170
170
|
// Documentation: https://github.com/epeli/underscore.string
|
171
171
|
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
172
|
-
// Version '3.0.
|
172
|
+
// Version '3.0.3'
|
173
173
|
|
174
174
|
'use strict';
|
175
175
|
|
@@ -179,7 +179,7 @@ function s(value) {
|
|
179
179
|
this._wrapped = value;
|
180
180
|
}
|
181
181
|
|
182
|
-
s.VERSION = '3.0.
|
182
|
+
s.VERSION = '3.0.3';
|
183
183
|
|
184
184
|
s.isBlank = _dereq_('./isBlank');
|
185
185
|
s.stripTags = _dereq_('./stripTags');
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/underscore/string/3.0.
|
1
|
+
//= require js_stack/plugins/underscore/string/3.0.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Pewiński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml_coffee_assets
|
@@ -115,7 +115,7 @@ files:
|
|
115
115
|
- vendor/assets/javascripts/js_stack/base/marionette/2.0.3.js
|
116
116
|
- vendor/assets/javascripts/js_stack/base/marionette/2.1.0.js
|
117
117
|
- vendor/assets/javascripts/js_stack/base/marionette/2.2.2.js
|
118
|
-
- vendor/assets/javascripts/js_stack/base/marionette/2.3.
|
118
|
+
- vendor/assets/javascripts/js_stack/base/marionette/2.3.2.js
|
119
119
|
- vendor/assets/javascripts/js_stack/base/underscore.js
|
120
120
|
- vendor/assets/javascripts/js_stack/base/underscore/1.5.2.js
|
121
121
|
- vendor/assets/javascripts/js_stack/base/underscore/1.6.0.js
|
@@ -140,20 +140,21 @@ files:
|
|
140
140
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.6.3.js
|
141
141
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.7.0.js
|
142
142
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.8.0.js
|
143
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.11.3.js
|
143
144
|
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.8.1.js
|
144
|
-
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.9.
|
145
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.9.2.js
|
145
146
|
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.4.15.js
|
146
147
|
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.5.3.js
|
147
|
-
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.6.
|
148
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.6.1.js
|
148
149
|
- vendor/assets/javascripts/js_stack/plugins/cocktail.js
|
149
|
-
- vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.
|
150
|
+
- vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.10.js
|
150
151
|
- vendor/assets/javascripts/js_stack/plugins/moment.js
|
151
152
|
- vendor/assets/javascripts/js_stack/plugins/underscore.inflections.js
|
152
153
|
- vendor/assets/javascripts/js_stack/plugins/underscore.string.js
|
153
154
|
- vendor/assets/javascripts/js_stack/plugins/underscore/inflections/0.2.1.js
|
154
155
|
- vendor/assets/javascripts/js_stack/plugins/underscore/string/2.3.2.js
|
155
156
|
- vendor/assets/javascripts/js_stack/plugins/underscore/string/2.4.0.js
|
156
|
-
- vendor/assets/javascripts/js_stack/plugins/underscore/string/3.0.
|
157
|
+
- vendor/assets/javascripts/js_stack/plugins/underscore/string/3.0.3.js
|
157
158
|
homepage: https://github.com/netguru/js_stack
|
158
159
|
licenses:
|
159
160
|
- MIT
|