luca 0.8.3 → 0.8.06

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.
@@ -1,20 +1,22 @@
1
1
  (function() {
2
2
 
3
+ _.mixin(_.string);
4
+
3
5
  window.Luca = {
4
- VERSION: "0.8.3",
6
+ VERSION: "0.8.06",
5
7
  core: {},
6
8
  containers: {},
7
9
  components: {},
8
10
  modules: {},
9
- util: {},
10
11
  fields: {},
11
- component_cache: {
12
- cid_index: {},
13
- name_index: {}
14
- },
12
+ util: {},
15
13
  registry: {
16
14
  classes: {},
17
15
  namespaces: ["Luca.containers", "Luca.components"]
16
+ },
17
+ component_cache: {
18
+ cid_index: {},
19
+ name_index: {}
18
20
  }
19
21
  };
20
22
 
@@ -57,16 +59,11 @@
57
59
  }, source_object);
58
60
  };
59
61
 
60
- Luca.util.classify = function(string) {
61
- if (string == null) string = "";
62
- return _.string.camelize(_.string.capitalize(string));
63
- };
64
-
65
62
  Luca.registry.lookup = function(ctype) {
66
63
  var c, className, parents;
67
64
  c = Luca.registry.classes[ctype];
68
65
  if (c != null) return c;
69
- className = Luca.util.classify(ctype);
66
+ className = _.camelize(_.capitalize(ctype));
70
67
  parents = _(Luca.registry.namespaces).map(function(namespace) {
71
68
  return Luca.util.nestedValue(namespace, window || global);
72
69
  });
@@ -77,7 +74,7 @@
77
74
 
78
75
  Luca.util.lazyComponent = function(config) {
79
76
  var componentClass, constructor, ctype;
80
- ctype = config.ctype || config.type;
77
+ ctype = config.ctype;
81
78
  componentClass = Luca.registry.lookup(ctype);
82
79
  if (!componentClass) {
83
80
  throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
@@ -90,7 +87,7 @@
90
87
  var exists;
91
88
  exists = Luca.registry.classes[component];
92
89
  if (exists != null) {
93
- return console.log("Can not register component with the signature " + component + ". Already exists");
90
+ throw "Can not register component with the signature " + component + ". Already exists";
94
91
  } else {
95
92
  return Luca.registry.classes[component] = constructor_class;
96
93
  }
@@ -269,14 +266,6 @@
269
266
  Luca.templates || (Luca.templates = {});
270
267
  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('');};
271
268
  }).call(this);
272
- (function() {
273
- Luca.templates || (Luca.templates = {});
274
- 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('');};
275
- }).call(this);
276
- (function() {
277
- Luca.templates || (Luca.templates = {});
278
- 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('');};
279
- }).call(this);
280
269
  (function() {
281
270
  Luca.templates || (Luca.templates = {});
282
271
  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('');};
@@ -447,7 +436,7 @@
447
436
  parts = eventId.split(':');
448
437
  prefix = parts.shift();
449
438
  parts = _(parts).map(function(p) {
450
- return _.string.capitalize(p);
439
+ return _.capitalize(p);
451
440
  });
452
441
  fn = prefix + parts.join('');
453
442
  return _this.bind(eventId, function() {
@@ -924,8 +913,7 @@
924
913
  } catch (e) {
925
914
  console.log("Error Rendering Component " + (component.name || component.cid), component);
926
915
  console.log(e.message);
927
- console.log(e.stack);
928
- if ((Luca.silenceRenderErrors != null) !== true) throw e;
916
+ return console.log(e.stack);
929
917
  }
930
918
  });
931
919
  },
@@ -1107,7 +1095,7 @@
1107
1095
 
