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,592 +0,0 @@
1
-
2
-
3
- /*** src/joosy/extensions/resources-form/form ***/
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.Form = (function(_super) {
9
- __extends(Form, _super);
10
-
11
- Form.include(Joosy.Modules.Container);
12
-
13
- Form.include(Joosy.Modules.Log);
14
-
15
- Form.include(Joosy.Modules.Events);
16
-
17
- Form.prototype.invalidationClass = 'field_with_errors';
18
-
19
- Form.prototype.substitutions = {};
20
-
21
- Form.mapElements({
22
- 'fields': 'input,select,textarea'
23
- });
24
-
25
- Form.submit = function(form, options) {
26
- if (options == null) {
27
- options = {};
28
- }
29
- form = new this(form, options);
30
- form.container.submit();
31
- form.unbind();
32
- return null;
33
- };
34
-
35
- Form.attach = function() {
36
- return (function(func, args, ctor) {
37
- ctor.prototype = func.prototype;
38
- var child = new ctor, result = func.apply(child, args);
39
- return Object(result) === result ? result : child;
40
- })(Joosy.Form, arguments, function(){});
41
- };
42
-
43
- function Form(form, options) {
44
- var method, _ref,
45
- _this = this;
46
- if (options == null) {
47
- options = {};
48
- }
49
- if (Object.isFunction(options)) {
50
- this.success = options;
51
- } else {
52
- Object.each(options, function(key, value) {
53
- return _this[key] = value;
54
- });
55
- }
56
- this.container = $(form);
57
- if (this.container.length === 0) {
58
- return;
59
- }
60
- this.__assignElements();
61
- this.__delegateEvents();
62
- method = (_ref = this.container.get(0).getAttribute('method')) != null ? _ref.toLowerCase() : void 0;
63
- if (method && !['get', 'post'].any(method)) {
64
- this.__markMethod(method);
65
- this.container.attr('method', 'POST');
66
- }
67
- this.container.ajaxForm({
68
- dataType: 'json',
69
- beforeSend: function() {
70
- if (_this.__debounce.apply(_this, arguments)) {
71
- return false;
72
- }
73
- _this.__before.apply(_this, arguments);
74
- _this.__pending_request = true;
75
- _this.debugAs(_this, 'beforeSend: pending_request = true');
76
- return true;
77
- },
78
- success: function() {
79
- _this.__pending_request = false;
80
- _this.debugAs(_this, 'success: pending_request = false');
81
- return _this.__success.apply(_this, arguments);
82
- },
83
- error: function() {
84
- _this.__pending_request = false;
85
- _this.debugAs(_this, 'error: pending_request = false');
86
- return _this.__error.apply(_this, arguments);
87
- },
88
- xhr: function() {
89
- var xhr;
90
- xhr = $.ajaxSettings.xhr();
91
- if ((xhr.upload != null) && _this.progress) {
92
- xhr.upload.onprogress = function(event) {
93
- if (event.lengthComputable) {
94
- return _this.progress((event.position / event.total * 100).round(2));
95
- }
96
- };
97
- }
98
- return xhr;
99
- }
100
- });
101
- if (this.resource != null) {
102
- this.fill(this.resource, options);
103
- delete this.resource;
104
- }
105
- if (this.action != null) {
106
- this.container.attr('action', this.action);
107
- this.container.attr('method', 'POST');
108
- }
109
- if (this.method != null) {
110
- this.__markMethod(this.method);
111
- }
112
- }
113
-
114
- Form.prototype.unbind = function() {
115
- return this.container.unbind('submit').find('input:submit,input:image,button:submit').unbind('click');
116
- };
117
-
118
- Form.prototype.fill = function(resource, options) {
119
- var data, filler, url,
120
- _this = this;
121
- if (Object.isFunction(resource.build)) {
122
- resource = resource.build();
123
- }
124
- this.__resource = resource;
125
- if ((options != null ? options.decorator : void 0) != null) {
126
- data = options.decorator(resource.data);
127
- } else {
128
- data = resource.data;
129
- }
130
- filler = function(data, scope) {
131
- if (data.__joosy_form_filler_lock) {
132
- return;
133
- }
134
- data.__joosy_form_filler_lock = true;
135
- Object.each(data, function(property, val) {
136
- var entity, i, input, key, _i, _len, _ref, _results;
137
- key = _this.concatFieldName(scope, property);
138
- input = _this.$fields("[name='" + key + "']:not(:file),[name='" + (key.underscore()) + "']:not(:file),[name='" + (key.camelize(false)) + "']:not(:file)");
139
- if (input.length > 0) {
140
- if (input.is(':checkbox')) {
141
- if (val) {
142
- input.attr('checked', 'checked');
143
- } else {
144
- input.removeAttr('checked');
145
- }
146
- } else if (input.is(':radio')) {
147
- input.filter("[value='" + val + "']").attr('checked', 'checked');
148
- } else {
149
- input.val(val);
150
- }
151
- }
152
- if (val instanceof Joosy.Resources.RESTCollection) {
153
- _ref = val.data;
154
- _results = [];
155
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
156
- entity = _ref[i];
157
- _results.push(filler(entity.data, _this.concatFieldName(scope, "[" + property + "_attributes][" + i + "]")));
158
- }
159
- return _results;
160
- } else if (val instanceof Joosy.Resources.REST) {
161
- return filler(val.data, _this.concatFieldName(scope, "[" + property + "_attributes][0]"));
162
- } else if (Object.isObject(val) || Object.isArray(val)) {
163
- return filler(val, key);
164
- } else {
165
-
166
- }
167
- });
168
- return delete data.__joosy_form_filler_lock;
169
- };
170
- filler(data, resource.__entityName || options.resourceName);
171
- $('input[name=_method]', this.container).remove();
172
- if (resource.id()) {
173
- this.__markMethod((options != null ? options.method : void 0) || 'PUT');
174
- }
175
- url = (options != null ? options.action : void 0) || (resource.id() != null ? resource.memberPath() : resource.collectionPath());
176
- this.container.attr('action', url);
177
- return this.container.attr('method', 'POST');
178
- };
179
-
180
- Form.prototype.submit = function() {
181
- return this.container.submit();
182
- };
183
-
184
- Form.prototype.serialize = function(skipMethod) {
185
- var data;
186
- if (skipMethod == null) {
187
- skipMethod = true;
188
- }
189
- data = this.container.serialize();
190
- if (skipMethod) {
191
- data = data.replace(/\&?\_method\=put/i, '');
192
- }
193
- return data;
194
- };
195
-
196
- Form.prototype.__success = function(response, status, xhr) {
197
- var _ref;
198
- if (xhr) {
199
- return typeof this.success === "function" ? this.success(response) : void 0;
200
- } else if ((200 <= (_ref = response.status) && _ref < 300)) {
201
- return this.success(response.json);
202
- } else {
203
- return this.__error(response.json);
204
- }
205
- };
206
-
207
- Form.prototype.__before = function(xhr, settings) {
208
- if ((this.before == null) || this.before.apply(this, arguments) === true) {
209
- return this.$fields().removeClass(this.invalidationClass);
210
- }
211
- };
212
-
213
- Form.prototype.__error = function(data) {
214
- var error, errors,
215
- _this = this;
216
- errors = (function() {
217
- if (data.responseText) {
218
- try {
219
- return data = jQuery.parseJSON(data.responseText);
220
- } catch (_error) {
221
- error = _error;
222
- return {};
223
- }
224
- } else {
225
- return data;
226
- }
227
- })();
228
- if ((this.error == null) || this.error(errors) === true) {
229
- errors = this.__stringifyErrors(errors);
230
- Object.each(errors, function(field, notifications) {
231
- var input;
232
- input = _this.findField(field).addClass(_this.invalidationClass);
233
- return typeof _this.notification === "function" ? _this.notification(input, notifications) : void 0;
234
- });
235
- return errors;
236
- }
237
- return false;
238
- };
239
-
240
- Form.prototype.__debounce = function(xhr) {
241
- this.debugAs(this, "debounce: pending_request == " + this.__pending_request);
242
- if (this.__pending_request && this.debounce !== false) {
243
- if (this.debounce || Joosy.Application.debounceForms) {
244
- xhr.abort();
245
- this.debugAs(this, "debounce: xhr aborted");
246
- return true;
247
- }
248
- }
249
- return false;
250
- };
251
-
252
- Form.prototype.findField = function(field) {
253
- return this.$fields("[name='" + field + "']");
254
- };
255
-
256
- Form.prototype.__markMethod = function(method) {
257
- if (method == null) {
258
- method = 'PUT';
259
- }
260
- method = $('<input/>', {
261
- type: 'hidden',
262
- name: '_method',
263
- value: method
264
- });
265
- return this.container.append(method);
266
- };
267
-
268
- Form.prototype.__stringifyErrors = function(errors) {
269
- var result,
270
- _this = this;
271
- result = {};
272
- Object.each(errors, function(field, notifications) {
273
- var f, name, splited, _i, _len;
274
- if (_this.substitutions[field] != null) {
275
- field = _this.substitutions[field];
276
- }
277
- if (Object.isObject(notifications) || _this.isArrayOfObjects(notifications)) {
278
- return Object.each(_this.__foldInlineEntities(notifications), function(key, value) {
279
- return result[field + key] = value;
280
- });
281
- } else {
282
- if (field.indexOf(".") !== -1) {
283
- splited = field.split('.');
284
- field = splited.shift();
285
- if (_this.resourceName || _this.__resource) {
286
- name = _this.resourceName || _this.__resource.__entityName;
287
- field = name + ("[" + field + "]");
288
- }
289
- for (_i = 0, _len = splited.length; _i < _len; _i++) {
290
- f = splited[_i];
291
- field += "[" + f + "]";
292
- }
293
- } else if (_this.resourceName || _this.__resource) {
294
- name = _this.resourceName || _this.__resource.__entityName;
295
- field = name + ("[" + field + "]");
296
- }
297
- return result[field] = notifications;
298
- }
299
- });
300
- return result;
301
- };
302
-
303
- Form.prototype.__foldInlineEntities = function(hash, scope, result) {
304
- var _this = this;
305
- if (scope == null) {
306
- scope = "";
307
- }
308
- if (result == null) {
309
- result = {};
310
- }
311
- Object.each(hash, function(key, value) {
312
- if (Object.isObject(value) || _this.isArrayOfObjects(value)) {
313
- return _this.__foldInlineEntities(value, "" + scope + "[" + key + "]", result);
314
- } else {
315
- return result["" + scope + "[" + key + "]"] = value;
316
- }
317
- });
318
- return result;
319
- };
320
-
321
- Form.prototype.concatFieldName = function(wrapper, name) {
322
- var items;
323
- items = this.splitFieldName(wrapper).concat(this.splitFieldName(name));
324
- return "" + items[0] + "[" + (items.slice(1).join('][')) + "]";
325
- };
326
-
327
- Form.prototype.splitFieldName = function(name) {
328
- var first, items;
329
- items = name.split('][');
330
- first = items[0].split('[');
331
- if (first.length === 2) {
332
- if (first[0].isBlank()) {
333
- items.splice(0, 1, first[1]);
334
- } else {
335
- items.splice(0, 1, first[0], first[1]);
336
- }
337
- items[items.length - 1] = items[items.length - 1].split(']')[0];
338
- }
339
- return items;
340
- };
341
-
342
- Form.prototype.isArrayOfObjects = function(array) {
343
- return Object.isArray(array) && array.every(function(elem) {
344
- return Object.isObject(elem);
345
- });
346
- };
347
-
348
- return Form;
349
-
350
- })(Joosy.Module);
351
-
352
-
353
- /*** src/joosy/extensions/resources-form/helpers/form ***/
354
-
355
- Joosy.helpers('Application', function() {
356
- var Form, description, input,
357
- _this = this;
358
- description = function(resource, method, extendIds, idSuffix) {
359
- var id;
360
- if (Joosy.Module.hasAncestor(resource.constructor, Joosy.Resources.Base)) {
361
- id = resource.id();
362
- resource = resource.__entityName;
363
- }
364
- return {
365
- name: resource + ("" + (method.match(/^\[.*\]$/) ? method : "[" + method + "]")),
366
- id: resource + (id && extendIds ? '_' + id : '') + ("_" + (method.parameterize().underscore())) + (idSuffix ? '_' + idSuffix : '')
367
- };
368
- };
369
- input = function(type, resource, method, options) {
370
- var d;
371
- if (options == null) {
372
- options = {};
373
- }
374
- d = description(resource, method, options.extendIds, options.idSuffix);
375
- delete options.extendIds;
376
- delete options.idSuffix;
377
- return _this.tag('input', Joosy.Module.merge({
378
- type: type,
379
- name: d.name,
380
- id: d.id
381
- }, options));
382
- };
383
- Form = (function() {
384
- function Form(context, resource, options) {
385
- this.context = context;
386
- this.resource = resource;
387
- this.options = options;
388
- }
389
-
390
- Form.prototype.label = function(method, options, content) {
391
- if (options == null) {
392
- options = {};
393
- }
394
- if (content == null) {
395
- content = '';
396
- }
397
- if (!Object.isObject(options)) {
398
- content = options;
399
- options = {};
400
- }
401
- return this.context.label(this.resource, method, Joosy.Module.merge({
402
- extendIds: this.options.extendIds
403
- }, options), content);
404
- };
405
-
406
- Form.prototype.radioButton = function(method, tagValue, options) {
407
- if (options == null) {
408
- options = {};
409
- }
410
- return this.context.radioButton(this.resource, method, tagValue, Joosy.Module.merge({
411
- extendIds: this.options.extendIds
412
- }, options));
413
- };
414
-
415
- Form.prototype.textArea = function(method, options) {
416
- if (options == null) {
417
- options = {};
418
- }
419
- return this.context.textArea(this.resource, method, Joosy.Module.merge({
420
- extendIds: this.options.extendIds
421
- }, options));
422
- };
423
-
424
- Form.prototype.checkBox = function(method, options, checkedValue, uncheckedValue) {
425
- if (options == null) {
426
- options = {};
427
- }
428
- if (checkedValue == null) {
429
- checkedValue = 1;
430
- }
431
- if (uncheckedValue == null) {
432
- uncheckedValue = 0;
433
- }
434
- return this.context.checkBox(this.resource, method, Joosy.Module.merge({
435
- extendIds: this.options.extendIds
436
- }, options), checkedValue, uncheckedValue);
437
- };
438
-
439
- Form.prototype.select = function(method, options, htmlOptions) {
440
- if (options == null) {
441
- options = {};
442
- }
443
- if (htmlOptions == null) {
444
- htmlOptions = {};
445
- }
446
- return this.context.select(this.resource, method, options, Joosy.Module.merge({
447
- extendIds: this.options.extendIds
448
- }, htmlOptions));
449
- };
450
-
451
- return Form;
452
-
453
- })();
454
- ['text', 'file', 'hidden', 'password'].each(function(type) {
455
- return Form.prototype[type + 'Field'] = function(method, options) {
456
- if (options == null) {
457
- options = {};
458
- }
459
- return this.context[type + 'Field'](this.resource, method, Joosy.Module.merge({
460
- extendIds: this.options.extendIds
461
- }, options));
462
- };
463
- });
464
- this.formFor = function(resource, options, block) {
465
- var form, uuid;
466
- if (options == null) {
467
- options = {};
468
- }
469
- if (Object.isFunction(options)) {
470
- block = options;
471
- options = {};
472
- }
473
- uuid = Joosy.uuid();
474
- form = this.tag('form', Joosy.Module.merge(options.html || {}, {
475
- id: uuid
476
- }), block != null ? block.call(this, new Form(this, resource, options)) : void 0);
477
- if (typeof this.onRefresh === "function") {
478
- this.onRefresh(function() {
479
- return Joosy.Form.attach('#' + uuid, Joosy.Module.merge(options, {
480
- resource: resource
481
- }));
482
- });
483
- }
484
- return form;
485
- };
486
- this.label = function(resource, method, options, content) {
487
- var d;
488
- if (options == null) {
489
- options = {};
490
- }
491
- if (content == null) {
492
- content = '';
493
- }
494
- if (!Object.isObject(options)) {
495
- content = options;
496
- options = {};
497
- }
498
- d = description(resource, method, options.extendIds);
499
- delete options.extendIds;
500
- return this.tag('label', Joosy.Module.merge(options, {
501
- "for": d.id
502
- }), content);
503
- };
504
- ['text', 'file', 'hidden', 'password'].each(function(type) {
505
- return _this[type + 'Field'] = function(resource, method, options) {
506
- if (options == null) {
507
- options = {};
508
- }
509
- return input(type, resource, method, options);
510
- };
511
- });
512
- this.radioButton = function(resource, method, tagValue, options) {
513
- if (options == null) {
514
- options = {};
515
- }
516
- return input('radio', resource, method, Joosy.Module.merge({
517
- value: tagValue,
518
- idSuffix: tagValue
519
- }, options));
520
- };
521
- this.checkBox = function(resource, method, options, checkedValue, uncheckedValue) {
522
- var box, spy;
523
- if (options == null) {
524
- options = {};
525
- }
526
- if (checkedValue == null) {
527
- checkedValue = 1;
528
- }
529
- if (uncheckedValue == null) {
530
- uncheckedValue = 0;
531
- }
532
- spy = this.tag('input', Joosy.Module.merge({
533
- name: description(resource, method).name,
534
- value: uncheckedValue,
535
- type: 'hidden'
536
- }));
537
- box = input('checkbox', resource, method, Joosy.Module.merge({
538
- value: checkedValue
539
- }, options));
540
- return spy + box;
541
- };
542
- this.select = function(resource, method, options, htmlOptions) {
543
- var extendIds, key, opts, val,
544
- _this = this;
545
- if (Object.isObject(options)) {
546
- opts = [];
547
- for (key in options) {
548
- val = options[key];
549
- opts.push([val, key]);
550
- }
551
- } else {
552
- opts = options;
553
- }
554
- if (htmlOptions.includeBlank) {
555
- delete htmlOptions.includeBlank;
556
- opts.unshift(['', '']);
557
- }
558
- opts = opts.reduce(function(str, vals) {
559
- var params;
560
- params = Object.isArray(vals) ? [
561
- 'option', {
562
- value: vals[1]
563
- }, vals[0]
564
- ] : ['option', {}, vals];
565
- if (htmlOptions.value === (Object.isArray(vals) ? vals[1] : vals)) {
566
- params[1].selected = 'selected';
567
- }
568
- return str += _this.tag.apply(_this, params);
569
- }, '');
570
- extendIds = htmlOptions.extendIds;
571
- delete htmlOptions.value;
572
- delete htmlOptions.extendIds;
573
- return this.tag('select', Joosy.Module.merge(description(resource, method, extendIds), htmlOptions), opts);
574
- };
575
- return this.textArea = function(resource, method, options) {
576
- var extendIds, value;
577
- if (options == null) {
578
- options = {};
579
- }
580
- value = options.value;
581
- extendIds = options.extendIds;
582
- delete options.value;
583
- delete options.extendIds;
584
- return this.tag('textarea', Joosy.Module.merge(description(resource, method, extendIds), options), value);
585
- };
586
- });
587
-
588
-
589
- /*** src/joosy/extensions/resources-form/index ***/
590
-
591
-
592
- ;