joosy 1.2.0.alpha.41 → 1.2.0.alpha.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gruntfile.coffee +27 -7
  4. data/bin/joosy +1 -1
  5. data/bower.json +3 -2
  6. data/build/joosy/extensions/preloaders.js +189 -0
  7. data/build/joosy/extensions/resources-form.js +588 -0
  8. data/build/joosy/extensions/resources.js +673 -0
  9. data/build/joosy.js +2395 -0
  10. data/{src/joosy/generators → generators}/base.coffee +2 -2
  11. data/{src/joosy/generators → generators/command}/command.coffee +16 -3
  12. data/generators/command/help.coffee +38 -0
  13. data/{src/joosy/generators → generators}/layout.coffee +0 -0
  14. data/{src/joosy/generators → generators}/page.coffee +0 -0
  15. data/{src/joosy/generators → generators}/project/base.coffee +2 -4
  16. data/{src/joosy/generators → generators}/project/standalone.coffee +4 -3
  17. data/{src/joosy/generators → generators}/project.coffee +0 -0
  18. data/generators/templates/application/base/application.coffee +13 -0
  19. data/{templates → generators/templates}/application/base/helpers/application.coffee +0 -0
  20. data/{templates → generators/templates}/application/base/layouts/application.coffee +0 -0
  21. data/{templates → generators/templates}/application/base/pages/application.coffee +0 -0
  22. data/{templates → generators/templates}/application/base/pages/welcome/index.coffee +0 -0
  23. data/{templates → generators/templates}/application/base/routes.coffee +0 -0
  24. data/{templates → generators/templates}/application/base/templates/layouts/application.jst.hamlc +0 -0
  25. data/{templates → generators/templates}/application/base/templates/pages/welcome/index.jst.hamlc +0 -0
  26. data/{templates → generators/templates}/application/standalone/Gruntfile.coffee +1 -0
  27. data/{templates → generators/templates}/application/standalone/Procfile +0 -0
  28. data/{templates → generators/templates}/application/standalone/_gitignore +0 -0
  29. data/generators/templates/application/standalone/bower.json +17 -0
  30. data/{templates → generators/templates}/application/standalone/package.json +0 -0
  31. data/{templates → generators/templates}/application/standalone/source/haml/index.haml +0 -0
  32. data/{templates → generators/templates}/application/standalone/source/stylesheets/application.styl +0 -0
  33. data/{templates → generators/templates}/layout/basic.coffee +0 -0
  34. data/{templates → generators/templates}/layout/namespaced.coffee +0 -0
  35. data/{templates → generators/templates}/page/basic.coffee +0 -0
  36. data/{templates → generators/templates}/page/namespaced.coffee +0 -0
  37. data/{templates → generators/templates}/widget/basic.coffee +0 -0
  38. data/{templates → generators/templates}/widget/namespaced.coffee +0 -0
  39. data/{src/joosy/generators → generators}/widget.coffee +0 -0
  40. data/lib/joosy.rb +3 -3
  41. data/package.json +2 -3
  42. data/source/joosy/application.coffee +95 -0
  43. data/source/joosy/events/namespace.coffee +24 -0
  44. data/{src → source}/joosy/extensions/preloaders/caching.coffee +0 -0
  45. data/{src → source}/joosy/extensions/preloaders/index.coffee +0 -0
  46. data/{src → source}/joosy/extensions/preloaders/inline.coffee +0 -0
  47. data/{src → source}/joosy/extensions/resources/base.coffee +16 -8
  48. data/{src → source}/joosy/extensions/resources/collection.coffee +0 -0
  49. data/{src → source}/joosy/extensions/resources/index.coffee +0 -0
  50. data/{src → source}/joosy/extensions/resources/rest.coffee +0 -0
  51. data/{src → source}/joosy/extensions/resources/rest_collection.coffee +0 -0
  52. data/{src → source}/joosy/extensions/resources-form/form.coffee +18 -18
  53. data/{src → source}/joosy/extensions/resources-form/helpers/form.coffee +6 -6
  54. data/{src → source}/joosy/extensions/resources-form/index.coffee +0 -0
  55. data/source/joosy/helpers/routes.coffee +10 -0
  56. data/source/joosy/helpers/view.coffee +115 -0
  57. data/{src/joosy/core → source/joosy}/helpers/widgets.coffee +1 -1
  58. data/{src/joosy/core → source/joosy}/joosy.coffee +59 -19
  59. data/source/joosy/layout.coffee +73 -0
  60. data/{src/joosy/core → source/joosy}/module.coffee +7 -2
  61. data/{src/joosy/core/modules/container.coffee → source/joosy/modules/dom.coffee} +24 -17
  62. data/source/joosy/modules/events.coffee +156 -0
  63. data/source/joosy/modules/filters.coffee +67 -0
  64. data/{src/joosy/core → source/joosy}/modules/log.coffee +7 -3
  65. data/source/joosy/modules/page/scrolling.coffee +51 -0
  66. data/source/joosy/modules/page/title.coffee +18 -0
  67. data/{src/joosy/core → source/joosy}/modules/renderer.coffee +12 -13
  68. data/{src/joosy/core → source/joosy}/modules/time_manager.coffee +5 -1
  69. data/{src/joosy/core → source/joosy}/modules/widgets_manager.coffee +9 -5
  70. data/source/joosy/page.coffee +68 -0
  71. data/{src/joosy/core → source/joosy}/resources/watcher.coffee +5 -1
  72. data/source/joosy/router.coffee +305 -0
  73. data/{src/joosy/core → source/joosy}/templaters/jst.coffee +10 -7
  74. data/source/joosy/widget.coffee +385 -0
  75. data/source/joosy.coffee +1 -0
  76. data/{src/vendor → source}/metamorph.coffee +0 -0
  77. data/spec/helpers/matchers.coffee +8 -1
  78. data/spec/joosy/core/application_spec.coffee +121 -20
  79. data/spec/joosy/core/helpers/view_spec.coffee +3 -3
  80. data/spec/joosy/core/helpers/widgets_spec.coffee +3 -6
  81. data/spec/joosy/core/joosy_spec.coffee +0 -5
  82. data/spec/joosy/core/layout_spec.coffee +2 -28
  83. data/spec/joosy/core/modules/dom_spec.coffee +133 -0
  84. data/spec/joosy/core/modules/events_spec.coffee +16 -9
  85. data/spec/joosy/core/modules/filters_spec.coffee +232 -89
  86. data/spec/joosy/core/modules/log_spec.coffee +2 -2
  87. data/spec/joosy/core/modules/renderer_spec.coffee +8 -4
  88. data/spec/joosy/core/page_spec.coffee +2 -201
  89. data/spec/joosy/core/router_spec.coffee +295 -233
  90. data/spec/joosy/core/templaters/jst_spec.coffee +1 -1
  91. data/spec/joosy/core/widget_spec.coffee +373 -34
  92. data/spec/joosy/environments/amd_spec.coffee +38 -0
  93. data/spec/joosy/environments/global_spec.coffee +21 -0
  94. data/spec/joosy/extensions/form/form_spec.coffee +18 -18
  95. data/spec/joosy/extensions/form/helpers/forms_spec.coffee +1 -1
  96. data/spec/joosy/extensions/resources/base_spec.coffee +23 -11
  97. data/tasks/joosy.coffee +6 -9
  98. metadata +75 -69
  99. data/lib/extensions/preloaders.js +0 -193
  100. data/lib/extensions/resources-form.js +0 -592
  101. data/lib/extensions/resources.js +0 -675
  102. data/lib/joosy.js +0 -2199
  103. data/spec/joosy/core/modules/container_spec.coffee +0 -153
  104. data/spec/joosy/core/modules/widget_manager_spec.coffee +0 -96
  105. data/src/joosy/core/application.coffee +0 -59
  106. data/src/joosy/core/helpers/view.coffee +0 -52
  107. data/src/joosy/core/layout.coffee +0 -174
  108. data/src/joosy/core/modules/events.coffee +0 -188
  109. data/src/joosy/core/modules/filters.coffee +0 -42
  110. data/src/joosy/core/page.coffee +0 -383
  111. data/src/joosy/core/router.coffee +0 -313
  112. data/src/joosy/core/widget.coffee +0 -88
  113. data/src/joosy.coffee +0 -1
  114. data/templates/application/base/application.coffee +0 -9
  115. data/templates/application/standalone/bower.json +0 -7
