luca 0.8.06 → 0.8.59

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 (51) hide show
  1. data/CHANGELOG +32 -1
  2. data/Guardfile +14 -9
  3. data/app.rb +1 -0
  4. data/assets/javascripts/sandbox/config.coffee +1 -1
  5. data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +6 -0
  6. data/lib/luca/rails/version.rb +1 -1
  7. data/spec/framework_spec.coffee +33 -1
  8. data/src/components/application.coffee +1 -3
  9. data/src/components/base_toolbar.coffee +5 -6
  10. data/src/components/collection_inspector.coffee +2 -0
  11. data/src/components/collection_loader_view.coffee +7 -6
  12. data/src/components/controller.coffee +3 -1
  13. data/src/components/development_console.coffee +7 -4
  14. data/src/components/fields/button_field.coffee +2 -5
  15. data/src/components/fields/checkbox_array.coffee +64 -0
  16. data/src/components/fields/checkbox_field.coffee +7 -10
  17. data/src/components/fields/file_upload_field.coffee +3 -6
  18. data/src/components/fields/hidden_field.coffee +4 -10
  19. data/src/components/fields/select_field.coffee +15 -18
  20. data/src/components/fields/text_area_field.coffee +5 -8
  21. data/src/components/fields/text_field.coffee +7 -14
  22. data/src/components/fields/type_ahead_field.coffee +4 -6
  23. data/src/components/form_button_toolbar.coffee +4 -4
  24. data/src/components/form_view.coffee +24 -10
  25. data/src/components/grid_view.coffee +80 -42
  26. data/src/components/record_manager.coffee +21 -22
  27. data/src/components/template.coffee +6 -8
  28. data/src/containers/card_view.coffee +2 -4
  29. data/src/containers/column_view.coffee +10 -12
  30. data/src/containers/modal_view.coffee +7 -9
  31. data/src/containers/panel_view.coffee +4 -4
  32. data/src/containers/split_view.coffee +3 -5
  33. data/src/containers/tab_view.coffee +3 -2
  34. data/src/containers/viewport.coffee +2 -3
  35. data/src/core/container.coffee +4 -4
  36. data/src/core/field.coffee +14 -13
  37. data/src/core/model.coffee +1 -1
  38. data/src/core/view.coffee +12 -3
  39. data/src/framework.coffee +134 -17
  40. data/src/managers/collection_manager.coffee +1 -1
  41. data/src/stylesheets/components/development_console.scss +5 -0
  42. data/src/templates/fields/checkbox_array.luca +5 -0
  43. data/src/templates/fields/checkbox_array_item.luca +4 -0
  44. data/vendor/assets/javascripts/luca-ui-base.js +155 -43
  45. data/vendor/assets/javascripts/luca-ui-spec.js +385 -133
  46. data/vendor/assets/javascripts/luca-ui.js +344 -132
  47. data/vendor/assets/javascripts/luca-ui.min.js +3 -3
  48. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +4 -1
  49. data/vendor/assets/stylesheets/luca-ui-spec.css +4 -1
  50. data/vendor/assets/stylesheets/luca-ui.css +4 -1
  51. metadata +6 -2
