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.

153 lines
3.5 KiB

  1. // Generated by CoffeeScript 1.6.2
  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); _ref1 = Collection.__super__.constructor.apply(this, arguments);
  56. return _ref1;
  57. }
  58. Collection.prototype.log = log;
  59. Collection.prototype.emit = emit;
  60. Collection.prototype.destroy = function() {
  61. this.emit('destroy');
  62. this.off().stopListening();
  63. return this;
  64. };
  65. return Collection;
  66. })(Backbone.Collection);
  67. View = (function(_super) {
  68. __extends(View, _super);
  69. function View() {
  70. _ref2 = View.__super__.constructor.apply(this, arguments);
  71. return _ref2;
  72. }
  73. View.prototype.log = log;
  74. View.prototype.emit = emit;
  75. return View;
  76. })(Backbone.View);
  77. QueryCollection = (function(_super) {
  78. __extends(QueryCollection, _super);
  79. function QueryCollection() {
  80. this.destroy = __bind(this.destroy, this); _ref3 = QueryCollection.__super__.constructor.apply(this, arguments);
  81. return _ref3;
  82. }
  83. QueryCollection.prototype.log = log;
  84. QueryCollection.prototype.emit = emit;
  85. QueryCollection.prototype.Collection = QueryCollection;
  86. QueryCollection.prototype.setParentCollection = function() {
  87. var parentCollection;
  88. QueryCollection.__super__.setParentCollection.apply(this, arguments);
  89. parentCollection = this.getParentCollection();
  90. parentCollection.on('destroy', this.destroy);
  91. return this;
  92. };
  93. QueryCollection.prototype.destroy = function() {
  94. this.emit('destroy');
  95. this.off().stopListening();
  96. return this;
  97. };
  98. return QueryCollection;
  99. })(queryEngine.QueryCollection);
  100. module.exports = {
  101. queryEngine: queryEngine,
  102. Backbone: Backbone,
  103. Events: Events,
  104. Model: Model,
  105. Collection: Collection,
  106. View: View,
  107. QueryCollection: QueryCollection
  108. };