@@ -0,0 +1,673 @@
1
+ (function() {
2
+ var __hasProp = {}.hasOwnProperty,
3
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
4
+ __slice = [].slice;
5
+
6
+ Joosy.Resources.Base = (function(_super) {
7
+ __extends(Base, _super);
8
+
9
+ Base.include(Joosy.Modules.Log);
10
+
11
+ Base.include(Joosy.Modules.Events);
12
+
13
+ Base.prototype.__primaryKey = 'id';
14
+
15
+ Base.prototype.__source = false;
16
+
17
+ Base.resetIdentity = function() {
18
+ return Joosy.Resources.Base.identity = {};
19
+ };
20
+
21
+ Base.beforeLoad = function(action) {
22
+ if (!this.prototype.hasOwnProperty('__beforeLoads')) {
23
+ this.prototype.__beforeLoads = [].concat(this.__super__.__beforeLoads || []);
24
+ }
25
+ return this.prototype.__beforeLoads.push(action);
26
+ };
27
+
28
+ Base.primaryKey = function(primaryKey) {
29
+ return this.prototype.__primaryKey = primaryKey;
30
+ };
31
+
32
+ Base.source = function(location) {
33
+ return this.__source = location;
34
+ };
35
+
36
+ Base.at = function() {
37
+ var Clone, args, _ref;
38
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
39
+ Clone = (function(_super1) {
40
+ __extends(Clone, _super1);
41
+
42
+ function Clone() {
43
+ _ref = Clone.__super__.constructor.apply(this, arguments);
44
+ return _ref;
45
+ }
46
+
47
+ return Clone;
48
+
49
+ })(this);
50
+ if (args.length === 1 && Object.isArray(args[0])) {
51
+ return this.at.apply(this, args[0]);
52
+ } else {
53
+ Clone.__source = args.reduce(function(path, arg) {
54
+ return path += arg instanceof Joosy.Resources.Base ? arg.memberPath() : arg.replace(/^\/?/, '/');
55
+ }, '');
56
+ if (this.prototype.__entityName && args[args.length - 1] instanceof Joosy.Resources.Base) {
57
+ Clone.__source += '/' + this.prototype.__entityName.pluralize();
58
+ }
59
+ return Clone;
60
+ }
61
+ };
62
+
63
+ Base.entity = function(name) {
64
+ return this.prototype.__entityName = name;
65
+ };
66
+
67
+ Base.collection = function(klass) {
68
+ return this.prototype.__collection = function() {
69
+ return klass;
70
+ };
71
+ };
72
+
73
+ Base.prototype.__collection = function() {
74
+ var named;
75
+ named = this.__entityName.camelize().pluralize() + 'Collection';
76
+ if (window[named]) {
77
+ return window[named];
78
+ } else {
79
+ return Joosy.Resources.Collection;
80
+ }
81
+ };
82
+
83
+ Base.map = function(name, klass) {
84
+ if (klass == null) {
85
+ klass = false;
86
+ }
87
+ if (!klass) {
88
+ klass = window[name.singularize().camelize()];
89
+ }
90
+ if (!klass) {
91
+ throw new Error("" + (Joosy.Module.__className(this)) + "> class can not be detected for '" + name + "' mapping");
92
+ }
93
+ return this.beforeLoad(function(data) {
94
+ if (!Joosy.Module.hasAncestor(klass, Joosy.Resources.Base)) {
95
+ klass = klass();
96
+ }
97
+ return this.__map(data, name, klass);
98
+ });
99
+ };
100
+
101
+ Base.build = function(data) {
102
+ var id, key, klass, shim, value, _base, _base1, _ref;
103
+ if (data == null) {
104
+ data = {};
105
+ }
106
+ klass = this.prototype.__entityName;
107
+ (_base = Joosy.Resources.Base).identity || (_base.identity = {});
108
+ (_base1 = Joosy.Resources.Base.identity)[klass] || (_base1[klass] = {});
109
+ shim = function() {
110
+ return shim.__call.apply(shim, arguments);
111
+ };
112
+ if (shim.__proto__) {
113
+ shim.__proto__ = this.prototype;
114
+ } else {
115
+ _ref = this.prototype;
116
+ for (key in _ref) {
117
+ value = _ref[key];
118
+ shim[key] = value;
119
+ }
120
+ }
121
+ shim.constructor = this;
122
+ if (Object.isNumber(data) || Object.isString(data)) {
123
+ id = data;
124
+ data = {};
125
+ data[shim.__primaryKey] = id;
126
+ }
127
+ if (Joosy.Resources.Base.identity) {
128
+ id = data[shim.__primaryKey];
129
+ if ((id != null) && Joosy.Resources.Base.identity[klass][id]) {
130
+ shim = Joosy.Resources.Base.identity[klass][id];
131
+ shim.load(data);
132
+ } else {
133
+ Joosy.Resources.Base.identity[klass][id] = shim;
134
+ this.apply(shim, [data]);
135
+ }
136
+ } else {
137
+ this.apply(shim, [data]);
138
+ }
139
+ return shim;
140
+ };
141
+
142
+ function Base(data) {
143
+ if (data == null) {
144
+ data = {};
145
+ }
146
+ this.__fillData(data, false);
147
+ }
148
+
149
+ Base.prototype.id = function() {
150
+ return this.data[this.__primaryKey];
151
+ };
152
+
153
+ Base.prototype.knownAttributes = function() {
154
+ return Object.keys(this.data);
155
+ };
156
+
157
+ Base.prototype.load = function(data) {
158
+ this.__fillData(data);
159
+ return this;
160
+ };
161
+
162
+ Base.prototype.__get = function(path) {
163
+ var target;
164
+ target = this.__callTarget(path, true);
165
+ if (!target) {
166
+ return void 0;
167
+ } else if (target[0] instanceof Joosy.Resources.Base) {
168
+ return target[0](target[1]);
169
+ } else {
170
+ return target[0][target[1]];
171
+ }
172
+ };
173
+
174
+ Base.prototype.__set = function(path, value) {
175
+ var target;
176
+ target = this.__callTarget(path);
177
+ if (target[0] instanceof Joosy.Resources.Base) {
178
+ target[0](target[1], value);
179
+ } else {
180
+ target[0][target[1]] = value;
181
+ }
182
+ this.trigger('changed');
183
+ return null;
184
+ };
185
+
186
+ Base.prototype.__callTarget = function(path, safe) {
187
+ var keyword, part, target, _i, _len;
188
+ if (safe == null) {
189
+ safe = false;
190
+ }
191
+ if (path.has(/\./) && (this.data[path] == null)) {
192
+ path = path.split('.');
193
+ keyword = path.pop();
194
+ target = this.data;
195
+ for (_i = 0, _len = path.length; _i < _len; _i++) {
196
+ part = path[_i];
197
+ if (safe && (target[part] == null)) {
198
+ return false;
199
+ }
200
+ target[part] || (target[part] = {});
201
+ if (target instanceof Joosy.Resources.Base) {
202
+ target = target(part);
203
+ } else {
204
+ target = target[part];
205
+ }
206
+ }
207
+ return [target, keyword];
208
+ } else {
209
+ return [this.data, path];
210
+ }
211
+ };
212
+
213
+ Base.prototype.__call = function(path, value) {
214
+ if (arguments.length > 1) {
215
+ return this.__set(path, value);
216
+ } else {
217
+ return this.__get(path);
218
+ }
219
+ };
220
+
221
+ Base.prototype.__fillData = function(data, notify) {
222
+ if (notify == null) {
223
+ notify = true;
224
+ }
225
+ this.raw = data;
226
+ if (!this.hasOwnProperty('data')) {
227
+ this.data = {};
228
+ }
229
+ Joosy.Module.merge(this.data, this.__prepareData(data));
230
+ if (notify) {
231
+ this.trigger('changed');
232
+ }
233
+ return null;
234
+ };
235
+
236
+ Base.prototype.__prepareData = function(data) {
237
+ var bl, name, _i, _len, _ref;
238
+ if (Object.isObject(data) && Object.keys(data).length === 1 && this.__entityName) {
239
+ name = this.__entityName.camelize(false);
240
+ if (data[name]) {
241
+ data = data[name];
242
+ }
243
+ }
244
+ if (this.__beforeLoads != null) {
245
+ _ref = this.__beforeLoads;
246
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
247
+ bl = _ref[_i];
248
+ data = bl.call(this, data);
249
+ }
250
+ }
251
+ return data;
252
+ };
253
+
254
+ Base.prototype.__map = function(data, name, klass) {
255
+ var entry;
256
+ if (Object.isArray(data[name])) {
257
+ entry = new (klass.prototype.__collection())(klass);
258
+ entry.load(data[name]);
259
+ data[name] = entry;
260
+ } else if (Object.isObject(data[name])) {
261
+ data[name] = klass.build(data[name]);
262
+ }
263
+ return data;
264
+ };
265
+
266
+ return Base;
267
+
268
+ })(Joosy.Module);
269
+
270
+ }).call(this);
271
+ (function() {
272
+ var __hasProp = {}.hasOwnProperty,
273
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
274
+ __slice = [].slice;
275
+
276
+ Joosy.Resources.Collection = (function(_super) {
277
+ __extends(Collection, _super);
278
+
279
+ Collection.include(Joosy.Modules.Events);
280
+
281
+ Collection.beforeLoad = function(action) {
282
+ return this.prototype.__beforeLoad = action;
283
+ };
284
+
285
+ Collection.model = function(model) {
286
+ return this.prototype.model = model;
287
+ };
288
+
289
+ function Collection(model, findOptions) {
290
+ if (model == null) {
291
+ model = false;
292
+ }
293
+ this.findOptions = findOptions;
294
+ if (model) {
295
+ this.model = model;
296
+ }
297
+ this.data = [];
298
+ if (!this.model) {
299
+ throw new Error("" + (Joosy.Module.__className(this)) + "> model can't be empty");
300
+ }
301
+ }
302
+
303
+ Collection.prototype.load = function(entities, notify) {
304
+ if (notify == null) {
305
+ notify = true;
306
+ }
307
+ if (this.__beforeLoad != null) {
308
+ entities = this.__beforeLoad(entities);
309
+ }
310
+ this.data = this.modelize(entities);
311
+ if (notify) {
312
+ this.trigger('changed');
313
+ }
314
+ return this;
315
+ };
316
+
317
+ Collection.prototype.modelize = function(collection) {
318
+ var root,
319
+ _this = this;
320
+ root = this.model.prototype.__entityName.pluralize();
321
+ if (!(collection instanceof Array)) {
322
+ collection = collection != null ? collection[root.camelize(false)] : void 0;
323
+ if (!(collection instanceof Array)) {
324
+ throw new Error("Can not read incoming JSON");
325
+ }
326
+ }
327
+ return collection.map(function(x) {
328
+ return _this.model.build(x);
329
+ });
330
+ };
331
+
332
+ Collection.prototype.each = function(callback) {
333
+ return this.data.each(callback);
334
+ };
335
+
336
+ Collection.prototype.size = function() {
337
+ return this.data.length;
338
+ };
339
+
340
+ Collection.prototype.find = function(description) {
341
+ return this.data.find(description);
342
+ };
343
+
344
+ Collection.prototype.sortBy = function() {
345
+ var params, _ref;
346
+ params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
347
+ return (_ref = this.data).sortBy.apply(_ref, params);
348
+ };
349
+
350
+ Collection.prototype.findById = function(id) {
351
+ return this.data.find(function(x) {
352
+ return x.id().toString() === id.toString();
353
+ });
354
+ };
355
+
356
+ Collection.prototype.at = function(i) {
357
+ return this.data[i];
358
+ };
359
+
360
+ Collection.prototype.remove = function(target, notify) {
361
+ var index, result;
362
+ if (notify == null) {
363
+ notify = true;
364
+ }
365
+ if (Object.isNumber(target)) {
366
+ index = target;
367
+ } else {
368
+ index = this.data.indexOf(target);
369
+ }
370
+ if (index >= 0) {
371
+ result = this.data.splice(index, 1)[0];
372
+ if (notify) {
373
+ this.trigger('changed');
374
+ }
375
+ }
376
+ return result;
377
+ };
378
+
379
+ Collection.prototype.add = function(element, index, notify) {
380
+ if (index == null) {
381
+ index = false;
382
+ }
383
+ if (notify == null) {
384
+ notify = true;
385
+ }
386
+ if (typeof index === 'number') {
387
+ this.data.splice(index, 0, element);
388
+ } else {
389
+ this.data.push(element);
390
+ }
391
+ if (notify) {
392
+ this.trigger('changed');
393
+ }
394
+ return element;
395
+ };
396
+
397
+ return Collection;
398
+
399
+ })(Joosy.Module);
400
+
401
+ }).call(this);
402
+ (function() {
403
+ var _ref,
404
+ __hasProp = {}.hasOwnProperty,
405
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
406
+
407
+ Joosy.Resources.REST = (function(_super) {
408
+ __extends(REST, _super);
409
+
410
+ function REST() {
411
+ _ref = REST.__super__.constructor.apply(this, arguments);
412
+ return _ref;
413
+ }
414
+
415
+ REST.prototype.__collection = function() {
416
+ var named;
417
+ named = this.__entityName.camelize().pluralize() + 'Collection';
418
+ if (window[named]) {
419
+ return window[named];
420
+ } else {
421
+ return Joosy.Resources.RESTCollection;
422
+ }
423
+ };
424
+
425
+ REST.__parentsPath = function(parents) {
426
+ return parents.reduce(function(path, parent) {
427
+ return path += Joosy.Module.hasAncestor(parent.constructor, Joosy.Resources.REST) ? parent.memberPath() : parent;
428
+ }, '');
429
+ };
430
+
431
+ REST.basePath = function(options) {
432
+ var path;
433
+ if (options == null) {
434
+ options = {};
435
+ }
436
+ if ((this.__source != null) && (options.parent == null)) {
437
+ path = this.__source;
438
+ } else {
439
+ path = '/';
440
+ if (this.__namespace__.length > 0) {
441
+ path += this.__namespace__.map(function(s) {
442
+ return s.toLowerCase();
443
+ }).join('/') + '/';
444
+ }
445
+ path += this.prototype.__entityName.pluralize();
446
+ }
447
+ if (options.parent != null) {
448
+ path = this.__parentsPath(Object.isArray(options.parent) ? options.parent : [options.parent]) + path;
449
+ }
450
+ return path;
451
+ };
452
+
453
+ REST.prototype.basePath = function(options) {
454
+ if (options == null) {
455
+ options = {};
456
+ }
457
+ return this.constructor.basePath(options);
458
+ };
459
+
460
+ REST.memberPath = function(id, options) {
461
+ var path;
462
+ if (options == null) {
463
+ options = {};
464
+ }
465
+ path = this.basePath(options) + ("/" + id);
466
+ if (options.from != null) {
467
+ path += "/" + options.from;
468
+ }
469
+ return path;
470
+ };
471
+
472
+ REST.prototype.memberPath = function(options) {
473
+ if (options == null) {
474
+ options = {};
475
+ }
476
+ return this.constructor.memberPath(this.id(), options);
477
+ };
478
+
479
+ REST.collectionPath = function(options) {
480
+ var path;
481
+ if (options == null) {
482
+ options = {};
483
+ }
484
+ path = this.basePath(options);
485
+ if (options.from != null) {
486
+ path += "/" + options.from;
487
+ }
488
+ return path;
489
+ };
490
+
491
+ REST.prototype.collectionPath = function(options) {
492
+ if (options == null) {
493
+ options = {};
494
+ }
495
+ return this.constructor.collectionPath(options);
496
+ };
497
+
498
+ REST.get = function(options, callback) {
499
+ if (Object.isFunction(options)) {
500
+ callback = options;
501
+ options = {};
502
+ }
503
+ return this.__query(this.collectionPath(options), 'GET', options.params, callback);
504
+ };
505
+
506
+ REST.post = function(options, callback) {
507
+ if (Object.isFunction(options)) {
508
+ callback = options;
509
+ options = {};
510
+ }
511
+ return this.__query(this.collectionPath(options), 'POST', options.params, callback);
512
+ };
513
+
514
+ REST.put = function(options, callback) {
515
+ if (Object.isFunction(options)) {
516
+ callback = options;
517
+ options = {};
518
+ }
519
+ return this.__query(this.collectionPath(options), 'PUT', options.params, callback);
520
+ };
521
+
522
+ REST["delete"] = function(options, callback) {
523
+ if (Object.isFunction(options)) {
524
+ callback = options;
525
+ options = {};
526
+ }
527
+ return this.__query(this.collectionPath(options), 'DELETE', options.params, callback);
528
+ };
529
+
530
+ REST.prototype.get = function(options, callback) {
531
+ if (Object.isFunction(options)) {
532
+ callback = options;
533
+ options = {};
534
+ }
535
+ return this.constructor.__query(this.memberPath(options), 'GET', options.params, callback);
536
+ };
537
+
538
+ REST.prototype.post = function(options, callback) {
539
+ if (Object.isFunction(options)) {
540
+ callback = options;
541
+ options = {};
542
+ }
543
+ return this.constructor.__query(this.memberPath(options), 'POST', options.params, callback);
544
+ };
545
+
546
+ REST.prototype.put = function(options, callback) {
547
+ if (Object.isFunction(options)) {
548
+ callback = options;
549
+ options = {};
550
+ }
551
+ return this.constructor.__query(this.memberPath(options), 'PUT', options.params, callback);
552
+ };
553
+
554
+ REST.prototype["delete"] = function(options, callback) {
555
+ if (Object.isFunction(options)) {
556
+ callback = options;
557
+ options = {};
558
+ }
559
+ return this.constructor.__query(this.memberPath(options), 'DELETE', options.params, callback);
560
+ };
561
+
562
+ REST.find = function(where, options, callback) {
563
+ var result,
564
+ _this = this;
565
+ if (options == null) {
566
+ options = {};
567
+ }
568
+ if (callback == null) {
569
+ callback = false;
570
+ }
571
+ if (Object.isFunction(options)) {
572
+ callback = options;
573
+ options = {};
574
+ }
575
+ if (where === 'all') {
576
+ result = new (this.prototype.__collection())(this, options);
577
+ this.__query(this.collectionPath(options), 'GET', options.params, function(data) {
578
+ result.load(data);
579
+ return typeof callback === "function" ? callback(result, data) : void 0;
580
+ });
581
+ } else {
582
+ result = this.build(where);
583
+ this.__query(this.memberPath(where, options), 'GET', options.params, function(data) {
584
+ result.load(data);
585
+ return typeof callback === "function" ? callback(result, data) : void 0;
586
+ });
587
+ }
588
+ return result;
589
+ };
590
+
591
+ REST.__query = function(path, method, params, callback) {
592
+ var options;
593
+ options = {
594
+ data: params,
595
+ type: method,
596
+ cache: false,
597
+ dataType: 'json'
598
+ };
599
+ if (Object.isFunction(callback)) {
600
+ options.success = callback;
601
+ } else {
602
+ Joosy.Module.merge(options, callback);
603
+ }
604
+ return $.ajax(path, options);
605
+ };
606
+
607
+ REST.prototype.reload = function(options, callback) {
608
+ var _this = this;
609
+ if (options == null) {
610
+ options = {};
611
+ }
612
+ if (callback == null) {
613
+ callback = false;
614
+ }
615
+ if (Object.isFunction(options)) {
616
+ callback = options;
617
+ options = {};
618
+ }
619
+ return this.constructor.__query(this.memberPath(options), 'GET', options.params, function(data) {
620
+ _this.load(data);
621
+ return typeof callback === "function" ? callback(_this) : void 0;
622
+ });
623
+ };
624
+
625
+ return REST;
626
+
627
+ })(Joosy.Resources.Base);
628
+
629
+ }).call(this);
630
+ (function() {
631
+ var _ref,
632
+ __hasProp = {}.hasOwnProperty,
633
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
634
+
635
+ Joosy.Resources.RESTCollection = (function(_super) {
636
+ __extends(RESTCollection, _super);
637
+
638
+ function RESTCollection() {
639
+ _ref = RESTCollection.__super__.constructor.apply(this, arguments);
640
+ return _ref;
641
+ }
642
+
643
+ RESTCollection.include(Joosy.Modules.Log);
644
+
645
+ RESTCollection.include(Joosy.Modules.Events);
646
+
647
+ RESTCollection.prototype.reload = function(options, callback) {
648
+ var _this = this;
649
+ if (options == null) {
650
+ options = {};
651
+ }
652
+ if (callback == null) {
653
+ callback = false;
654
+ }
655
+ if (Object.isFunction(options)) {
656
+ callback = options;
657
+ options = {};
658
+ }
659
+ return this.model.__query(this.model.collectionPath(options), 'GET', options.params, function(data) {
660
+ _this.load(data);
661
+ return typeof callback === "function" ? callback(data) : void 0;
662
+ });
663
+ };
664
+
665
+ return RESTCollection;
666
+
667
+ })(Joosy.Resources.Collection);
668
+
669
+ }).call(this);
670
+ (function() {
671
+
672
+
673
+ }).call(this);