@@ -1,25 +1,26 @@
1
1
  (function() {
2
-
3
- _.mixin(_.string);
2
+ var DefineProxy;
4
3
 
5
4
  window.Luca = {
6
- VERSION: "0.8.06",
5
+ VERSION: "0.8.59",
7
6
  core: {},
8
7
  containers: {},
9
8
  components: {},
10
9
  modules: {},
11
- fields: {},
12
10
  util: {},
13
- registry: {
14
- classes: {},
15
- namespaces: ["Luca.containers", "Luca.components"]
16
- },
11
+ fields: {},
17
12
  component_cache: {
18
13
  cid_index: {},
19
14
  name_index: {}
15
+ },
16
+ registry: {
17
+ classes: {},
18
+ namespaces: ["Luca.containers", "Luca.components"]
20
19
  }
21
20
  };
22
21
 
22
+ Luca.enableGlobalObserver = false;
23
+
23
24
  Luca.enableBootstrap = true;
24
25
 
25
26
  Luca.isBackboneModel = function(obj) {
@@ -53,28 +54,35 @@
53
54
  return Luca.component_cache.cid_index[lookup_id];
54
55
  };
55
56
 
56
- Luca.util.nestedValue = function(accessor, source_object) {
57
+ Luca.util.resolve = function(accessor, source_object) {
57
58
  return _(accessor.split(/\./)).inject(function(obj, key) {
58
59
  return obj = obj != null ? obj[key] : void 0;
59
60
  }, source_object);
60
61
  };
61
62
 
63
+ Luca.util.nestedValue = Luca.util.resolve;
64
+
65
+ Luca.util.classify = function(string) {
66
+ if (string == null) string = "";
67
+ return _.string.camelize(_.string.capitalize(string));
68
+ };
69
+
62
70
  Luca.registry.lookup = function(ctype) {
63
- var c, className, parents;
71
+ var c, className, parents, _ref;
64
72
  c = Luca.registry.classes[ctype];
65
73
  if (c != null) return c;
66
- className = _.camelize(_.capitalize(ctype));
74
+ className = Luca.util.classify(ctype);
67
75
  parents = _(Luca.registry.namespaces).map(function(namespace) {
68
76
  return Luca.util.nestedValue(namespace, window || global);
69
77
  });
70
- return _.first(_.compact(_(parents).map(function(parent) {
78
+ return (_ref = _(parents).chain().map(function(parent) {
71
79
  return parent[className];
72
- })));
80
+ }).compact().value()) != null ? _ref[0] : void 0;
73
81
  };
74
82
 
75
83
  Luca.util.lazyComponent = function(config) {
76
84
  var componentClass, constructor, ctype;
77
- ctype = config.ctype;
85
+ ctype = config.ctype || config.type;
78
86
  componentClass = Luca.registry.lookup(ctype);
79
87
  if (!componentClass) {
80
88
  throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
@@ -86,8 +94,8 @@
86
94
  Luca.register = function(component, constructor_class) {
87
95
  var exists;
88
96
  exists = Luca.registry.classes[component];
89
- if (exists != null) {
90
- throw "Can not register component with the signature " + component + ". Already exists";
97
+ if ((exists != null) && !(window.TestRun != null)) {
98
+ return console.log("Attempting to register component with the signature " + component + ". Already exists");
91
99
  } else {
92
100
  return Luca.registry.classes[component] = constructor_class;
93
101
  }
@@ -115,6 +123,102 @@
115
123
  }
116
124
  };
117
125
 
126
+ Luca.template = function(template_name, variables) {
127
+ var jst, luca, needle, template, _ref;
128
+ window.JST || (window.JST = {});
129
+ luca = (_ref = Luca.templates) != null ? _ref[template_name] : void 0;
130
+ jst = typeof JST !== "undefined" && JST !== null ? JST[template_name] : void 0;
131
+ if (!((luca != null) || (jst != null))) {
132
+ needle = new RegExp("" + template_name + "$");
133
+ luca = _(Luca.templates).detect(function(fn, template_id) {
134
+ return needle.exec(template_id);
135
+ });
136
+ jst = _(JST).detect(function(fn, template_id) {
137
+ return needle.exec(template_id);
138
+ });
139
+ }
140
+ if (!(luca || jst)) throw "Could not find template with " + template_name;
141
+ template = luca || jst;
142
+ if (variables != null) return template(variables);
143
+ return template;
144
+ };
145
+
146
+ DefineProxy = (function() {
147
+
148
+ function DefineProxy(componentName) {
149
+ var parts;
150
+ this.namespace = window || global;
151
+ this.componentId = this.componentName = componentName;
152
+ if (componentName.match(/\./)) {
153
+ this.namespaced = true;
154
+ parts = componentName.split('.');
155
+ this.componentId = parts.pop();
156
+ this.namespace = parts.join('.');
157
+ Luca.registry.addNamespace(parts.join('.'));
158
+ }
159
+ }
160
+
161
+ DefineProxy.prototype["in"] = function(namespace) {
162
+ this.namespace = namespace;
163
+ return this;
164
+ };
165
+
166
+ DefineProxy.prototype.from = function(superClassName) {
167
+ this.superClassName = superClassName;
168
+ return this;
169
+ };
170
+
171
+ DefineProxy.prototype["extends"] = function(superClassName) {
172
+ this.superClassName = superClassName;
173
+ return this;
174
+ };
175
+
176
+ DefineProxy.prototype.extend = function(superClassName) {
177
+ this.superClassName = superClassName;
178
+ return this;
179
+ };
180
+
181
+ DefineProxy.prototype["with"] = function(properties) {
182
+ var at;
183
+ at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
184
+ if (this.namespaced && _.isUndefined(at)) {
185
+ eval("window." + this.namespace + " = {}");
186
+ at = Luca.util.resolve(this.namespace, window || global);
187
+ }
188
+ at[this.componentId] = Luca.extend(this.superClassName, this.componentName, properties);
189
+ Luca.register(_.string.underscored(this.componentId), this.componentName);
190
+ return at[this.componentId];
191
+ };
192
+
193
+ return DefineProxy;
194
+
195
+ })();
196
+
197
+ Luca.define = function(componentName) {
198
+ return new DefineProxy(componentName);
199
+ };
200
+
201
+ Luca.component = Luca.define;
202
+
203
+ Luca.extend = function(superClassName, childName, properties) {
204
+ var superClass;
205
+ if (properties == null) properties = {};
206
+ superClass = Luca.util.resolve(superClassName, window || global);
207
+ if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
208
+ throw "" + superClassName + " is not a valid component to extend from";
209
+ }
210
+ properties._className = childName;
211
+ properties._superClass = function() {
212
+ superClass._className || (superClass._className = superClassName);
213
+ return superClass;
214
+ };
215
+ return superClass.extend(properties);
216
+ };
217
+
218
+ _.mixin({
219
+ component: Luca.define
220
+ });
221
+
118
222
  $((function() {
119
223
  return $('body').addClass('luca-ui-enabled');
120
224
  })());
@@ -266,6 +370,14 @@
266
370
  Luca.templates || (Luca.templates = {});
267
371
  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('');};
268
372
  }).call(this);
373
+ (function() {
374
+ Luca.templates || (Luca.templates = {});
375
+ Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-horizontal\'>\n <div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n </div>\n</div>\n');}return __p.join('');};
376
+ }).call(this);
377
+ (function() {
378
+ Luca.templates || (Luca.templates = {});
379
+ 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('');};
380
+ }).call(this);
269
381
  (function() {
270
382
  Luca.templates || (Luca.templates = {});
271
383
  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('');};
@@ -360,6 +472,7 @@
360
472
  });
