You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
3.7 KiB

  1. // Generated by CoffeeScript 1.6.3
  2. var Backbone, Collection, Events, Model, QueryCollection, View, emit, extendr, log, queryEngine, _ref, _ref1, _ref2, _ref3,
  3. __slice = [].slice,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  6. __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  7. extendr = require('extendr');
  8. queryEngine = require('query-engine');
  9. Backbone = queryEngine.Backbone;
  10. log = function() {
  11. var args;
  12. args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  13. args.unshift('log');
  14. this.emit.apply(this, args);
  15. return this;
  16. };
  17. emit = function() {
  18. var args;
  19. args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  20. return this.trigger.apply(this, args);
  21. };
  22. Events = (function() {
  23. function Events() {}
  24. Events.prototype.log = log;
  25. Events.prototype.emit = emit;
  26. return Events;
  27. })();
  28. extendr.extend(Events.prototype, Backbone.Events);
  29. Model = (function(_super) {
  30. __extends(Model, _super);
  31. function Model() {
  32. _ref = Model.__super__.constructor.apply(this, arguments);
  33. return _ref;
  34. }
  35. Model.prototype.log = log;
  36. Model.prototype.emit = emit;
  37. Model.prototype.setDefaults = function(defaults) {
  38. var key, set, value, _ref1;
  39. set = {};
  40. for (key in defaults) {
  41. if (!__hasProp.call(defaults, key)) continue;
  42. value = defaults[key];
  43. if (this.get(key) === ((_ref1 = this.defaults) != null ? _ref1[key] : void 0)) {
  44. set[key] = value;
  45. }
  46. }
  47. this.set(set);
  48. return this;
  49. };
  50. return Model;
  51. })(Backbone.Model);
  52. Collection = (function(_super) {
  53. __extends(Collection, _super);
  54. function Collection() {
  55. this.destroy = __bind(this.destroy, this);
  56. _ref1 = Collection.__super__.constructor.apply(this, arguments);
  57. return _ref1;
  58. }
  59. Collection.prototype.log = log;
  60. Collection.prototype.emit = emit;
  61. Collection.prototype.destroy = function() {
  62. this.emit('destroy');
  63. this.off().stopListening();
  64. return this;
  65. };
  66. return Collection;
  67. })(Backbone.Collection);
  68. Collection.prototype.model = Model;
  69. Collection.prototype.collection = Collection;
  70. View = (function(_super) {
  71. __extends(View, _super);
  72. function View() {
  73. _ref2 = View.__super__.constructor.apply(this, arguments);
  74. return _ref2;
  75. }
  76. View.prototype.log = log;
  77. View.prototype.emit = emit;
  78. return View;
  79. })(Backbone.View);
  80. QueryCollection = (function(_super) {
  81. __extends(QueryCollection, _super);
  82. function QueryCollection() {
  83. this.destroy = __bind(this.destroy, this);
  84. _ref3 = QueryCollection.__super__.constructor.apply(this, arguments);
  85. return _ref3;
  86. }
  87. QueryCollection.prototype.log = log;
  88. QueryCollection.prototype.emit = emit;
  89. QueryCollection.prototype.setParentCollection = function() {
  90. var parentCollection;
  91. QueryCollection.__super__.setParentCollection.apply(this, arguments);
  92. parentCollection = this.getParentCollection();
  93. parentCollection.on('destroy', this.destroy);
  94. return this;
  95. };
  96. QueryCollection.prototype.destroy = function() {
  97. this.emit('destroy');
  98. this.off().stopListening();
  99. return this;
  100. };
  101. return QueryCollection;
  102. })(queryEngine.QueryCollection);
  103. QueryCollection.prototype.model = Model;
  104. QueryCollection.prototype.collection = QueryCollection;
  105. module.exports = {
  106. queryEngine: queryEngine,
  107. Backbone: Backbone,
  108. Events: Events,
  109. Model: Model,
  110. Collection: Collection,
  111. View: View,
  112. QueryCollection: QueryCollection
  113. };