1108
1096
  CollectionManager.prototype.guessCollectionClass = function(key) {
1109
1097
  var classified, guess;
1110
- classified = Luca.util.classify(key);
1098
+ classified = _(key).chain().capitalize().camelize().value();
1111
1099
  guess = (this.collectionNamespace || (window || global))[classified];
1112
1100
  guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
1113
1101
  return guess;
@@ -1775,13 +1763,12 @@
1775
1763
  setupBindings: function() {
1776
1764
  var _this = this;
1777
1765
  this.manager.bind("collection_loaded", function(name) {
1778
- var collectionName, loaded, progress, total;
1766
+ var loaded, progress, total;
1779
1767
  loaded = _this.manager.loadedCollectionsCount();
1780
1768
  total = _this.manager.totalCollectionsCount();
1781
1769
  progress = parseInt((loaded / total) * 100);
1782
- collectionName = _.string.titleize(_.string.humanize(name));
1783
1770
  _this.modalContainer().find('.progress .bar').attr("style", "width: " + progress + "%;");
1784
- return _this.modalContainer().find('.message').html("Loaded " + collectionName + "...");
1771
+ return _this.modalContainer().find('.message').html("Loaded " + (_(name).chain().humanize().titleize().value()) + "...");
1785
1772
  });
1786
1773
  return this.manager.bind("all_collections_loaded", function() {
1787
1774
  _this.modalContainer().find('.message').html("All done!");
@@ -1941,89 +1928,6 @@
1941
1928
 
1942
1929
  Luca.register("button_field", "Luca.fields.ButtonField");
1943
1930
 
1944
- }).call(this);
1945
- (function() {
1946
-
1947
- Luca.fields.CheckboxArray = Luca.core.Field.extend({
1948
- template: "fields/checkbox_array",
1949
- events: {
1950
- "click input": "clickHandler"
1951
- },
1952
- initialize: function(options) {
1953
- this.options = options != null ? options : {};
1954
- _.extend(this, this.options);
1955
- _.extend(this, Luca.modules.Deferrable);
1956
- _.bindAll(this, "populateCheckboxes", "clickHandler", "_updateModel");
1957
- Luca.core.Field.prototype.initialize.apply(this, arguments);
1958
- this.input_id || (this.input_id = _.uniqueId('field'));
1959
- this.input_name || (this.input_name = this.name);
1960
- this.label || (this.label = this.name);
1961
- this.valueField || (this.valueField = "id");
1962
- this.displayField || (this.displayField = "name");
1963
- return this.selectedItems = [];
1964
- },
1965
- afterInitialize: function(options) {
1966
- this.options = options != null ? options : {};
1967
- try {
1968
- this.configure_collection();
1969
- } catch (e) {
1970
- console.log("Error Configuring Collection", this, e.message);
1971
- }
1972
- return this.collection.bind("reset", this.populateCheckboxes);
1973
- },
1974
- afterRender: function() {
1975
- var _ref, _ref2;
1976
- if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
1977
- return this.populateCheckboxes();
1978
- } else {
1979
- return this.collection.trigger("reset");
1980
- }
1981
- },
1982
- clickHandler: function(event) {
1983
- var checkbox;
1984
- checkbox = event.target;
1985
- if (checkbox.checked) {
1986
- this.selectedItems.push(checkbox.value);
1987
- } else {
1988
- if (this.selectedItems.indexOf(checkbox.value) !== -1) {
1989
- this.selectedItems = _.without(this.selectedItems, [checkbox.value]);
1990
- }
1991
- }
1992
- return this._updateModel();
1993
- },
1994
- populateCheckboxes: function() {
1995
- var controls,
1996
- _this = this;
1997
- controls = $(this.el).find('.controls');
1998
- controls.empty();
1999
- this.selectedItems = this.getModel().get(this.name);
2000
- this.collection.each(function(model) {
2001
- var input_id, label, value;
2002
- value = model.get(_this.valueField);
2003
- label = model.get(_this.displayField);
2004
- input_id = _.uniqueId('field');
2005
- controls.append(Luca.templates["fields/checkbox_array_item"]({
2006
- label: label,
2007
- value: value,
2008
- input_id: input_id,
2009
- input_name: _this.input_name
2010
- }));
2011
- if (_this.selectedItems.indexOf(value) !== -1) {
2012
- return _this.$("#" + input_id).attr("checked", "checked");
2013
- }
2014
- });
2015
- return $(this.container).append(this.$el);
2016
- },
2017
- _updateModel: function() {
2018
- var attributes;
2019
- attributes = {};
2020
- attributes[this.name] = this.selectedItems;
2021
- return this.getModel().set(attributes);
2022
- }
2023
- });
2024
-
2025
- Luca.register("checkbox_array", "Luca.fields.CheckboxArray");
2026
-
2027
1931
  }).call(this);
2028
1932
  (function() {
2029
1933
 
@@ -2431,24 +2335,8 @@
2431
2335
  return component.container = container;
2432
2336
  });
2433
2337
  },
2434
- afterComponents: function() {
2435
- var _ref,
2436
- _this = this;
2437
- if ((_ref = Luca.core.Container.prototype.afterComponents) != null) {
2438
- _ref.apply(this, arguments);
2439
- }
2440
- return this.eachField(function(field) {
2441
- field.getForm = function() {
2442
- return _this;
2443
- };
2444
- return field.getModel = function() {
2445
- return _this.currentModel();
2446
- };
2447
- });
2448
- },
2449
2338
  render: function() {
2450
- $(this.container).append(this.$el);
2451
- return this;
2339
+ return $(this.container).append(this.$el);
2452
2340
  },
2453
2341
  wrapper: function() {
2454
2342
  return this.$el.parents('.luca-ui-form-view-wrapper');
@@ -2465,9 +2353,6 @@
2465
2353
  return toolbar.render();
2466
2354
  });
2467
2355
  },
2468
- eachField: function(iterator) {
2469
- return _(this.getFields()).map(iterator);
2470
- },
2471
2356
  getField: function(name) {
2472
2357
  return _(this.getFields('name', name)).first();
2473
2358
  },
@@ -2547,8 +2432,8 @@
2547
2432
  key = field.input_name || field.name;
2548
2433
  skip = false;
2549
2434
  if (options.skip_buttons && field.ctype === "button_field") skip = true;
2550
- if (options.reject_blank === true && _.string.isBlank(value)) skip = true;
2551
- if (field.input_name === "id" && _.string.isBlank(value)) skip = true;
2435
+ if (options.reject_blank === true && _.isBlank(value)) skip = true;
2436
+ if (field.input_name === "id" && _.isBlank(value)) skip = true;
2552
2437
  if (skip !== true) memo[key] = value;
2553
2438
  return memo;
2554
2439
  }, {});