js_stack 0.4.0 → 0.5.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 +7 -12
- data/README.md +35 -208
- data/lib/js_stack/version.rb +1 -1
- data/vendor/assets/javascripts/js_stack/base/backbone/1.1.1.js +1609 -0
- data/vendor/assets/javascripts/js_stack/base/backbone.js +1 -1
- data/vendor/assets/javascripts/js_stack/base/underscore/1.6.0.js +1344 -0
- data/vendor/assets/javascripts/js_stack/base/underscore.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.6.1.js +722 -0
- data/vendor/assets/javascripts/js_stack/plugins/backbone/mutators/0.4.1.js +207 -0
- data/vendor/assets/javascripts/js_stack/plugins/backbone.associations.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone.mutators.js +1 -0
- data/vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.3.js +101 -0
- data/vendor/assets/javascripts/js_stack/plugins/cocktail.js +1 -0
- metadata +9 -2
@@ -0,0 +1,207 @@
|
|
1
|
+
/*! Backbone.Mutators - v0.4.1
|
2
|
+
------------------------------
|
3
|
+
Build @ 2013-12-01
|
4
|
+
Documentation and Full License Available at:
|
5
|
+
http://asciidisco.github.com/Backbone.Mutators/index.html
|
6
|
+
git://github.com/asciidisco/Backbone.Mutators.git
|
7
|
+
Copyright (c) 2013 Sebastian Golasch <public@asciidisco.com>
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
10
|
+
copy of this software and associated documentation files (the "Software"),
|
11
|
+
to deal in the Software without restriction, including without limitation
|
12
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
13
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
14
|
+
|
15
|
+
Software is furnished to do so, subject to the following conditions:
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
17
|
+
all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
23
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
24
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
25
|
+
IN THE SOFTWARE.*/
|
26
|
+
(function (root, factory, undef) {
|
27
|
+
'use strict';
|
28
|
+
|
29
|
+
if (typeof exports === 'object') {
|
30
|
+
// Node. Does not work with strict CommonJS, but
|
31
|
+
// only CommonJS-like enviroments that support module.exports,
|
32
|
+
// like Node.
|
33
|
+
module.exports = factory(require('underscore'), require('Backbone'));
|
34
|
+
} else if (typeof define === 'function' && define.amd) {
|
35
|
+
// AMD. Register as an anonymous module.
|
36
|
+
define(['underscore', 'backbone'], function (_, Backbone) {
|
37
|
+
// Check if we use the AMD branch of Back
|
38
|
+
_ = _ === undef ? root._ : _;
|
39
|
+
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
40
|
+
return (root.returnExportsGlobal = factory(_, Backbone, root));
|
41
|
+
});
|
42
|
+
} else {
|
43
|
+
// Browser globals
|
44
|
+
root.returnExportsGlobal = factory(root._, root.Backbone);
|
45
|
+
}
|
46
|
+
|
47
|
+
// Usage:
|
48
|
+
//
|
49
|
+
// Note: This plugin is UMD compatible, you can use it in node, amd and vanilla js envs
|
50
|
+
//
|
51
|
+
// Vanilla JS:
|
52
|
+
// <script src="underscore.js"></script>
|
53
|
+
// <script src="backbone.js"></script>
|
54
|
+
// <script src="backbone.mutators.js"></script>
|
55
|
+
//
|
56
|
+
// Node:
|
57
|
+
// var _ = require('underscore');
|
58
|
+
// var Backbone = require('backbone');
|
59
|
+
// var Mutators = require('backbone.mutators');
|
60
|
+
//
|
61
|
+
//
|
62
|
+
// AMD:
|
63
|
+
// define(['underscore', 'backbone', 'backbone.mutators'], function (_, Backbone, Mutators) {
|
64
|
+
// // insert sample from below
|
65
|
+
// return User;
|
66
|
+
// });
|
67
|
+
//
|
68
|
+
// var User = Backbone.Model.extend({
|
69
|
+
// mutators: {
|
70
|
+
// fullname: function () {
|
71
|
+
// return this.firstname + ' ' + this.lastname;
|
72
|
+
// }
|
73
|
+
// },
|
74
|
+
//
|
75
|
+
// defaults: {
|
76
|
+
// firstname: 'Sebastian',
|
77
|
+
// lastname: 'Golasch'
|
78
|
+
// }
|
79
|
+
// });
|
80
|
+
//
|
81
|
+
// var user = new User();
|
82
|
+
// user.get('fullname') // returns 'Sebastian Golasch'
|
83
|
+
// user.toJSON() // return '{firstname: 'Sebastian', lastname: 'Golasch', fullname: 'Sebastian Golasch'}'
|
84
|
+
|
85
|
+
}(this, function (_, Backbone, root, undef) {
|
86
|
+
'use strict';
|
87
|
+
|
88
|
+
// check if we use the amd branch of backbone and underscore
|
89
|
+
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
90
|
+
_ = _ === undef ? root._ : _;
|
91
|
+
|
92
|
+
// extend backbones model prototype with the mutator functionality
|
93
|
+
var Mutator = function () {},
|
94
|
+
oldGet = Backbone.Model.prototype.get,
|
95
|
+
oldSet = Backbone.Model.prototype.set,
|
96
|
+
oldToJson = Backbone.Model.prototype.toJSON;
|
97
|
+
|
98
|
+
// This is necessary to ensure that Models declared without the mutators object do not throw and error
|
99
|
+
Mutator.prototype.mutators = {};
|
100
|
+
|
101
|
+
// override get functionality to fetch the mutator props
|
102
|
+
Mutator.prototype.get = function (attr) {
|
103
|
+
var isMutator = this.mutators !== undef;
|
104
|
+
|
105
|
+
// check if we have a getter mutation
|
106
|
+
if (isMutator === true && _.isFunction(this.mutators[attr]) === true) {
|
107
|
+
return this.mutators[attr].call(this);
|
108
|
+
}
|
109
|
+
|
110
|
+
// check if we have a deeper nested getter mutation
|
111
|
+
if (isMutator === true && _.isObject(this.mutators[attr]) === true && _.isFunction(this.mutators[attr].get) === true) {
|
112
|
+
return this.mutators[attr].get.call(this);
|
113
|
+
}
|
114
|
+
|
115
|
+
return oldGet.call(this, attr);
|
116
|
+
};
|
117
|
+
|
118
|
+
// override set functionality to set the mutator props
|
119
|
+
Mutator.prototype.set = function (key, value, options) {
|
120
|
+
var isMutator = this.mutators !== undef,
|
121
|
+
ret = null,
|
122
|
+
attrs = null;
|
123
|
+
|
124
|
+
ret = oldSet.call(this, key, value, options);
|
125
|
+
|
126
|
+
// seamleassly stolen from backbone core
|
127
|
+
// check if the setter action is triggered
|
128
|
+
// using key <-> value or object
|
129
|
+
if (_.isObject(key) || key === null) {
|
130
|
+
attrs = key;
|
131
|
+
options = value;
|
132
|
+
} else {
|
133
|
+
attrs = {};
|
134
|
+
attrs[key] = value;
|
135
|
+
}
|
136
|
+
|
137
|
+
// check if we have a deeper nested setter mutation
|
138
|
+
if (isMutator === true && _.isObject(this.mutators[key]) === true) {
|
139
|
+
|
140
|
+
// check if we need to set a single value
|
141
|
+
if (_.isFunction(this.mutators[key].set) === true) {
|
142
|
+
ret = this.mutators[key].set.call(this, key, attrs[key], options, _.bind(oldSet, this));
|
143
|
+
} else if(_.isFunction(this.mutators[key])){
|
144
|
+
ret = this.mutators[key].call(this, key, attrs[key], options, _.bind(oldSet, this));
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
if (isMutator === true && _.isObject(attrs)) {
|
149
|
+
_.each(attrs, _.bind(function (attr, attrKey) {
|
150
|
+
if (_.isObject(this.mutators[attrKey]) === true) {
|
151
|
+
// check if we need to set a single value
|
152
|
+
|
153
|
+
var meth = this.mutators[attrKey];
|
154
|
+
if(_.isFunction(meth.set)){
|
155
|
+
meth = meth.set;
|
156
|
+
}
|
157
|
+
|
158
|
+
if(_.isFunction(meth)){
|
159
|
+
if (options === undef || (_.isObject(options) === true && options.silent !== true && (options.mutators !== undef && options.mutators.silent !== true))) {
|
160
|
+
this.trigger('mutators:set:' + attrKey);
|
161
|
+
}
|
162
|
+
meth.call(this, attrKey, attr, options, _.bind(oldSet, this));
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
166
|
+
}, this));
|
167
|
+
}
|
168
|
+
|
169
|
+
return ret;
|
170
|
+
};
|
171
|
+
|
172
|
+
// override toJSON functionality to serialize mutator properties
|
173
|
+
Mutator.prototype.toJSON = function (options) {
|
174
|
+
// fetch ye olde values
|
175
|
+
var attr = oldToJson.call(this),
|
176
|
+
isSaving,
|
177
|
+
isTransient;
|
178
|
+
// iterate over all mutators (if there are some)
|
179
|
+
_.each(this.mutators, _.bind(function (mutator, name) {
|
180
|
+
// check if we have some getter mutations
|
181
|
+
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
|
182
|
+
isSaving = _.has(options || {}, 'emulateHTTP');
|
183
|
+
isTransient = this.mutators[name].transient;
|
184
|
+
if (!isSaving || !isTransient) {
|
185
|
+
attr[name] = _.bind(this.mutators[name].get, this)();
|
186
|
+
}
|
187
|
+
} else {
|
188
|
+
attr[name] = _.bind(this.mutators[name], this)();
|
189
|
+
}
|
190
|
+
}, this));
|
191
|
+
|
192
|
+
return attr;
|
193
|
+
};
|
194
|
+
|
195
|
+
// override get functionality to get HTML-escaped the mutator props
|
196
|
+
Mutator.prototype.escape = function (attr){
|
197
|
+
var val = this.get(attr);
|
198
|
+
return _.escape(val == null ? '' : '' + val);
|
199
|
+
};
|
200
|
+
|
201
|
+
// extend the models prototype
|
202
|
+
_.extend(Backbone.Model.prototype, Mutator.prototype);
|
203
|
+
|
204
|
+
// make mutators globally available under the Backbone namespace
|
205
|
+
Backbone.Mutators = Mutator;
|
206
|
+
return Mutator;
|
207
|
+
}));
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/backbone/associations/0.
|
1
|
+
//= require js_stack/plugins/backbone/associations/0.6.1
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require js_stack/plugins/backbone/mutators/0.4.1
|
@@ -0,0 +1,101 @@
|
|
1
|
+
// Cocktail.js 0.5.3
|
2
|
+
// (c) 2012 Onsi Fakhouri
|
3
|
+
// Cocktail.js may be freely distributed under the MIT license.
|
4
|
+
// http://github.com/onsi/cocktail
|
5
|
+
(function() {
|
6
|
+
var Cocktail = {};
|
7
|
+
|
8
|
+
if (typeof exports !== 'undefined') {
|
9
|
+
Cocktail = exports;
|
10
|
+
} else if (typeof define === 'function') {
|
11
|
+
define(function(require) {
|
12
|
+
return Cocktail;
|
13
|
+
});
|
14
|
+
} else {
|
15
|
+
this.Cocktail = Cocktail;
|
16
|
+
}
|
17
|
+
|
18
|
+
Cocktail.mixins = {};
|
19
|
+
|
20
|
+
Cocktail.mixin = function mixin(klass) {
|
21
|
+
var mixins = _.chain(arguments).toArray().rest().flatten().value();
|
22
|
+
// Allows mixing into the constructor's prototype or the dynamic instance
|
23
|
+
var obj = klass.prototype || klass;
|
24
|
+
|
25
|
+
var collisions = {};
|
26
|
+
|
27
|
+
_(mixins).each(function(mixin) {
|
28
|
+
if (_.isString(mixin)) {
|
29
|
+
mixin = Cocktail.mixins[mixin];
|
30
|
+
}
|
31
|
+
_(mixin).each(function(value, key) {
|
32
|
+
if (_.isFunction(value)) {
|
33
|
+
// If the mixer already has that exact function reference
|
34
|
+
// Note: this would occur on an accidental mixin of the same base
|
35
|
+
if (obj[key] === value) return;
|
36
|
+
|
37
|
+
if (obj[key]) {
|
38
|
+
collisions[key] = collisions[key] || [obj[key]];
|
39
|
+
collisions[key].push(value);
|
40
|
+
}
|
41
|
+
obj[key] = value;
|
42
|
+
} else if (_.isArray(value)) {
|
43
|
+
obj[key] = _.union(value, obj[key] || []);
|
44
|
+
} else if (_.isObject(value)) {
|
45
|
+
obj[key] = _.extend({}, value, obj[key] || {});
|
46
|
+
} else if (!(key in obj)) {
|
47
|
+
obj[key] = value;
|
48
|
+
}
|
49
|
+
});
|
50
|
+
});
|
51
|
+
|
52
|
+
_(collisions).each(function(propertyValues, propertyName) {
|
53
|
+
obj[propertyName] = function() {
|
54
|
+
var that = this,
|
55
|
+
args = arguments,
|
56
|
+
returnValue;
|
57
|
+
|
58
|
+
_(propertyValues).each(function(value) {
|
59
|
+
var returnedValue = _.isFunction(value) ? value.apply(that, args) : value;
|
60
|
+
returnValue = (typeof returnedValue === 'undefined' ? returnValue : returnedValue);
|
61
|
+
});
|
62
|
+
|
63
|
+
return returnValue;
|
64
|
+
};
|
65
|
+
});
|
66
|
+
|
67
|
+
return klass;
|
68
|
+
};
|
69
|
+
|
70
|
+
var originalExtend;
|
71
|
+
|
72
|
+
Cocktail.patch = function patch(Backbone) {
|
73
|
+
originalExtend = Backbone.Model.extend;
|
74
|
+
|
75
|
+
var extend = function(protoProps, classProps) {
|
76
|
+
var klass = originalExtend.call(this, protoProps, classProps);
|
77
|
+
|
78
|
+
var mixins = klass.prototype.mixins;
|
79
|
+
if (mixins && klass.prototype.hasOwnProperty('mixins')) {
|
80
|
+
Cocktail.mixin(klass, mixins);
|
81
|
+
}
|
82
|
+
|
83
|
+
return klass;
|
84
|
+
};
|
85
|
+
|
86
|
+
_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
|
87
|
+
klass.mixin = function mixin() {
|
88
|
+
Cocktail.mixin(this, _.toArray(arguments));
|
89
|
+
};
|
90
|
+
|
91
|
+
klass.extend = extend;
|
92
|
+
});
|
93
|
+
};
|
94
|
+
|
95
|
+
Cocktail.unpatch = function unpatch(Backbone) {
|
96
|
+
_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
|
97
|
+
klass.mixin = undefined;
|
98
|
+
klass.extend = originalExtend;
|
99
|
+
});
|
100
|
+
};
|
101
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require js_stack/plugins/cocktail/0.5.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: 0.
|
4
|
+
version: 0.5.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: 2014-02-
|
12
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml_coffee_assets
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- vendor/assets/javascripts/js_stack/base/backbone.js
|
105
105
|
- vendor/assets/javascripts/js_stack/base/backbone/1.0.0.js
|
106
106
|
- vendor/assets/javascripts/js_stack/base/backbone/1.1.0.js
|
107
|
+
- vendor/assets/javascripts/js_stack/base/backbone/1.1.1.js
|
107
108
|
- vendor/assets/javascripts/js_stack/base/hamlcoffee.js
|
108
109
|
- vendor/assets/javascripts/js_stack/base/jsroutes.js
|
109
110
|
- vendor/assets/javascripts/js_stack/base/marionette.js
|
@@ -113,9 +114,11 @@ files:
|
|
113
114
|
- vendor/assets/javascripts/js_stack/base/marionette/1.6.2.js
|
114
115
|
- vendor/assets/javascripts/js_stack/base/underscore.js
|
115
116
|
- vendor/assets/javascripts/js_stack/base/underscore/1.5.2.js
|
117
|
+
- vendor/assets/javascripts/js_stack/base/underscore/1.6.0.js
|
116
118
|
- vendor/assets/javascripts/js_stack/plugins.js
|
117
119
|
- vendor/assets/javascripts/js_stack/plugins/backbone.associations.js
|
118
120
|
- vendor/assets/javascripts/js_stack/plugins/backbone.deepmodel.js
|
121
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone.mutators.js
|
119
122
|
- vendor/assets/javascripts/js_stack/plugins/backbone.pageable.js
|
120
123
|
- vendor/assets/javascripts/js_stack/plugins/backbone.stickit.js
|
121
124
|
- vendor/assets/javascripts/js_stack/plugins/backbone.validation.js
|
@@ -123,7 +126,9 @@ files:
|
|
123
126
|
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.5.1.js
|
124
127
|
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.5.4.js
|
125
128
|
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.5.5.js
|
129
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.6.1.js
|
126
130
|
- vendor/assets/javascripts/js_stack/plugins/backbone/deepmodel/0.10.4.js
|
131
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/mutators/0.4.1.js
|
127
132
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.3.2.js
|
128
133
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.4.5.js
|
129
134
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.6.3.js
|
@@ -132,6 +137,8 @@ files:
|
|
132
137
|
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.9.1.js
|
133
138
|
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.4.5.js
|
134
139
|
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.4.8.js
|
140
|
+
- vendor/assets/javascripts/js_stack/plugins/cocktail.js
|
141
|
+
- vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.3.js
|
135
142
|
- vendor/assets/javascripts/js_stack/plugins/moment.js
|
136
143
|
- vendor/assets/javascripts/js_stack/plugins/underscore.inflections.js
|
137
144
|
- vendor/assets/javascripts/js_stack/plugins/underscore.string.js
|