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
@@ -1,675 +0,0 @@
1
-
2
-
3
- /*** src/joosy/extensions/resources/base ***/
4
-
5
- var __hasProp = {}.hasOwnProperty,
6
- __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; };
7
-
8
- Joosy.Resources.Base = (function(_super) {
9
- __extends(Base, _super);
10
-
11
- Base.include(Joosy.Modules.Log);
12
-
13
- Base.include(Joosy.Modules.Events);
14
-
15
- Base.prototype.__primaryKey = 'id';
16
-
17
- Base.prototype.__source = false;
18
-
19
- Base.resetIdentity = function() {
20
- return Joosy.Resources.Base.identity = {};
21
- };
22
-
23
- Base.beforeLoad = function(action) {
24
- if (!this.prototype.hasOwnProperty('__beforeLoads')) {
25
- this.prototype.__beforeLoads = [].concat(this.__super__.__beforeLoads || []);
26
- }
27
- return this.prototype.__beforeLoads.push(action);
28
- };
29
-
30
- Base.primaryKey = function(primaryKey) {
31
- return this.prototype.__primaryKey = primaryKey;
32
- };
33
-
34
- Base.source = function(location) {
35
- return this.__source = location;
36
- };
37
-
38
- Base.at = function(entity) {
39
- var Clone, _ref;
40
- Clone = (function(_super1) {
41
- __extends(Clone, _super1);
42
-
43
- function Clone() {
44
- _ref = Clone.__super__.constructor.apply(this, arguments);
45
- return _ref;
46
- }
47
-
48
- return Clone;
49
-
50
- })(this);
51
- if (entity instanceof Joosy.Resources.Base) {
52
- Clone.__source = entity.memberPath();
53
- if (this.prototype.__entityName) {
54
- Clone.__source += '/' + this.prototype.__entityName.pluralize();
55
- }
56
- } else {
57
- Clone.__source = entity;
58
- }
59
- return Clone;
60
- };
61
-
62
- Base.entity = function(name) {
63
- return this.prototype.__entityName = name;
64
- };
65
-
66
- Base.collection = function(klass) {
67
- return this.prototype.__collection = function() {
68
- return klass;
69
- };
70
- };
71
-
72
- Base.prototype.__collection = function() {
73
- var named;
74
- named = this.__entityName.camelize().pluralize() + 'Collection';
75
- if (window[named]) {
76
- return window[named];
77
- } else {
78
- return Joosy.Resources.Collection;
79
- }
80
- };
81
-
82
- Base.map = function(name, klass) {
83
- if (klass == null) {
84
- klass = false;
85
- }
86
- if (!klass) {
87
- klass = window[name.singularize().camelize()];
88
- }
89
- if (!klass) {
90
- throw new Error("" + (Joosy.Module.__className(this)) + "> class can not be detected for '" + name + "' mapping");
91
- }
92
- return this.beforeLoad(function(data) {
93
- if (!Joosy.Module.hasAncestor(klass, Joosy.Resources.Base)) {
94
- klass = klass();
95
- }
96
- return this.__map(data, name, klass);
97
- });
98
- };
99
-
100
- Base.build = function(data) {
101
- var id, key, klass, shim, value, _base, _base1, _ref;
102
- if (data == null) {
103
- data = {};
104
- }
105
- klass = this.prototype.__entityName;
106
- (_base = Joosy.Resources.Base).identity || (_base.identity = {});
107
- (_base1 = Joosy.Resources.Base.identity)[klass] || (_base1[klass] = {});
108
- shim = function() {
109
- return shim.__call.apply(shim, arguments);
110
- };
111
- if (shim.__proto__) {
112
- shim.__proto__ = this.prototype;
113
- } else {
114
- _ref = this.prototype;
115
- for (key in _ref) {
116
- value = _ref[key];
117
- shim[key] = value;
118
- }
119
- }
120
- shim.constructor = this;
121
- if (Object.isNumber(data) || Object.isString(data)) {
122
- id = data;
123
- data = {};
124
- data[shim.__primaryKey] = id;
125
- }
126
- if (Joosy.Application.identity) {
127
- id = data[shim.__primaryKey];
128
- if ((id != null) && Joosy.Resources.Base.identity[klass][id]) {
129
- shim = Joosy.Resources.Base.identity[klass][id];
130
- shim.load(data);
131
- } else {
132
- Joosy.Resources.Base.identity[klass][id] = shim;
133
- this.apply(shim, [data]);
134
- }
135
- } else {
136
- this.apply(shim, [data]);
137
- }
138
- return shim;
139
- };
140
-
141
- function Base(data) {
142
- if (data == null) {
143
- data = {};
144
- }
145
- this.__fillData(data, false);
146
- }
147
-
148
- Base.prototype.id = function() {
149
- return this.data[this.__primaryKey];
150
- };
151
-
152
- Base.prototype.knownAttributes = function() {
153
- return this.data.keys();
154
- };
155
-
156
- Base.prototype.load = function(data) {
157
- this.__fillData(data);
158
- return this;
159
- };
160
-
161
- Base.prototype.__get = function(path) {
162
- var target;
163
- target = this.__callTarget(path, true);
164
- if (!target) {
165
- return void 0;
166
- } else if (target[0] instanceof Joosy.Resources.Base) {
167
- return target[0](target[1]);
168
- } else {
169
- return target[0][target[1]];
170
- }
171
- };
172
-
173
- Base.prototype.__set = function(path, value) {
174
- var target;
175
- target = this.__callTarget(path);
176
- if (target[0] instanceof Joosy.Resources.Base) {
177
- target[0](target[1], value);
178
- } else {
179
- target[0][target[1]] = value;
180
- }
181
- this.trigger('changed');
182
- return null;
183
- };
184
-
185
- Base.prototype.__callTarget = function(path, safe) {
186
- var keyword, part, target, _i, _len;
187
- if (safe == null) {
188
- safe = false;
189
- }
190
- if (path.has(/\./) && (this.data[path] == null)) {
191
- path = path.split('.');
192
- keyword = path.pop();
193
- target = this.data;
194
- for (_i = 0, _len = path.length; _i < _len; _i++) {
195
- part = path[_i];
196
- if (safe && (target[part] == null)) {
197
- return false;
198
- }
199
- target[part] || (target[part] = {});
200
- if (target instanceof Joosy.Resources.Base) {
201
- target = target(part);
202
- } else {
203
- target = target[part];
204
- }
205
- }
206
- return [target, keyword];
207
- } else {
208
- return [this.data, path];
209
- }
210
- };
211
-
212
- Base.prototype.__call = function(path, value) {
213
- if (arguments.length > 1) {
214
- return this.__set(path, value);
215
- } else {
216
- return this.__get(path);
217
- }
218
- };
219
-
220
- Base.prototype.__fillData = function(data, notify) {
221
- if (notify == null) {
222
- notify = true;
223
- }
224
- this.raw = data;
225
- if (!this.hasOwnProperty('data')) {
226
- this.data = {};
227
- }
228
- Joosy.Module.merge(this.data, this.__prepareData(data));
229
- if (notify) {
230
- this.trigger('changed');
231
- }
232
- return null;
233
- };
234
-
235
- Base.prototype.__prepareData = function(data) {
236
- var bl, name, _i, _len, _ref;
237
- if (Object.isObject(data) && Object.keys(data).length === 1 && this.__entityName) {
238
- name = this.__entityName.camelize(false);
239
- if (data[name]) {
240
- data = data[name];
241
- }
242
- }
243
- if (this.__beforeLoads != null) {
244
- _ref = this.__beforeLoads;
245
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
246
- bl = _ref[_i];
247
- data = bl.call(this, data);
248
- }
249
- }
250
- return data;
251
- };
252
-
253
- Base.prototype.__map = function(data, name, klass) {
254
- var entry;
255
- if (Object.isArray(data[name])) {
256
- entry = new (klass.prototype.__collection())(klass);
257
- entry.load(data[name]);
258
- data[name] = entry;
259
- } else if (Object.isObject(data[name])) {
260
- data[name] = klass.build(data[name]);
261
- }
262
- return data;
263
- };
264
-
265
- return Base;
266
-
267
- })(Joosy.Module);
268
-
269
-
270
- /*** src/joosy/extensions/resources/collection ***/
271
-
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
-
402
- /*** src/joosy/extensions/resources/rest ***/
403
-
404
- var _ref,
405
- __hasProp = {}.hasOwnProperty,
406
- __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; };
407
-
408
- Joosy.Resources.REST = (function(_super) {
409
- __extends(REST, _super);
410
-
411
- function REST() {
412
- _ref = REST.__super__.constructor.apply(this, arguments);
413
- return _ref;
414
- }
415
-
416
- REST.prototype.__collection = function() {
417
- var named;
418
- named = this.__entityName.camelize().pluralize() + 'Collection';
419
- if (window[named]) {
420
- return window[named];
421
- } else {
422
- return Joosy.Resources.RESTCollection;
423
- }
424
- };
425
-
426
- REST.__parentsPath = function(parents) {
427
- return parents.reduce(function(path, parent) {
428
- return path += Joosy.Module.hasAncestor(parent.constructor, Joosy.Resources.REST) ? parent.memberPath() : parent;
429
- }, '');
430
- };
431
-
432
- REST.basePath = function(options) {
433
- var path;
434
- if (options == null) {
435
- options = {};
436
- }
437
- if ((this.__source != null) && (options.parent == null)) {
438
- path = this.__source;
439
- } else {
440
- path = '/';
441
- if (this.__namespace__.length > 0) {
442
- path += this.__namespace__.map(function(s) {
443
- return s.toLowerCase();
444
- }).join('/') + '/';
445
- }
446
- path += this.prototype.__entityName.pluralize();
447
- }
448
- if (options.parent != null) {
449
- path = this.__parentsPath(Object.isArray(options.parent) ? options.parent : [options.parent]) + path;
450
- }
451
- return path;
452
- };
453
-
454
- REST.prototype.basePath = function(options) {
455
- if (options == null) {
456
- options = {};
457
- }
458
- return this.constructor.basePath(options);
459
- };
460
-
461
- REST.memberPath = function(id, options) {
462
- var path;
463
- if (options == null) {
464
- options = {};
465
- }
466
- path = this.basePath(options) + ("/" + id);
467
- if (options.from != null) {
468
- path += "/" + options.from;
469
- }
470
- return path;
471
- };
472
-
473
- REST.prototype.memberPath = function(options) {
474
- if (options == null) {
475
- options = {};
476
- }
477
- return this.constructor.memberPath(this.id(), options);
478
- };
479
-
480
- REST.collectionPath = function(options) {
481
- var path;
482
- if (options == null) {
483
- options = {};
484
- }
485
- path = this.basePath(options);
486
- if (options.from != null) {
487
- path += "/" + options.from;
488
- }
489
- return path;
490
- };
491
-
492
- REST.prototype.collectionPath = function(options) {
493
- if (options == null) {
494
- options = {};
495
- }
496
- return this.constructor.collectionPath(options);
497
- };
498
-
499
- REST.get = function(options, callback) {
500
- if (Object.isFunction(options)) {
501
- callback = options;
502
- options = {};
503
- }
504
- return this.__query(this.collectionPath(options), 'GET', options.params, callback);
505
- };
506
-
507
- REST.post = function(options, callback) {
508
- if (Object.isFunction(options)) {
509
- callback = options;
510
- options = {};
511
- }
512
- return this.__query(this.collectionPath(options), 'POST', options.params, callback);
513
- };
514
-
515
- REST.put = function(options, callback) {
516
- if (Object.isFunction(options)) {
517
- callback = options;
518
- options = {};
519
- }
520
- return this.__query(this.collectionPath(options), 'PUT', options.params, callback);
521
- };
522
-
523
- REST["delete"] = function(options, callback) {
524
- if (Object.isFunction(options)) {
525
- callback = options;
526
- options = {};
527
- }
528
- return this.__query(this.collectionPath(options), 'DELETE', options.params, callback);
529
- };
530
-
531
- REST.prototype.get = function(options, callback) {
532
- if (Object.isFunction(options)) {
533
- callback = options;
534
- options = {};
535
- }
536
- return this.constructor.__query(this.memberPath(options), 'GET', options.params, callback);
537
- };
538
-
539
- REST.prototype.post = function(options, callback) {
540
- if (Object.isFunction(options)) {
541
- callback = options;
542
- options = {};
543
- }
544
- return this.constructor.__query(this.memberPath(options), 'POST', options.params, callback);
545
- };
546
-
547
- REST.prototype.put = function(options, callback) {
548
- if (Object.isFunction(options)) {
549
- callback = options;
550
- options = {};
551
- }
552
- return this.constructor.__query(this.memberPath(options), 'PUT', options.params, callback);
553
- };
554
-
555
- REST.prototype["delete"] = function(options, callback) {
556
- if (Object.isFunction(options)) {
557
- callback = options;
558
- options = {};
559
- }
560
- return this.constructor.__query(this.memberPath(options), 'DELETE', options.params, callback);
561
- };
562
-
563
- REST.find = function(where, options, callback) {
564
- var result,
565
- _this = this;
566
- if (options == null) {
567
- options = {};
568
- }
569
- if (callback == null) {
570
- callback = false;
571
- }
572
- if (Object.isFunction(options)) {
573
- callback = options;
574
- options = {};
575
- }
576
- if (where === 'all') {
577
- result = new (this.prototype.__collection())(this, options);
578
- this.__query(this.collectionPath(options), 'GET', options.params, function(data) {
579
- result.load(data);
580
- return typeof callback === "function" ? callback(result, data) : void 0;
581
- });
582
- } else {
583
- result = this.build(where);
584
- this.__query(this.memberPath(where, options), 'GET', options.params, function(data) {
585
- result.load(data);
586
- return typeof callback === "function" ? callback(result, data) : void 0;
587
- });
588
- }
589
- return result;
590
- };
591
-
592
- REST.__query = function(path, method, params, callback) {
593
- var options;
594
- options = {
595
- data: params,
596
- type: method,
597
- cache: false,
598
- dataType: 'json'
599
- };
600
- if (Object.isFunction(callback)) {
601
- options.success = callback;
602
- } else {
603
- Joosy.Module.merge(options, callback);
604
- }
605
- return $.ajax(path, options);
606
- };
607
-
608
- REST.prototype.reload = function(options, callback) {
609
- var _this = this;
610
- if (options == null) {
611
- options = {};
612
- }
613
- if (callback == null) {
614
- callback = false;
615
- }
616
- if (Object.isFunction(options)) {
617
- callback = options;
618
- options = {};
619
- }
620
- return this.constructor.__query(this.memberPath(options), 'GET', options.params, function(data) {
621
- _this.load(data);
622
- return typeof callback === "function" ? callback(_this) : void 0;
623
- });
624
- };
625
-
626
- return REST;
627
-
628
- })(Joosy.Resources.Base);
629
-
630
-
631
- /*** src/joosy/extensions/resources/rest_collection ***/
632
-
633
- var _ref,
634
- __hasProp = {}.hasOwnProperty,
635
- __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; };
636
-
637
- Joosy.Resources.RESTCollection = (function(_super) {
638
- __extends(RESTCollection, _super);
639
-
640
- function RESTCollection() {
641
- _ref = RESTCollection.__super__.constructor.apply(this, arguments);
642
- return _ref;
643
- }
644
-
645
- RESTCollection.include(Joosy.Modules.Log);
646
-
647
- RESTCollection.include(Joosy.Modules.Events);
648
-
649
- RESTCollection.prototype.reload = function(options, callback) {
650
- var _this = this;
651
- if (options == null) {
652
- options = {};
653
- }
654
- if (callback == null) {
655
- callback = false;
656
- }
657
- if (Object.isFunction(options)) {
658
- callback = options;
659
- options = {};
660
- }
661
- return this.model.__query(this.model.collectionPath(options), 'GET', options.params, function(data) {
662
- _this.load(data);
663
- return typeof callback === "function" ? callback(data) : void 0;
664
- });
665
- };
666
-
667
- return RESTCollection;
668
-
669
- })(Joosy.Resources.Collection);
670
-
671
-
672
- /*** src/joosy/extensions/resources/index ***/
673
-
674
-
675
- ;