luca 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. data/.gitignore +1 -0
  2. data/.rvmrc +1 -1
  3. data/CHANGELOG +46 -2
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +2 -2
  6. data/Guardfile +1 -1
  7. data/README.md +64 -27
  8. data/ROADMAP +17 -2
  9. data/Rakefile +49 -1
  10. data/app.rb +38 -2
  11. data/assets/javascripts/luca-ui-base.coffee +1 -20
  12. data/assets/javascripts/luca-ui-full.js +3 -0
  13. data/assets/javascripts/luca-ui.coffee +0 -5
  14. data/assets/javascripts/sandbox/application.coffee +24 -18
  15. data/assets/javascripts/sandbox/router.coffee +16 -6
  16. data/assets/javascripts/sandbox/templates/builder/component_list.luca +1 -0
  17. data/assets/javascripts/sandbox/templates/builder.luca +2 -0
  18. data/assets/javascripts/sandbox/templates/main.luca +4 -3
  19. data/assets/javascripts/sandbox/templates/sandbox/docs_index.luca +1 -0
  20. data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +6 -1
  21. data/assets/javascripts/sandbox/templates/sandbox/readme.luca +30 -0
  22. data/assets/javascripts/sandbox/views/builder/builder_canvas.coffee +3 -0
  23. data/assets/javascripts/sandbox/views/builder/builder_editor.coffee +6 -0
  24. data/assets/javascripts/sandbox/views/builder/component_list.coffee +38 -0
  25. data/assets/javascripts/sandbox/views/builder/project_browser.coffee +14 -0
  26. data/assets/javascripts/sandbox/views/builder.coffee +133 -0
  27. data/assets/javascripts/sandbox/views/docs_controller.coffee +7 -0
  28. data/assets/javascripts/sandbox/views/inspector/instance_filter.coffee +18 -0
  29. data/assets/javascripts/sandbox/{collections/sample.coffee → views/inspector/instance_list.coffee} +0 -0
  30. data/assets/javascripts/sandbox/views/inspector.coffee +11 -0
  31. data/assets/javascripts/sandbox.coffee +2 -0
  32. data/assets/stylesheets/luca-ui-full.css +3 -0
  33. data/assets/stylesheets/sandbox/builder.scss +79 -0
  34. data/assets/stylesheets/sandbox/sandbox.scss +2 -1
  35. data/docs/application.md +41 -0
  36. data/docs/collection.md +79 -0
  37. data/docs/collection_manager.md +76 -0
  38. data/docs/container_philosophy.md +122 -0
  39. data/docs/event_binding_helpers.md +164 -0
  40. data/docs/method_caching_and_computed_properties.md +77 -0
  41. data/docs/view.md +119 -0
  42. data/lib/luca/rails/version.rb +1 -1
  43. data/lib/luca/template.rb +9 -9
  44. data/site/assets/bootstrap.min.js +7 -0
  45. data/site/assets/luca-ui-bootstrap.css +19 -1
  46. data/site/assets/luca-ui-development-tools.css +10 -0
  47. data/site/assets/luca-ui-development-tools.min.js +15 -0
  48. data/site/assets/luca-ui-full.min.js +8 -0
  49. data/site/assets/luca-ui.min.js +4 -0
  50. data/site/assets/sandbox.css +52 -4
  51. data/site/assets/sandbox.js +368 -30
  52. data/site/docs/application.html +41 -0
  53. data/site/docs/caching.html +43 -0
  54. data/site/docs/collection.html +75 -0
  55. data/site/docs/collection_manager.html +71 -0
  56. data/site/docs/containers.html +118 -0
  57. data/site/docs/events.html +153 -0
  58. data/site/docs/view.html +128 -0
  59. data/site/img/glyphicons-halflings-white.png +0 -0
  60. data/site/img/glyphicons-halflings.png +0 -0
  61. data/site/source-map.js +1 -0
  62. data/spec/core/view_spec.coffee +5 -17
  63. data/spec/managers/collection_manager_spec.coffee +4 -7
  64. data/src/components/application.coffee +202 -77
  65. data/src/components/base_toolbar.coffee +1 -1
  66. data/src/components/collection_view.coffee +38 -10
  67. data/src/components/controller.coffee +24 -1
  68. data/src/components/fields/checkbox_field.coffee +9 -12
  69. data/src/components/fields/label_field.coffee +14 -0
  70. data/src/components/fields/select_field.coffee +2 -2
  71. data/src/components/fields/text_field.coffee +12 -7
  72. data/src/components/fields/type_ahead_field.coffee +1 -0
  73. data/src/components/form_view.coffee +44 -25
  74. data/src/components/page_controller.coffee +2 -0
  75. data/src/containers/card_view.coffee +4 -1
  76. data/src/containers/column_view.coffee +2 -1
  77. data/src/containers/modal_view.coffee +6 -2
  78. data/src/containers/page_view.coffee +2 -0
  79. data/src/containers/panel_toolbar.coffee +0 -5
  80. data/src/containers/viewport.coffee +28 -10
  81. data/src/core/collection.coffee +7 -1
  82. data/src/core/container.coffee +57 -30
  83. data/src/core/core.coffee +0 -186
  84. data/src/core/field.coffee +11 -3
  85. data/src/core/model.coffee +31 -16
  86. data/src/core/panel.coffee +6 -46
  87. data/src/core/registry.coffee +19 -2
  88. data/src/core/script_loader.coffee +32 -0
  89. data/src/core/view.coffee +112 -139
  90. data/src/define.coffee +110 -0
  91. data/src/framework.coffee +8 -2
  92. data/src/luca.coffee +22 -0
  93. data/src/managers/collection_manager.coffee +65 -31
  94. data/src/modules/load_mask.coffee +47 -0
  95. data/src/plugins/development_tool_helpers.coffee +21 -0
  96. data/src/plugins/events.coffee +54 -0
  97. data/src/stylesheets/components/viewport.scss +15 -0
  98. data/src/stylesheets/containers/container.scss +1 -4
  99. data/src/stylesheets/tools/component_tester.scss +18 -0
  100. data/src/templates/fields/select_field.luca +6 -5
  101. data/src/templates/fields/text_field.luca +10 -9
  102. data/src/tools/application_inspector.coffee +2 -0
  103. data/src/tools/coffee_script_editor.coffee +28 -6
  104. data/src/tools/collections/components.coffee +59 -0
  105. data/src/tools/collections/instances.coffee +15 -0
  106. data/src/tools/component_tester.coffee +12 -22
  107. data/src/tools/console.coffee +22 -4
  108. data/src/tools/models/components.coffee +16 -54
  109. data/src/tools/models/instance.coffee +2 -0
  110. data/src/{core/util.coffee → util.coffee} +10 -1
  111. data/vendor/assets/javascripts/luca-ui-base.js +132 -137
  112. data/vendor/assets/javascripts/luca-ui-development-tools.js +191 -219
  113. data/vendor/assets/javascripts/luca-ui-development-tools.min.js +2 -2
  114. data/vendor/assets/javascripts/luca-ui-full.js +4680 -0
  115. data/vendor/assets/javascripts/luca-ui-full.min.js +8 -0
  116. data/vendor/assets/javascripts/luca-ui-spec.js +291 -225
  117. data/vendor/assets/javascripts/luca-ui.js +1001 -724
  118. data/vendor/assets/javascripts/luca-ui.min.js +4 -4
  119. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +19 -1
  120. data/vendor/assets/stylesheets/luca-ui-development-tools.css +10 -0
  121. data/vendor/assets/stylesheets/luca-ui-full.css +1334 -0
  122. data/vendor/assets/stylesheets/luca-ui-spec.css +19 -1
  123. data/vendor/assets/stylesheets/luca-ui.css +19 -1
  124. data/views/index.erb +2 -5
  125. metadata +58 -9
  126. data/lib/sprockets/luca_template.rb +0 -49
  127. data/src/tools/class_browser.coffee +0 -39
  128. data/src/tools/components/class_browser_detail.coffee +0 -10
  129. data/src/tools/components/class_browser_list.coffee +0 -74
@@ -18,14 +18,15 @@
18
18
  };
19
19
 
20
20
  _.extend(Luca, {
21
- VERSION: "0.9.2",
21
+ VERSION: "0.9.4",
22
22
  core: {},
23
23
  containers: {},
24
24
  components: {},
25
25
  modules: {},
26
26
  util: {},
27
27
  fields: {},
28
- registry: {}
28
+ registry: {},
29
+ options: {}
29
30
  });
30
31
 
31
32
  _.extend(Luca, Backbone.Events);
@@ -71,26 +72,32 @@
71
72
  };
72
73
 
73
74
  Luca.isBackboneModel = function(obj) {
75
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
74
76
  return _.isFunction(obj != null ? obj.set : void 0) && _.isFunction(obj != null ? obj.get : void 0) && _.isObject(obj != null ? obj.attributes : void 0);
75
77
  };
76
78
 
77
79
  Luca.isBackboneView = function(obj) {
80
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
78
81
  return _.isFunction(obj != null ? obj.render : void 0) && !_.isUndefined(obj != null ? obj.el : void 0);
79
82
  };
80
83
 
81
84
  Luca.isBackboneCollection = function(obj) {
85
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
82
86
  return _.isFunction(obj != null ? obj.fetch : void 0) && _.isFunction(obj != null ? obj.reset : void 0);
83
87
  };
84
88
 
85
89
  Luca.isViewPrototype = function(obj) {
90
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
86
91
  return (obj != null) && (obj.prototype != null) && (obj.prototype.make != null) && (obj.prototype.$ != null) && (obj.prototype.render != null);
87
92
  };
88
93
 
89
94
  Luca.isModelPrototype = function(obj) {
95
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
90
96
  return (obj != null) && (typeof obj.prototype === "function" ? obj.prototype((obj.prototype.save != null) && (obj.prototype.changedAttributes != null)) : void 0);
91
97
  };
92
98
 
93
99
  Luca.isCollectionPrototype = function(obj) {
100
+ if (_.isString(obj)) obj = Luca.util.resolve(obj);
94
101
  return (obj != null) && (obj.prototype != null) && !Luca.isModelPrototype(obj) && (obj.prototype.reset != null) && (obj.prototype.select != null) && (obj.prototype.reject != null);
95
102
  };
96
103
 
@@ -306,6 +313,20 @@
306
313
 
307
314
  Luca.util.make = Backbone.View.prototype.make;
308
315
 
316
+ Luca.util.list = function(list, options, ordered) {
317
+ var container, item, _i, _len;
318
+ if (options == null) options = {};
319
+ container = ordered ? "ol" : "ul";
320
+ container = Luca.util.make(container, options);
321
+ if (_.isArray(list)) {
322
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
323
+ item = list[_i];
324
+ $(container).append(Luca.util.make("li", {}, item));
325
+ }
326
+ }
327
+ return container.outerHTML;
328
+ };
329
+
309
330
  Luca.util.label = function(contents, type, baseClass) {
310
331
  var cssClass;
311
332
  if (contents == null) contents = "";
@@ -330,7 +351,99 @@
330
351
 
331
352
  }).call(this);
