ende 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +1 -1
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +7 -4
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +16 -8
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +10 -5
- data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +4 -8
- data/lib/assets/javascripts/widgets/authenticator/presenter.js.coffee +4 -4
- data/lib/assets/javascripts/widgets/authenticator/states/default.html +1 -1
- data/lib/assets/javascripts/widgets/tray/main.js.coffee +26 -0
- data/lib/ende/version.rb +1 -1
- data/lib/tasks/component.thor +1 -1
- data/vendor/assets/javascripts/ende/build.js +10008 -8202
- data/vendor/components/KapIT-observe-utils/component.json +16 -0
- data/vendor/components/KapIT-observe-utils/lib/observe-utils.js +780 -0
- data/vendor/components/chaijs-assertion-error/component.json +18 -0
- data/vendor/components/chaijs-assertion-error/index.js +110 -0
- data/vendor/components/chaijs-chai/component.json +47 -0
- data/vendor/components/chaijs-chai/index.js +1 -0
- data/vendor/components/chaijs-chai/lib/chai/assertion.js +130 -0
- data/vendor/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
- data/vendor/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
- data/vendor/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
- data/vendor/components/chaijs-chai/lib/chai/interface/should.js +76 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/index.js +108 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/test.js +26 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
- data/vendor/components/chaijs-chai/lib/chai/utils/type.js +45 -0
- data/vendor/components/chaijs-chai/lib/chai.js +80 -0
- data/vendor/components/chaijs-deep-eql/component.json +18 -0
- data/vendor/components/chaijs-deep-eql/lib/eql.js +257 -0
- data/vendor/components/chaijs-type-detect/component.json +16 -0
- data/vendor/components/chaijs-type-detect/lib/type.js +142 -0
- data/vendor/components/component-bind/component.json +14 -0
- data/vendor/components/component-bind/index.js +24 -0
- data/vendor/components/component-delegate/component.json +19 -0
- data/vendor/components/component-delegate/index.js +42 -0
- data/vendor/components/component-event/component.json +13 -0
- data/vendor/components/component-event/index.js +40 -0
- data/vendor/components/component-jquery/component.json +14 -0
- data/vendor/components/component-jquery/index.js +9601 -0
- data/vendor/components/component-link-delegate/component.json +23 -0
- data/vendor/components/component-link-delegate/index.js +60 -0
- data/vendor/components/component-matches-selector/component.json +20 -0
- data/vendor/components/component-matches-selector/index.js +45 -0
- data/vendor/components/component-query/component.json +21 -0
- data/vendor/components/component-query/index.js +21 -0
- data/vendor/components/component-type/component.json +18 -0
- data/vendor/components/component-type/index.js +32 -0
- data/vendor/components/component-url/component.json +17 -0
- data/vendor/components/component-url/index.js +63 -0
- data/vendor/components/components-modernizr/component.json +18 -0
- data/vendor/components/components-modernizr/modernizr.js +1393 -0
- data/vendor/components/discore-closest/component.json +14 -0
- data/vendor/components/discore-closest/index.js +18 -0
- data/vendor/components/indefinido-advisable/component.json +21 -0
- data/vendor/components/indefinido-advisable/index.js +1 -0
- data/vendor/components/indefinido-advisable/lib/advisable.js +60 -0
- data/vendor/components/indefinido-indemma/component.json +40 -0
- data/vendor/components/indefinido-indemma/index.js +1 -0
- data/vendor/components/indefinido-indemma/lib/extensions/rivets.js +23 -0
- data/vendor/components/indefinido-indemma/lib/record/associable.js +217 -0
- data/vendor/components/indefinido-indemma/lib/record/maid.js +24 -0
- data/vendor/components/indefinido-indemma/lib/record/resource.js +104 -0
- data/vendor/components/indefinido-indemma/lib/record/rest.js +36 -0
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +326 -0
- data/vendor/components/indefinido-indemma/lib/record/scopable.js +279 -0
- data/vendor/components/indefinido-indemma/lib/record/translationable.js +19 -0
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +216 -0
- data/vendor/components/indefinido-indemma/lib/record/validations/associated.js +30 -0
- data/vendor/components/indefinido-indemma/lib/record/validations/confirmation.js +19 -0
- data/vendor/components/indefinido-indemma/lib/record/validations/cpf.js +60 -0
- data/vendor/components/indefinido-indemma/lib/record/validations/presence.js +19 -0
- data/vendor/components/indefinido-indemma/lib/record/validations/remote.js +71 -0
- data/vendor/components/indefinido-indemma/lib/record.js +167 -0
- data/vendor/components/indefinido-indemma/vendor/sinon.js +4290 -0
- data/vendor/components/indefinido-indemma/vendor/stampit.js +392 -0
- data/vendor/components/indefinido-observable/component.json +25 -0
- data/vendor/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
- data/vendor/components/indefinido-observable/index.js +1 -0
- data/vendor/components/indefinido-observable/lib/adapters/rivets.js +26 -0
- data/vendor/components/indefinido-observable/lib/observable.js +320 -0
- data/vendor/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
- data/vendor/components/indefinido-observable/vendor/shims/accessors.js +173 -0
- data/vendor/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
- data/vendor/components/indefinido-observable/vendor/shims/object.create.js +77 -0
- data/vendor/components/mikeric-rivets/component.json +15 -0
- data/vendor/components/mikeric-rivets/dist/rivets.js +1239 -0
- data/vendor/components/paulmillr-es6-shim/component.json +17 -0
- data/vendor/components/paulmillr-es6-shim/es6-shim.js +985 -0
- data/vendor/components/pluma-assimilate/component.json +25 -0
- data/vendor/components/pluma-assimilate/dist/assimilate.js +87 -0
- data/vendor/components/segmentio-extend/component.json +13 -0
- data/vendor/components/segmentio-extend/index.js +15 -0
- metadata +98 -2
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "closest",
|
3
|
+
"description": "Find the closest ancestor matching a selector string",
|
4
|
+
"version": "0.1.0",
|
5
|
+
"repo": "discore/closest",
|
6
|
+
"dependencies": {
|
7
|
+
"component/matches-selector": "*"
|
8
|
+
},
|
9
|
+
"main": "index.js",
|
10
|
+
"scripts": [
|
11
|
+
"index.js"
|
12
|
+
],
|
13
|
+
"license": "MIT"
|
14
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
var matches = require('matches-selector')
|
2
|
+
|
3
|
+
module.exports = function (element, selector, checkYoSelf, root) {
|
4
|
+
element = checkYoSelf ? element : element.parentNode
|
5
|
+
root = root || document
|
6
|
+
|
7
|
+
do {
|
8
|
+
if (matches(element, selector))
|
9
|
+
return element
|
10
|
+
// After `matches` on the edge case that
|
11
|
+
// the selector matches the root
|
12
|
+
// (when the root is not the document)
|
13
|
+
if (element === root)
|
14
|
+
return
|
15
|
+
// Make sure `element !== document`
|
16
|
+
// otherwise we get an illegal invocation
|
17
|
+
} while ((element = element.parentNode) && element !== document)
|
18
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "advisable",
|
3
|
+
"repo": "indefinido/advisable",
|
4
|
+
"description": "Aspect oriented programming mixin",
|
5
|
+
"version": "0.0.1",
|
6
|
+
"keywords": [
|
7
|
+
"aspect",
|
8
|
+
"aop",
|
9
|
+
"mixin"
|
10
|
+
],
|
11
|
+
"dependencies": {
|
12
|
+
"component/jquery": "*"
|
13
|
+
},
|
14
|
+
"development": {},
|
15
|
+
"license": "WTFP",
|
16
|
+
"paths": [],
|
17
|
+
"scripts": [
|
18
|
+
"index.js",
|
19
|
+
"lib/advisable.js"
|
20
|
+
]
|
21
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./lib/advisable');
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var $, advice, mixin;
|
2
|
+
|
3
|
+
$ = require('jquery');
|
4
|
+
|
5
|
+
advice = {
|
6
|
+
around: function(base, wrapped) {
|
7
|
+
return function() {
|
8
|
+
var args;
|
9
|
+
|
10
|
+
args = $.makeArray(arguments);
|
11
|
+
return wrapped.apply(this, [$.proxy(base, this)].concat(args));
|
12
|
+
};
|
13
|
+
},
|
14
|
+
before: function(base, before) {
|
15
|
+
return this.around(base, function() {
|
16
|
+
var args, orig;
|
17
|
+
|
18
|
+
args = $.makeArray(arguments);
|
19
|
+
orig = args.shift();
|
20
|
+
before.apply(this, args);
|
21
|
+
return orig.apply(this, args);
|
22
|
+
});
|
23
|
+
},
|
24
|
+
after: function(base, after) {
|
25
|
+
return this.around(base, function() {
|
26
|
+
var args, orig, res;
|
27
|
+
|
28
|
+
args = $.makeArray(arguments);
|
29
|
+
orig = args.shift();
|
30
|
+
res = orig.apply(this, args);
|
31
|
+
after.apply(this, args);
|
32
|
+
return res;
|
33
|
+
});
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
mixin = {
|
38
|
+
before: function(method, advicer) {
|
39
|
+
if (typeof this[method] === 'function') {
|
40
|
+
return this[method] = advice.before(this[method], advicer);
|
41
|
+
}
|
42
|
+
throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method]));
|
43
|
+
},
|
44
|
+
after: function(method, advicer) {
|
45
|
+
if (typeof this[method] === 'function') {
|
46
|
+
return this[method] = advice.after(this[method], advicer);
|
47
|
+
}
|
48
|
+
throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method]));
|
49
|
+
},
|
50
|
+
around: function(method, advicer) {
|
51
|
+
if (typeof this[method] === 'function') {
|
52
|
+
return this[method] = advice.around(this[method], advicer);
|
53
|
+
}
|
54
|
+
throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method]));
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
exports.mixin = function(object) {
|
59
|
+
return $.extend(object, mixin);
|
60
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "indemma",
|
3
|
+
"repo": "indefinido/indemma",
|
4
|
+
"description": "Indemma (mind picture = memory), client side ES5 observable REST model",
|
5
|
+
"version": "0.0.2",
|
6
|
+
"keywords": [],
|
7
|
+
"dependencies": {
|
8
|
+
"pluma/assimilate": "*",
|
9
|
+
"component/type": "*",
|
10
|
+
"component/bind": "*",
|
11
|
+
"component/jquery": "*",
|
12
|
+
"indefinido/observable": "*",
|
13
|
+
"indefinido/advisable": "*",
|
14
|
+
"chaijs/chai": "*"
|
15
|
+
},
|
16
|
+
"development": {
|
17
|
+
"chaijs/chai": "*"
|
18
|
+
},
|
19
|
+
"license": "WTFPL",
|
20
|
+
"scripts": [
|
21
|
+
"index.js",
|
22
|
+
"vendor/stampit.js",
|
23
|
+
"vendor/sinon.js",
|
24
|
+
"lib/record.js",
|
25
|
+
"lib/record/associable.js",
|
26
|
+
"lib/record/resource.js",
|
27
|
+
"lib/record/rest.js",
|
28
|
+
"lib/record/restfulable.js",
|
29
|
+
"lib/record/scopable.js",
|
30
|
+
"lib/record/maid.js",
|
31
|
+
"lib/record/translationable.js",
|
32
|
+
"lib/record/validations/remote.js",
|
33
|
+
"lib/record/validations/presence.js",
|
34
|
+
"lib/record/validations/confirmation.js",
|
35
|
+
"lib/record/validations/associated.js",
|
36
|
+
"lib/record/validations/cpf.js",
|
37
|
+
"lib/record/validatable.js",
|
38
|
+
"lib/extensions/rivets.js"
|
39
|
+
]
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./lib/record');
|
@@ -0,0 +1,23 @@
|
|
1
|
+
var root;
|
2
|
+
|
3
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
4
|
+
|
5
|
+
model.rivets = function() {
|
6
|
+
var model_extensions;
|
7
|
+
|
8
|
+
model_extensions = {
|
9
|
+
record: {
|
10
|
+
tie: function(element) {
|
11
|
+
var lasso;
|
12
|
+
|
13
|
+
lasso = {};
|
14
|
+
lasso[this.resource] = this;
|
15
|
+
return rivets.bind(element, lasso);
|
16
|
+
}
|
17
|
+
},
|
18
|
+
preloadData: true
|
19
|
+
};
|
20
|
+
return model.mix(function(modelable) {
|
21
|
+
return $.extend(true, modelable, model_extensions);
|
22
|
+
});
|
23
|
+
};
|
@@ -0,0 +1,217 @@
|
|
1
|
+
var $, associable, model, plural, root, singular,
|
2
|
+
__slice = [].slice;
|
3
|
+
|
4
|
+
root = window;
|
5
|
+
|
6
|
+
$ = require('jquery');
|
7
|
+
|
8
|
+
require('./resource');
|
9
|
+
|
10
|
+
plural = {
|
11
|
+
add: function() {
|
12
|
+
var attributes, params, _i, _len, _results;
|
13
|
+
|
14
|
+
params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
15
|
+
_results = [];
|
16
|
+
for (_i = 0, _len = params.length; _i < _len; _i++) {
|
17
|
+
attributes = params[_i];
|
18
|
+
_results.push(this.push(this.build(attributes)));
|
19
|
+
}
|
20
|
+
return _results;
|
21
|
+
},
|
22
|
+
create: function() {
|
23
|
+
var attributes, params, record, _i, _len, _results;
|
24
|
+
|
25
|
+
params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
26
|
+
_results = [];
|
27
|
+
for (_i = 0, _len = params.length; _i < _len; _i++) {
|
28
|
+
attributes = params[_i];
|
29
|
+
record = this.build(attributes);
|
30
|
+
this.push(record);
|
31
|
+
_results.push(record.save());
|
32
|
+
}
|
33
|
+
return _results;
|
34
|
+
},
|
35
|
+
build: function(data) {
|
36
|
+
var _name;
|
37
|
+
|
38
|
+
if (data == null) {
|
39
|
+
data = {};
|
40
|
+
}
|
41
|
+
data.parent_resource = this.parent_resource;
|
42
|
+
if (this.parent != null) {
|
43
|
+
data.route || (data.route = "" + this.parent.route + "/" + this.parent._id + "/" + (model.pluralize(this.resource.toString())));
|
44
|
+
}
|
45
|
+
if (this.route !== data.route && this.route) {
|
46
|
+
throw "associable.has_many: cannot redefine route of association " + this.parent_resource + "." + this.resource + " from " + this.route + " to " + data.route;
|
47
|
+
}
|
48
|
+
data[_name = this.parent_resource] || (data[_name] = this.parent);
|
49
|
+
return model[model.singularize(this.resource)](data);
|
50
|
+
},
|
51
|
+
push: Array.prototype.push,
|
52
|
+
length: 0,
|
53
|
+
json: function() {
|
54
|
+
var record, _i, _len, _results;
|
55
|
+
|
56
|
+
_results = [];
|
57
|
+
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
58
|
+
record = this[_i];
|
59
|
+
_results.push(record.json());
|
60
|
+
}
|
61
|
+
return _results;
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
singular = {
|
66
|
+
create: function(data) {
|
67
|
+
return model[this.resource].create($.extend({}, this, data));
|
68
|
+
},
|
69
|
+
build: function(data) {
|
70
|
+
return this[this.parent_resource][this.resource] = model[this.resource]($.extend({}, this, data));
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
associable = {
|
75
|
+
model: function(options) {
|
76
|
+
var callbacks;
|
77
|
+
|
78
|
+
if (this.resource == null) {
|
79
|
+
console.error('resource must be defined in order to associate');
|
80
|
+
}
|
81
|
+
callbacks = {
|
82
|
+
has_many: {
|
83
|
+
nest_attributes: function() {
|
84
|
+
var association, association_name, association_names, associations_attributes, message, _i, _len, _results;
|
85
|
+
|
86
|
+
association_names = model[this.resource].has_many;
|
87
|
+
if (association_names) {
|
88
|
+
_results = [];
|
89
|
+
for (_i = 0, _len = association_names.length; _i < _len; _i++) {
|
90
|
+
association_name = association_names[_i];
|
91
|
+
associations_attributes = this["" + association_name + "_attributes"];
|
92
|
+
if (associations_attributes && associations_attributes.length) {
|
93
|
+
association = this[model.pluralize(association_name)];
|
94
|
+
if (!association) {
|
95
|
+
message = "has_many.nest_attributes: Association not found for " + association_name + ". \n";
|
96
|
+
message += "did you set it on model declaration? \n has_many: " + association_name + " ";
|
97
|
+
throw message;
|
98
|
+
}
|
99
|
+
association.resource = model.singularize(association.resource);
|
100
|
+
association.add.apply(association, associations_attributes);
|
101
|
+
_results.push(association.resource = model.pluralize(association.resource));
|
102
|
+
} else {
|
103
|
+
_results.push(void 0);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return _results;
|
107
|
+
}
|
108
|
+
},
|
109
|
+
update_association: function(data) {
|
110
|
+
var associated, association, association_name, id, pluralized_association, _i, _j, _len, _len1, _ref;
|
111
|
+
|
112
|
+
id = this._id || data._id || data.id;
|
113
|
+
if (!id) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
_ref = model[this.resource].has_many;
|
117
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
118
|
+
association_name = _ref[_i];
|
119
|
+
pluralized_association = model.pluralize(association_name);
|
120
|
+
association = this[pluralized_association];
|
121
|
+
if (!association.route) {
|
122
|
+
association.route = "/" + (model.pluralize(this.resource)) + "/" + id + "/" + (model.pluralize(association.resource));
|
123
|
+
for (_j = 0, _len1 = association.length; _j < _len1; _j++) {
|
124
|
+
associated = association[_j];
|
125
|
+
if (!associated.route && (associated.parent != null)) {
|
126
|
+
associated.route = "/" + (model.pluralize(this.resource)) + "/" + id + "/" + (model.pluralize(association.resource));
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
return true;
|
132
|
+
},
|
133
|
+
autosave: function() {
|
134
|
+
return this.save();
|
135
|
+
}
|
136
|
+
}
|
137
|
+
};
|
138
|
+
if (this.has_many && $.type(this.has_many) !== 'array') {
|
139
|
+
this.has_many = [this.has_many];
|
140
|
+
}
|
141
|
+
if (this.has_one && $.type(this.has_one) !== 'array') {
|
142
|
+
this.has_one = [this.has_one];
|
143
|
+
}
|
144
|
+
if (this.belongs_to && $.type(this.belongs_to) !== 'array') {
|
145
|
+
this.belongs_to = [this.belongs_to];
|
146
|
+
}
|
147
|
+
this.has_many || (this.has_many = []);
|
148
|
+
this.has_one || (this.has_one = []);
|
149
|
+
this.belongs_to || (this.belongs_to = []);
|
150
|
+
return this.create_associations = function() {
|
151
|
+
var association_name, association_proxy, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
|
152
|
+
|
153
|
+
if (options.has_many) {
|
154
|
+
_ref = options.has_many;
|
155
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
156
|
+
resource = _ref[_i];
|
157
|
+
association_proxy = {
|
158
|
+
resource: resource,
|
159
|
+
parent_resource: this.resource,
|
160
|
+
parent: this
|
161
|
+
};
|
162
|
+
association_name = model.pluralize(resource);
|
163
|
+
this[association_name] = $.extend(association_proxy, plural);
|
164
|
+
}
|
165
|
+
this.after('saved', callbacks.has_many.update_association);
|
166
|
+
callbacks.has_many.nest_attributes.call(this);
|
167
|
+
}
|
168
|
+
if (options.has_one) {
|
169
|
+
_ref1 = options.has_one;
|
170
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
171
|
+
resource = _ref1[_j];
|
172
|
+
association_proxy = {
|
173
|
+
resource: resource,
|
174
|
+
parent_resource: this.resource
|
175
|
+
};
|
176
|
+
association_proxy[this.resource] = this;
|
177
|
+
this["build_" + resource] = $.proxy(singular.build, association_proxy);
|
178
|
+
this["create_" + resource] = $.proxy(singular.create, association_proxy);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
if (options.belongs_to) {
|
182
|
+
_ref2 = options.belongs_to;
|
183
|
+
_results = [];
|
184
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
185
|
+
resource = _ref2[_k];
|
186
|
+
association_proxy = {
|
187
|
+
resource: resource,
|
188
|
+
parent_resource: this.resource
|
189
|
+
};
|
190
|
+
association_proxy[this.resource] = this;
|
191
|
+
this["build_" + resource] = $.proxy(singular.build, association_proxy);
|
192
|
+
_results.push(this["create_" + resource] = $.proxy(singular.create, association_proxy));
|
193
|
+
}
|
194
|
+
return _results;
|
195
|
+
}
|
196
|
+
};
|
197
|
+
},
|
198
|
+
record: function(options) {
|
199
|
+
if (this.resource == null) {
|
200
|
+
console.error('resource must be defined in order to associate');
|
201
|
+
}
|
202
|
+
return model[this.resource.name || this.resource.toString()].create_associations.call(this);
|
203
|
+
}
|
204
|
+
};
|
205
|
+
|
206
|
+
model = root.model;
|
207
|
+
|
208
|
+
model.mix(function(modelable) {
|
209
|
+
modelable.after_mix.push(associable.model);
|
210
|
+
return modelable.record.after_initialize.push(associable.record);
|
211
|
+
});
|
212
|
+
|
213
|
+
model.associable = {
|
214
|
+
mix: function(blender) {
|
215
|
+
return blender(singular, plural);
|
216
|
+
}
|
217
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
var maid, model;
|
2
|
+
|
3
|
+
maid = {
|
4
|
+
model: function() {
|
5
|
+
if (this.washing != null) {
|
6
|
+
return this.record.after_initialize.push(maid.record);
|
7
|
+
}
|
8
|
+
},
|
9
|
+
record: function() {
|
10
|
+
return this.subscribe('dirty', function(dirty) {
|
11
|
+
var _this = this;
|
12
|
+
|
13
|
+
return dirty && setTimeout(function() {
|
14
|
+
return _this.save();
|
15
|
+
}, 500);
|
16
|
+
});
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
model = window.model;
|
21
|
+
|
22
|
+
model.mix(function(modelable) {
|
23
|
+
return modelable.after_mix.unshift(maid.model);
|
24
|
+
});
|
@@ -0,0 +1,104 @@
|
|
1
|
+
var model, resource, resourceable, stampit;
|
2
|
+
|
3
|
+
stampit = require('../../vendor/stampit');
|
4
|
+
|
5
|
+
resource = stampit({
|
6
|
+
toString: function() {
|
7
|
+
return this.name;
|
8
|
+
}
|
9
|
+
}, {
|
10
|
+
name: 'unknown',
|
11
|
+
scope: null,
|
12
|
+
singular: false
|
13
|
+
}, function() {
|
14
|
+
this.param_name || (this.param_name = this.name);
|
15
|
+
return this;
|
16
|
+
});
|
17
|
+
|
18
|
+
resourceable = {
|
19
|
+
pluralize: function(word) {
|
20
|
+
if (!(word && word.length)) {
|
21
|
+
throw new TypeError("Invalid string passed to pluralize '" + word + "'");
|
22
|
+
}
|
23
|
+
if (word.indexOf('s') !== word.length - 1) {
|
24
|
+
return word + 's';
|
25
|
+
} else {
|
26
|
+
return word;
|
27
|
+
}
|
28
|
+
},
|
29
|
+
singularize: function(word) {
|
30
|
+
if (!(word && word.length)) {
|
31
|
+
throw new TypeError("Invalid string passed to singularize '" + word + "'");
|
32
|
+
}
|
33
|
+
if (word.indexOf('s') === word.length - 1) {
|
34
|
+
return word.substring(0, word.length - 1);
|
35
|
+
} else {
|
36
|
+
return word;
|
37
|
+
}
|
38
|
+
},
|
39
|
+
route: {
|
40
|
+
get: function() {
|
41
|
+
var route;
|
42
|
+
|
43
|
+
if (this.initial_route != null) {
|
44
|
+
return this.initial_route;
|
45
|
+
}
|
46
|
+
if (typeof this.resource === 'string') {
|
47
|
+
this.resource = {
|
48
|
+
name: this.resource
|
49
|
+
};
|
50
|
+
}
|
51
|
+
route = '/';
|
52
|
+
if (this.parent != null) {
|
53
|
+
route += "" + this.parent.route + "/" + this.parent._id + "/";
|
54
|
+
}
|
55
|
+
if (this.resource.scope != null) {
|
56
|
+
route += this.resource.scope + '/';
|
57
|
+
}
|
58
|
+
route += this.resource.singular ? this.resource.name : model.pluralize(this.resource.name);
|
59
|
+
this.initial_route = route;
|
60
|
+
return route;
|
61
|
+
},
|
62
|
+
set: function(value) {
|
63
|
+
return this.initial_route = value;
|
64
|
+
}
|
65
|
+
},
|
66
|
+
parent_id: {
|
67
|
+
get: function() {
|
68
|
+
return this[this.parent_resource]._id;
|
69
|
+
},
|
70
|
+
set: function() {
|
71
|
+
return console.error('Warning changing associations throught parent_id not allowed for security and style guide purposes');
|
72
|
+
}
|
73
|
+
},
|
74
|
+
initialize: function() {
|
75
|
+
var resource_definition, _ref;
|
76
|
+
|
77
|
+
if (this.parent_resource) {
|
78
|
+
Object.defineProperty(this, "" + this.parent_resource + "_id", resourceable.parent_id);
|
79
|
+
}
|
80
|
+
resource_definition = {};
|
81
|
+
if (typeof this.resource === 'string') {
|
82
|
+
resource_definition = {
|
83
|
+
name: this.resource
|
84
|
+
};
|
85
|
+
}
|
86
|
+
if (typeof this.resource === 'object') {
|
87
|
+
resource_definition = this.resource;
|
88
|
+
}
|
89
|
+
resource_definition.parent = this.parent_resource;
|
90
|
+
this.resource = resource(resource_definition);
|
91
|
+
return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route', resourceable.route);
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
model = window.model;
|
96
|
+
|
97
|
+
model.mix(function(modelable) {
|
98
|
+
modelable.record.after_initialize.unshift(resourceable.initialize);
|
99
|
+
return modelable.after_mix.unshift(resourceable.initialize);
|
100
|
+
});
|
101
|
+
|
102
|
+
model.singularize = resourceable.singularize;
|
103
|
+
|
104
|
+
model.pluralize = resourceable.pluralize;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
var $, request;
|
2
|
+
|
3
|
+
$ = require('jquery');
|
4
|
+
|
5
|
+
module.exports = {
|
6
|
+
get: function(data) {
|
7
|
+
return request.call(this, 'get', (this._id ? "" + this.route + "/" + this._id : this.route), data);
|
8
|
+
},
|
9
|
+
put: function(data) {
|
10
|
+
return request.call(this, 'put', "" + this.route + "/" + this._id, data);
|
11
|
+
},
|
12
|
+
post: function(data) {
|
13
|
+
return request.call(this, 'post', this.route, data);
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
17
|
+
request = function(method, url, data) {
|
18
|
+
var param_name;
|
19
|
+
|
20
|
+
param_name = this.resource.param_name || this.resource.toString();
|
21
|
+
if (!data && this.json) {
|
22
|
+
data = {};
|
23
|
+
data[param_name] = this.json();
|
24
|
+
}
|
25
|
+
if (data[param_name]) {
|
26
|
+
delete data[param_name]._id;
|
27
|
+
delete data[param_name].id;
|
28
|
+
}
|
29
|
+
return $.ajax({
|
30
|
+
url: url,
|
31
|
+
data: data,
|
32
|
+
type: method,
|
33
|
+
dataType: 'json',
|
34
|
+
context: this
|
35
|
+
});
|
36
|
+
};
|