361
473
  definition.render = function() {
362
474
  var _this = this;
475
+ if (this.layoutTemplate != null) this.$el.html();
363
476
  if (this.deferrable) {
364
477
  this.trigger("before:render", this);
365
478
  this.deferrable.bind(this.deferrable_event, _.once(function() {
@@ -382,10 +495,19 @@
382
495
  return this;
383
496
  }
384
497
  };
385
- return Luca.View.originalExtend.apply(this, [definition]);
498
+ return Luca.View.originalExtend.call(this, definition);
386
499
  };
387
500
 
388
501
  _.extend(Luca.View.prototype, {
502
+ applyStyles: function(styles) {
503
+ var setting, value;
504
+ if (styles == null) styles = {};
505
+ for (setting in styles) {
506
+ value = styles[setting];
507
+ this.$el.css(setting, value);
508
+ }
509
+ return this;
510
+ },
389
511
  debug: function() {
390
512
  var message, _i, _len, _results;
391
513
  if (!(this.debugMode || (window.LucaDebugMode != null))) return;
@@ -397,7 +519,7 @@
397
519
  return _results;
398
520
  },
399
521
  trigger: function() {
400
- if (Luca.enableGlobalObserver) {
522
+ if (Luca.enableGlobalObserver && this.observeEvents === true) {
401
523
  Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
402
524
  type: "view"
403
525
  }));
@@ -436,7 +558,7 @@
436
558
  parts = eventId.split(':');
437
559
  prefix = parts.shift();
438
560
  parts = _(parts).map(function(p) {
439
- return _.capitalize(p);
561
+ return _.string.capitalize(p);
440
562
  });
441
563
  fn = prefix + parts.join('');
442
564
  return _this.bind(eventId, function() {
@@ -477,7 +599,7 @@
477
599
  }).call(this);
478
600
  (function() {
479
601
 
480
- Luca.Model = Backbone.Model.extend({
602
+ _.component('Luca.Model')["extends"]('Backbone.Model')["with"]({
481
603
  initialize: function() {
482
604
  var attr, dependencies, _ref, _results,
483
605
  _this = this;
@@ -743,7 +865,7 @@
743
865
  }).call(this);
744
866
  (function() {
745
867
 
746
- Luca.core.Field = Luca.View.extend({
868
+ _.component('Luca.core.Field')["extends"]('Luca.View')["with"]({
747
869
  className: 'luca-ui-text-field luca-ui-field',
748
870
  isField: true,
749
871
  template: 'fields/text_field',
@@ -802,7 +924,7 @@
802
924
  }).call(this);
803
925
  (function() {
804
926
 
805
- Luca.core.Container = Luca.View.extend({
927
+ _.component('Luca.core.Container')["extends"]('Luca.View')["with"]({
806
928
  className: 'luca-ui-container',
807
929
  componentClass: 'luca-ui-panel',
808
930
  isContainer: true,
@@ -913,7 +1035,8 @@
913
1035
  } catch (e) {
914
1036
  console.log("Error Rendering Component " + (component.name || component.cid), component);
915
1037
  console.log(e.message);
916
- return console.log(e.stack);
1038
+ console.log(e.stack);
1039
+ if ((Luca.silenceRenderErrors != null) !== true) throw e;
917
1040
  }
918
1041
  });
919
1042
  },
@@ -1008,8 +1131,6 @@
1008
1131
  }
1009
1132
  });
1010
1133
 
1011
- Luca.register("container", "Luca.core.Container");
1012
-
1013
1134
  }).call(this);
1014
1135
  (function() {
1015
1136
  var instances;
@@ -1095,7 +1216,7 @@
1095
1216
 
1096
1217
  CollectionManager.prototype.guessCollectionClass = function(key) {
1097
1218
  var classified, guess;
1098
- classified = _(key).chain().capitalize().camelize().value();
1219
+ classified = Luca.util.classify(key);
1099
1220
  guess = (this.collectionNamespace || (window || global))[classified];
1100
1221
  guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
1101
1222
  return guess;
@@ -1209,7 +1330,7 @@
1209
1330
  }).call(this);
1210
1331
  (function() {
1211
1332
 
1212
- Luca.containers.SplitView = Luca.core.Container.extend({
1333
+ _.component('Luca.containers.SplitView')["extends"]('Luca.core.Container')["with"]({
1213
1334
  layout: '100',
1214
1335
  componentType: 'split_view',
1215
1336
  containerTemplate: 'containers/basic',
@@ -1217,12 +1338,10 @@
1217
1338
  componentClass: 'luca-ui-panel'
1218
1339
  });
1219
1340
 
1220
- Luca.register('split_view', "Luca.containers.SplitView");
1221
-
1222
1341
  }).call(this);
1223
1342
  (function() {
1224
1343
 
1225
- Luca.containers.ColumnView = Luca.core.Container.extend({
1344
+ _.component('Luca.containers.ColumnView')["extends"]('Luca.core.Container')["with"]({
1226
1345
  componentType: 'column_view',
1227
1346
  className: 'luca-ui-column-view',
1228
1347
  components: [],
@@ -1269,12 +1388,10 @@
1269
1388
  }
1270
1389
  });
1271
1390
 
1272
- Luca.register('column_view', "Luca.containers.ColumnView");
1273
-
1274
1391
  }).call(this);
1275
1392
  (function() {
1276
1393
 
1277
- Luca.containers.CardView = Luca.core.Container.extend({
1394
+ _.component("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({
1278
1395
  componentType: 'card_view',
1279
1396
  className: 'luca-ui-card-view-wrapper',
1280
1397
  activeCard: 0,
@@ -1378,12 +1495,10 @@
1378
1495
  }
1379
1496
  });
1380
1497
 
1381
- Luca.register('card_view', "Luca.containers.CardView");
1382
-
1383
1498
  }).call(this);
1384
1499
  (function() {
1385
1500
 
1386
- Luca.containers.ModalView = Luca.core.Container.extend({
1501
+ _.component('Luca.containers.ModalView')["extends"]('Luca.core.Container')["with"]({
1387
1502
  componentType: 'modal_view',
1388
1503
  className: 'luca-ui-modal-view',
1389
1504
  components: [],
@@ -1465,12 +1580,10 @@
1465
1580
  }
1466
1581
  });
1467
1582
 
1468
- Luca.register("modal_view", "Luca.containers.ModalView");
1469
-
1470
1583
  }).call(this);
1471
1584
  (function() {
1472
1585
 
1473
- Luca.containers.PanelView = Luca.core.Container.extend({
1586
+ _.component('Luca.containers.PanelView')["extends"]('Luca.core.Container')["with"]({
1474
1587
  className: 'luca-ui-panel',
1475
1588
  initialize: function(options) {
1476
1589
  this.options = options != null ? options : {};
@@ -1503,7 +1616,7 @@
1503
1616
  }).call(this);
1504
1617
  (function() {
1505
1618
 
1506
- Luca.containers.TabView = Luca.containers.CardView.extend({
1619
+ _.component('Luca.containers.TabView')["extends"]('Luca.containers.CardView')["with"]({
1507
1620
  events: {
1508
1621
  "click ul.nav-tabs li": "select"
1509
1622
  },
@@ -1520,7 +1633,7 @@
1520
1633
  return this.bind("after:card:switch", this.highlightSelectedTab);
1521
1634
  },
1522
1635
  activeTabSelector: function() {
1523
- return this.tabSelectors().eq(this.activeCard);
1636
+ return this.tabSelectors().eq(this.activeCard || this.activeTab || this.activeItem);
1524
1637
  },
1525
1638
  prepareLayout: function() {
1526
1639
  var _this = this;
@@ -1583,7 +1696,7 @@
1583
1696
  }).call(this);
1584
1697
  (function() {
1585
1698
 
1586
- Luca.containers.Viewport = Luca.containers.CardView.extend({
1699
+ _.component('Luca.containers.Viewport').extend('Luca.containers.CardView')["with"]({
1587
1700
  activeItem: 0,
1588
1701
  className: 'luca-ui-viewport',
1589
1702
  fullscreen: true,
@@ -1593,7 +1706,6 @@
1593
1706
  if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
1594
1707
  },
1595
1708
  render: function() {
1596
- console.log("Rendering Viewport");
1597
1709
  return this.$el.addClass('luca-ui-viewport');
1598
1710
  }
1599
1711
  });