332
353
  (function() {
333
- var DeferredBindingProxy, DefineProxy;
354
+
355
+ Luca.DevelopmentToolHelpers = {
356
+ refreshCode: function() {
357
+ var view;
358
+ view = this;
359
+ _(this.eventHandlerProperties()).each(function(prop) {
360
+ return view[prop] = view.definitionClass()[prop];
361
+ });
362
+ if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
363
+ return this.delegateEvents();
364
+ },
365
+ eventHandlerProperties: function() {
366
+ var handlerIds;
367
+ handlerIds = _(this.events).values();
368
+ return _(handlerIds).select(function(v) {
369
+ return _.isString(v);
370
+ });
371
+ },
372
+ eventHandlerFunctions: function() {
373
+ var handlerIds,
374
+ _this = this;
375
+ handlerIds = _(this.events).values();
376
+ return _(handlerIds).map(function(handlerId) {
377
+ if (_.isFunction(handlerId)) {
378
+ return handlerId;
379
+ } else {
380
+ return _this[handlerId];
381
+ }
382
+ });
383
+ }
384
+ };
385
+
386
+ }).call(this);
387
+ (function() {
388
+ var DeferredBindingProxy;
389
+
390
+ DeferredBindingProxy = (function() {
391
+
392
+ function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
393
+ var fn,
394
+ _this = this;
395
+ this.object = object;
396
+ if (wrapWithUnderscore == null) wrapWithUnderscore = true;
397
+ if (_.isFunction(operation)) {
398
+ fn = operation;
399
+ } else if (_.isString(operation) && _.isFunction(this.object[operation])) {
400
+ fn = this.object[operation];
401
+ }
402
+ if (!_.isFunction(fn)) {
403
+ throw "Must pass a function or a string representing one";
404
+ }
405
+ if (wrapWithUnderscore === true) {
406
+ this.fn = function() {
407
+ return _.defer(fn);
408
+ };
409
+ } else {
410
+ this.fn = fn;
411
+ }
412
+ this;
413
+ }
414
+
415
+ DeferredBindingProxy.prototype.until = function(watch, trigger) {
416
+ if ((watch != null) && !(trigger != null)) {
417
+ trigger = watch;
418
+ watch = this.object;
419
+ }
420
+ watch.once(trigger, this.fn);
421
+ return this.object;
422
+ };
423
+
424
+ return DeferredBindingProxy;
425
+
426
+ })();
427
+
428
+ Luca.Events = {
429
+ defer: function(operation, wrapWithUnderscore) {
430
+ if (wrapWithUnderscore == null) wrapWithUnderscore = true;
431
+ return new DeferredBindingProxy(this, operation, wrapWithUnderscore);
432
+ },
433
+ once: function(trigger, callback, context) {
434
+ var onceFn;
435
+ context || (context = this);
436
+ onceFn = function() {
437
+ callback.apply(context, arguments);
438
+ return this.unbind(trigger, onceFn);
439
+ };
440
+ return this.bind(trigger, onceFn);
441
+ }
442
+ };
443
+
444
+ }).call(this);
445
+ (function() {
446
+ var DefineProxy;
334
447
 
335
448
  Luca.define = function(componentName) {
336
449
  return new DefineProxy(componentName);
@@ -379,7 +492,7 @@
379
492
  };
380
493
 
381
494
  DefineProxy.prototype["with"] = function(properties) {
382
- var at, componentType;
495
+ var at, componentType, _base;
383
496
  at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
384
497
  if (this.namespaced && !(at != null)) {
385
498
  eval("(window||global)." + this.namespace + " = {}");
@@ -389,6 +502,8 @@
389
502
  if (Luca.autoRegister === true) {
390
503
  if (Luca.isViewPrototype(at[this.componentId])) componentType = "view";
391
504
  if (Luca.isCollectionPrototype(at[this.componentId])) {
505
+ (_base = Luca.Collection).namespaces || (_base.namespaces = []);
506
+ Luca.Collection.namespaces.push(this.namespace);
392
507
  componentType = "collection";
393
508
  }
394
509
  if (Luca.isModelPrototype(at[this.componentId])) componentType = "model";
@@ -402,7 +517,7 @@
402
517
  })();
403
518
 
404
519
  Luca.extend = function(superClassName, childName, properties) {
405
- var superClass;
520
+ var definition, mixin, superClass, _i, _len, _ref;
406
521
  if (properties == null) properties = {};
407
522
  superClass = Luca.util.resolve(superClassName, window || global);
408
523
  if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
@@ -417,120 +532,212 @@
417
532
  var _ref;
418
533
  return (_ref = this._superClass().prototype[method]) != null ? _ref.apply(context, args) : void 0;
419
534
  };
420
- return superClass.extend(properties);
535
+ definition = superClass.extend(properties);
536
+ if (_.isArray(properties != null ? properties.include : void 0)) {
537
+ _ref = properties.include;
538
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
539
+ mixin = _ref[_i];
540
+ if (_.isString(mixin)) mixin = Luca.util.resolve(mixin);
541
+ _.extend(definition.prototype, mixin);
542
+ }
543
+ }
544
+ return definition;
421
545
  };
422
546
 
423
547
  _.mixin({
424
548
  def: Luca.define
425
549
  });
426
550
 
427
- DeferredBindingProxy = (function() {
551
+ }).call(this);
552
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-actions\'>\n <a class=\'btn btn-primary submit-button\'>\n <i class=\'icon-ok icon-white\'></i>\n Save Changes\n </a>\n <a class=\'btn reset-button cancel-button\'>\n <i class=\'icon-remove\'></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');}; }).call(this);
553
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'modal\' id=\'progress-model\' style=\'display: none;\'>\n <div class=\'progress progress-info progress-striped active\'>\n <div class=\'bar\' style=\'width: 0%;\'></div>\n </div>\n <div class=\'message\'>\n Initializing...\n </div>\n</div>\n');}return __p.join('');}; }).call(this);
554
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', className ,'\'>\n <a class=\'close\' data-dismiss=\'alert\' href=\'#\'>x</a>\n ', message ,'\n</div>\n');}return __p.join('');}; }).call(this);
555
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'></div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
556
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'empty-text-wrapper\'>\n <p>\n ', text ,'\n </p>\n</div>\n');}return __p.join('');}; }).call(this);
557
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'load-mask\'>\n <div class=\'progress progress-striped active\'>\n <div class=\'bar\' style=\'width:1%\'></div>\n </div>\n</div>\n');}return __p.join('');}; }).call(this);
558
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'navbar-inner\'>\n <div class=\'luca-ui-navbar-body container\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
559
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', classes ,'\' id=\'', id ,'\' style=\'', style ,'\'></div>\n');}return __p.join('');}; }).call(this);
560
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'tab-selector-container\' id=\'', cid ,'-tab-selector\'>\n <ul class=\'nav nav-tabs\' id=\'', cid ,'-tabs-nav\'>\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class=\'tab-selector\' data-target=\'', i ,'\'>\n <a data-target=\'', i ,'\'>\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');}; }).call(this);
561
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul class=\'nav ', navClass ,'\' id=\'', cid ,'-tabs-selector\'></ul>\n<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');}; }).call(this);
562
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-toolbar-wrapper\' id=\'', id ,'\'></div>\n');}return __p.join('');}; }).call(this);
563
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label>&nbsp</label>\n<input class=\'btn ', input_class ,'\' id=\'', input_id ,'\' style=\'', inputStyles ,'\' type=\'', input_type ,'\' value=\'', input_value ,'\' />\n');}return __p.join('');}; }).call(this);
564
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class=\'btn ', input_class ,'\'>\n '); if(icon_class.length) { __p.push('\n <i class=\'', icon_class ,'\'></i>\n '); } __p.push('\n ', input_value ,'\n</a>\n');}return __p.join('');}; }).call(this);
565
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
566
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n <input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'checkbox\' value=\'', value ,'\' />\n ', label ,'\n</label>\n');}return __p.join('');}; }).call(this);
567
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n <input name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'checkbox\' value=\'', input_value ,'\' />\n</label>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
568
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<input id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'file\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
569
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'hidden\' value=\'', input_value ,'\' />\n');}return __p.join('');}; }).call(this);
570
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<div class=\'controls\'>\n <select id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></select>\n '); if(helperText) { __p.push('\n <p class=\'helper-text help-block\'>\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');}; }).call(this);
571
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<textarea class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></textarea>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
572
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class=\'control-label\' for=\'', input_id ,'\'>\n ', label ,'\n</label>\n'); } __p.push('\n<div class=\'controls\'>\n '); if( typeof(addOn) !== "undefined" ) { __p.push('\n <span class=\'add-on\'>\n ', addOn ,'\n </span>\n '); } __p.push('\n <input class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' placeholder=\'', placeHolder ,'\' style=\'', inputStyles ,'\' type=\'text\' />\n '); if(helperText) { __p.push('\n <p class=\'helper-text help-block\'>\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');}; }).call(this);
573
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["sample/contents"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<p>Sample Contents</p>\n');}return __p.join('');}; }).call(this);
574
+ (function() {Luca.templates || (Luca.templates = {}); Luca.templates["sample/welcome"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('welcome.luca\n');}return __p.join('');}; }).call(this);
575
+ (function() {
428
576
 
429
- function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
430
- var fn,
431
- _this = this;
432
- this.object = object;
433
- if (wrapWithUnderscore == null) wrapWithUnderscore = true;
434
- if (_.isFunction(operation)) {
435
- fn = operation;
436
- } else if (_.isString(operation) && _.isFunction(this.object[operation])) {
437
- fn = this.object[operation];
577
+ Luca.modules.Deferrable = {
578
+ configure_collection: function(setAsDeferrable) {
579
+ var collectionManager, _ref, _ref2;
580
+ if (setAsDeferrable == null) setAsDeferrable = true;
581
+ if (!this.collection) return;
582
+ if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
583
+ this.collection = collectionManager.getOrCreate(this.collection);
438
584
  }
439
- if (!_.isFunction(fn)) {
440
- throw "Must pass a function or a string representing one";
585
+ if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
586
+ this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
441
587
  }
442
- if (wrapWithUnderscore === true) {
443
- this.fn = function() {
444
- return _.defer(fn);
445
- };
446
- } else {
447
- this.fn = fn;
588
+ if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
589
+ this.deferrable_trigger = this.collection.deferrable_trigger;
448
590
  }
449
- this;
591
+ if (setAsDeferrable) return this.deferrable = this.collection;
450
592
  }
593
+ };
451
594
 
452
- DeferredBindingProxy.prototype.until = function(watch, trigger) {
453
- if ((watch != null) && !(trigger != null)) {
454
- trigger = watch;
455
- watch = this.object;
456
- }
457
- watch.once(trigger, this.fn);
458
- return this.object;
459
- };
460
-
461
- return DeferredBindingProxy;
462
-
463
- })();
595
+ }).call(this);
596
+ (function() {
464
597
 
465
- Luca.Events = {
466
- defer: function(operation, wrapWithUnderscore) {
467
- if (wrapWithUnderscore == null) wrapWithUnderscore = true;
468
- return new DeferredBindingProxy(this, operation, wrapWithUnderscore);
598
+ Luca.modules.LoadMaskable = {
599
+ _included: function(self, module) {
600
+ var _this = this;
601
+ _.bindAll(self, "applyLoadMask", "disableLoadMask");
602
+ if (this.loadMask === true) {
603
+ this.defer(function() {
604
+ _this.$el.addClass('with-mask');
605
+ if (_this.$('.load-mask').length === 0) {
606
+ _this.loadMaskTarget().prepend(Luca.template(_this.loadMaskTemplate, _this));
607
+ return _this.$('.load-mask').hide();
608
+ }
609
+ }).until("after:render");
610
+ this.on(this.loadmaskEnableEvent || "enable:loadmask", this.applyLoadMask);
611
+ return this.on(this.loadmaskDisableEvent || "disable:loadmask", this.applyLoadMask);
612
+ }
469
613
  },
470
- once: function(trigger, callback, context) {
471
- var onceFn;
472
- context || (context = this);
473
- onceFn = function() {
474
- callback.apply(context, arguments);
475
- return this.unbind(trigger, onceFn);
476
- };
477
- return this.bind(trigger, onceFn);
614
+ loadMaskTarget: function() {
615
+ if (this.loadMaskEl != null) {
616
+ return this.$(this.loadMaskEl);
617
+ } else {
618
+ return this.$bodyEl();
619
+ }
620
+ },
621
+ disableLoadMask: function() {
622
+ this.$('.load-mask .bar').css("width", "100%");
623
+ this.$('.load-mask').hide();
624
+ return clearInterval(this.loadMaskInterval);
625
+ },
626
+ enableLoadMask: function() {
627
+ var maxWidth,
628
+ _this = this;
629
+ this.$('.load-mask').show().find('.bar').css("width", "0%");
630
+ maxWidth = this.$('.load-mask .progress').width();
631
+ if (maxWidth < 20 && (maxWidth = this.$el.width()) < 20) {
632
+ maxWidth = this.$el.parent().width();
633
+ }
634
+ this.loadMaskInterval = setInterval(function() {
635
+ var currentWidth, newWidth;
636
+ currentWidth = _this.$('.load-mask .bar').width();
637
+ newWidth = currentWidth + 12;
638
+ return _this.$('.load-mask .bar').css('width', newWidth);
639
+ }, 200);
640
+ if (this.loadMaskTimeout == null) return;
641
+ return _.delay(function() {
642
+ return _this.disableLoadMask();
643
+ }, this.loadMaskTimeout);
644
+ },
645
+ applyLoadMask: function() {
646
+ if (this.$('.load-mask').is(":visible")) {
647
+ return this.disableLoadMask();
648
+ } else {
649
+ return this.enableLoadMask();
650
+ }
478
651
  }
479
652
  };
480
653
 
481
- Luca.ScriptLoader = (function() {
654
+ }).call(this);
655
+ (function() {
482
656
 
483
- ScriptLoader.loaded = {};
657
+ Luca.LocalStore = (function() {
484
658
 
485
- function ScriptLoader(options) {
486
- var ready;
487
- if (options == null) options = {};
488
- _.extend(this, Backbone.Events, Luca.Events);
489
- this.autoStart = options.autoStart === true;
490
- this.scripts = options.scripts;
491
- ready = function() {
492
- return this.trigger("ready");
493
- };
494
- this.ready = _.after(this.scripts.length, ready);
495
- _.bindAll(this, "load", "ready");
496
- this.defer("load").until(this, "start");
497
- if (this.autoStart === true) this.trigger("start");
498
- this.bind("ready", this.onReady);
659
+ function LocalStore(name) {
660
+ var store;
661
+ this.name = name;
662
+ store = localStorage.getItem(this.name);
663
+ this.data = (store && JSON.parse(store)) || {};
499
664
  }
500
665
 
501
- ScriptLoader.prototype.applyPrefix = function(script) {
502
- return script;
666
+ LocalStore.prototype.guid = function() {
667
+ var S4;
668
+ S4 = function() {
669
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
670
+ };
671
+ return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
503
672
  };
504
673
 
505
- ScriptLoader.prototype.onReady = function() {
506
- return console.log("All dependencies loaded");
674
+ LocalStore.prototype.save = function() {
675
+ return localStorage.setItem(this.name, JSON.stringify(this.data));
507
676
  };
508
677
 
509
- ScriptLoader.prototype.start = function() {
510
- return this.trigger("start");
678
+ LocalStore.prototype.create = function(model) {
679
+ if (!model.id) model.id = model.attribtues.id = this.guid();
680
+ this.data[model.id] = model;
681
+ this.save();
682
+ return model;
511
683
  };
512
684
 
513
- ScriptLoader.prototype.load = function() {
514
- var script, _i, _len, _ref, _results;
515
- _ref = this.scripts;
516
- _results = [];
517
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
518
- script = _ref[_i];
519
- _results.push(Luca.util.loadScript(this.applyPrefix(script), this.ready));
520
- }
521
- return _results;
685
+ LocalStore.prototype.update = function(model) {
686
+ this.data[model.id] = model;
687
+ this.save();
688
+ return model;
522
689
  };
523
690
 
524
- return ScriptLoader;
525
-
526
- })();
691
+ LocalStore.prototype.find = function(model) {
692
+ return this.data[model.id];
693
+ };
527
694
 
528
- }).call(this);
529
- (function() {
530
- var component_cache, registry;
695
+ LocalStore.prototype.findAll = function() {
696
+ return _.values(this.data);
697
+ };
531
698
 
532
- registry = {
533
- classes: {},
699
+ LocalStore.prototype.destroy = function(model) {
700
+ delete this.data[model.id];
701
+ this.save();
702
+ return model;
703
+ };
704
+
705
+ return LocalStore;
706
+
707
+ })();
708
+
709
+ Backbone.LocalSync = function(method, model, options) {
710
+ var resp, store;
711
+ store = model.localStorage || model.collection.localStorage;
712
+ resp = (function() {
713
+ switch (method) {
714
+ case "read":
715
+ if (model.id) {
716
+ return store.find(model);
717
+ } else {
718
+ return store.findAll();
719
+ }
720
+ case "create":
721
+ return store.create(model);
722
+ case "update":
723
+ return store.update(model);
724
+ case "delete":
725
+ return store.destroy(model);
726
+ }
727
+ })();
728
+ if (resp) {
729
+ return options.success(resp);
730
+ } else {
731
+ return options.error("Record not found");
732
+ }
733
+ };
734
+
735
+ }).call(this);
736
+ (function() {
737
+ var component_cache, registry;
738
+
739
+ registry = {
740
+ classes: {},
534
741
  model_classes: {},
535
742
  collection_classes: {},
536
743
  namespaces: ['Luca.containers', 'Luca.components']
@@ -586,8 +793,21 @@
586
793
  });
587
794
  };
588
795
 
796
+ Luca.registry.aliases = {
797
+ grid: "grid_view",
798
+ form: "form_view",
799
+ text: "text_field",
800
+ button: "button_field",
801
+ select: "select_field",
802
+ card: "card_view",
803
+ paged: "card_view",
804
+ wizard: "card_view",
805
+ collection: "collection_view"
806
+ };
807
+
589
808
  Luca.registry.lookup = function(ctype) {
590
- var c, className, fullPath, parents, _ref;
809
+ var alias, c, className, fullPath, parents, _ref;
810
+ if (alias = Luca.registry.aliases[ctype]) ctype = alias;
591
811
  c = registry.classes[ctype];
592
812
  if (c != null) return c;
593
813
  className = Luca.util.classify(ctype);
@@ -597,9 +817,13 @@
597
817
  }).compact().value()) != null ? _ref[0] : void 0;
598
818
  };
599
819
 
820
+ Luca.registry.instances = function() {
821
+ return _(component_cache.cid_index).values();
822
+ };
823
+
600
824
  Luca.registry.findInstancesByClassName = function(className) {
601
825
  var instances;
602
- instances = _(component_cache.cid_index).values();
826
+ instances = Luca.registry.instances();
603
827
  return _(instances).select(function(instance) {
604
828
  var _ref;
605
829
  return instance.displayName === className || (typeof instance._superClass === "function" ? (_ref = instance._superClass()) != null ? _ref.displayName : void 0 : void 0) === className;
@@ -608,7 +832,7 @@
608
832
 
609
833
  Luca.registry.classes = function(toString) {
610
834
  if (toString == null) toString = false;
611
- return _(registry.classes).map(function(className, ctype) {
835
+ return _(_.extend({}, registry.classes, registry.model_classes, registry.collection_classes)).map(function(className, ctype) {
612
836
  if (toString) {
613
837
  return className;
614
838
  } else {
@@ -638,58 +862,106 @@
638
862
 
639
863
  }).call(this);
640
864
  (function() {
641
- var customizeRender, originalExtend;
865
+ var __slice = Array.prototype.slice;
866
+
867
+ Luca.Observer = (function() {
868
+
869
+ function Observer(options) {
870
+ var _this = this;
871
+ this.options = options != null ? options : {};
872
+ _.extend(this, Backbone.Events);
873
+ this.type = this.options.type;
874
+ if (this.options.debugAll) {
875
+ this.bind("all", function(trigger, one, two) {
876
+ return console.log("ALL", trigger, one, two);
877
+ });
878
+ }
879
+ }
880
+
881
+ Observer.prototype.relay = function() {
882
+ var args, triggerer;
883
+ triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
884
+ console.log("Relaying", trigger, args);
885
+ this.trigger("event", triggerer, args);
886
+ return this.trigger("event:" + args[0], triggerer, args.slice(1));
887
+ };
888
+
889
+ return Observer;
890
+
891
+ })();
892
+
893
+ Luca.Observer.enableObservers = function(options) {
894
+ if (options == null) options = {};
895
+ Luca.enableGlobalObserver = true;
896
+ Luca.ViewObserver = new Luca.Observer(_.extend(options, {
897
+ type: "view"
898
+ }));
899
+ return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
900
+ type: "collection"
901
+ }));
902
+ };
903
+
904
+ }).call(this);
905
+ (function() {
906
+ var bindAllEventHandlers, customizeRender, originalExtend, registerApplicationEvents, registerCollectionEvents;
642
907
 
643
908
  _.def("Luca.View")["extends"]("Backbone.View")["with"]({
909
+ include: ['Luca.Events'],
644
910
  additionalClassNames: [],
645
- debug: function() {
646
- var message, _i, _len, _results;
647
- if (!(this.debugMode || (window.LucaDebugMode != null))) return;
648
- _results = [];
649
- for (_i = 0, _len = arguments.length; _i < _len; _i++) {
650
- message = arguments[_i];
651
- _results.push(console.log([this.name || this.cid, message]));
652
- }
653
- return _results;
654
- },
655
- trigger: function() {
656
- if (Luca.enableGlobalObserver) {
657
- if (Luca.developmentMode === true || this.observeEvents === true) {
658
- Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
659
- type: "view"
660
- }));
661
- Luca.ViewObserver.relay(this, arguments);
662
- }
663
- }
664
- return Backbone.View.prototype.trigger.apply(this, arguments);
665
- },
666
911
  hooks: ["after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation"],
667
912
  initialize: function(options) {
668
- var additional, template, unique, _i, _len, _ref;
913
+ var additional, module, template, templateVars, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4;
669
914
  this.options = options != null ? options : {};
915
+ this.trigger("before:initialize", this, this.options);
670
916
  _.extend(this, this.options);
671
917
  if (this.name != null) this.cid = _.uniqueId(this.name);
918
+ templateVars = this.bodyTemplateVars ? this.bodyTemplateVars.call(this) : this;
672
919
  if (template = this.bodyTemplate) {
673
920
  this.$el.empty();
674
- Luca.View.prototype.$html.call(this, Luca.template(template, this));
921
+ Luca.View.prototype.$html.call(this, Luca.template(template, templateVars));
675
922
  }
676
923
  Luca.cache(this.cid, this);
677
- unique = _(Luca.View.prototype.hooks.concat(this.hooks)).uniq();
678
- this.setupHooks(unique);
679
- if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
924
+ this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq());
925
+ if (this.autoBindEventHandlers === true || this.bindAllEvents === true) {
926
+ bindAllEventHandlers.call(this);
927
+ }
680
928
  if (this.additionalClassNames) {
681
929
  if (_.isString(this.additionalClassNames)) {
682
930
  this.additionalClassNames = this.additionalClassNames.split(" ");
683
931
  }
684
- _ref = this.additionalClassNames;
685
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
686
- additional = _ref[_i];
932
+ }
933
+ if (this.gridSpan) this.additionalClassNames.push("span" + this.gridSpan);
934
+ if (this.gridOffset) {
935
+ this.additionalClassNames.push("offset" + this.gridOffset);
936
+ }
937
+ if (this.gridRowFluid) this.additionalClassNames.push("row-fluid");
938
+ if (this.gridRow) this.additionalClassNames.push("row");
939
+ if (((_ref = this.additionalClassNames) != null ? _ref.length : void 0) > 0) {
940
+ _ref2 = this.additionalClassNames;
941
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
942
+ additional = _ref2[_i];
687
943
  this.$el.addClass(additional);
688
944
  }
689
945
  }
690
- this.trigger("after:initialize", this);
691
- this.registerCollectionEvents();
692
- return this.delegateEvents();
946
+ if (this.wrapperClass != null) this.$wrap(this.wrapperClass);
947
+ registerCollectionEvents.call(this);
948
+ registerApplicationEvents.call(this);
949
+ this.delegateEvents();
950
+ if (this.stateful === true && !(this.state != null)) {
951
+ this.state = new Backbone.Model(this.defaultState || {});
952
+ if (this.set == null) {
953
+ this.set = _.bind(this, this.state.set);
954
+ this.get = _.bind(this, this.state.get);
955
+ }
956
+ }
957
+ if (((_ref3 = this.mixins) != null ? _ref3.length : void 0) > 0) {
958
+ _ref4 = this.mixins;
959
+ for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) {
960
+ module = _ref4[_j];
961
+ Luca.modules[module]._included.call(this, this, module);
962
+ }
963
+ }
964
+ return this.trigger("after:initialize", this);
693
965
  },
694
966
  $wrap: function(wrapper) {
695
967
  if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
@@ -712,6 +984,9 @@
712
984
  $attach: function() {
713
985
  return this.$container().append(this.el);
714
986
  },
987
+ $bodyEl: function() {
988
+ return this.$el;
989
+ },
715
990
  $container: function() {
716
991
  return $(this.container);
717
992
  },
@@ -731,72 +1006,15 @@
731
1006
  return _this.bind(eventId, callback);
732
1007
  });
733
1008
  },
734
- getCollectionManager: function() {
735
- var _base;
736
- return this.collectionManager || (typeof (_base = Luca.CollectionManager).get === "function" ? _base.get() : void 0);
737
- },
738
- registerCollectionEvents: function() {
739
- var manager,
740
- _this = this;
741
- manager = this.getCollectionManager();
742
- return _(this.collectionEvents).each(function(handler, signature) {
743
- var collection, event, key, _ref;
744
- _ref = signature.split(" "), key = _ref[0], event = _ref[1];
745
- collection = _this["" + key + "Collection"] = manager.getOrCreate(key);
746
- if (!collection) throw "Could not find collection specified by " + key;
747
- if (_.isString(handler)) handler = _this[handler];
748
- if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
749
- try {
750
- return collection.bind(event, handler);
751
- } catch (e) {
752
- console.log("Error Binding To Collection in registerCollectionEvents", _this);
753
- throw e;
754
- }
755
- });
756
- },
757
1009
  registerEvent: function(selector, handler) {
758
1010
  this.events || (this.events = {});
759
1011
  this.events[selector] = handler;
760
1012
  return this.delegateEvents();
761
1013
  },
762
- bindAllEventHandlers: function() {
763
- var _this = this;
764
- return _(this.events).each(function(handler, event) {
765
- if (_.isString(handler)) return _.bindAll(_this, handler);
766
- });
767
- },
768
1014
  definitionClass: function() {
769
1015
  var _ref;
770
1016
  return (_ref = Luca.util.resolve(this.displayName, window)) != null ? _ref.prototype : void 0;
771
1017
  },
772
- refreshCode: function() {
773
- var view;
774
- view = this;
775
- _(this.eventHandlerProperties()).each(function(prop) {
776
- return view[prop] = view.definitionClass()[prop];
777
- });
778
- if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
779
- return this.delegateEvents();
780
- },
781
- eventHandlerProperties: function() {
782
- var handlerIds;
783
- handlerIds = _(this.events).values();
784
- return _(handlerIds).select(function(v) {
785
- return _.isString(v);
786
- });
787
- },
788
- eventHandlerFunctions: function() {
789
- var handlerIds,
790
- _this = this;
791
- handlerIds = _(this.events).values();
792
- return _(handlerIds).map(function(handlerId) {
793
- if (_.isFunction(handlerId)) {
794
- return handlerId;
795
- } else {
796
- return _this[handlerId];
797
- }
798
- });
799
- },
800
1018
  collections: function() {
801
1019
  return Luca.util.selectProperties(Luca.isBackboneCollection, this);
802
1020
  },
@@ -805,6 +1023,27 @@
805
1023
  },
806
1024
  views: function() {
807
1025
  return Luca.util.selectProperties(Luca.isBackboneView, this);
1026
+ },
1027
+ debug: function() {
1028
+ var message, _i, _len, _results;
1029
+ if (!(this.debugMode || (window.LucaDebugMode != null))) return;
1030
+ _results = [];
1031
+ for (_i = 0, _len = arguments.length; _i < _len; _i++) {
1032
+ message = arguments[_i];
1033
+ _results.push(console.log([this.name || this.cid, message]));
1034
+ }
1035
+ return _results;
1036
+ },
1037
+ trigger: function() {
1038
+ if (Luca.enableGlobalObserver) {
1039
+ if (Luca.developmentMode === true || this.observeEvents === true) {
1040
+ Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
1041
+ type: "view"
1042
+ }));
1043
+ Luca.ViewObserver.relay(this, arguments);
1044
+ }
1045
+ }
1046
+ return Backbone.View.prototype.trigger.apply(this, arguments);
808
1047
  }
809
1048
  });
810
1049
 
@@ -852,36 +1091,108 @@
852
1091
  return definition;
853
1092
  };
854
1093
 
1094
+ bindAllEventHandlers = function() {
1095
+ var _this = this;
1096
+ return _(this.events).each(function(handler, event) {
1097
+ if (_.isString(handler)) return _.bindAll(_this, handler);
1098
+ });
1099
+ };
1100
+
1101
+ registerApplicationEvents = function() {
1102
+ var app, eventTrigger, handler, _len, _ref, _ref2, _results;
1103
+ if (_.isEmpty(this.applicationEvents)) return;
1104
+ app = this.app;
1105
+ if (_.isString(app) || _.isUndefined(app)) {
1106
+ app = (_ref = Luca.Application) != null ? typeof _ref.get === "function" ? _ref.get(app) : void 0 : void 0;
1107
+ }
1108
+ if (!Luca.supportsEvents(app)) {
1109
+ throw "Error binding to the application object on " + (this.name || this.cid);
1110
+ }
1111
+ _ref2 = this.applicationEvents;
1112
+ _results = [];
1113
+ for (handler = 0, _len = _ref2.length; handler < _len; handler++) {
1114
+ eventTrigger = _ref2[handler];
1115
+ if (_.isString(handler)) handler = this[handler];
1116
+ if (!_.isFunction(handler)) {
1117
+ throw "Error registering application event " + eventTrigger + " on " + (this.name || this.cid);
1118
+ }
1119
+ _results.push(app.on(eventTrigger, handler));
1120
+ }
1121
+ return _results;
1122
+ };
1123
+
1124
+ registerCollectionEvents = function() {
1125
+ var collection, eventTrigger, handler, key, manager, signature, _ref, _ref2, _results;
1126
+ if (_.isEmpty(this.collectionEvents)) return;
1127
+ manager = this.collectionManager;
1128
+ if (_.isString(manager) || _.isUndefined(manager)) {
1129
+ manager = Luca.CollectionManager.get(manager);
1130
+ }
1131
+ _ref = this.collectionEvents;
1132
+ _results = [];
1133
+ for (signature in _ref) {
1134
+ handler = _ref[signature];
1135
+ console.log("Sig", signature, "Handler", handler);
1136
+ _ref2 = signature.split(" "), key = _ref2[0], eventTrigger = _ref2[1];
1137
+ collection = manager.getOrCreate(key);
1138
+ if (!collection) throw "Could not find collection specified by " + key;
1139
+ if (_.isString(handler)) handler = this[handler];
1140
+ if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
1141
+ try {
1142
+ _results.push(collection.bind(eventTrigger, handler));
1143
+ } catch (e) {
1144
+ console.log("Error Binding To Collection in registerCollectionEvents", this);
1145
+ throw e;
1146
+ }
1147
+ }
1148
+ return _results;
1149
+ };
1150
+
855
1151
  Luca.View.extend = function(definition) {
1152
+ var module, _i, _len, _ref;
856
1153
  definition = customizeRender(definition);
1154
+ if ((definition.mixins != null) && _.isArray(definition.mixins)) {
1155
+ _ref = definition.mixins;
1156
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1157
+ module = _ref[_i];
1158
+ _.extend(definition, Luca.modules[module]);
1159
+ }
1160
+ }
857
1161
  return originalExtend.call(this, definition);
858
1162
  };
859
1163
 
860
1164
  }).call(this);
861
1165
  (function() {
1166
+ var setupComputedProperties;
1167
+
1168
+ setupComputedProperties = function() {
1169
+ var attr, dependencies, _ref, _results,
1170
+ _this = this;
1171
+ if (_.isUndefined(this.computed)) return;
1172
+ this._computed = {};
1173
+ _ref = this.computed;
1174
+ _results = [];
1175
+ for (attr in _ref) {
1176
+ dependencies = _ref[attr];
1177
+ this.on("change:" + attr, function() {
1178
+ return _this._computed[attr] = _this[attr].call(_this);
1179
+ });
1180
+ if (_.isString(dependencies)) dependencies = dependencies.split(',');
1181
+ _results.push(_(dependencies).each(function(dep) {
1182
+ _this.on("change:" + dep, function() {
1183
+ return _this.trigger("change:" + attr);
1184
+ });
1185
+ if (_this.has(dep)) return _this.trigger("change:" + attr);
1186
+ }));
1187
+ }
1188
+ return _results;
1189
+ };
862
1190
 
863
1191
  _.def('Luca.Model')["extends"]('Backbone.Model')["with"]({
1192
+ include: ['Luca.Events'],
864
1193
  initialize: function() {
865
- var attr, dependencies, _ref, _results,
866
- _this = this;
867
1194
  Backbone.Model.prototype.initialize(this, arguments);
868
- if (_.isUndefined(this.computed)) return;
869
- this._computed = {};
870
- _ref = this.computed;
871
- _results = [];
872
- for (attr in _ref) {
873
- dependencies = _ref[attr];
874
- this.on("change:" + attr, function() {
875
- return _this._computed[attr] = _this[attr].call(_this);
876
- });
877
- _results.push(_(dependencies).each(function(dep) {
878
- _this.on("change:" + dep, function() {
879
- return _this.trigger("change:" + attr);
880
- });
881
- if (_this.has(dep)) return _this.trigger("change:" + attr);
882
- }));
883
- }
884
- return _results;
1195
+ return setupComputedProperties.call(this);
885
1196
  },
886
1197
  get: function(attr) {
887
1198
  var _ref;
@@ -902,6 +1213,7 @@
902
1213
  if (Backbone.QueryCollection != null) source = 'Backbone.QueryCollection';
903
1214
 
904
1215
  _.def("Luca.Collection")["extends"](source)["with"]({
1216
+ include: ['Luca.Events'],
905
1217
  cachedMethods: [],
906
1218
  remoteFilter: false,
907
1219
  initialize: function(models, options) {
@@ -1259,60 +1571,10 @@
1259
1571
  loadMask: false,
1260
1572
  loadMaskTemplate: ["components/load_mask"],
1261
1573
  loadMaskTimeout: 3000,
1574
+ mixins: ["LoadMaskable"],
1262
1575
  initialize: function(options) {
1263
- var _this = this;
1264
1576
  this.options = options != null ? options : {};
1265
- Luca.View.prototype.initialize.apply(this, arguments);
1266
- _.bindAll(this, "applyLoadMask", "disableLoadMask");
1267
- if (this.loadMask === true) {
1268
- this.defer(function() {
1269
- _this.$el.addClass('with-mask');
1270
- if (_this.$('.load-mask').length === 0) {
1271
- _this.loadMaskTarget().prepend(Luca.template(_this.loadMaskTemplate, _this));
1272
- return _this.$('.load-mask').hide();
1273
- }
1274
- }).until("after:render");
1275
- this.on("enable:loadmask", this.applyLoadMask);
1276
- return this.on("disable:loadmask", this.applyLoadMask);
1277
- }
1278
- },
1279
- loadMaskTarget: function() {
1280
- if (this.loadMaskEl != null) {
1281
- return this.$(this.loadMaskEl);
1282
- } else {
1283
- return this.$bodyEl();
1284
- }
1285
- },
1286
- disableLoadMask: function() {
1287
- this.$('.load-mask .bar').css("width", "100%");
1288
- this.$('.load-mask').hide();
1289
- return clearInterval(this.loadMaskInterval);
1290
- },
1291
- enableLoadMask: function() {
1292
- var maxWidth,
1293
- _this = this;
1294
- this.$('.load-mask').show().find('.bar').css("width", "0%");
1295
- maxWidth = this.$('.load-mask .progress').width();
1296
- if (maxWidth < 20 && (maxWidth = this.$el.width()) < 20) {
1297
- maxWidth = this.$el.parent().width();
1298
- }
1299
- this.loadMaskInterval = setInterval(function() {
1300
- var currentWidth, newWidth;
1301
- currentWidth = _this.$('.load-mask .bar').width();
1302
- newWidth = currentWidth + 12;
1303
- return _this.$('.load-mask .bar').css('width', newWidth);
1304
- }, 200);
1305
- if (this.loadMaskTimeout == null) return;
1306
- return _.delay(function() {
1307
- return _this.disableLoadMask();
1308
- }, this.loadMaskTimeout);
1309
- },
1310
- applyLoadMask: function() {
1311
- if (this.$('.load-mask').is(":visible")) {
1312
- return this.disableLoadMask();
1313
- } else {
1314
- return this.enableLoadMask();
1315
- }
1577
+ return Luca.View.prototype.initialize.apply(this, arguments);
1316
1578
  },
1317
1579
  applyStyles: function(styles, body) {
1318
1580
  var setting, target, value;
@@ -1363,6 +1625,9 @@
1363
1625
  if (variables == null) variables = {};
1364
1626
  return this.$html(Luca.template(template, variables));
1365
1627
  },
1628
+ $empty: function() {
1629
+ return this.$bodyEl().empty();
1630
+ },
1366
1631
  $html: function(content) {
1367
1632
  return this.$bodyEl().html(content);
1368
1633
  },
@@ -1387,241 +1652,6 @@
1387
1652
  }
1388
1653
  });
1389
1654
 
1390
- }).call(this);
1391
- (function() {
1392
-
1393
- Luca.modules.Deferrable = {
1394
- configure_collection: function(setAsDeferrable) {
1395
- var collectionManager, _ref, _ref2;
1396
- if (setAsDeferrable == null) setAsDeferrable = true;
1397
- if (!this.collection) return;
1398
- if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
1399
- this.collection = collectionManager.getOrCreate(this.collection);
1400
- }
1401
- if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
1402
- this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
1403
- }
1404
- if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
1405
- this.deferrable_trigger = this.collection.deferrable_trigger;
1406
- }
1407
- if (setAsDeferrable) return this.deferrable = this.collection;
1408
- }
1409
- };
1410
-
1411
- }).call(this);
1412
- (function() {
1413
-
1414
- Luca.LocalStore = (function() {
1415
-
1416
- function LocalStore(name) {
1417
- var store;
1418
- this.name = name;
1419
- store = localStorage.getItem(this.name);
1420
- this.data = (store && JSON.parse(store)) || {};
1421
- }
1422
-
1423
- LocalStore.prototype.guid = function() {
1424
- var S4;
1425
- S4 = function() {
1426
- return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
1427
- };
1428
- return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
1429
- };
1430
-
1431
- LocalStore.prototype.save = function() {
1432
- return localStorage.setItem(this.name, JSON.stringify(this.data));
1433
- };
1434
-
1435
- LocalStore.prototype.create = function(model) {
1436
- if (!model.id) model.id = model.attribtues.id = this.guid();
1437
- this.data[model.id] = model;
1438
- this.save();
1439
- return model;
1440
- };
1441
-
1442
- LocalStore.prototype.update = function(model) {
1443
- this.data[model.id] = model;
1444
- this.save();
1445
- return model;
1446
- };
1447
-
1448
- LocalStore.prototype.find = function(model) {
1449
- return this.data[model.id];
1450
- };
1451
-
1452
- LocalStore.prototype.findAll = function() {
1453
- return _.values(this.data);
1454
- };
1455
-
1456
- LocalStore.prototype.destroy = function(model) {
1457
- delete this.data[model.id];
1458
- this.save();
1459
- return model;
1460
- };
1461
-
1462
- return LocalStore;
1463
-
1464
- })();
1465
-
1466
- Backbone.LocalSync = function(method, model, options) {
1467
- var resp, store;
1468
- store = model.localStorage || model.collection.localStorage;
1469
- resp = (function() {
1470
- switch (method) {
1471
- case "read":
1472
- if (model.id) {
1473
- return store.find(model);
1474
- } else {
1475
- return store.findAll();
1476
- }
1477
- case "create":
1478
- return store.create(model);
1479
- case "update":
1480
- return store.update(model);
1481
- case "delete":
1482
- return store.destroy(model);
1483
- }
1484
- })();
1485
- if (resp) {
1486
- return options.success(resp);
1487
- } else {
1488
- return options.error("Record not found");
1489
- }
1490
- };
1491
-
1492
- }).call(this);
1493
- (function() {
1494
- Luca.templates || (Luca.templates = {});
1495
- Luca.templates["components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-actions\'>\n <a class=\'btn btn-primary submit-button\'>\n <i class=\'icon-ok icon-white\'></i>\n Save Changes\n </a>\n <a class=\'btn reset-button cancel-button\'>\n <i class=\'icon-remove\'></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');};
1496
- }).call(this);
1497
- (function() {
1498
- Luca.templates || (Luca.templates = {});
1499
- Luca.templates["components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'modal\' id=\'progress-model\' style=\'display: none;\'>\n <div class=\'progress progress-info progress-striped active\'>\n <div class=\'bar\' style=\'width: 0%;\'></div>\n </div>\n <div class=\'message\'>\n Initializing...\n </div>\n</div>\n');}return __p.join('');};
1500
- }).call(this);
1501
- (function() {
1502
- Luca.templates || (Luca.templates = {});
1503
- Luca.templates["components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', className ,'\'>\n <a class=\'close\' data-dismiss=\'alert\' href=\'#\'>x</a>\n ', message ,'\n</div>\n');}return __p.join('');};
1504
- }).call(this);
1505
- (function() {
1506
- Luca.templates || (Luca.templates = {});
1507
- Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'></div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'></div>\n</div>\n');}return __p.join('');};
1508
- }).call(this);
1509
- (function() {
1510
- Luca.templates || (Luca.templates = {});
1511
- Luca.templates["components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'empty-text-wrapper\'>\n <p>\n ', text ,'\n </p>\n</div>\n');}return __p.join('');};
1512
- }).call(this);
1513
- (function() {
1514
- Luca.templates || (Luca.templates = {});
1515
- Luca.templates["components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'load-mask\'>\n <div class=\'progress progress-striped active\'>\n <div class=\'bar\' style=\'width:1%\'></div>\n </div>\n</div>\n');}return __p.join('');};
1516
- }).call(this);
1517
- (function() {
1518
- Luca.templates || (Luca.templates = {});
1519
- Luca.templates["components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'navbar-inner\'>\n <div class=\'luca-ui-navbar-body container\'></div>\n</div>\n');}return __p.join('');};
1520
- }).call(this);
1521
- (function() {
1522
- Luca.templates || (Luca.templates = {});
1523
- Luca.templates["containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', classes ,'\' id=\'', id ,'\' style=\'', style ,'\'></div>\n');}return __p.join('');};
1524
- }).call(this);
1525
- (function() {
1526
- Luca.templates || (Luca.templates = {});
1527
- Luca.templates["containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'tab-selector-container\' id=\'', cid ,'-tab-selector\'>\n <ul class=\'nav nav-tabs\' id=\'', cid ,'-tabs-nav\'>\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class=\'tab-selector\' data-target=\'', i ,'\'>\n <a data-target=\'', i ,'\'>\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');};
1528
- }).call(this);
1529
- (function() {
1530
- Luca.templates || (Luca.templates = {});
1531
- Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul class=\'nav ', navClass ,'\' id=\'', cid ,'-tabs-selector\'></ul>\n<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');};
1532
- }).call(this);
1533
- (function() {
1534
- Luca.templates || (Luca.templates = {});
1535
- Luca.templates["containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-toolbar-wrapper\' id=\'', id ,'\'></div>\n');}return __p.join('');};
1536
- }).call(this);
1537
- (function() {
1538
- Luca.templates || (Luca.templates = {});
1539
- Luca.templates["fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label>&nbsp</label>\n<input class=\'btn ', input_class ,'\' id=\'', input_id ,'\' style=\'', inputStyles ,'\' type=\'', input_type ,'\' value=\'', input_value ,'\' />\n');}return __p.join('');};
1540
- }).call(this);
1541
- (function() {
1542
- Luca.templates || (Luca.templates = {});
1543
- Luca.templates["fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class=\'btn ', input_class ,'\'>\n '); if(icon_class.length) { __p.push('\n <i class=\'', icon_class ,'\'></i>\n '); } __p.push('\n ', input_value ,'\n</a>\n');}return __p.join('');};
1544
- }).call(this);
1545
- (function() {
1546
- Luca.templates || (Luca.templates = {});
1547
- Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n</div>\n');}return __p.join('');};
1548
- }).call(this);
1549
- (function() {
1550
- Luca.templates || (Luca.templates = {});
1551
- Luca.templates["fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n <input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'checkbox\' value=\'', value ,'\' />\n ', label ,'\n</label>\n');}return __p.join('');};
1552
- }).call(this);
1553
- (function() {
1554
- Luca.templates || (Luca.templates = {});
1555
- Luca.templates["fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n <input name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'checkbox\' value=\'', input_value ,'\' />\n</label>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1556
- }).call(this);
1557
- (function() {
1558
- Luca.templates || (Luca.templates = {});
1559
- Luca.templates["fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<input id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'file\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1560
- }).call(this);
1561
- (function() {
1562
- Luca.templates || (Luca.templates = {});
1563
- Luca.templates["fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'hidden\' value=\'', input_value ,'\' />\n');}return __p.join('');};
1564
- }).call(this);
1565
- (function() {
1566
- Luca.templates || (Luca.templates = {});
1567
- Luca.templates["fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<select id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></select>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1568
- }).call(this);
1569
- (function() {
1570
- Luca.templates || (Luca.templates = {});
1571
- Luca.templates["fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<textarea class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></textarea>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1572
- }).call(this);
1573
- (function() {
1574
- Luca.templates || (Luca.templates = {});
1575
- Luca.templates["fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class=\'control-label\' for=\'', input_id ,'\'>\n ', label ,'\n</label>\n'); } __p.push('\n'); if( typeof(addOn) !== "undefined" ) { __p.push('\n<span class=\'add-on\'>\n ', addOn ,'\n</span>\n'); } __p.push('\n<input class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' placeholder=\'', placeHolder ,'\' style=\'', inputStyles ,'\' type=\'text\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1576
- }).call(this);
1577
- (function() {
1578
- Luca.templates || (Luca.templates = {});
1579
- Luca.templates["sample/contents"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<p>Sample Contents</p>\n');}return __p.join('');};
1580
- }).call(this);
1581
- (function() {
1582
- Luca.templates || (Luca.templates = {});
1583
- Luca.templates["sample/welcome"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('welcome.luca\n');}return __p.join('');};
1584
- }).call(this);
1585
- (function() {
1586
- var __slice = Array.prototype.slice;
1587
-
1588
- Luca.Observer = (function() {
1589
-
1590
- function Observer(options) {
1591
- var _this = this;
1592
- this.options = options != null ? options : {};
1593
- _.extend(this, Backbone.Events);
1594
- this.type = this.options.type;
1595
- if (this.options.debugAll) {
1596
- this.bind("all", function(trigger, one, two) {
1597
- return console.log("ALL", trigger, one, two);
1598
- });
1599
- }
1600
- }
1601
-
1602
- Observer.prototype.relay = function() {
1603
- var args, triggerer;
1604
- triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1605
- console.log("Relaying", trigger, args);
1606
- this.trigger("event", triggerer, args);
1607
- return this.trigger("event:" + args[0], triggerer, args.slice(1));
1608
- };
1609
-
1610
- return Observer;
1611
-
1612
- })();
1613
-
1614
- Luca.Observer.enableObservers = function(options) {
1615
- if (options == null) options = {};
1616
- Luca.enableGlobalObserver = true;
1617
- Luca.ViewObserver = new Luca.Observer(_.extend(options, {
1618
- type: "view"
1619
- }));
1620
- return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
1621
- type: "collection"
1622
- }));
1623
- };
1624
-
1625
1655
  }).call(this);
1626
1656
  (function() {
1627
1657
 
@@ -1652,7 +1682,7 @@
1652
1682
  beforeRender: function() {
1653
1683
  if (Luca.enableBootstrap) this.$el.addClass('control-group');
1654
1684
  if (this.required) this.$el.addClass('required');
1655
- this.$el.html(Luca.templates[this.template](this));
1685
+ this.$el.html(Luca.template(this.template, this));
1656
1686
  return this.input = $('input', this.el);
1657
1687
  },
1658
1688
  change_handler: function(e) {
@@ -1665,7 +1695,19 @@
1665
1695
  return $("input", this.el).attr('disabled', false);
1666
1696
  },
1667
1697
  getValue: function() {
1668
- return this.input.attr('value');
1698
+ var raw;
1699
+ raw = this.input.attr('value');
1700
+ if (_.str.isBlank(raw)) return raw;
1701
+ switch (this.valueType) {
1702
+ case "integer":
1703
+ return parseInt(raw);
1704
+ case "string":
1705
+ return "" + raw;
1706
+ case "float":
1707
+ return parseFloat(raw);
1708
+ default:
1709
+ return raw;
1710
+ }
1669
1711
  },
1670
1712
  render: function() {
1671
1713
  return $(this.container).append(this.$el);
@@ -1766,15 +1808,17 @@
1766
1808
  }
1767
1809
  }
1768
1810
  return _(this.components).each(function(component, index) {
1769
- var container, panel, _ref2;
1770
- container = (_ref2 = _this.componentContainers) != null ? _ref2[index] : void 0;
1771
- container["class"] = container["class"] || container.className || container.classes;
1772
- if (_this.appendContainers) {
1773
- panel = _this.make(_this.componentTag, container, '');
1811
+ var ce, componentContainerElement, panel, _ref2;
1812
+ ce = componentContainerElement = (_ref2 = _this.componentContainers) != null ? _ref2[index] : void 0;
1813
+ ce["class"] = ce["class"] || ce.className || ce.classes;
1814
+ if (_this.generateComponentElements) {
1815
+ panel = _this.make(_this.componentTag, componentContainerElement, '');
1774
1816
  _this.$append(panel);
1775
1817
  }
1776
1818
  if (component.container == null) {
1777
- if (_this.appendContainers) component.container = "#" + container.id;
1819
+ if (_this.generateComponentElements) {
1820
+ component.container = "#" + componentContainerElement.id;
1821
+ }
1778
1822
  return component.container || (component.container = _this.$bodyEl());
1779
1823
  }
1780
1824
  });
@@ -1790,6 +1834,11 @@
1790
1834
  this.components = _(this.components).map(function(object, index) {
1791
1835
  var component;
1792
1836
  component = Luca.isBackboneView(object) ? object : (object.type || (object.type = object.ctype), !(object.type != null) ? object.components != null ? object.type = object.ctype = 'container' : object.type = object.ctype = Luca.defaultComponentType : void 0, Luca.util.lazyComponent(object));
1837
+ if (_.isString(component.getter)) {
1838
+ _this[component.getter] = (function() {
1839
+ return component;
1840
+ });
1841
+ }
1793
1842
  if (!component.container && component.options.container) {
1794
1843
  component.container = component.options.container;
1795
1844
  }
@@ -1804,15 +1853,16 @@
1804
1853
  return map;
1805
1854
  },
1806
1855
  renderComponents: function(debugMode) {
1807
- var _this = this;
1856
+ var container;
1808
1857
  this.debugMode = debugMode != null ? debugMode : "";
1809
1858
  this.debug("container render components");
1859
+ container = this;
1810
1860
  return _(this.components).each(function(component) {
1811
1861
  component.getParent = function() {
1812
- return _this;
1862
+ return container;
1813
1863
  };
1814
- $(component.container).append($(component.el));
1815
1864
  try {
1865
+ $(component.container).append(component.el);
1816
1866
  return component.render();
1817
1867
  } catch (e) {
1818
1868
  console.log("Error Rendering Component " + (component.name || component.cid), component);
@@ -1833,26 +1883,20 @@
1833
1883
  if (component != null) {
1834
1884
  if ((_ref = component.trigger) != null) {
1835
1885
  _ref.call(component, "first:activation", component, activator);
1836
- }
1837
- }
1838
- return component.previously_activated = true;
1839
- }
1840
- });
1841
- },
1842
- select: function(attribute, value, deep) {
1843
- var components;
1844
- if (deep == null) deep = false;
1845
- components = _(this.components).map(function(component) {
1846
- var matches, test;
1847
- matches = [];
1848
- test = component[attribute];
1849
- if (test === value) matches.push(component);
1850
- if (deep === true && component.isContainer === true) {
1851
- matches.push(component.select(attribute, value, true));
1886
+ }
1887
+ }
1888
+ return component.previously_activated = true;
1852
1889
  }
1853
- return _.compact(matches);
1854
1890
  });
1855
- return _.flatten(components);
1891
+ },
1892
+ pluck: function(attribute) {
1893
+ return _(this.components).pluck(attribute);
1894
+ },
1895
+ invoke: function(method) {
1896
+ return _(this.components).invoke(method);
1897
+ },
1898
+ map: function(fn) {
1899
+ return _(this.components).map(fn);
1856
1900
  },
1857
1901
  componentEvents: {},
1858
1902
  registerComponentEvents: function() {
@@ -1914,12 +1958,16 @@
1914
1958
  return this.components[this.activeItem];
1915
1959
  },
1916
1960
  componentElements: function() {
1917
- return $(">." + this.componentClass, this.el);
1961
+ return this.$(">." + this.componentClass, this.$bodyEl());
1918
1962
  },
1919
1963
  getComponent: function(needle) {
1920
1964
  return this.components[needle];
1921
1965
  },
1922
1966
  rootComponent: function() {
1967
+ console.log("Calling rootComponent will be deprecated. use isRootComponent instead");
1968
+ return !(this.getParent != null);
1969
+ },
1970
+ isRootComponent: function() {
1923
1971
  return !(this.getParent != null);
1924
1972
  },
1925
1973
  getRootComponent: function() {
@@ -1928,18 +1976,49 @@
1928
1976
  } else {
1929
1977
  return this.getParent().getRootComponent();
1930
1978
  }
1979
+ },
1980
+ selectByAttribute: function(attribute, value, deep) {
1981
+ var components;
1982
+ if (deep == null) deep = false;
1983
+ components = _(this.components).map(function(component) {
1984
+ var matches, test;
1985
+ matches = [];
1986
+ test = component[attribute];
1987
+ if (test === value) matches.push(component);
1988
+ if (deep === true) {
1989
+ matches.push(typeof component.selectByAttribute === "function" ? component.selectByAttribute(attribute, value, true) : void 0);
1990
+ }
1991
+ return _.compact(matches);
1992
+ });
1993
+ return _.flatten(components);
1994
+ },
1995
+ select: function(attribute, value, deep) {
1996
+ if (deep == null) deep = false;
1997
+ console.log("Container.select will be replaced by selectByAttribute in 1.0");
1998
+ return Luca.core.Container.prototype.selectByAttribute.apply(this, arguments);
1931
1999
  }
1932
2000
  });
1933
2001
 
2002
+ Luca.core.Container.componentRenderer = function(container, component) {
2003
+ var attachMethod;
2004
+ attachMethod = $(component.container)[component.attachWith || "append"];
2005
+ return attachMethod(component.render().el);
2006
+ };
2007
+
1934
2008
  }).call(this);
1935
2009
  (function() {
2010
+ var guessCollectionClass, handleInitialCollections, loadInitialCollections;
1936
2011
 
1937
2012
  Luca.CollectionManager = (function() {
1938
2013
 
1939
2014
  CollectionManager.prototype.name = "primary";
1940
2015
 
2016
+ CollectionManager.prototype.collectionNamespace = Luca.Collection.namespace;
2017
+
1941
2018
  CollectionManager.prototype.__collections = {};
1942
2019
 
2020
+ CollectionManager.prototype.relayEvents = true;
2021
+
1943
2022
  function CollectionManager(options) {
1944
2023
  var existing, manager, _base, _base2;
1945
2024
  this.options = options != null ? options : {};
@@ -1957,21 +2036,7 @@
1957
2036
  return Luca.CollectionManager.instances[name];
1958
2037
  };
1959
2038
  this.state = new Luca.Model();
1960
- if (this.initialCollections) {
1961
- this.state.set({
1962
- loaded_collections_count: 0,
1963
- collections_count: this.initialCollections.length
1964
- });
1965
- this.state.bind("change:loaded_collections_count", this.collectionCountDidChange);
1966
- if (this.useProgressLoader) {
1967
- this.loaderView || (this.loaderView = new Luca.components.CollectionLoaderView({
1968
- manager: this,
1969
- name: "collection_loader_view"
1970
- }));
1971
- }
1972
- this.loadInitialCollections();
1973
- }
1974
- this;
2039
+ if (this.initialCollections) handleInitialCollections.call(this);
1975
2040
  }
1976
2041
 
1977
2042
  CollectionManager.prototype.add = function(key, collection) {
@@ -1984,19 +2049,23 @@
1984
2049
  };
1985
2050
 
1986
2051
  CollectionManager.prototype.create = function(key, collectionOptions, initialModels) {
1987
- var CollectionClass, collection;
2052
+ var CollectionClass, collection, collectionManager;
1988
2053
  if (collectionOptions == null) collectionOptions = {};
1989
2054
  if (initialModels == null) initialModels = [];
1990
2055
  CollectionClass = collectionOptions.base;
1991
- CollectionClass || (CollectionClass = this.guessCollectionClass(key));
2056
+ CollectionClass || (CollectionClass = guessCollectionClass.call(this, key));
1992
2057
  if (collectionOptions.private) collectionOptions.name = "";
1993
2058
  collection = new CollectionClass(initialModels, collectionOptions);
1994
2059
  this.add(key, collection);
2060
+ collectionManager = this;
2061
+ if (this.relayEvents === true) {
2062
+ this.bind("*", function() {
2063
+ return console.log("Relay Events on Collection Manager *", collection, arguments);
2064
+ });
2065
+ }
1995
2066
  return collection;
1996
2067
  };
1997
2068
 
1998
- CollectionManager.prototype.collectionNamespace = Luca.Collection.namespace;
1999
-
2000
2069
  CollectionManager.prototype.currentScope = function() {
2001
2070
  var current_scope, _base;
2002
2071
  if (current_scope = this.getScope()) {
@@ -2018,43 +2087,30 @@
2018
2087
  return;
2019
2088
  };
2020
2089
 
2090
+ CollectionManager.prototype.destroy = function(key) {
2091
+ var c;
2092
+ c = this.get(key);
2093
+ delete this.currentScope()[key];
2094
+ return c;
2095
+ };
2096
+
2021
2097
  CollectionManager.prototype.getOrCreate = function(key, collectionOptions, initialModels) {
2022
2098
  if (collectionOptions == null) collectionOptions = {};
2023
2099
  if (initialModels == null) initialModels = [];
2024
2100
  return this.get(key) || this.create(key, collectionOptions, initialModels, false);
2025
2101
  };
2026
2102
 
2027
- CollectionManager.prototype.guessCollectionClass = function(key) {
2028
- var classified, guess;
2029
- classified = Luca.util.classify(key);
2030
- guess = (this.collectionNamespace || (window || global))[classified];
2031
- guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
2032
- return guess;
2033
- };
2034
-
2035
- CollectionManager.prototype.loadInitialCollections = function() {
2036
- var collectionDidLoad,
2037
- _this = this;
2038
- collectionDidLoad = function(collection) {
2039
- collection.unbind("reset");
2040
- return _this.trigger("collection_loaded", collection.name);
2041
- };
2042
- return _(this.initialCollections).each(function(name) {
2043
- var collection;
2044
- collection = _this.getOrCreate(name);
2045
- collection.bind("reset", function() {
2046
- return collectionDidLoad(collection);
2047
- });
2048
- return collection.fetch();
2049
- });
2050
- };
2051
-
2052
2103
  CollectionManager.prototype.collectionCountDidChange = function() {
2053
- if (this.totalCollectionsCount() === this.loadedCollectionsCount()) {
2054
- return this.trigger("all_collections_loaded");
2104
+ if (this.allCollectionsLoaded()) {
2105
+ this.trigger("all_collections_loaded");
2106
+ return this.trigger("initial:load");
2055
2107
  }
2056
2108
  };
2057
2109
 
2110
+ CollectionManager.prototype.allCollectionsLoaded = function() {
2111
+ return this.totalCollectionsCount() === this.loadedCollectionsCount();
2112
+ };
2113
+
2058
2114
  CollectionManager.prototype.totalCollectionsCount = function() {
2059
2115
  return this.state.get("collections_count");
2060
2116
  };
@@ -2077,6 +2133,60 @@
2077
2133
  return Luca.CollectionManager.instances = {};
2078
2134
  };
2079
2135
 
2136
+ guessCollectionClass = function(key) {
2137
+ var classified, guess, guesses, _ref;
2138
+ classified = Luca.util.classify(key);
2139
+ guess = (this.collectionNamespace || (window || global))[classified];
2140
+ guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
2141
+ if (!(guess != null) && ((_ref = Luca.Collection.namespaces) != null ? _ref.length : void 0) > 0) {
2142
+ guesses = _(Luca.Collection.namespaces.reverse()).map(function(namespace) {
2143
+ return Luca.util.resolve("" + namespace + "." + classified) || Luca.util.resolve("" + namespace + "." + classified + "Collection");
2144
+ });
2145
+ guesses = _(guesses).compact();
2146
+ if (guesses.length > 0) guess = guesses[0];
2147
+ }
2148
+ return guess;
2149
+ };
2150
+
2151
+ loadInitialCollections = function() {
2152
+ var collectionDidLoad,
2153
+ _this = this;
2154
+ collectionDidLoad = function(collection) {
2155
+ var current;
2156
+ current = _this.state.get("loaded_collections_count");
2157
+ _this.state.set("loaded_collections_count", current + 1);
2158
+ _this.trigger("collection_loaded", collection.name);
2159
+ return collection.unbind("reset");
2160
+ };
2161
+ return _(this.initialCollections).each(function(name) {
2162
+ var collection;
2163
+ collection = _this.getOrCreate(name);
2164
+ collection.once("reset", function() {
2165
+ return collectionDidLoad(collection);
2166
+ });
2167
+ return collection.fetch();
2168
+ });
2169
+ };
2170
+
2171
+ handleInitialCollections = function() {
2172
+ var _this = this;
2173
+ this.state.set({
2174
+ loaded_collections_count: 0,
2175
+ collections_count: this.initialCollections.length
2176
+ });
2177
+ this.state.bind("change:loaded_collections_count", function() {
2178
+ return _this.collectionCountDidChange();
2179
+ });
2180
+ if (this.useProgressLoader) {
2181
+ this.loaderView || (this.loaderView = new Luca.components.CollectionLoaderView({
2182
+ manager: this,
2183
+ name: "collection_loader_view"
2184
+ }));
2185
+ }
2186
+ loadInitialCollections.call(this);
2187
+ return this;
2188
+ };
2189
+
2080
2190
  }).call(this);
2081
2191
  (function() {
2082
2192
 
@@ -2148,12 +2258,13 @@
2148
2258
  components: [],
2149
2259
  initialize: function(options) {
2150
2260
  this.options = options != null ? options : {};
2261
+ console.log("Column Views are deprecated in favor of just using grid css on a normal container");
2151
2262
  Luca.core.Container.prototype.initialize.apply(this, arguments);
2152
2263
  return this.setColumnWidths();
2153
2264
  },
2154
2265
  componentClass: 'luca-ui-column',
2155
2266
  containerTemplate: "containers/basic",
2156
- appendContainers: true,
2267
+ generateComponentElements: true,
2157
2268
  autoColumnWidths: function() {
2158
2269
  var widths,
2159
2270
  _this = this;
@@ -2193,7 +2304,7 @@
2193
2304
  components: [],
2194
2305
  hooks: ['before:card:switch', 'after:card:switch'],
2195
2306
  componentClass: 'luca-ui-card',
2196
- appendContainers: true,
2307
+ generateComponentElements: true,
2197
2308
  initialize: function(options) {
2198
2309
  this.options = options;
2199
2310
  Luca.core.Container.prototype.initialize.apply(this, arguments);
@@ -2235,7 +2346,8 @@
2235
2346
  return this.activeComponent().trigger("first:activation", this, this.activeComponent());
2236
2347
  },
2237
2348
  activate: function(index, silent, callback) {
2238
- var current, previous, _ref, _ref2, _ref3, _ref4;
2349
+ var current, previous, _ref, _ref2, _ref3, _ref4,
2350
+ _this = this;
2239
2351
  if (silent == null) silent = false;
2240
2352
  if (_.isFunction(silent)) {
2241
2353
  silent = false;
@@ -2261,6 +2373,9 @@
2261
2373
  _ref2.apply(previous, ["before:activation", this, previous, current]);
2262
2374
  }
2263
2375
  }
2376
+ _.defer(function() {
2377
+ return _this.$el.data(_this.activeAttribute || "active-card", current.name);
2378
+ });
2264
2379
  }
2265
2380
  this.componentElements().hide();
2266
2381
  if (!current.previously_activated) {
@@ -2287,10 +2402,11 @@
2287
2402
  }).call(this);
2288
2403
  (function() {
2289
2404
 
2290
- _.def("Luca.ModalView")["extends"]("Luca.View")["with"]({
2405
+ _.def("Luca.ModalView")["extends"]("Luca.core.Container")["with"]({
2291
2406
  closeOnEscape: true,
2292
2407
  showOnInitialize: false,
2293
2408
  backdrop: false,
2409
+ className: "luca-ui-container modal",
2294
2410
  container: function() {
2295
2411
  return $('body');
2296
2412
  },
@@ -2307,16 +2423,24 @@
2307
2423
  this.$el.addClass('modal');
2308
2424
  if (this.fade === true) this.$el.addClass('fade');
2309
2425
  $('body').append(this.$el);
2310
- return this.$el.modal({
2426
+ this.$el.modal({
2311
2427
  backdrop: this.backdrop === true,
2312
2428
  keyboard: this.closeOnEscape === true,
2313
2429
  show: this.showOnInitialize === true
2314
2430
  });
2431
+ return this;
2315
2432
  }
2316
2433
  });
2317
2434
 
2318
2435
  _.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]();
2319
2436
 
2437
+ }).call(this);
2438
+ (function() {
2439
+
2440
+ _.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({
2441
+ version: 2
2442
+ });
2443
+
2320
2444
  }).call(this);
2321
2445
  (function() {
2322
2446
  var buildButton, make, prepareButtons;
@@ -2442,9 +2566,6 @@
2442
2566
  return _(elements).each(function(element) {
2443
2567
  return _this.$el.append(element);
2444
2568
  });
2445
- },
2446
- afterRender: function() {
2447
- return this._super("afterRender", this, arguments);
2448
2569
  }
2449
2570
  });
2450
2571
 
@@ -2577,19 +2698,31 @@
2577
2698
 
2578
2699
  _.def('Luca.containers.Viewport').extend('Luca.containers.CardView')["with"]({
2579
2700
  activeItem: 0,
2580
- className: 'luca-ui-viewport',
2701
+ additionalClassNames: 'luca-ui-viewport',
2581
2702
  fullscreen: true,
2582
2703
  fluid: false,
2583
- wrapperClass: 'row',
2584
2704
  initialize: function(options) {
2585
2705
  this.options = options != null ? options : {};
2586
2706
  _.extend(this, this.options);
2587
2707
  if (Luca.enableBootstrap === true) {
2588
- if (this.fluid === true) this.wrapperClass = "row-fluid";
2589
- this.$wrap(this.wrapperClass);
2708
+ this.wrapperClass = this.fluid === true ? Luca.containers.Viewport.fluidWrapperClass : Luca.containers.Viewport.defaultWrapperClass;
2590
2709
  }
2591
2710
  Luca.core.Container.prototype.initialize.apply(this, arguments);
2592
- if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
2711
+ if (this.fullscreen === true) return this.enableFullscreen();
2712
+ },
2713
+ enableFluid: function() {
2714
+ return this.$el.parent().addClass(this.wrapperClass);
2715
+ },
2716
+ disableFluid: function() {
2717
+ return this.$el.parent().removeClass(this.wrapperClass);
2718
+ },
2719
+ enableFullscreen: function() {
2720
+ $('html,body').addClass('luca-ui-fullscreen');
2721
+ return this.$el.addClass('fullscreen-enabled');
2722
+ },
2723
+ disableFullscreen: function() {
2724
+ $('html,body').removeClass('luca-ui-fullscreen');
2725
+ return this.$el.removeClass('fullscreen-enabled');
2593
2726
  },
2594
2727
  beforeRender: function() {
2595
2728
  var _ref;
@@ -2599,13 +2732,19 @@
2599
2732
  if (this.topNav != null) this.renderTopNavigation();
2600
2733
  if (this.bottomNav != null) return this.renderBottomNavigation();
2601
2734
  },
2735
+ height: function() {
2736
+ return this.$el.height();
2737
+ },
2738
+ width: function() {
2739
+ return this.$el.width();
2740
+ },
2602
2741
  afterRender: function() {
2603
2742
  var _ref;
2604
2743
  if ((_ref = Luca.containers.CardView.prototype.after) != null) {
2605
2744
  _ref.apply(this, arguments);
2606
2745
  }
2607
- if (Luca.enableBootstrap === true) {
2608
- return this.$el.children().wrap('<div class="container" />');
2746
+ if (Luca.enableBootstrap === true && this.containerClassName) {
2747
+ return this.$el.children().wrap('<div class="#{ containerClassName }" />');
2609
2748
  }
2610
2749
  },
2611
2750
  renderTopNavigation: function() {
@@ -2626,6 +2765,15 @@
2626
2765
  renderBottomNavigation: function() {}
2627
2766
  });
2628
2767
 
2768
+ Luca.containers.Viewport.defaultWrapperClass = 'row';
2769
+
2770
+ Luca.containers.Viewport.fluidWrapperClass = 'row-fluid';
2771
+
2772
+ }).call(this);
2773
+ (function() {
2774
+
2775
+
2776
+
2629
2777
  }).call(this);
2630
2778
  (function() {
2631
2779
 
@@ -2644,13 +2792,24 @@
2644
2792
 
2645
2793
  }).call(this);
2646
2794
  (function() {
2795
+ var startHistory;
2796
+
2797
+ startHistory = function() {
2798
+ return Backbone.history.start();
2799
+ };
2647
2800
 
2648
2801
  _.def('Luca.Application')["extends"]('Luca.containers.Viewport')["with"]({
2649
- autoStartHistory: true,
2802
+ name: "MyApp",
2803
+ defaultState: {},
2804
+ autoBoot: false,
2805
+ autoStartHistory: "before:render",
2650
2806
  useCollectionManager: true,
2807
+ collectionManager: {},
2651
2808
  collectionManagerClass: "Luca.CollectionManager",
2652
2809
  plugin: false,
2653
2810
  useController: true,
2811
+ useKeyHandler: false,
2812
+ keyEvents: {},
2654
2813
  components: [
2655
2814
  {
2656
2815
  ctype: 'template',
@@ -2660,37 +2819,43 @@
2660
2819
  }
2661
2820
  ],
2662
2821
  initialize: function(options) {
2663
- var definedComponents, _base,
2822
+ var alreadyRunning, app, appName, _base,
2664
2823
  _this = this;
2665
2824
  this.options = options != null ? options : {};
2825
+ app = this;
2826
+ appName = this.name;
2827
+ alreadyRunning = typeof Luca.getApplication === "function" ? Luca.getApplication() : void 0;
2828
+ (_base = Luca.Application).instances || (_base.instances = {});
2829
+ Luca.Application.instances[appName] = app;
2666
2830
  Luca.containers.Viewport.prototype.initialize.apply(this, arguments);
2667
- if (this.useController === true) definedComponents = this.components || [];
2668
- this.components = [
2669
- {
2670
- ctype: 'controller',
2671
- name: "main_controller",
2672
- components: definedComponents
2673
- }
2674
- ];
2675
- if (this.useCollectionManager === true) {
2676
- if (_.isString(this.collectionManagerClass)) {
2677
- this.collectionManagerClass = Luca.util.resolve(this.collectionManagerClass);
2678
- }
2679
- this.collectionManager || (this.collectionManager = typeof (_base = Luca.CollectionManager).get === "function" ? _base.get() : void 0);
2680
- this.collectionManager || (this.collectionManager = new this.collectionManagerClass(this.collectionManagerOptions || (this.collectionManagerOptions = {})));
2681
- }
2682
2831
  this.state = new Luca.Model(this.defaultState);
2832
+ this.setupMainController();
2833
+ this.setupCollectionManager();
2683
2834
  this.defer(function() {
2684
- return _this.render();
2685
- }).until("ready");
2686
- if (this.useKeyRouter === true && (this.keyEvents != null)) {
2687
- this.setupKeyRouter();
2688
- }
2689
- if (this.plugin !== true) {
2690
- return Luca.getApplication = function() {
2691
- return _this;
2835
+ return app.render();
2836
+ }).until(this, "ready");
2837
+ this.setupRouter();
2838
+ if (this.useKeyRouter === true) {
2839
+ console.log("The useKeyRouter property is being deprecated. switch to useKeyHandler instead");
2840
+ }
2841
+ if ((this.useKeyHandler === true || this.useKeyRouter === true) && (this.keyEvents != null)) {
2842
+ this.setupKeyHandler();
2843
+ }
2844
+ if (!(this.plugin === true || alreadyRunning)) {
2845
+ Luca.getApplication = function(name) {
2846
+ if (name == null) return app;
2847
+ return Luca.Application.instances[name];
2692
2848
  };
2693
2849
  }
2850
+ if (this.autoBoot) {
2851
+ if (Luca.util.resolve(this.name)) {
2852
+ throw "Attempting to override window." + this.name + " when it already exists";
2853
+ }
2854
+ return $(function() {
2855
+ window[appName] = app;
2856
+ return app.boot();
2857
+ });
2858
+ }
2694
2859
  },
2695
2860
  activeView: function() {
2696
2861
  var active;
@@ -2700,50 +2865,17 @@
2700
2865
  return this.view(this.activeSection());
2701
2866
  }
2702
2867
  },
2703
- activeSubSection: function() {
2704
- return this.get("active_sub_section");
2705
- },
2706
2868
  activeSection: function() {
2707
2869
  return this.get("active_section");
2708
2870
  },
2709
- beforeRender: function() {
2710
- var routerStartEvent, _ref;
2711
- if ((_ref = Luca.containers.Viewport.prototype.beforeRender) != null) {
2712
- _ref.apply(this, arguments);
2713
- }
2714
- if ((this.router != null) && this.autoStartHistory === true) {
2715
- routerStartEvent = this.startRouterOn || "after:render";
2716
- if (routerStartEvent === "before:render") {
2717
- return Backbone.history.start();
2718
- } else {
2719
- return this.bind(routerStartEvent, function() {
2720
- return Backbone.history.start();
2721
- });
2722
- }
2723
- }
2871
+ activeSubSection: function() {
2872
+ return this.get("active_sub_section");
2724
2873
  },
2725
- afterComponents: function() {
2726
- var _ref, _ref2, _ref3,
2727
- _this = this;
2728
- if ((_ref = Luca.containers.Viewport.prototype.afterComponents) != null) {
2729
- _ref.apply(this, arguments);
2730
- }
2731
- if ((_ref2 = this.getMainController()) != null) {
2732
- _ref2.bind("after:card:switch", function(previous, current) {
2733
- return _this.state.set({
2734
- active_section: current.name
2735
- });
2736
- });
2737
- }
2738
- return (_ref3 = this.getMainController()) != null ? _ref3.each(function(component) {
2739
- if (component.ctype.match(/controller$/)) {
2740
- return component.bind("after:card:switch", function(previous, current) {
2741
- return _this.state.set({
2742
- active_sub_section: current.name
2743
- });
2744
- });
2745
- }
2746
- }) : void 0;
2874
+ activePages: function() {
2875
+ var _this = this;
2876
+ return this.$('.luca-ui-controller').map(function(index, element) {
2877
+ return $(element).data('active-section');
2878
+ });
2747
2879
  },
2748
2880
  boot: function() {
2749
2881
  return this.trigger("ready");
@@ -2754,12 +2886,8 @@
2754
2886
  get: function(attribute) {
2755
2887
  return this.state.get(attribute);
2756
2888
  },
2757
- getMainController: function() {
2758
- if (this.useController === true) return this.components[0];
2759
- return Luca.cache('main_controller');
2760
- },
2761
- set: function(attributes) {
2762
- return this.state.set(attributes);
2889
+ set: function(attribute, value, options) {
2890
+ return this.state.set.apply(this.state, arguments);
2763
2891
  },
2764
2892
  view: function(name) {
2765
2893
  return Luca.cache(name);
@@ -2767,17 +2895,11 @@
2767
2895
  navigate_to: function(component_name, callback) {
2768
2896
  return this.getMainController().navigate_to(component_name, callback);
2769
2897
  },
2770
- setupKeyRouter: function() {
2771
- var router, _base;
2772
- if (!this.keyEvents) return;
2773
- (_base = this.keyEvents).control_meta || (_base.control_meta = {});
2774
- if (this.keyEvents.meta_control) {
2775
- _.extend(this.keyEvents.control_meta, this.keyEvents.meta_control);
2776
- }
2777
- router = _.bind(this.keyRouter, this);
2778
- return $(document).keydown(router);
2898
+ getMainController: function() {
2899
+ if (this.useController === true) return this.components[0];
2900
+ return Luca.cache('main_controller');
2779
2901
  },
2780
- keyRouter: function(e) {
2902
+ keyHandler: function(e) {
2781
2903
  var control, isInputEvent, keyEvent, keyname, meta, source, _ref;
2782
2904
  if (!(e && this.keyEvents)) return;
2783
2905
  isInputEvent = $(e.target).is('input') || $(e.target).is('textarea');
@@ -2791,12 +2913,103 @@
2791
2913
  source = control ? this.keyEvents.control : source;
2792
2914
  source = meta && control ? this.keyEvents.meta_control : source;
2793
2915
  if (keyEvent = source != null ? source[keyname] : void 0) {
2794
- if (this[keyEvent] != null) {
2916
+ if ((this[keyEvent] != null) && _.isFunction(this[keyEvent])) {
2795
2917
  return (_ref = this[keyEvent]) != null ? _ref.call(this) : void 0;
2796
2918
  } else {
2797
- return this.trigger(keyEvent);
2919
+ return this.trigger(keyEvent, e, keyname);
2920
+ }
2921
+ }
2922
+ },
2923
+ setupControllerBindings: function() {
2924
+ var app, _ref, _ref2,
2925
+ _this = this;
2926
+ app = this;
2927
+ if ((_ref = this.getMainController()) != null) {
2928
+ _ref.bind("after:card:switch", function(previous, current) {
2929
+ _this.state.set({
2930
+ active_section: current.name
2931
+ });
2932
+ return app.trigger("page:change");
2933
+ });
2934
+ }
2935
+ return (_ref2 = this.getMainController()) != null ? _ref2.each(function(component) {
2936
+ if (component.ctype.match(/controller$/)) {
2937
+ return component.bind("after:card:switch", function(previous, current) {
2938
+ _this.state.set({
2939
+ active_sub_section: current.name
2940
+ });
2941
+ return app.trigger("sub:page:change");
2942
+ });
2943
+ }
2944
+ }) : void 0;
2945
+ },
2946
+ setupMainController: function() {
2947
+ var definedComponents;
2948
+ if (this.useController === true) {
2949
+ definedComponents = this.components || [];
2950
+ this.components = [
2951
+ {
2952
+ ctype: 'controller',
2953
+ name: "main_controller",
2954
+ components: definedComponents
2955
+ }
2956
+ ];
2957
+ return this.defer(this.setupControllerBindings, false).until("after:components");
2958
+ }
2959
+ },
2960
+ setupCollectionManager: function() {
2961
+ var collectionManagerOptions, _base, _ref, _ref2;
2962
+ if (this.useCollectionManager === true) {
2963
+ if (_.isString(this.collectionManagerClass)) {
2964
+ this.collectionManagerClass = Luca.util.resolve(this.collectionManagerClass);
2965
+ }
2966
+ collectionManagerOptions = this.collectionManagerOptions;
2967
+ if (_.isObject(this.collectionManager) && !_.isFunction((_ref = this.collectionManager) != null ? _ref.get : void 0)) {
2968
+ collectionManagerOptions = this.collectionManager;
2969
+ this.collectionManager = void 0;
2970
+ }
2971
+ if (_.isString(this.collectionManager)) {
2972
+ collectionManagerOptions = {
2973
+ name: this.collectionManager
2974
+ };
2975
+ }
2976
+ this.collectionManager = typeof (_base = Luca.CollectionManager).get === "function" ? _base.get(collectionManagerOptions.name) : void 0;
2977
+ if (!_.isFunction((_ref2 = this.collectionManager) != null ? _ref2.get : void 0)) {
2978
+ return this.collectionManager = new this.collectionManagerClass(collectionManagerOptions);
2979
+ }
2980
+ }
2981
+ },
2982
+ setupRouter: function() {
2983
+ var app, routerClass;
2984
+ app = this;
2985
+ if (_.isString(this.router)) {
2986
+ routerClass = Luca.util.resolve(this.router);
2987
+ this.router = new routerClass({
2988
+ app: app
2989
+ });
2990
+ }
2991
+ if (this.router && this.autoStartHistory) {
2992
+ if (this.autoStartHistory === true) {
2993
+ this.autoStartHistory = "before:render";
2798
2994
  }
2995
+ return this.defer(startHistory, false).until(this, this.autoStartHistory);
2996
+ }
2997
+ },
2998
+ setupKeyHandler: function() {
2999
+ var handler, keyEvent, _base, _i, _len, _ref, _results;
3000
+ if (!this.keyEvents) return;
3001
+ (_base = this.keyEvents).control_meta || (_base.control_meta = {});
3002
+ if (this.keyEvents.meta_control) {
3003
+ _.extend(this.keyEvents.control_meta, this.keyEvents.meta_control);
3004
+ }
3005
+ handler = _.bind(this.keyHandler, this);
3006
+ _ref = this.keypressEvents || ["keydown"];
3007
+ _results = [];
3008
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
3009
+ keyEvent = _ref[_i];
3010
+ _results.push($(document).on(keyEvent, handler));
2799
3011
  }
3012
+ return _results;
2800
3013
  }
2801
3014
  });
2802
3015
 
@@ -2804,7 +3017,7 @@
2804
3017
  (function() {
2805
3018
 
2806
3019
  _.def('Luca.components.Toolbar')["extends"]('Luca.core.Container')["with"]({
2807
- className: 'luca-ui-toolbar',
3020
+ className: 'luca-ui-toolbar toolbar',
2808
3021
  position: 'bottom',
2809
3022
  initialize: function(options) {
2810
3023
  this.options = options != null ? options : {};
@@ -2861,8 +3074,6 @@
2861
3074
  (function() {
2862
3075
  var make;
2863
3076
 
2864
- make = Luca.View.prototype.make;
2865
-
2866
3077
  _.def("Luca.components.CollectionView")["extends"]("Luca.components.Panel")["with"]({
2867
3078
  tagName: "div",
2868
3079
  className: "luca-ui-collection-view",
@@ -2871,7 +3082,9 @@
2871
3082
  itemRenderer: void 0,
2872
3083
  itemTagName: 'li',
2873
3084
  itemClassName: 'collection-item',
3085
+ hooks: ["empty:results"],
2874
3086
  initialize: function(options) {
3087
+ var _this = this;
2875
3088
  this.options = options != null ? options : {};
2876
3089
  _.extend(this, this.options);
2877
3090
  _.bindAll(this, "refresh");
@@ -2883,13 +3096,22 @@
2883
3096
  }
2884
3097
  Luca.components.Panel.prototype.initialize.apply(this, arguments);
2885
3098
  if (_.isString(this.collection) && Luca.CollectionManager.get()) {
2886
- this.collection = Luca.CollectionManager.get().get(this.collection);
3099
+ this.collection = Luca.CollectionManager.get().getOrCreate(this.collection);
2887
3100
  }
2888
3101
  if (Luca.isBackboneCollection(this.collection)) {
2889
- this.collection.bind("reset", this.refresh);
3102
+ this.collection.on("before:fetch", function() {
3103
+ if (_this.loadMask === true) return _this.trigger("enable:loadmask");
3104
+ });
3105
+ this.collection.bind("reset", function() {
3106
+ if (_this.loadMask === true) _this.trigger("disable:loadmask");
3107
+ return _this.refresh();
3108
+ });
2890
3109
  this.collection.bind("add", this.refresh);
2891
- return this.collection.bind("remove", this.refresh);
3110
+ this.collection.bind("remove", this.refresh);
3111
+ } else {
3112
+ throw "Collection Views must have a valid backbone collection";
2892
3113
  }
3114
+ if (this.collection.length > 0) return this.refresh();
2893
3115
  },
2894
3116
  attributesForItem: function(item) {
2895
3117
  return _.extend({}, {
@@ -2904,7 +3126,7 @@
2904
3126
  content = templateFn.call(this, item);
2905
3127
  }
2906
3128
  if ((this.itemRenderer != null) && _.isFunction(this.itemRenderer)) {
2907
- content = this.itemRenderer.call(this, item);
3129
+ content = this.itemRenderer.call(this, item, item.model, item.index);
2908
3130
  }
2909
3131
  if (this.itemProperty) {
2910
3132
  content = item.model.get(this.itemProperty) || item.model[this.itemProperty];
@@ -2929,11 +3151,11 @@
2929
3151
  }
2930
3152
  },
2931
3153
  refresh: function() {
2932
- var panel;
2933
- panel = this;
3154
+ var _this = this;
2934
3155
  this.$bodyEl().empty();
3156
+ if (this.getModels().length === 0) this.trigger("empty:results");
2935
3157
  return _(this.getModels()).each(function(model, index) {
2936
- return panel.$append(panel.makeItem(model, index));
3158
+ return _this.$append(_this.makeItem(model, index));
2937
3159
  });
2938
3160
  },
2939
3161
  registerEvent: function(domEvent, selector, handler) {
@@ -2947,16 +3169,19 @@
2947
3169
  },
2948
3170
  render: function() {
2949
3171
  this.refresh();
2950
- if (this.$el.parent().length > 0 && (this.container != null)) {
2951
- return this.$attach();
2952
- }
3172
+ if (this.$el.parent().length > 0 && (this.container != null)) this.$attach();
3173
+ return this;
2953
3174
  }
2954
3175
  });
2955
3176
 
3177
+ make = Luca.View.prototype.make;
3178
+
2956
3179
  }).call(this);
2957
3180
  (function() {
2958
3181
 
2959
3182
  _.def('Luca.components.Controller')["extends"]('Luca.containers.CardView')["with"]({
3183
+ additionalClassNames: ['luca-ui-controller'],
3184
+ activeAttribute: "active-section",
2960
3185
  initialize: function(options) {
2961
3186
  var _ref;
2962
3187
  this.options = options;
@@ -2975,6 +3200,27 @@
2975
3200
  return fn.apply(_this, [component]);
2976
3201
  });
2977
3202
  },
3203
+ activeSection: function() {
3204
+ return this.get("activeSection");
3205
+ },
3206
+ controllers: function(deep) {
3207
+ if (deep == null) deep = false;
3208
+ return this.select('ctype', 'controller', deep);
3209
+ },
3210
+ availableSections: function() {
3211
+ var base,
3212
+ _this = this;
3213
+ base = {};
3214
+ base[this.name] = this.sectionNames();
3215
+ return _(this.controllers()).reduce(function(memo, controller) {
3216
+ memo[controller.name] = controller.sectionNames();
3217
+ return memo;
3218
+ }, base);
3219
+ },
3220
+ sectionNames: function(deep) {
3221
+ if (deep == null) deep = false;
3222
+ return this.pluck('name');
3223
+ },
2978
3224
  "default": function(callback) {
2979
3225
  return this.navigate_to(this.defaultCard, callback);
2980
3226
  },
@@ -3169,20 +3415,20 @@
3169
3415
  events: {
3170
3416
  "change input": "change_handler"
3171
3417
  },
3418
+ className: 'luca-ui-checkbox-field luca-ui-field',
3419
+ template: 'fields/checkbox_field',
3420
+ hooks: ["checked", "unchecked"],
3421
+ send_blanks: true,
3172
3422
  change_handler: function(e) {
3173
3423
  var me, my;
3174
- me = my = $(e.currentTarget);
3175
- this.trigger("on:change", this, e);
3176
- if (me.checked === true) {
3177
- return this.trigger("checked");
3424
+ me = my = $(e.target);
3425
+ if (me.is(":checked")) {
3426
+ this.trigger("checked");
3178
3427
  } else {
3179
- return this.trigger("unchecked");
3428
+ this.trigger("unchecked");
3180
3429
  }
3430
+ return this.trigger("on:change", this, e, me.is(":checked"));
3181
3431
  },
3182
- className: 'luca-ui-checkbox-field luca-ui-field',
3183
- template: 'fields/checkbox_field',
3184
- hooks: ["checked", "unchecked"],
3185
- send_blanks: true,
3186
3432
  initialize: function(options) {
3187
3433
  this.options = options != null ? options : {};
3188
3434
  _.extend(this, this.options);
@@ -3199,7 +3445,7 @@
3199
3445
  return this.input.attr('checked', checked);
3200
3446
  },
3201
3447
  getValue: function() {
3202
- return this.input.attr('checked') === true;
3448
+ return this.input.is(":checked");
3203
3449
  }
3204
3450
  });
3205
3451
 
@@ -3237,6 +3483,25 @@
3237
3483
  }
3238
3484
  });
3239
3485
 
3486
+ }).call(this);
3487
+ (function() {
3488
+
3489
+ _.def("Luca.components.LabelField")["extends"]("Luca.core.Field")["with"]({
3490
+ className: "luca-ui-field luca-ui-label-field",
3491
+ getValue: function() {
3492
+ return this.$('input').attr('value');
3493
+ },
3494
+ formatter: function(value) {
3495
+ value || (value = this.getValue());
3496
+ return _.str.titleize(value);
3497
+ },
3498
+ setValue: function(value) {
3499
+ this.trigger("change", value, this.getValue());
3500
+ this.$('input').attr('value', value);
3501
+ return this.$('.value').html(this.formatter(value));
3502
+ }
3503
+ });
3504
+
3240
3505
  }).call(this);
3241
3506
  (function() {
3242
3507
 
@@ -3283,7 +3548,7 @@
3283
3548
  if (!_.isArray(record)) return record;
3284
3549
  hash = {};
3285
3550
  hash[_this.valueField] = record[0];
3286
- hash[_this.displayField] = record[1];
3551
+ hash[_this.displayField] = record[1] || record[0];
3287
3552
  return hash;
3288
3553
  });
3289
3554
  },
@@ -3378,11 +3643,6 @@
3378
3643
 
3379
3644
  }).call(this);
3380
3645
  (function() {
3381
- var change_handler;
3382
-
3383
- change_handler = function(e) {
3384
- return this.trigger("on:change", this, e);
3385
- };
3386
3646
 
3387
3647
  _.def('Luca.fields.TextField')["extends"]('Luca.core.Field')["with"]({
3388
3648
  events: {
@@ -3393,9 +3653,10 @@
3393
3653
  template: 'fields/text_field',
3394
3654
  autoBindEventHandlers: true,
3395
3655
  send_blanks: true,
3656
+ keyEventThrottle: 300,
3396
3657
  initialize: function(options) {
3397
3658
  this.options = options != null ? options : {};
3398
- Luca.core.Field.prototype.initialize.apply(this, arguments);
3659
+ if (this.enableKeyEvents) this.registerEvent("keyup input", "keyup_handler");
3399
3660
  this.input_id || (this.input_id = _.uniqueId('field'));
3400
3661
  this.input_name || (this.input_name = this.name);
3401
3662
  this.label || (this.label = this.name);
@@ -3408,22 +3669,20 @@
3408
3669
  this.$el.addClass('input-append');
3409
3670
  this.addOn = this.append;
3410
3671
  }
3411
- if (this.enableKeyEvents) {
3412
- return this.registerEvent("keydown input", "keydown_handler");
3413
- }
3672
+ return Luca.core.Field.prototype.initialize.apply(this, arguments);
3673
+ },
3674
+ keyup_handler: function(e) {
3675
+ return this.trigger("on:keyup", this, e);
3414
3676
  },
3415
3677
  blur_handler: function(e) {
3416
- var me, my;
3417
- return me = my = $(e.currentTarget);
3678
+ return this.trigger("on:blur", this, e);
3418
3679
  },
3419
3680
  focus_handler: function(e) {
3420
- var me, my;
3421
- return me = my = $(e.currentTarget);
3681
+ return this.trigger("on:focus", this, e);
3422
3682
  },
3423
- change_handler: change_handler,
3424
- keydown_handler: _.throttle((function(e) {
3425
- return change_handler.apply(this, arguments);
3426
- }), 300)
3683
+ change_handler: function(e) {
3684
+ return this.trigger("on:change", this, e);
3685
+ }
3427
3686
  });
3428
3687
 
3429
3688
  }).call(this);
@@ -3432,6 +3691,7 @@
3432
3691
  _.def('Luca.fields.TypeAheadField')["extends"]('Luca.fields.TextField')["with"]({
3433
3692
  className: 'luca-ui-field',
3434
3693
  getSource: function() {
3694
+ if (_.isFunction(this.source)) return this.source.call(this);
3435
3695
  return this.source || [];
3436
3696
  },
3437
3697
  matcher: function(item) {
@@ -3515,6 +3775,7 @@
3515
3775
  toolbar: true,
3516
3776
  legend: "",
3517
3777
  bodyClassName: "form-view-body",
3778
+ version: "0.9.33333333",
3518
3779
  initialize: function(options) {
3519
3780
  this.options = options != null ? options : {};
3520
3781
  if (this.loadMask == null) this.loadMask = Luca.enableBootstrap;
@@ -3580,17 +3841,22 @@
3580
3841
  return _(this.getFields()).map(iterator);
3581
3842
  },
3582
3843
  getField: function(name) {
3583
- return _(this.getFields('name', name)).first();
3844
+ var passOne;
3845
+ passOne = _(this.getFields('name', name)).first();
3846
+ if (passOne != null) return passOne;
3847
+ return _(this.getFields('input_name', name)).first();
3584
3848
  },
3585
3849
  getFields: function(attr, value) {
3586
3850
  var fields;
3587
- fields = this.select("isField", true, true);
3588
- if (!(attr && value)) return fields;
3589
- _(fields).select(function(field) {
3590
- var property;
3591
- property = field[attr];
3592
- return (property != null) && value === (_.isFunction(property) ? property() : property);
3593
- });
3851
+ fields = this.selectByAttribute("isField", true, true);
3852
+ if ((attr != null) && (value != null)) {
3853
+ fields = _(fields).select(function(field) {
3854
+ var property;
3855
+ property = field[attr];
3856
+ if (_.isFunction(property)) property = property.call(field);
3857
+ return property === value;
3858
+ });
3859
+ }
3594
3860
  return fields;
3595
3861
  },
3596
3862
  loadModel: function(current_model) {
@@ -3646,22 +3912,32 @@
3646
3912
  if ((options.silent != null) !== true) return this.syncFormWithModel();
3647
3913
  },
3648
3914
  getValues: function(options) {
3915
+ var values,
3916
+ _this = this;
3649
3917
  if (options == null) options = {};
3650
3918
  if (options.reject_blank == null) options.reject_blank = true;
3651
3919
  if (options.skip_buttons == null) options.skip_buttons = true;
3652
- return _(this.getFields()).inject(function(memo, field) {
3653
- var key, skip, value;
3920
+ if (options.blanks === false) options.reject_blank = true;
3921
+ values = _(this.getFields()).inject(function(memo, field) {
3922
+ var allowBlankValues, key, skip, value, valueIsBlank;
3654
3923
  value = field.getValue();
3655
3924
  key = field.input_name || field.name;
3656
- skip = false;
3657
- if (options.skip_buttons && field.ctype === "button_field") skip = true;
3658
- if (_.string.isBlank(value)) {
3659
- if (options.reject_blank && !field.send_blanks) skip = true;
3660
- if (field.input_name === "id") skip = true;
3925
+ valueIsBlank = !!(_.str.isBlank(value) || _.isUndefined(value));
3926
+ allowBlankValues = !options.reject_blank && !field.send_blanks;
3927
+ if (options.debug) {
3928
+ console.log("" + key + " Options", options, "Value", value, "Value Is Blank?", valueIsBlank, "Allow Blanks?", allowBlankValues);
3929
+ }
3930
+ if (options.skip_buttons && field.ctype === "button_field") {
3931
+ skip = true;
3932
+ } else {
3933
+ if (valueIsBlank && allowBlankValues === false) skip = true;
3934
+ if (field.input_name === "id" && valueIsBlank === true) skip = true;
3661
3935
  }
3936
+ if (options.debug) console.log("Skip is true on " + key);
3662
3937
  if (skip !== true) memo[key] = value;
3663
3938
  return memo;
3664
- }, {});
3939
+ }, options.defaults || {});
3940
+ return values;
3665
3941
  },
3666
3942
  submit_success_handler: function(model, response, xhr) {
3667
3943
  this.trigger("after:submit", this, model, response);
@@ -4009,6 +4285,13 @@
4009
4285
  }
4010
4286
  });
4011
4287
 
4288
+ }).call(this);
4289
+ (function() {
4290
+
4291
+ _.def("Luca.PageController")["extends"]("Luca.components.Controller")["with"]({
4292
+ version: 2
4293
+ });
4294
+
4012
4295
  }).call(this);
4013
4296
  (function() {
4014
4297
 
@@ -4286,12 +4569,6 @@
4286
4569
  }).call(this);
4287
4570
  (function() {
4288
4571
 
4289
- _.extend(Luca, Luca.Events);
4290
-
4291
- _.extend(Luca.View.prototype, Luca.Events);
4292
-
4293
- _.extend(Luca.Collection.prototype, Luca.Events);
4294
4572
 
4295
- _.extend(Luca.Model.prototype, Luca.Events);
4296
4573
 
4297
4574
  }).call(this);